| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 554acf6 commit 2e7764d
3 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1,6 +1,6 @@ | |||
| 1 | 1 | package com.github.dockerjava.core.command; | |
| 2 | 2 | ||
| 3 | - import com.fasterxml.jackson.annotation.JsonIgnore; | ||
| 3 | + import com.fasterxml.jackson.annotation.JsonAutoDetect; | ||
| 4 | 4 | import com.fasterxml.jackson.annotation.JsonProperty; | |
| 5 | 5 | import com.github.dockerjava.api.command.CreateContainerCmd; | |
| 6 | 6 | import com.github.dockerjava.api.command.CreateContainerResponse; | |
@@ -30,6 +30,13 @@ | |||
| 30 | 30 | * Creates a new container. | |
| 31 | 31 | * `/containers/create` | |
| 32 | 32 | */ | |
| 33 | + @JsonAutoDetect( | ||
| 34 | + fieldVisibility = JsonAutoDetect.Visibility.NONE, | ||
| 35 | + setterVisibility = JsonAutoDetect.Visibility.NONE, | ||
| 36 | + getterVisibility = JsonAutoDetect.Visibility.NONE, | ||
| 37 | + isGetterVisibility = JsonAutoDetect.Visibility.NONE, | ||
| 38 | + creatorVisibility = JsonAutoDetect.Visibility.NONE | ||
| 39 | + ) | ||
| 33 | 40 | public class CreateContainerCmdImpl extends AbstrDockerCmd<CreateContainerCmd, CreateContainerResponse> implements | |
| 34 | 41 | CreateContainerCmd { | |
| 35 | 42 | ||
@@ -122,13 +129,10 @@ public class CreateContainerCmdImpl extends AbstrDockerCmd<CreateContainerCmd, C | |||
| 122 | 129 | @JsonProperty("NetworkingConfig") | |
| 123 | 130 | private NetworkingConfig networkingConfig; | |
| 124 | 131 | ||
| 125 | - @JsonIgnore | ||
| 126 | 132 | private String ipv4Address = null; | |
| 127 | 133 | ||
| 128 | - @JsonIgnore | ||
| 129 | 134 | private String ipv6Address = null; | |
| 130 | 135 | ||
| 131 | - @JsonIgnore | ||
| 132 | 136 | private List<String> aliases = null; | |
| 133 | 137 | ||
| 134 | 138 | private AuthConfig authConfig; | |
@@ -151,7 +155,6 @@ public CreateContainerCmd withAuthConfig(AuthConfig authConfig) { | |||
| 151 | 155 | } | |
| 152 | 156 | ||
| 153 | 157 | @Override | |
| 154 | - @JsonIgnore | ||
| 155 | 158 | public List<String> getAliases() { | |
| 156 | 159 | return aliases; | |
| 157 | 160 | } | |
@@ -256,7 +259,6 @@ public CreateContainerCmd withEnv(List<String> env) { | |||
| 256 | 259 | } | |
| 257 | 260 | ||
| 258 | 261 | @Override | |
| 259 | - @JsonIgnore | ||
| 260 | 262 | public ExposedPort[] getExposedPorts() { | |
| 261 | 263 | return exposedPorts.getExposedPorts(); | |
| 262 | 264 | } | |
@@ -277,7 +279,6 @@ public CreateContainerCmd withExposedPorts(List<ExposedPort> exposedPorts) { | |||
| 277 | 279 | /** | |
| 278 | 280 | * @see #stopSignal | |
| 279 | 281 | */ | |
| 280 | - @JsonIgnore | ||
| 281 | 282 | @Override | |
| 282 | 283 | public String getStopSignal() { | |
| 283 | 284 | return stopSignal; | |
@@ -326,7 +327,6 @@ public CreateContainerCmd withImage(String image) { | |||
| 326 | 327 | } | |
| 327 | 328 | ||
| 328 | 329 | @Override | |
| 329 | - @JsonIgnore | ||
| 330 | 330 | public Map<String, String> getLabels() { | |
| 331 | 331 | return labels; | |
| 332 | 332 | } | |
@@ -430,7 +430,6 @@ public CreateContainerCmd withAttachStdout(Boolean attachStdout) { | |||
| 430 | 430 | } | |
| 431 | 431 | ||
| 432 | 432 | @Override | |
| 433 | - @JsonIgnore | ||
| 434 | 433 | public Volume[] getVolumes() { | |
| 435 | 434 | return volumes.getVolumes(); | |
| 436 | 435 | } | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1,6 +1,9 @@ | |||
| 1 | 1 | package com.github.dockerjava.cmd; | |
| 2 | 2 | ||
| 3 | + import com.fasterxml.jackson.databind.ObjectMapper; | ||
| 4 | + import com.fasterxml.jackson.databind.node.ObjectNode; | ||
| 3 | 5 | import com.github.dockerjava.api.async.ResultCallback; | |
| 6 | + import com.github.dockerjava.api.command.CreateContainerCmd; | ||
| 4 | 7 | import com.github.dockerjava.api.command.CreateContainerResponse; | |
| 5 | 8 | import com.github.dockerjava.api.command.CreateNetworkResponse; | |
| 6 | 9 | import com.github.dockerjava.api.command.CreateVolumeResponse; | |
@@ -70,6 +73,7 @@ | |||
| 70 | 73 | import static org.hamcrest.Matchers.emptyString; | |
| 71 | 74 | import static org.hamcrest.Matchers.not; | |
| 72 | 75 | import static org.hamcrest.Matchers.notNullValue; | |
| 76 | + import static org.hamcrest.Matchers.nullValue; | ||
| 73 | 77 | import static org.hamcrest.Matchers.startsWith; | |
| 74 | 78 | import static org.junit.Assert.assertNotNull; | |
| 75 | 79 | import static org.junit.Assert.assertSame; | |
@@ -1108,4 +1112,17 @@ public void overrideHostConfigWithRawValues() { | |||
| 1108 | 1112 | ||
| 1109 | 1113 | assertThat(inspectContainerResponse.getHostConfig().getNanoCPUs(), is(500_000_000L)); | |
| 1110 | 1114 | } | |
| 1115 | + | ||
| 1116 | + @Test | ||
| 1117 | + public void shouldNotEncodeAuth() { | ||
| 1118 | + CreateContainerCmd cmd = dockerRule.getClient().createContainerCmd(DEFAULT_IMAGE) | ||
| 1119 | + .withAuthConfig(new AuthConfig().withEmail("test@test.com")) | ||
| 1120 | + .withCmd("sleep", "9999"); | ||
| 1121 | + | ||
| 1122 | + ObjectMapper objectMapper = dockerRule.getConfig().getObjectMapper(); | ||
| 1123 | + | ||
| 1124 | + ObjectNode jsonNode = objectMapper.valueToTree(cmd); | ||
| 1125 | + | ||
| 1126 | + assertThat(jsonNode.get("authConfig"), nullValue()); | ||
| 1127 | + } | ||
| 1111 | 1128 | } | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -37,8 +37,10 @@ public class DockerRule extends ExternalResource { | |||
| 37 | 37 | ||
| 38 | 38 | private final Set<String> createdVolumeNames = new HashSet<>(); | |
| 39 | 39 | ||
| 40 | + private final DefaultDockerClientConfig config = config(); | ||
| 41 | + | ||
| 40 | 42 | public DockerClient newClient() { | |
| 41 | - DockerClientImpl dockerClient = CmdIT.createDockerClient(config()); | ||
| 43 | + DockerClientImpl dockerClient = CmdIT.createDockerClient(config); | ||
| 42 | 44 | ||
| 43 | 45 | dockerClient.withDockerCmdExecFactory( | |
| 44 | 46 | new DockerCmdExecFactoryDelegate(dockerClient.dockerCmdExecFactory) { | |
@@ -82,6 +84,10 @@ protected DockerClient getDockerClient() { | |||
| 82 | 84 | }; | |
| 83 | 85 | } | |
| 84 | 86 | ||
| 87 | + public DefaultDockerClientConfig getConfig() { | ||
| 88 | + return config; | ||
| 89 | + } | ||
| 90 | + | ||
| 85 | 91 | public DockerClient getClient() { | |
| 86 | 92 | if (dockerClient != null) { | |
| 87 | 93 | return dockerClient; | |
| Back | FazBrowse Home | New Git URL |
0 commit comments