Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Moves CommitConfig into CommitCmd
This is the first step toward simplifying or getting rid of the
CommitConfig object.
  • Loading branch information
mfulgo committed Aug 1, 2014
commit 476dafc2ff3a0eda247dc684f8cdd20115b09d6c
216 changes: 202 additions & 14 deletions src/main/java/com/github/dockerjava/client/command/CommitCmd.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,20 @@
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.MultivaluedMap;

import com.fasterxml.jackson.annotation.JsonProperty;
import com.github.dockerjava.client.model.ExposedPorts;
import com.github.dockerjava.client.model.Volumes;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.fasterxml.jackson.databind.node.ObjectNode;
import com.github.dockerjava.client.DockerException;
import com.github.dockerjava.client.NotFoundException;
import com.github.dockerjava.client.model.CommitConfig;
import com.google.common.base.Preconditions;
import com.sun.jersey.api.client.UniformInterfaceException;
import com.sun.jersey.api.client.WebResource;
import com.sun.jersey.core.util.MultivaluedMapImpl;


/**
*
* Create a new image from a container's changes. Returns the new image ID.
Expand Down Expand Up @@ -60,12 +61,6 @@ public boolean hasPauseEnabled() {
return pause;
}

public CommitCmd withCommitConfig(CommitConfig commitConfig) {
checkCommitConfig(commitConfig);
this.commitConfig = commitConfig;
return this;
}

public CommitCmd withAttachStderr(boolean attachStderr) {
this.commitConfig.setAttachStderr(attachStderr);
return this;
Expand Down Expand Up @@ -144,13 +139,7 @@ public String toString() {
.toString();
}

private void checkCommitConfig(CommitConfig commitConfig) {
Preconditions.checkNotNull(commitConfig, "CommitConfig was not specified");
}

protected String impl() throws DockerException {
checkCommitConfig(commitConfig);

MultivaluedMap<String, String> params = new MultivaluedMapImpl();
params.add("container", containerId);
params.add("repo", repository);
Expand All @@ -177,4 +166,203 @@ protected String impl() throws DockerException {
throw new DockerException(e);
}
}

/**
*
* @author Konstantin Pelykh (kpelykh@gmail.com)
*
*/
// TODO Simplify this
private static class CommitConfig {

@JsonProperty("AttachStdin")
private boolean attachStdin;

@JsonProperty("AttachStdout")
private boolean attachStdout;

@JsonProperty("AttachStderr")
private boolean attachStderr;

@JsonProperty("Cmd")
private String[] cmd;

@JsonProperty("DisableNetwork")
private boolean disableNetwork;

@JsonProperty("Env")
private String[] env;

@JsonProperty("ExposedPorts")
private ExposedPorts exposedPorts;

@JsonProperty("Hostname")
private String hostname;

@JsonProperty("Memory")
private Integer memory;

@JsonProperty("MemorySwap")
private Integer memorySwap;

@JsonProperty("OpenStdin")
private boolean openStdin;

@JsonProperty("PortSpecs")
private String[] portSpecs;

@JsonProperty("StdinOnce")
private boolean stdinOnce;

@JsonProperty("Tty")
private boolean tty;

@JsonProperty("User")
private String user;

@JsonProperty("Volumes")
private Volumes volumes;

@JsonProperty("WorkingDir")
private String workingDir;

public boolean isAttachStdin() {
return attachStdin;
}

public void setAttachStdin(boolean attachStdin) {
this.attachStdin = attachStdin;
}

public boolean isAttachStdout() {
return attachStdout;
}

public void setAttachStdout(boolean attachStdout) {
this.attachStdout = attachStdout;
}

public boolean isAttachStderr() {
return attachStderr;
}

public void setAttachStderr(boolean attachStderr) {
this.attachStderr = attachStderr;
}

public String[] getCmd() {
return cmd;
}

public void setCmd(String[] cmd) {
this.cmd = cmd;
}

public boolean isDisableNetwork() {
return disableNetwork;
}

public void setDisableNetwork(boolean disableNetwork) {
this.disableNetwork = disableNetwork;
}

public String[] getEnv() {
return env;
}

public void setEnv(String[] env) {
this.env = env;
}

public ExposedPorts getExposedPorts() {
return exposedPorts;
}

public void setExposedPorts(ExposedPorts exposedPorts) {
this.exposedPorts = exposedPorts;
}

public String getHostname() {
return hostname;
}

public void setHostname(String hostname) {
this.hostname = hostname;
}

public Integer getMemory() {
return memory;
}

public void setMemory(Integer memory) {
this.memory = memory;
}

public Integer getMemorySwap() {
return memorySwap;
}

public void setMemorySwap(Integer memorySwap) {
this.memorySwap = memorySwap;
}

public boolean isOpenStdin() {
return openStdin;
}

public void setOpenStdin(boolean openStdin) {
this.openStdin = openStdin;
}

public String[] getPortSpecs() {
return portSpecs;
}

public void setPortSpecs(String[] portSpecs) {
this.portSpecs = portSpecs;
}

public boolean isStdinOnce() {
return stdinOnce;
}

public void setStdinOnce(boolean stdinOnce) {
this.stdinOnce = stdinOnce;
}

public boolean isTty() {
return tty;
}

public void setTty(boolean tty) {
this.tty = tty;
}

public String getUser() {
return user;
}

public void setUser(String user) {
this.user = user;
}

public Volumes getVolumes() {
return volumes;
}

public void setVolumes(Volumes volumes) {
this.volumes = volumes;
}

public String getWorkingDir() {
return workingDir;
}

public void setWorkingDir(String workingDir) {
this.workingDir = workingDir;
}



}
}
Loading