|
|
|
|
@ -48,7 +48,8 @@ public class ContainerConfig {
@@ -48,7 +48,8 @@ public class ContainerConfig {
|
|
|
|
|
private final String json; |
|
|
|
|
|
|
|
|
|
ContainerConfig(String user, ImageReference image, String command, List<String> args, Map<String, String> labels, |
|
|
|
|
List<Binding> bindings, Map<String, String> env, String networkMode) throws IOException { |
|
|
|
|
List<Binding> bindings, Map<String, String> env, String networkMode, List<String> securityOptions) |
|
|
|
|
throws IOException { |
|
|
|
|
Assert.notNull(image, "Image must not be null"); |
|
|
|
|
Assert.hasText(command, "Command must not be empty"); |
|
|
|
|
ObjectMapper objectMapper = SharedObjectMapper.get(); |
|
|
|
|
@ -70,6 +71,10 @@ public class ContainerConfig {
@@ -70,6 +71,10 @@ public class ContainerConfig {
|
|
|
|
|
} |
|
|
|
|
ArrayNode bindsNode = hostConfigNode.putArray("Binds"); |
|
|
|
|
bindings.forEach((binding) -> bindsNode.add(binding.toString())); |
|
|
|
|
if (securityOptions != null && !securityOptions.isEmpty()) { |
|
|
|
|
ArrayNode securityOptsNode = hostConfigNode.putArray("SecurityOpt"); |
|
|
|
|
securityOptions.forEach(securityOptsNode::add); |
|
|
|
|
} |
|
|
|
|
this.json = objectMapper.writeValueAsString(node); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@ -120,6 +125,8 @@ public class ContainerConfig {
@@ -120,6 +125,8 @@ public class ContainerConfig {
|
|
|
|
|
|
|
|
|
|
private String networkMode; |
|
|
|
|
|
|
|
|
|
private final List<String> securityOptions = new ArrayList<>(); |
|
|
|
|
|
|
|
|
|
Update(ImageReference image) { |
|
|
|
|
this.image = image; |
|
|
|
|
} |
|
|
|
|
@ -128,7 +135,7 @@ public class ContainerConfig {
@@ -128,7 +135,7 @@ public class ContainerConfig {
|
|
|
|
|
update.accept(this); |
|
|
|
|
try { |
|
|
|
|
return new ContainerConfig(this.user, this.image, this.command, this.args, this.labels, this.bindings, |
|
|
|
|
this.env, this.networkMode); |
|
|
|
|
this.env, this.networkMode, this.securityOptions); |
|
|
|
|
} |
|
|
|
|
catch (IOException ex) { |
|
|
|
|
throw new IllegalStateException(ex); |
|
|
|
|
@ -197,6 +204,14 @@ public class ContainerConfig {
@@ -197,6 +204,14 @@ public class ContainerConfig {
|
|
|
|
|
this.networkMode = networkMode; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* Update the container config with a security option. |
|
|
|
|
* @param option the security option |
|
|
|
|
*/ |
|
|
|
|
public void withSecurityOption(String option) { |
|
|
|
|
this.securityOptions.add(option); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|