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

Make specifying the version during configuration optional #1012

Merged
merged 1 commit into from
Nov 16, 2018

Conversation

dfunckt
Copy link
Member

@dfunckt dfunckt commented Nov 5, 2018

version used to be optional but it seems we recently had to make it a required parameter. However it really feels redundant when all it’s used for is to determine whether the command should issue a legacy user API key or a provisioning key.

This makes version optional but tries to figure it out by itself by reading os-release from the image's boot partition. This is not foul-proof however, and while it'll work with most recent images (see balena-io-modules/balena-device-init#37) it won't work with all and in that case it'll bail out and only then warn the user to specify it via the --version argument.

Change-type: minor
Depends-on: balena-io-modules/balena-device-init#37

@dfunckt dfunckt requested review from thgreasi and pimterry November 5, 2018 08:35
@dfunckt dfunckt force-pushed the optional-os-version branch 4 times, most recently from 94cd6c8 to 51452ac Compare November 5, 2018 19:05
@balena-io balena-io deleted a comment Nov 5, 2018
@balena-io balena-io deleted a comment Nov 5, 2018
@thgreasi
Copy link
Member

thgreasi commented Nov 6, 2018

@dfunckt Should we close this now that the respective sdk pr is closed?

@dfunckt
Copy link
Member Author

dfunckt commented Nov 6, 2018

@thgreasi no, version will only be optional for the user, it will still be required in the SDK and API. This PR takes care of figuring the version automatically if the user didn't provide one.

Copy link
Member

@thgreasi thgreasi left a comment

Choose a reason for hiding this comment

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

❤️ the new approach that checks & handles the old versions first 👍
Please update the action description to state that --version isn't required since it now states

Calling this command with the exact version number of the targeted image is required.

@dfunckt dfunckt force-pushed the optional-os-version branch 5 times, most recently from f694a1a to 42b9ee4 Compare November 14, 2018 12:28
@dfunckt dfunckt requested a review from thgreasi November 14, 2018 12:28
@dfunckt
Copy link
Member Author

dfunckt commented Nov 14, 2018

@thgreasi updated, can you please another look?

})
.then(JSON.parse)
.catch(() => balena.models.device.getManifestBySlug(deviceType));
const init: typeof _deviceInit = require('balena-device-init');
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit: If you make this function async, then this can become:

const init = await import('balena-device-init');

and that way it'll automatically pick up the types by itself, so you can drop the _deviceInit import.

That would also let you use await below to flatten the promise chain there, which would make that a little clearer too.

The one constraint is that you can't import Bluebird as Promise any more in that case. Elsewhere we've just been renaming the import to Bluebird.

image: string,
manifest: BalenaSdk.DeviceType,
): Promise<string | null> {
const init: typeof _deviceInit = require('balena-device-init');
Copy link
Contributor

Choose a reason for hiding this comment

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

Ditto

@dfunckt dfunckt force-pushed the optional-os-version branch 2 times, most recently from 7675131 to 69cf2c9 Compare November 16, 2018 14:32
@dfunckt dfunckt force-pushed the optional-os-version branch from 69cf2c9 to feaa8d6 Compare November 16, 2018 15:14
@dfunckt
Copy link
Member Author

dfunckt commented Nov 16, 2018

@resin-ci retest

1 similar comment
@nazrhom
Copy link
Contributor

nazrhom commented Nov 16, 2018

@resin-ci retest

`version` used to be optional but it seems we recently had to make it a required parameter. However it really feels redundant when all it’s used for is to determine whether the command should issue a legacy user API key or a provisioning key.

This makes version optional but tries to figure it out by itself by reading os-release from the image's boot partition. This is not foul-proof however, and while it'll work with most recent images it won't work with all and in that case it'll bail out and only then warn the user to specify it via the --version argument.

Change-type: minor
@dfunckt dfunckt force-pushed the optional-os-version branch from feaa8d6 to 8291c96 Compare November 16, 2018 17:39
@dfunckt
Copy link
Member Author

dfunckt commented Nov 16, 2018

@resin-ci retest

@dfunckt dfunckt merged commit a0003c5 into master Nov 16, 2018
@dfunckt dfunckt deleted the optional-os-version branch November 16, 2018 18:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants