Skip to content

Commit

Permalink
Make takeover an ActionName
Browse files Browse the repository at this point in the history
Also define expected minTakeoverVersion for Xavier device types
  • Loading branch information
pipex committed Nov 15, 2024
1 parent 1dae6c5 commit dfc8274
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 9 deletions.
23 changes: 20 additions & 3 deletions lib/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,15 @@ export const actionsConfig: ActionsConfig = {
minSourceVersion: '2.0.0+rev1',
minTargetVersion: '2.2.0+rev1',
},
takeover: {
// Takeover is a possible action returned by getHUPActionType
// but it really is a special case of balenahup that will happen
// when minTakeoverVersion is defined.
// We use nonsense values here to prevent this being used as any
// other action
minSourceVersion: '99.99.99',
minTargetVersion: '99.99.99',
},
},
deviceTypesDefaults: {
balenahup: {},
Expand Down Expand Up @@ -82,11 +91,19 @@ export const actionsConfig: ActionsConfig = {
minSourceVersion: '2.7.4',
},
},
'jetson-xavier': {
balenahup: {
minTakeoverVersion: '6.0.50',
},
},
'jetson-xavier-nx-devkit': {
balenahup: {
minTakeoverVersion: '6.0.50+rev1',
},
},
'jetson-xavier-nx-devkit-emmc': {
balenahup: {
// NOTE: this version is here as a placeholder for
// testing. Replace with the correct version before merging
minTakeoverVersion: '5.1.45+rev1',
minTakeoverVersion: '6.0.39',
},
},
qemux86: {
Expand Down
3 changes: 2 additions & 1 deletion lib/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ export class HUPActionHelper {
deviceType: string,
currentVersion: string,
targetVersion: string,
): ActionName | 'takeover' {
): ActionName {
const currentVersionParsed = bSemver.parse(currentVersion);
if (currentVersionParsed == null) {
throw new HUPActionError('Invalid current balenaOS version');
Expand Down Expand Up @@ -120,6 +120,7 @@ export class HUPActionHelper {
);
}
} else {
// actionName may change below to 'takeover'
actionName = 'balenahup';
}

Expand Down
2 changes: 1 addition & 1 deletion lib/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
limitations under the License.
*/

export type ActionName = 'resinhup11' | 'resinhup12' | 'balenahup';
export type ActionName = 'resinhup11' | 'resinhup12' | 'balenahup' | 'takeover';

export interface ActionConfig {
// the minimum resinOS source version, that the upgrade can be done for, includes this version
Expand Down
8 changes: 4 additions & 4 deletions tests/01-actions.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -734,10 +734,10 @@ describe('BalenaHupActionUtils', () => {
[
{
deviceType: 'jetson-xavier-nx-devkit-emmc',
before: '5.0.0',
cutoff: '5.1.45',
takeover: '5.1.45+rev1',
after: '5.2.0',
before: '6.0.0',
cutoff: '6.0.38',
takeover: '6.0.39',
after: '6.1.0',
},
].forEach(({ deviceType, before, cutoff, takeover, after }) => {
it(`should return 'balenahup' if doing HUP for ${deviceType} to a version before ${takeover}`, () => {
Expand Down

0 comments on commit dfc8274

Please sign in to comment.