From fcec8a063478bcd4ab5db22a50165cd9f6f41414 Mon Sep 17 00:00:00 2001 From: cfredri4 <50839054+cfredri4@users.noreply.github.com> Date: Tue, 14 Jul 2020 10:44:08 +0200 Subject: [PATCH 1/4] Also add fixed COLUMNS to localMachine To fix issue with docker-compose when system terminal is narrow. Also harmonize code according to RemoteBuilder.build. --- .../docker/compose/connection/DockerMachine.java | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/docker-compose-rule-core/src/main/java/com/palantir/docker/compose/connection/DockerMachine.java b/docker-compose-rule-core/src/main/java/com/palantir/docker/compose/connection/DockerMachine.java index d6525fe73..bdc962a93 100644 --- a/docker-compose-rule-core/src/main/java/com/palantir/docker/compose/connection/DockerMachine.java +++ b/docker-compose-rule-core/src/main/java/com/palantir/docker/compose/connection/DockerMachine.java @@ -100,12 +100,19 @@ public LocalBuilder withEnvironment(Map newEnvironment) { public DockerMachine build() { dockerType.validateEnvironmentVariables(systemEnvironment); AdditionalEnvironmentValidator.validate(additionalEnvironment); - Map combinedEnvironment = newHashMap(); - combinedEnvironment.putAll(systemEnvironment); - combinedEnvironment.putAll(additionalEnvironment); String dockerHost = systemEnvironment.getOrDefault(DOCKER_HOST, ""); - return new DockerMachine(dockerType.resolveIp(dockerHost), ImmutableMap.copyOf(combinedEnvironment)); + String hostIp = dockerType.resolveIp(dockerHost); + + Map environment = ImmutableMap.builder() + // 2019-12-17: newer docker-compose adjusts its output based on the number of columns available + // in the terminal. This interferes with parsing of the output of docker-compose, so "COLUMNS" is + // set to an artificially large value. + .put("COLUMNS", "10000") + .putAll(systemEnvironment) + .putAll(additionalEnvironment) + .build(); + return new DockerMachine(hostIp, environment); } } From 7d47035326fe51a16b73a8d9f4f02200c391cd7f Mon Sep 17 00:00:00 2001 From: cfredri4 <50839054+cfredri4@users.noreply.github.com> Date: Tue, 14 Jul 2020 10:50:31 +0200 Subject: [PATCH 2/4] Update DockerMachine.java Oops, wrong order --- .../com/palantir/docker/compose/connection/DockerMachine.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docker-compose-rule-core/src/main/java/com/palantir/docker/compose/connection/DockerMachine.java b/docker-compose-rule-core/src/main/java/com/palantir/docker/compose/connection/DockerMachine.java index bdc962a93..12e805e5f 100644 --- a/docker-compose-rule-core/src/main/java/com/palantir/docker/compose/connection/DockerMachine.java +++ b/docker-compose-rule-core/src/main/java/com/palantir/docker/compose/connection/DockerMachine.java @@ -108,9 +108,9 @@ public DockerMachine build() { // 2019-12-17: newer docker-compose adjusts its output based on the number of columns available // in the terminal. This interferes with parsing of the output of docker-compose, so "COLUMNS" is // set to an artificially large value. - .put("COLUMNS", "10000") .putAll(systemEnvironment) .putAll(additionalEnvironment) + .put("COLUMNS", "10000") .build(); return new DockerMachine(hostIp, environment); } From c0f88728855462bfc7b55e4aa8f6be1c52201e71 Mon Sep 17 00:00:00 2001 From: cfredri4 <50839054+cfredri4@users.noreply.github.com> Date: Wed, 15 Jul 2020 12:02:17 +0200 Subject: [PATCH 3/4] Revert LocalBuilder changes After review comment Instead harmonize RemoteBuilder with LocalBuilder --- .../compose/connection/DockerMachine.java | 36 +++++++++---------- 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/docker-compose-rule-core/src/main/java/com/palantir/docker/compose/connection/DockerMachine.java b/docker-compose-rule-core/src/main/java/com/palantir/docker/compose/connection/DockerMachine.java index 12e805e5f..3cbcc98fd 100644 --- a/docker-compose-rule-core/src/main/java/com/palantir/docker/compose/connection/DockerMachine.java +++ b/docker-compose-rule-core/src/main/java/com/palantir/docker/compose/connection/DockerMachine.java @@ -104,15 +104,15 @@ public DockerMachine build() { String dockerHost = systemEnvironment.getOrDefault(DOCKER_HOST, ""); String hostIp = dockerType.resolveIp(dockerHost); - Map environment = ImmutableMap.builder() - // 2019-12-17: newer docker-compose adjusts its output based on the number of columns available - // in the terminal. This interferes with parsing of the output of docker-compose, so "COLUMNS" is - // set to an artificially large value. - .putAll(systemEnvironment) - .putAll(additionalEnvironment) - .put("COLUMNS", "10000") - .build(); - return new DockerMachine(hostIp, environment); + Map combinedEnvironment = newHashMap(); + combinedEnvironment.putAll(systemEnvironment); + combinedEnvironment.putAll(additionalEnvironment); + // 2019-12-17: newer docker-compose adjusts its output based on the number of columns available + // in the terminal. This interferes with parsing of the output of docker-compose, so "COLUMNS" is + // set to an artificially large value. + combinedEnvironment.put("COLUMNS", "10000"): + + return new DockerMachine(hostIp, ImmutableMap.copyOf(combinedEnvironment)); } } @@ -161,15 +161,15 @@ public DockerMachine build() { String dockerHost = dockerEnvironment.getOrDefault(DOCKER_HOST, ""); String hostIp = new RemoteHostIpResolver().resolveIp(dockerHost); - Map environment = ImmutableMap.builder() - // 2019-12-17: newer docker-compose adjusts its output based on the number of columns available - // in the terminal. This interferes with parsing of the output of docker-compose, so "COLUMNS" is - // set to an artificially large value. - .put("COLUMNS", "10000") - .putAll(dockerEnvironment) - .putAll(additionalEnvironment) - .build(); - return new DockerMachine(hostIp, environment); + Map combinedEnvironment = newHashMap(); + combinedEnvironment.putAll(dockerEnvironment); + combinedEnvironment.putAll(additionalEnvironment); + // 2019-12-17: newer docker-compose adjusts its output based on the number of columns available + // in the terminal. This interferes with parsing of the output of docker-compose, so "COLUMNS" is + // set to an artificially large value. + combinedEnvironment.put("COLUMNS", "10000"): + + return new DockerMachine(hostIp, ImmutableMap.copyOf(combinedEnvironment)); } } From a7b03834d8a566d69a3cbcf7cf910063b2d02bad Mon Sep 17 00:00:00 2001 From: cfredri4 <50839054+cfredri4@users.noreply.github.com> Date: Wed, 15 Jul 2020 12:06:13 +0200 Subject: [PATCH 4/4] Typo --- .../com/palantir/docker/compose/connection/DockerMachine.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docker-compose-rule-core/src/main/java/com/palantir/docker/compose/connection/DockerMachine.java b/docker-compose-rule-core/src/main/java/com/palantir/docker/compose/connection/DockerMachine.java index 3cbcc98fd..51eded915 100644 --- a/docker-compose-rule-core/src/main/java/com/palantir/docker/compose/connection/DockerMachine.java +++ b/docker-compose-rule-core/src/main/java/com/palantir/docker/compose/connection/DockerMachine.java @@ -110,7 +110,7 @@ public DockerMachine build() { // 2019-12-17: newer docker-compose adjusts its output based on the number of columns available // in the terminal. This interferes with parsing of the output of docker-compose, so "COLUMNS" is // set to an artificially large value. - combinedEnvironment.put("COLUMNS", "10000"): + combinedEnvironment.put("COLUMNS", "10000"); return new DockerMachine(hostIp, ImmutableMap.copyOf(combinedEnvironment)); } @@ -167,7 +167,7 @@ public DockerMachine build() { // 2019-12-17: newer docker-compose adjusts its output based on the number of columns available // in the terminal. This interferes with parsing of the output of docker-compose, so "COLUMNS" is // set to an artificially large value. - combinedEnvironment.put("COLUMNS", "10000"): + combinedEnvironment.put("COLUMNS", "10000"); return new DockerMachine(hostIp, ImmutableMap.copyOf(combinedEnvironment)); }