diff --git a/src/compose/service.ts b/src/compose/service.ts index 6ab54089..dd68c8e7 100644 --- a/src/compose/service.ts +++ b/src/compose/service.ts @@ -448,7 +448,7 @@ export class Service { // We cannot use || for this value, as the empty string is a // valid restart policy but will equate to null in an OR - let restart = (container.HostConfig.RestartPolicy || {}).Name; + let restart = _.get(container.HostConfig.RestartPolicy, 'Name'); if (restart == null) { restart = 'always'; } @@ -462,7 +462,9 @@ export class Service { // the entire ContainerInspectInfo object, or upstream the extra // fields to DefinitelyTyped svc.config = { - networkMode: container.HostConfig.NetworkMode, + // The typings say that this is optional, but it's + // always set by docker + networkMode: container.HostConfig.NetworkMode!, portMaps, expose, diff --git a/src/config/types.ts b/src/config/types.ts index 137b5102..e28215ee 100644 --- a/src/config/types.ts +++ b/src/config/types.ts @@ -19,8 +19,8 @@ export const PermissiveBoolean = new t.Type>( (m, c) => permissiveValue.validate(m, c).chain(v => { switch (typeof v) { - case 'boolean': case 'string': + case 'boolean': case 'number': const val = checkTruthy(v); if (val == null) { diff --git a/src/lib/validation.ts b/src/lib/validation.ts index d3cc2058..8a1ef31b 100644 --- a/src/lib/validation.ts +++ b/src/lib/validation.ts @@ -61,6 +61,9 @@ export function checkString(s: NullableLiteral): string | void { * which represents if the input was truthy */ export function checkTruthy(v: string | boolean | number): boolean | void { + if (_.isString(v)) { + v = v.toLowerCase(); + } switch (v) { case '1': case 'true':