mirror of
https://github.com/balena-io/balena-cli.git
synced 2024-12-19 05:37:51 +00:00
Merge pull request #2317 from balena-io/balena-deploy-no-device-types-v1
balena deploy: Retrieve the cpu arch as part of the device type resource
This commit is contained in:
commit
09dd2dd354
@ -148,23 +148,18 @@ export async function osProgressHandler(step: InitializeEmitter) {
|
||||
});
|
||||
}
|
||||
|
||||
export function getAppWithArch(
|
||||
export async function getAppWithArch(
|
||||
applicationName: string,
|
||||
): Promise<ApplicationWithDeviceType & { arch: string }> {
|
||||
return Promise.all([
|
||||
getApplication(applicationName),
|
||||
getBalenaSdk().models.config.getDeviceTypes(),
|
||||
]).then(function ([app, deviceTypes]) {
|
||||
const config = _.find<BalenaSdk.DeviceTypeJson.DeviceType>(deviceTypes, {
|
||||
slug: app.is_for__device_type[0].slug,
|
||||
});
|
||||
const app = await getApplication(applicationName);
|
||||
const { getExpanded } = await import('./pine');
|
||||
|
||||
if (!config) {
|
||||
throw new Error(`balena API request failed for fleet ${applicationName}`);
|
||||
}
|
||||
|
||||
return { ...app, arch: config.arch };
|
||||
});
|
||||
return {
|
||||
...app,
|
||||
arch: getExpanded(
|
||||
getExpanded(app.is_for__device_type)!.is_of__cpu_architecture,
|
||||
)!.slug,
|
||||
};
|
||||
}
|
||||
|
||||
// TODO: Drop this. The sdk now has this baked in application.get().
|
||||
@ -182,6 +177,11 @@ function getApplication(
|
||||
},
|
||||
is_for__device_type: {
|
||||
$select: 'slug',
|
||||
$expand: {
|
||||
is_of__cpu_architecture: {
|
||||
$select: 'slug',
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
};
|
||||
|
@ -79,8 +79,7 @@ describe('balena deploy', function () {
|
||||
docker = new DockerMock();
|
||||
api.expectGetWhoAmI({ optional: true, persist: true });
|
||||
api.expectGetMixpanel({ optional: true });
|
||||
api.expectGetConfigDeviceTypes();
|
||||
api.expectGetApplication();
|
||||
api.expectGetApplication({ expandArchitecture: true });
|
||||
api.expectGetRelease();
|
||||
api.expectGetUser();
|
||||
api.expectGetService({ serviceName: 'main' });
|
||||
|
@ -35,6 +35,7 @@ export class BalenaAPIMock extends NockMock {
|
||||
notFound = false,
|
||||
optional = false,
|
||||
persist = false,
|
||||
expandArchitecture = false,
|
||||
} = {}) {
|
||||
const interceptor = this.optGet(/^\/v6\/application($|[(?])/, {
|
||||
optional,
|
||||
@ -45,7 +46,12 @@ export class BalenaAPIMock extends NockMock {
|
||||
} else {
|
||||
interceptor.replyWithFile(
|
||||
200,
|
||||
path.join(apiResponsePath, 'application-GET-v6-expanded-app-type.json'),
|
||||
path.join(
|
||||
apiResponsePath,
|
||||
!expandArchitecture
|
||||
? 'application-GET-v6-expanded-app-type.json'
|
||||
: 'application-GET-v6-expanded-app-type-cpu-arch.json',
|
||||
),
|
||||
jHeader,
|
||||
);
|
||||
}
|
||||
|
@ -0,0 +1,53 @@
|
||||
{
|
||||
"d": [
|
||||
{
|
||||
"application_type": [
|
||||
{
|
||||
"name": "Starter",
|
||||
"slug": "microservices-starter",
|
||||
"supports_multicontainer": true,
|
||||
"is_legacy": false,
|
||||
"__metadata": {}
|
||||
}
|
||||
],
|
||||
"id": 1301645,
|
||||
"user": {
|
||||
"__deferred": {
|
||||
"uri": "/resin/user(43699)"
|
||||
},
|
||||
"__id": 43699
|
||||
},
|
||||
"organization": [
|
||||
{
|
||||
"handle": "gh_user"
|
||||
}
|
||||
],
|
||||
"depends_on__application": null,
|
||||
"actor": 3423895,
|
||||
"app_name": "testApp",
|
||||
"slug": "gh_user/testApp",
|
||||
"should_be__running_release": [
|
||||
{
|
||||
"commit": "96eec431d57e6976d3a756df33fde7e2"
|
||||
}
|
||||
],
|
||||
"is_for__device_type": [
|
||||
{
|
||||
"slug": "raspberrypi3",
|
||||
"is_of__cpu_architecture": [
|
||||
{
|
||||
"slug": "armv7hf"
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"should_track_latest_release": true,
|
||||
"is_accessible_by_support_until__date": null,
|
||||
"is_public": false,
|
||||
"is_host": false,
|
||||
"__metadata": {
|
||||
"uri": "/resin/application(@id)?@id=1301645"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
Loading…
Reference in New Issue
Block a user