diff --git a/lib/commands/env/add.ts b/lib/commands/env/add.ts index 9ea59faf..ffa841a5 100644 --- a/lib/commands/env/add.ts +++ b/lib/commands/env/add.ts @@ -227,7 +227,7 @@ async function setServiceVars( sdk, uuid, ['id'], - ['app_name'], + ['slug'], ); } catch (err) { console.error(`${err.message}, device: ${uuid}`); @@ -236,11 +236,7 @@ async function setServiceVars( } for (const service of options.service!.split(',')) { try { - const serviceId = await getServiceIdForApp( - sdk, - app.app_name, - service, - ); + const serviceId = await getServiceIdForApp(sdk, app.slug, service); await sdk.models.device.serviceVar.set( device.id, serviceId, diff --git a/lib/commands/envs.ts b/lib/commands/envs.ts index 19709e7e..20c47ea2 100644 --- a/lib/commands/envs.ts +++ b/lib/commands/envs.ts @@ -174,11 +174,11 @@ export default class EnvsCmd extends Command { balena, options.device, ['uuid'], - ['app_name'], + ['slug'], ); fullUUID = device.uuid; if (app) { - appNameOrSlug = app.app_name; + appNameOrSlug = app.slug; } } if (appNameOrSlug && options.service) { @@ -210,7 +210,14 @@ export default class EnvsCmd extends Command { // Replace undefined app names with 'N/A' or null varArray = varArray.map((i: EnvironmentVariableInfo) => { - i.appName = i.appName || (options.json ? null : 'N/A'); + if (i.appName) { + // use slug in v13, app name in v12 for compatibility + i.appName = isV13() + ? i.appName + : i.appName.substring(i.appName.indexOf('/') + 1); + } else { + i.appName = options.json ? null : 'N/A'; + } return i; }); diff --git a/tests/balena-api-mock.ts b/tests/balena-api-mock.ts index d14cbcd8..7f21febc 100644 --- a/tests/balena-api-mock.ts +++ b/tests/balena-api-mock.ts @@ -198,7 +198,7 @@ export class BalenaAPIMock extends NockMock { is_online: opts.isOnline, belongs_to__application: opts.inaccessibleApp ? [] - : [{ app_name: 'test' }], + : [{ app_name: 'test', slug: 'org/test' }], }, ], });