mirror of
https://github.com/balena-os/balena-supervisor.git
synced 2025-06-22 00:57:24 +00:00
Add support for init field from compose
Init supports boolean values, and is not included in the config when not defined. Change-type: patch Signed-off-by: Christina Ying Wang <christina@balena.io>
This commit is contained in:
committed by
Felipe Lalanne
parent
e01aaaaafb
commit
ed1c18e369
@ -337,6 +337,13 @@ class ServiceImpl implements Service {
|
||||
config.tty = Boolean(config.tty);
|
||||
}
|
||||
|
||||
// Only keep init field if it's a boolean
|
||||
if (config.init != null) {
|
||||
config.init = Boolean(config.init);
|
||||
} else {
|
||||
delete config.init;
|
||||
}
|
||||
|
||||
if (Array.isArray(config.sysctls)) {
|
||||
config.sysctls = _.fromPairs(
|
||||
_.map(config.sysctls, (v) => _.split(v, '=')),
|
||||
@ -598,6 +605,11 @@ class ServiceImpl implements Service {
|
||||
tty: container.Config.Tty || false,
|
||||
};
|
||||
|
||||
// Only add `init` if true or false, otherwise leave blank
|
||||
if (typeof container.HostConfig.Init === 'boolean') {
|
||||
svc.config.init = container.HostConfig.Init;
|
||||
}
|
||||
|
||||
const appId = checkInt(svc.config.labels['io.balena.app-id']);
|
||||
if (appId == null) {
|
||||
throw new InternalInconsistencyError(
|
||||
@ -739,6 +751,7 @@ class ServiceImpl implements Service {
|
||||
UsernsMode: this.config.usernsMode,
|
||||
NanoCpus: this.config.cpus,
|
||||
IpcMode: this.config.ipc,
|
||||
Init: this.config.init,
|
||||
} as Dockerode.ContainerCreateOptions['HostConfig'],
|
||||
Healthcheck: ComposeUtils.serviceHealthcheckToDockerHealthcheck(
|
||||
this.config.healthcheck,
|
||||
|
@ -183,7 +183,7 @@ export interface ServiceComposeConfig {
|
||||
groupAdd?: string[];
|
||||
healthcheck?: ComposeHealthcheck;
|
||||
image: string;
|
||||
init?: string | boolean;
|
||||
init?: boolean;
|
||||
labels?: { [labelName: string]: string };
|
||||
running?: boolean;
|
||||
networkMode?: string;
|
||||
@ -272,6 +272,7 @@ export interface ServiceConfig {
|
||||
domainname: string;
|
||||
hostname: string;
|
||||
ipc: string;
|
||||
init?: boolean;
|
||||
macAddress: string;
|
||||
memLimit: number;
|
||||
memReservation: number;
|
||||
|
Reference in New Issue
Block a user