From ecf4b046b5d30c6e726b61f1e2b1a39cc91b8e53 Mon Sep 17 00:00:00 2001 From: JSReds Date: Fri, 10 Mar 2023 15:54:31 +0100 Subject: [PATCH] Fix application isLegacy check for rename and deploy Change-type: patch --- lib/commands/deploy.ts | 2 +- lib/commands/fleet/rename.ts | 4 ++-- lib/utils/helpers.ts | 2 +- .../application-GET-v6-expanded-app-type-cpu-arch.json | 2 +- .../api-response/application-GET-v6-expanded-app-type.json | 2 +- 5 files changed, 6 insertions(+), 6 deletions(-) diff --git a/lib/commands/deploy.ts b/lib/commands/deploy.ts index a1c6fbac..86712c63 100644 --- a/lib/commands/deploy.ts +++ b/lib/commands/deploy.ts @@ -340,7 +340,7 @@ ${dockerignoreHelp} ); let release: Release | ComposeReleaseInfo['release']; - if (appType?.is_legacy) { + if (appType.slug === 'legacy-v1' || appType.slug === 'legacy-v2') { const { deployLegacy } = require('../utils/deploy-legacy'); const msg = getChalk().yellow( diff --git a/lib/commands/fleet/rename.ts b/lib/commands/fleet/rename.ts index ef58d281..2ec0da89 100644 --- a/lib/commands/fleet/rename.ts +++ b/lib/commands/fleet/rename.ts @@ -80,7 +80,7 @@ export default class FleetRenameCmd extends Command { const application = await getApplication(balena, params.fleet, { $expand: { application_type: { - $select: ['is_legacy'], + $select: ['slug'], }, }, }); @@ -92,7 +92,7 @@ export default class FleetRenameCmd extends Command { // Check app supports renaming const appType = (application.application_type as ApplicationType[])?.[0]; - if (appType.is_legacy) { + if (appType.slug === 'legacy-v1' || appType.slug === 'legacy-v2') { throw new ExpectedError( `Fleet ${params.fleet} is of 'legacy' type, and cannot be renamed.`, ); diff --git a/lib/utils/helpers.ts b/lib/utils/helpers.ts index dd9e9de5..fc4b05c1 100644 --- a/lib/utils/helpers.ts +++ b/lib/utils/helpers.ts @@ -184,7 +184,7 @@ export async function getAppWithArch( const options: BalenaSdk.PineOptions = { $expand: { application_type: { - $select: ['name', 'slug', 'supports_multicontainer', 'is_legacy'], + $select: ['name', 'slug', 'supports_multicontainer'], }, is_for__device_type: { $select: 'slug', diff --git a/tests/test-data/api-response/application-GET-v6-expanded-app-type-cpu-arch.json b/tests/test-data/api-response/application-GET-v6-expanded-app-type-cpu-arch.json index 4c543516..62fe7329 100644 --- a/tests/test-data/api-response/application-GET-v6-expanded-app-type-cpu-arch.json +++ b/tests/test-data/api-response/application-GET-v6-expanded-app-type-cpu-arch.json @@ -6,7 +6,7 @@ "name": "Starter", "slug": "microservices-starter", "supports_multicontainer": true, - "is_legacy": false, + "is_legacy": true, "__metadata": {} } ], diff --git a/tests/test-data/api-response/application-GET-v6-expanded-app-type.json b/tests/test-data/api-response/application-GET-v6-expanded-app-type.json index cf484631..6708b2f1 100644 --- a/tests/test-data/api-response/application-GET-v6-expanded-app-type.json +++ b/tests/test-data/api-response/application-GET-v6-expanded-app-type.json @@ -6,7 +6,7 @@ "name": "Starter", "slug": "microservices-starter", "supports_multicontainer": true, - "is_legacy": false, + "is_legacy": true, "__metadata": {} } ],