diff --git a/lib/config.ts b/lib/config.ts index b115bca..96c317f 100644 --- a/lib/config.ts +++ b/lib/config.ts @@ -17,6 +17,9 @@ import type { ActionsConfig } from './types'; export const actionsConfig: ActionsConfig = { + // 'takeover' is an ActionName, but we do not define an ActionsConfig for it. + // The name is used only as a result of processing a 'balenahup' ActionConfig. + // See the deviceTypes entries below that define a minTakeoverVersion. actions: { resinhup11: { minSourceVersion: '1.8.0', @@ -82,11 +85,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: { diff --git a/lib/index.ts b/lib/index.ts index 5c0e517..2839ab9 100644 --- a/lib/index.ts +++ b/lib/index.ts @@ -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'); @@ -120,13 +120,9 @@ export class HUPActionHelper { ); } } else { - // // Takeover overrides the checks below for the device type - // if (this.isTakeoverRequired(deviceType, currentVersion, targetVersion)) { - // return 'takeover'; - // } + // actionName may change below to 'takeover' actionName = 'balenahup'; } - const { actionsConfig } = this; const defaultActions = actionsConfig.deviceTypesDefaults; const deviceActions = actionsConfig.deviceTypes[deviceType] || {}; diff --git a/lib/types.ts b/lib/types.ts index 26a69dc..07561af 100644 --- a/lib/types.ts +++ b/lib/types.ts @@ -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 @@ -31,7 +31,9 @@ export interface ActionConfig { } export interface ActionsConfig { - actions: { [K in ActionName]: ActionConfig }; + // We do not define an ActionConfig for the 'takeover' ActionName. + // The name is used only as a result of processing a 'balenahup' ActionConfig. + actions: { [K in ActionName]?: ActionConfig }; deviceTypesDefaults: { [K in ActionName]?: Partial }; deviceTypes: Partial<{ [deviceTypeSlug: string]: { diff --git a/tests/01-actions.spec.ts b/tests/01-actions.spec.ts index 9969c06..bf58256 100644 --- a/tests/01-actions.spec.ts +++ b/tests/01-actions.spec.ts @@ -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}`, () => {