Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package com.github.dockerjava.core.command;

import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonAutoDetect;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.github.dockerjava.api.command.CreateContainerCmd;
import com.github.dockerjava.api.command.CreateContainerResponse;
Expand Down Expand Up @@ -30,6 +30,13 @@
* Creates a new container.
* `/containers/create`
*/
@JsonAutoDetect(
fieldVisibility = JsonAutoDetect.Visibility.NONE,
setterVisibility = JsonAutoDetect.Visibility.NONE,
getterVisibility = JsonAutoDetect.Visibility.NONE,
isGetterVisibility = JsonAutoDetect.Visibility.NONE,
creatorVisibility = JsonAutoDetect.Visibility.NONE
)
public class CreateContainerCmdImpl extends AbstrDockerCmd<CreateContainerCmd, CreateContainerResponse> implements
CreateContainerCmd {

Expand Down Expand Up @@ -122,13 +129,10 @@ public class CreateContainerCmdImpl extends AbstrDockerCmd<CreateContainerCmd, C
@JsonProperty("NetworkingConfig")
private NetworkingConfig networkingConfig;

@JsonIgnore
private String ipv4Address = null;

@JsonIgnore
private String ipv6Address = null;

@JsonIgnore
private List<String> aliases = null;

private AuthConfig authConfig;
Expand All @@ -151,7 +155,6 @@ public CreateContainerCmd withAuthConfig(AuthConfig authConfig) {
}

@Override
@JsonIgnore
public List<String> getAliases() {
return aliases;
}
Expand Down Expand Up @@ -256,7 +259,6 @@ public CreateContainerCmd withEnv(List<String> env) {
}

@Override
@JsonIgnore
public ExposedPort[] getExposedPorts() {
return exposedPorts.getExposedPorts();
}
Expand All @@ -277,7 +279,6 @@ public CreateContainerCmd withExposedPorts(List<ExposedPort> exposedPorts) {
/**
* @see #stopSignal
*/
@JsonIgnore
@Override
public String getStopSignal() {
return stopSignal;
Expand Down Expand Up @@ -326,7 +327,6 @@ public CreateContainerCmd withImage(String image) {
}

@Override
@JsonIgnore
public Map<String, String> getLabels() {
return labels;
}
Expand Down Expand Up @@ -430,7 +430,6 @@ public CreateContainerCmd withAttachStdout(Boolean attachStdout) {
}

@Override
@JsonIgnore
public Volume[] getVolumes() {
return volumes.getVolumes();
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
package com.github.dockerjava.cmd;

import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.node.ObjectNode;
import com.github.dockerjava.api.async.ResultCallback;
import com.github.dockerjava.api.command.CreateContainerCmd;
import com.github.dockerjava.api.command.CreateContainerResponse;
import com.github.dockerjava.api.command.CreateNetworkResponse;
import com.github.dockerjava.api.command.CreateVolumeResponse;
Expand Down Expand Up @@ -70,6 +73,7 @@
import static org.hamcrest.Matchers.emptyString;
import static org.hamcrest.Matchers.not;
import static org.hamcrest.Matchers.notNullValue;
import static org.hamcrest.Matchers.nullValue;
import static org.hamcrest.Matchers.startsWith;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertSame;
Expand Down Expand Up @@ -1108,4 +1112,17 @@ public void overrideHostConfigWithRawValues() {

assertThat(inspectContainerResponse.getHostConfig().getNanoCPUs(), is(500_000_000L));
}

@Test
public void shouldNotEncodeAuth() {
CreateContainerCmd cmd = dockerRule.getClient().createContainerCmd(DEFAULT_IMAGE)
.withAuthConfig(new AuthConfig().withEmail("[email protected]"))
.withCmd("sleep", "9999");

ObjectMapper objectMapper = dockerRule.getConfig().getObjectMapper();

ObjectNode jsonNode = objectMapper.valueToTree(cmd);

assertThat(jsonNode.get("authConfig"), nullValue());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,10 @@ public class DockerRule extends ExternalResource {

private final Set<String> createdVolumeNames = new HashSet<>();

private final DefaultDockerClientConfig config = config();

public DockerClient newClient() {
DockerClientImpl dockerClient = CmdIT.createDockerClient(config());
DockerClientImpl dockerClient = CmdIT.createDockerClient(config);

dockerClient.withDockerCmdExecFactory(
new DockerCmdExecFactoryDelegate(dockerClient.dockerCmdExecFactory) {
Expand Down Expand Up @@ -82,6 +84,10 @@ protected DockerClient getDockerClient() {
};
}

public DefaultDockerClientConfig getConfig() {
return config;
}

public DockerClient getClient() {
if (dockerClient != null) {
return dockerClient;
Expand Down