mirror of
https://github.com/balena-io/balena-cli.git
synced 2024-12-19 05:37:51 +00:00
Merge pull request #2307 from balena-io/2306-env-add-app-is-ambiguous
envs, env add: Fix "Application is ambiguous" when using device UUID
This commit is contained in:
commit
e137c2aed2
8
lib/commands/env/add.ts
vendored
8
lib/commands/env/add.ts
vendored
@ -227,7 +227,7 @@ async function setServiceVars(
|
|||||||
sdk,
|
sdk,
|
||||||
uuid,
|
uuid,
|
||||||
['id'],
|
['id'],
|
||||||
['app_name'],
|
['slug'],
|
||||||
);
|
);
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.error(`${err.message}, device: ${uuid}`);
|
console.error(`${err.message}, device: ${uuid}`);
|
||||||
@ -236,11 +236,7 @@ async function setServiceVars(
|
|||||||
}
|
}
|
||||||
for (const service of options.service!.split(',')) {
|
for (const service of options.service!.split(',')) {
|
||||||
try {
|
try {
|
||||||
const serviceId = await getServiceIdForApp(
|
const serviceId = await getServiceIdForApp(sdk, app.slug, service);
|
||||||
sdk,
|
|
||||||
app.app_name,
|
|
||||||
service,
|
|
||||||
);
|
|
||||||
await sdk.models.device.serviceVar.set(
|
await sdk.models.device.serviceVar.set(
|
||||||
device.id,
|
device.id,
|
||||||
serviceId,
|
serviceId,
|
||||||
|
@ -174,11 +174,11 @@ export default class EnvsCmd extends Command {
|
|||||||
balena,
|
balena,
|
||||||
options.device,
|
options.device,
|
||||||
['uuid'],
|
['uuid'],
|
||||||
['app_name'],
|
['slug'],
|
||||||
);
|
);
|
||||||
fullUUID = device.uuid;
|
fullUUID = device.uuid;
|
||||||
if (app) {
|
if (app) {
|
||||||
appNameOrSlug = app.app_name;
|
appNameOrSlug = app.slug;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (appNameOrSlug && options.service) {
|
if (appNameOrSlug && options.service) {
|
||||||
@ -210,7 +210,14 @@ export default class EnvsCmd extends Command {
|
|||||||
|
|
||||||
// Replace undefined app names with 'N/A' or null
|
// Replace undefined app names with 'N/A' or null
|
||||||
varArray = varArray.map((i: EnvironmentVariableInfo) => {
|
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;
|
return i;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -198,7 +198,7 @@ export class BalenaAPIMock extends NockMock {
|
|||||||
is_online: opts.isOnline,
|
is_online: opts.isOnline,
|
||||||
belongs_to__application: opts.inaccessibleApp
|
belongs_to__application: opts.inaccessibleApp
|
||||||
? []
|
? []
|
||||||
: [{ app_name: 'test' }],
|
: [{ app_name: 'test', slug: 'org/test' }],
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
});
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user