preload: Add the --no-pin-device-to-release flag to avoid interactive questions

Change-type: minor
See: https://balena.zulipchat.com/#narrow/stream/345746-aspect.2Fproduct/topic/Level.20-.20need.20thoughts.20on.20questions.20.26.20feature.20suggestions
This commit is contained in:
Thodoris Greasidis 2023-07-17 11:14:33 +03:00
parent 0086feb645
commit f53f148c89

View File

@ -46,7 +46,7 @@ interface FlagsDef extends DockerConnectionCliFlags {
commit?: string; commit?: string;
'splash-image'?: string; 'splash-image'?: string;
'dont-check-arch': boolean; 'dont-check-arch': boolean;
'pin-device-to-release': boolean; 'pin-device-to-release'?: boolean;
'additional-space'?: number; 'additional-space'?: number;
'add-certificate'?: string[]; 'add-certificate'?: string[];
help: void; help: void;
@ -122,7 +122,7 @@ https://github.com/balena-io-examples/staged-releases\
'disable architecture compatibility check between image and fleet', 'disable architecture compatibility check between image and fleet',
}), }),
'pin-device-to-release': flags.boolean({ 'pin-device-to-release': flags.boolean({
default: false, allowNo: true,
description: description:
'pin the preloaded device to the preloaded release on provision', 'pin the preloaded device to the preloaded release on provision',
char: 'p', char: 'p',
@ -230,7 +230,7 @@ Can be repeated to add multiple certificates.\
const splashImage = options['splash-image']; const splashImage = options['splash-image'];
const additionalSpace = options['additional-space']; const additionalSpace = options['additional-space'];
const dontCheckArch = options['dont-check-arch'] || false; const dontCheckArch = options['dont-check-arch'] || false;
const pinDevice = options['pin-device-to-release'] || false; const pinDevice = options['pin-device-to-release'];
if (dontCheckArch && !fleetSlug) { if (dontCheckArch && !fleetSlug) {
throw new ExpectedError( throw new ExpectedError(
@ -257,7 +257,7 @@ Can be repeated to add multiple certificates.\
splashImage, splashImage,
undefined, // TODO: Currently always undefined, investigate approach in ssh command. undefined, // TODO: Currently always undefined, investigate approach in ssh command.
dontCheckArch, dontCheckArch,
pinDevice, pinDevice ?? false,
certificates, certificates,
additionalSpace, additionalSpace,
); );
@ -450,14 +450,14 @@ Can be repeated to add multiple certificates.\
async offerToDisableAutomaticUpdates( async offerToDisableAutomaticUpdates(
application: Pick<Application, 'id' | 'should_track_latest_release'>, application: Pick<Application, 'id' | 'should_track_latest_release'>,
commit: string, commit: string,
pinDevice: boolean, pinDevice: boolean | undefined,
) { ) {
const balena = getBalenaSdk(); const balena = getBalenaSdk();
if ( if (
this.isCurrentCommit(commit) || this.isCurrentCommit(commit) ||
!application.should_track_latest_release || !application.should_track_latest_release ||
pinDevice pinDevice != null
) { ) {
return; return;
} }
@ -476,8 +476,9 @@ through the web dashboard or programatically through the balena API / SDK.
Documentation about release policies and pinning can be found at: Documentation about release policies and pinning can be found at:
https://www.balena.io/docs/learn/deploy/release-strategy/release-policy/ https://www.balena.io/docs/learn/deploy/release-strategy/release-policy/
Alternatively, the --pin-device-to-release flag may be used to pin only the Alternatively, the --pin-device-to-release or --no-pin-device-to-release flags may be used
preloaded device to the selected release. to avoid this interactive confirmation and pin only the preloaded device to the selected release
or keep it unpinned respectively.
Would you like to disable automatic updates for this fleet now?\ Would you like to disable automatic updates for this fleet now?\
`; `;
@ -511,7 +512,7 @@ Would you like to disable automatic updates for this fleet now?\
options: { options: {
slug?: string; slug?: string;
commit?: string; commit?: string;
pinDevice: boolean; pinDevice?: boolean;
}, },
) { ) {
await preloader.prepare(); await preloader.prepare();