Merge pull request #2316 from balena-io/os-download-no-device-types-v1

os download: Use the hostApps instead of the device-types/v1 endpoint
This commit is contained in:
bulldozer-balena[bot] 2021-08-31 01:32:58 +00:00 committed by GitHub
commit 370b844538
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -188,18 +188,21 @@ async function resolveOSVersion(deviceType: string, version: string) {
return version;
}
const { versions: vs, recommended } =
await getBalenaSdk().models.os.getSupportedVersions(deviceType);
const vs = (
(await getBalenaSdk().models.hostapp.getAllOsVersions([deviceType]))[
deviceType
] ?? []
).filter((v) => v.osType === 'default');
const choices = vs.map((v) => ({
value: v,
name: `v${v}` + (v === recommended ? ' (recommended)' : ''),
value: v.rawVersion,
name: `v${v.rawVersion}` + (v.isRecommended ? ' (recommended)' : ''),
}));
return getCliForm().ask({
message: 'Select the OS version:',
type: 'list',
choices,
default: recommended,
default: (vs.find((v) => v.isRecommended) ?? vs[0])?.rawVersion,
});
}