Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(app): Get protocolDisplayData based on protocol schema #3531

Merged
merged 8 commits into from
Jun 12, 2019

Conversation

Kadee80
Copy link
Contributor

@Kadee80 Kadee80 commented Jun 6, 2019

overview

This PR checks for protocol name, last modified, appName, and appVersion for based on protocol schema versions.

closes #3494

changelog

  • feat(app): Get protocol name for all V3 PD protocols

review requests

Labeled this a WIP for now - this issue is a little larger than expected as it touches more than just the name field once we start getting schema version from shared data. It also uncovered the lack of v3 protocol file flow type.

V2 protocol to test

V3 protocol to test

  • V2 protocols still show correct file info
  • V3 protocols show correct file info
  • Python protocols show correct file info

@Kadee80 Kadee80 added feature Ticket is a feature request / PR introduces a feature app Affects the `app` project ready for review json protocol schema labels Jun 6, 2019
@@ -108,6 +108,7 @@ type CreatorAppSelector = OutputSelector<
>

const getName: StringGetter = getter('metadata.protocol-name')
const getV3Name: StringGetter = getter('metadata.protocolName')
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Kind of at a loss for what to name this - since we need old and new for now and V3 will become the standard soon?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We're not dropping support for V1/V2 anytime soon AFAIK, and there will be future versions to co-support. Maybe something vaguely like:

const protocolV1V2GetterPaths = {
  name: 'metadata.protocol-name'
  ...etc
}

const PROTOCOL_GETTER_PATHS_BY_SCHEMA = {
  "1": protocolV1V2GetterPaths,
  "2": protocolV1V2GetterPaths,
  "3": {
    name: 'metadata.protocolName',
    ...etc
  }
}

const getProtocolSchemaVersion = getter('protocol-schema') || getter('schemaVersion') || null
// ...

const pathsForProtocol = getProtocolSchemaVersion(protocol)
const getName = getter(pathsForProtocol.name)

@codecov
Copy link

codecov bot commented Jun 6, 2019

Codecov Report

Merging #3531 into edge will increase coverage by 1.3%.
The diff coverage is 86.2%.

Impacted file tree graph

@@            Coverage Diff            @@
##             edge    #3531     +/-   ##
=========================================
+ Coverage   27.61%   28.91%   +1.3%     
=========================================
  Files         705      729     +24     
  Lines       11557    13086   +1529     
=========================================
+ Hits         3191     3784    +593     
- Misses       8366     9302    +936
Impacted Files Coverage Δ
app/src/protocol/protocol-data.js 77.77% <ø> (ø) ⬆️
shared-data/js/index.js 100% <ø> (ø) ⬆️
app/src/protocol/index.js 98.55% <100%> (+3.46%) ⬆️
shared-data/protocol/index.js 55.55% <55.55%> (ø)
...are-library/src/components/ui/LabeledValueTable.js 0% <0%> (ø) ⬆️
update-server/otupdate/balena/bootstrap.py 20% <0%> (ø)
update-server/otupdate/migration/file_actions.py 81.64% <0%> (ø)
update-server/otupdate/migration/__init__.py 100% <0%> (ø)
update-server/otupdate/buildroot/config.py 31.25% <0%> (ø)
update-server/otupdate/balena/endpoints.py 23.33% <0%> (ø)
... and 19 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update befded9...96ba6a7. Read the comment docs.

@Kadee80 Kadee80 force-pushed the app_protocol-meta-name branch from 050bcf6 to 4a42d20 Compare June 10, 2019 16:58
@Kadee80 Kadee80 changed the title feat(app): Get protocol name for all V3 PD protocols feat(app): Get protocolDisplayData based on protocol schema Jun 10, 2019
@Kadee80 Kadee80 force-pushed the app_protocol-meta-name branch from 4a42d20 to 7fe8691 Compare June 11, 2019 19:34
@Kadee80 Kadee80 requested review from b-cooper and removed request for Laura-Danielle June 11, 2019 19:34
Copy link
Contributor

@IanLondon IanLondon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

got some nits but not blocking

app/src/protocol/index.js Show resolved Hide resolved
app/src/protocol/types.js Show resolved Hide resolved
export function getProtocolSchemaVersion(data: ProtocolData): ?number {
if (data.schemaVersion) {
return data.schemaVersion
} else if (data['protocol-schema']) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To be stricter about the "legacy" protocol-schema key, we could do very explicit if (data['protocol-schema'] == '1.0.0') return 1; else if (data['protocol-schema'] == '2.0.0') return 2. If it's '3lolz' or even if it's 3.0.0 or 3, those are invalid ways to designate a protocol as v3

I know this strictness is totally overkill for how this fn is used in this PR, but we're going to use this fn for protocol migration very soon and for that I'm not comfortable with it being this permissive

- Warn against schemas > 3 not yet supported
@Kadee80 Kadee80 merged commit ec69d84 into edge Jun 12, 2019
@Kadee80 Kadee80 deleted the app_protocol-meta-name branch June 12, 2019 17:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
app Affects the `app` project feature Ticket is a feature request / PR introduces a feature json protocol schema
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Run App: Metadata fields in RA uses the file name instead of metadata key from file
2 participants