Skip to content

Commit

Permalink
Fixup to define 'takeover' as a ActionName without an ActionConfig.
Browse files Browse the repository at this point in the history
Also define expected minTakeoverVersion for Xavier device types.
  • Loading branch information
kb2ma committed Nov 15, 2024
1 parent 8f8a770 commit b004fc8
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 15 deletions.
17 changes: 14 additions & 3 deletions lib/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down Expand Up @@ -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: {
Expand Down
8 changes: 2 additions & 6 deletions 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,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] || {};
Expand Down
6 changes: 4 additions & 2 deletions 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 All @@ -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<ActionConfig> };
deviceTypes: Partial<{
[deviceTypeSlug: string]: {
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 b004fc8

Please sign in to comment.