|
1 | 1 | package de.gesellix.docker.remote.api.client; |
2 | 2 |
|
3 | 3 | import com.squareup.moshi.Moshi; |
| 4 | + |
| 5 | +import de.gesellix.docker.registry.LocalDocker; |
4 | 6 | import de.gesellix.docker.remote.api.ContainerCreateRequest; |
5 | 7 | import de.gesellix.docker.remote.api.ContainerCreateResponse; |
6 | 8 | import de.gesellix.docker.remote.api.ContainerInspectResponse; |
@@ -931,6 +933,16 @@ null, null, singletonList("/cat"), |
931 | 933 | null, |
932 | 934 | null |
933 | 935 | ); |
| 936 | + if (LocalDocker.isNativeWindows()) { |
| 937 | + containerCreateRequest.setTty(false); |
| 938 | + containerCreateRequest.setEntrypoint(singletonList("cmd")); |
| 939 | + containerCreateRequest.setCmd(Arrays.asList("/V:ON", "/C", "set /p line= & echo #!line!#")); |
| 940 | + } else { |
| 941 | + containerCreateRequest.setTty(false); |
| 942 | + containerCreateRequest.setEntrypoint(singletonList("/bin/sh")); |
| 943 | + containerCreateRequest.setCmd(Arrays.asList("-c", "read line && echo \"#$line#\"")); |
| 944 | + } |
| 945 | + |
934 | 946 | containerApi.containerCreate(containerCreateRequest, "container-attach-interactive-test"); |
935 | 947 | containerApi.containerStart("container-attach-interactive-test", null); |
936 | 948 |
|
@@ -981,10 +993,18 @@ public void run() { |
981 | 993 | } catch (InterruptedException e) { |
982 | 994 | e.printStackTrace(); |
983 | 995 | } |
984 | | - assertSame(Frame.StreamType.RAW, callback.frames.stream().findAny().get().getStreamType()); |
985 | | - assertEquals( |
986 | | - "hello echo\nhello echo".replaceAll("[\\n\\r]", ""), |
987 | | - callback.frames.stream().map(Frame::getPayloadAsString).collect(Collectors.joining()).replaceAll("[\\n\\r]", "")); |
| 996 | + |
| 997 | + if (containerCreateRequest.getTty() != null && containerCreateRequest.getTty()) { |
| 998 | + assertSame(Frame.StreamType.RAW, callback.frames.stream().findAny().get().getStreamType()); |
| 999 | + assertEquals( |
| 1000 | + "hello echo\nhello echo".replaceAll("[\\n\\r]", ""), |
| 1001 | + callback.frames.stream().map(Frame::getPayloadAsString).collect(Collectors.joining()).replaceAll("[\\n\\r]", "")); |
| 1002 | + } else { |
| 1003 | + assertSame(Frame.StreamType.STDOUT, callback.frames.stream().findAny().get().getStreamType()); |
| 1004 | + assertEquals( |
| 1005 | + "#hello echo#", |
| 1006 | + callback.frames.stream().map(Frame::getPayloadAsString).collect(Collectors.joining()).replaceAll("[\\n\\r]", "")); |
| 1007 | + } |
988 | 1008 |
|
989 | 1009 | removeContainer(engineApiClient, "container-attach-interactive-test"); |
990 | 1010 | } |
|
0 commit comments