mirror of
https://github.com/balena-io/balena-cli.git
synced 2024-12-20 14:13:07 +00:00
balena deploy: Retrieve the cpu arch as part of the device type resource
Connects-to: #2318 Change-type: patch Signed-off-by: Thodoris Greasidis <thodoris@balena.io>
This commit is contained in:
parent
f3ab41841a
commit
24fe6666e4
@ -148,23 +148,18 @@ export async function osProgressHandler(step: InitializeEmitter) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
export function getAppWithArch(
|
export async function getAppWithArch(
|
||||||
applicationName: string,
|
applicationName: string,
|
||||||
): Promise<ApplicationWithDeviceType & { arch: string }> {
|
): Promise<ApplicationWithDeviceType & { arch: string }> {
|
||||||
return Promise.all([
|
const app = await getApplication(applicationName);
|
||||||
getApplication(applicationName),
|
const { getExpanded } = await import('./pine');
|
||||||
getBalenaSdk().models.config.getDeviceTypes(),
|
|
||||||
]).then(function ([app, deviceTypes]) {
|
|
||||||
const config = _.find<BalenaSdk.DeviceTypeJson.DeviceType>(deviceTypes, {
|
|
||||||
slug: app.is_for__device_type[0].slug,
|
|
||||||
});
|
|
||||||
|
|
||||||
if (!config) {
|
return {
|
||||||
throw new Error(`balena API request failed for fleet ${applicationName}`);
|
...app,
|
||||||
}
|
arch: getExpanded(
|
||||||
|
getExpanded(app.is_for__device_type)!.is_of__cpu_architecture,
|
||||||
return { ...app, arch: config.arch };
|
)!.slug,
|
||||||
});
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: Drop this. The sdk now has this baked in application.get().
|
// TODO: Drop this. The sdk now has this baked in application.get().
|
||||||
@ -182,6 +177,11 @@ function getApplication(
|
|||||||
},
|
},
|
||||||
is_for__device_type: {
|
is_for__device_type: {
|
||||||
$select: 'slug',
|
$select: 'slug',
|
||||||
|
$expand: {
|
||||||
|
is_of__cpu_architecture: {
|
||||||
|
$select: 'slug',
|
||||||
|
},
|
||||||
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
@ -79,8 +79,7 @@ describe('balena deploy', function () {
|
|||||||
docker = new DockerMock();
|
docker = new DockerMock();
|
||||||
api.expectGetWhoAmI({ optional: true, persist: true });
|
api.expectGetWhoAmI({ optional: true, persist: true });
|
||||||
api.expectGetMixpanel({ optional: true });
|
api.expectGetMixpanel({ optional: true });
|
||||||
api.expectGetConfigDeviceTypes();
|
api.expectGetApplication({ expandArchitecture: true });
|
||||||
api.expectGetApplication();
|
|
||||||
api.expectGetRelease();
|
api.expectGetRelease();
|
||||||
api.expectGetUser();
|
api.expectGetUser();
|
||||||
api.expectGetService({ serviceName: 'main' });
|
api.expectGetService({ serviceName: 'main' });
|
||||||
|
@ -35,6 +35,7 @@ export class BalenaAPIMock extends NockMock {
|
|||||||
notFound = false,
|
notFound = false,
|
||||||
optional = false,
|
optional = false,
|
||||||
persist = false,
|
persist = false,
|
||||||
|
expandArchitecture = false,
|
||||||
} = {}) {
|
} = {}) {
|
||||||
const interceptor = this.optGet(/^\/v6\/application($|[(?])/, {
|
const interceptor = this.optGet(/^\/v6\/application($|[(?])/, {
|
||||||
optional,
|
optional,
|
||||||
@ -45,7 +46,12 @@ export class BalenaAPIMock extends NockMock {
|
|||||||
} else {
|
} else {
|
||||||
interceptor.replyWithFile(
|
interceptor.replyWithFile(
|
||||||
200,
|
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,
|
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