mirror of
https://github.com/balena-io/balena-cli.git
synced 2024-12-21 06:33:28 +00:00
Support container contracts when pushing to local devices
Change-type: patch Signed-off-by: Cameron Diver <cameron@balena.io>
This commit is contained in:
parent
4280a3cd4a
commit
0c5ed7adfb
@ -211,6 +211,7 @@ export async function deployToDevice(opts: DeviceDeployOptions): Promise<void> {
|
|||||||
const targetState = generateTargetState(
|
const targetState = generateTargetState(
|
||||||
currentTargetState,
|
currentTargetState,
|
||||||
project.composition,
|
project.composition,
|
||||||
|
buildTasks,
|
||||||
envs,
|
envs,
|
||||||
);
|
);
|
||||||
globalLogger.logDebug(`Sending target state: ${JSON.stringify(targetState)}`);
|
globalLogger.logDebug(`Sending target state: ${JSON.stringify(targetState)}`);
|
||||||
@ -488,8 +489,11 @@ function generateImageName(serviceName: string): string {
|
|||||||
export function generateTargetState(
|
export function generateTargetState(
|
||||||
currentTargetState: any,
|
currentTargetState: any,
|
||||||
composition: Composition,
|
composition: Composition,
|
||||||
|
buildTasks: BuildTask[],
|
||||||
env: ParsedEnvironment,
|
env: ParsedEnvironment,
|
||||||
): any {
|
): any {
|
||||||
|
const keyedBuildTasks = _.keyBy(buildTasks, 'serviceName');
|
||||||
|
|
||||||
const services: { [serviceId: string]: any } = {};
|
const services: { [serviceId: string]: any } = {};
|
||||||
let idx = 1;
|
let idx = 1;
|
||||||
_.each(composition.services, (opts, name) => {
|
_.each(composition.services, (opts, name) => {
|
||||||
@ -504,14 +508,20 @@ export function generateTargetState(
|
|||||||
};
|
};
|
||||||
|
|
||||||
opts.environment = _.merge(opts.environment, env[name]);
|
opts.environment = _.merge(opts.environment, env[name]);
|
||||||
|
const contract = keyedBuildTasks[name].contract;
|
||||||
|
|
||||||
services[idx] = _.merge(defaults, opts, {
|
services[idx] = {
|
||||||
imageId: idx,
|
...defaults,
|
||||||
serviceName: name,
|
...opts,
|
||||||
serviceId: idx,
|
...(contract != null ? { contract } : {}),
|
||||||
image: generateImageName(name),
|
...{
|
||||||
running: true,
|
imageId: idx,
|
||||||
});
|
serviceName: name,
|
||||||
|
serviceId: idx,
|
||||||
|
image: generateImageName(name),
|
||||||
|
running: true,
|
||||||
|
},
|
||||||
|
};
|
||||||
idx += 1;
|
idx += 1;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -351,7 +351,7 @@ export class LivepushManager {
|
|||||||
// If we re-apply the target state, the supervisor
|
// If we re-apply the target state, the supervisor
|
||||||
// should recreate the container
|
// should recreate the container
|
||||||
await this.api.setTargetState(
|
await this.api.setTargetState(
|
||||||
generateTargetState(currentState, this.composition, {}),
|
generateTargetState(currentState, this.composition, [buildTask], {}),
|
||||||
);
|
);
|
||||||
|
|
||||||
await this.awaitDeviceStateSettle();
|
await this.awaitDeviceStateSettle();
|
||||||
|
Loading…
Reference in New Issue
Block a user