Skip to content

Commit 118c3dc

Browse files
committed
Add ExecCreateCmd.Env
API v1.25: "POST /containers/(id or name)/exec now accepts an Env field, which holds a list of environment variables to be set in the context of the command execution."
1 parent d2b96e5 commit 118c3dc

File tree

2 files changed

+26
-0
lines changed

2 files changed

+26
-0
lines changed

src/main/java/com/github/dockerjava/api/command/ExecCreateCmd.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
package com.github.dockerjava.api.command;
22

3+
import java.util.List;
4+
35
import javax.annotation.CheckForNull;
46
import javax.annotation.Nonnull;
57

@@ -20,6 +22,9 @@ public interface ExecCreateCmd extends SyncDockerCmd<ExecCreateCmdResponse> {
2022
@CheckForNull
2123
Boolean hasTtyEnabled();
2224

25+
@CheckForNull
26+
List<String> getEnv();
27+
2328
@CheckForNull
2429
String getUser();
2530

@@ -37,6 +42,8 @@ public interface ExecCreateCmd extends SyncDockerCmd<ExecCreateCmdResponse> {
3742

3843
ExecCreateCmd withCmd(String... cmd);
3944

45+
ExecCreateCmd withEnv(List<String> env);
46+
4047
ExecCreateCmd withContainerId(@Nonnull String containerId);
4148

4249
ExecCreateCmd withTty(Boolean tty);

src/main/java/com/github/dockerjava/core/command/ExecCreateCmdImpl.java

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
import static com.google.common.base.Preconditions.checkNotNull;
44

5+
import java.util.List;
6+
57
import com.fasterxml.jackson.annotation.JsonInclude;
68
import com.fasterxml.jackson.annotation.JsonInclude.Include;
79
import com.fasterxml.jackson.annotation.JsonProperty;
@@ -41,6 +43,12 @@ public class ExecCreateCmdImpl extends AbstrDockerCmd<ExecCreateCmd, ExecCreateC
4143
@JsonProperty("Cmd")
4244
private String[] cmd;
4345

46+
/**
47+
* @since {@link com.github.dockerjava.core.RemoteApiVersion#VERSION_1_25}
48+
*/
49+
@JsonProperty("Env")
50+
private List<String> env;
51+
4452
/**
4553
* @since {@link com.github.dockerjava.core.RemoteApiVersion#VERSION_1_35}
4654
*/
@@ -95,6 +103,12 @@ public ExecCreateCmd withCmd(String... cmd) {
95103
return this;
96104
}
97105

106+
@Override
107+
public ExecCreateCmd withEnv(List<String> env) {
108+
this.env = env;
109+
return this;
110+
}
111+
98112
@Override
99113
public ExecCreateCmd withPrivileged(Boolean privileged) {
100114
this.privileged = privileged;
@@ -132,6 +146,11 @@ public Boolean hasTtyEnabled() {
132146
return tty;
133147
}
134148

149+
@Override
150+
public List<String> getEnv() {
151+
return env;
152+
}
153+
135154
@Override
136155
public Boolean getPrivileged() {
137156
return privileged;

0 commit comments

Comments
 (0)