From 8424fb44f6524fc745b47bce6e517b9d18133ef9 Mon Sep 17 00:00:00 2001 From: Cameron Diver Date: Wed, 1 May 2019 12:10:58 +0100 Subject: [PATCH 1/2] Perform case-insensitive checking when converting booleans from strings Change-type: patch Signed-off-by: Cameron Diver --- src/config/types.ts | 2 +- src/lib/validation.ts | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) 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': From 76e0361b0e52530472c1af0316ab33bd6aa43f2f Mon Sep 17 00:00:00 2001 From: Cameron Diver Date: Fri, 3 May 2019 11:31:13 +0100 Subject: [PATCH 2/2] Fix dockerode type failures Signed-off-by: Cameron Diver --- src/compose/service.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) 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,