org.cdk8s.plus.ContainerProps Maven / Gradle / Ivy
Show all versions of cdk8s-plus Show documentation
package org.cdk8s.plus;
/**
* Properties for creating a container.
*
* EXPERIMENTAL
*/
@javax.annotation.Generated(value = "jsii-pacmak/1.7.0 (build 179a3a5)", date = "2020-06-29T13:29:38.483Z")
@software.amazon.jsii.Jsii(module = org.cdk8s.plus.$Module.class, fqn = "cdk8s-plus.ContainerProps")
@software.amazon.jsii.Jsii.Proxy(ContainerProps.Jsii$Proxy.class)
@software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Experimental)
public interface ContainerProps extends software.amazon.jsii.JsiiSerializable {
/**
* Docker image name.
*
* EXPERIMENTAL
*/
@software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Experimental)
@org.jetbrains.annotations.NotNull java.lang.String getImage();
/**
* Entrypoint array.
*
* Not executed within a shell. The docker image's ENTRYPOINT is used if this is not provided. Variable references $(VAR_NAME) are expanded using the container's environment.
* If a variable cannot be resolved, the reference in the input string will be unchanged. The $(VAR_NAME) syntax can be escaped with a double $$, ie: $$(VAR_NAME).
* Escaped references will never be expanded, regardless of whether the variable exists or not. Cannot be updated.
* More info: https://kubernetes.io/docs/tasks/inject-data-application/define-command-argument-container/#running-a-command-in-a-shell
*
* Default: - The docker image's ENTRYPOINT.
*
* EXPERIMENTAL
*/
@software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Experimental)
default @org.jetbrains.annotations.Nullable java.util.List getCommand() {
return null;
}
/**
* List of environment variables to set in the container.
*
* Cannot be updated.
*
* Default: - No environment variables.
*
* EXPERIMENTAL
*/
@software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Experimental)
default @org.jetbrains.annotations.Nullable java.util.Map getEnv() {
return null;
}
/**
* Name of the container specified as a DNS_LABEL.
*
* Each container in a pod must have a unique name (DNS_LABEL). Cannot be updated.
*
* Default: 'main'
*
* EXPERIMENTAL
*/
@software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Experimental)
default @org.jetbrains.annotations.Nullable java.lang.String getName() {
return null;
}
/**
* Number of port to expose on the pod's IP address.
*
* This must be a valid port number, 0 < x < 65536.
*
* Default: - No port is exposed.
*
* EXPERIMENTAL
*/
@software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Experimental)
default @org.jetbrains.annotations.Nullable java.lang.Number getPort() {
return null;
}
/**
* Pod volumes to mount into the container's filesystem.
*
* Cannot be updated.
*
* EXPERIMENTAL
*/
@software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Experimental)
default @org.jetbrains.annotations.Nullable java.util.List getVolumeMounts() {
return null;
}
/**
* Container's working directory.
*
* If not specified, the container runtime's default will be used, which might be configured in the container image. Cannot be updated.
*
* Default: - The container runtime's default.
*
* EXPERIMENTAL
*/
@software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Experimental)
default @org.jetbrains.annotations.Nullable java.lang.String getWorkingDir() {
return null;
}
/**
* @return a {@link Builder} of {@link ContainerProps}
*/
@software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Experimental)
static Builder builder() {
return new Builder();
}
/**
* A builder for {@link ContainerProps}
*/
@software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Experimental)
public static final class Builder implements software.amazon.jsii.Builder {
private java.lang.String image;
private java.util.List command;
private java.util.Map env;
private java.lang.String name;
private java.lang.Number port;
private java.util.List volumeMounts;
private java.lang.String workingDir;
/**
* Sets the value of {@link ContainerProps#getImage}
* @param image Docker image name. This parameter is required.
* @return {@code this}
*/
@software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Experimental)
public Builder image(java.lang.String image) {
this.image = image;
return this;
}
/**
* Sets the value of {@link ContainerProps#getCommand}
* @param command Entrypoint array.
* Not executed within a shell. The docker image's ENTRYPOINT is used if this is not provided. Variable references $(VAR_NAME) are expanded using the container's environment.
* If a variable cannot be resolved, the reference in the input string will be unchanged. The $(VAR_NAME) syntax can be escaped with a double $$, ie: $$(VAR_NAME).
* Escaped references will never be expanded, regardless of whether the variable exists or not. Cannot be updated.
* More info: https://kubernetes.io/docs/tasks/inject-data-application/define-command-argument-container/#running-a-command-in-a-shell
* @return {@code this}
*/
@software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Experimental)
public Builder command(java.util.List command) {
this.command = command;
return this;
}
/**
* Sets the value of {@link ContainerProps#getEnv}
* @param env List of environment variables to set in the container.
* Cannot be updated.
* @return {@code this}
*/
@software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Experimental)
public Builder env(java.util.Map env) {
this.env = env;
return this;
}
/**
* Sets the value of {@link ContainerProps#getName}
* @param name Name of the container specified as a DNS_LABEL.
* Each container in a pod must have a unique name (DNS_LABEL). Cannot be updated.
* @return {@code this}
*/
@software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Experimental)
public Builder name(java.lang.String name) {
this.name = name;
return this;
}
/**
* Sets the value of {@link ContainerProps#getPort}
* @param port Number of port to expose on the pod's IP address.
* This must be a valid port number, 0 < x < 65536.
* @return {@code this}
*/
@software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Experimental)
public Builder port(java.lang.Number port) {
this.port = port;
return this;
}
/**
* Sets the value of {@link ContainerProps#getVolumeMounts}
* @param volumeMounts Pod volumes to mount into the container's filesystem.
* Cannot be updated.
* @return {@code this}
*/
@software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Experimental)
public Builder volumeMounts(java.util.List volumeMounts) {
this.volumeMounts = volumeMounts;
return this;
}
/**
* Sets the value of {@link ContainerProps#getWorkingDir}
* @param workingDir Container's working directory.
* If not specified, the container runtime's default will be used, which might be configured in the container image. Cannot be updated.
* @return {@code this}
*/
@software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Experimental)
public Builder workingDir(java.lang.String workingDir) {
this.workingDir = workingDir;
return this;
}
/**
* Builds the configured instance.
* @return a new instance of {@link ContainerProps}
* @throws NullPointerException if any required attribute was not provided
*/
@software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Experimental)
@Override
public ContainerProps build() {
return new Jsii$Proxy(image, command, env, name, port, volumeMounts, workingDir);
}
}
/**
* An implementation for {@link ContainerProps}
*/
@software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Experimental)
final class Jsii$Proxy extends software.amazon.jsii.JsiiObject implements ContainerProps {
private final java.lang.String image;
private final java.util.List command;
private final java.util.Map env;
private final java.lang.String name;
private final java.lang.Number port;
private final java.util.List volumeMounts;
private final java.lang.String workingDir;
/**
* Constructor that initializes the object based on values retrieved from the JsiiObject.
* @param objRef Reference to the JSII managed object.
*/
protected Jsii$Proxy(final software.amazon.jsii.JsiiObjectRef objRef) {
super(objRef);
this.image = this.jsiiGet("image", java.lang.String.class);
this.command = this.jsiiGet("command", software.amazon.jsii.NativeType.listOf(software.amazon.jsii.NativeType.forClass(java.lang.String.class)));
this.env = this.jsiiGet("env", software.amazon.jsii.NativeType.mapOf(software.amazon.jsii.NativeType.forClass(org.cdk8s.plus.EnvValue.class)));
this.name = this.jsiiGet("name", java.lang.String.class);
this.port = this.jsiiGet("port", java.lang.Number.class);
this.volumeMounts = this.jsiiGet("volumeMounts", software.amazon.jsii.NativeType.listOf(software.amazon.jsii.NativeType.forClass(org.cdk8s.plus.VolumeMount.class)));
this.workingDir = this.jsiiGet("workingDir", java.lang.String.class);
}
/**
* Constructor that initializes the object based on literal property values passed by the {@link Builder}.
*/
private Jsii$Proxy(final java.lang.String image, final java.util.List command, final java.util.Map env, final java.lang.String name, final java.lang.Number port, final java.util.List volumeMounts, final java.lang.String workingDir) {
super(software.amazon.jsii.JsiiObject.InitializationMode.JSII);
this.image = java.util.Objects.requireNonNull(image, "image is required");
this.command = command;
this.env = env;
this.name = name;
this.port = port;
this.volumeMounts = volumeMounts;
this.workingDir = workingDir;
}
@Override
public java.lang.String getImage() {
return this.image;
}
@Override
public java.util.List getCommand() {
return this.command;
}
@Override
public java.util.Map getEnv() {
return this.env;
}
@Override
public java.lang.String getName() {
return this.name;
}
@Override
public java.lang.Number getPort() {
return this.port;
}
@Override
public java.util.List getVolumeMounts() {
return this.volumeMounts;
}
@Override
public java.lang.String getWorkingDir() {
return this.workingDir;
}
@Override
public com.fasterxml.jackson.databind.JsonNode $jsii$toJson() {
final com.fasterxml.jackson.databind.ObjectMapper om = software.amazon.jsii.JsiiObjectMapper.INSTANCE;
final com.fasterxml.jackson.databind.node.ObjectNode data = com.fasterxml.jackson.databind.node.JsonNodeFactory.instance.objectNode();
data.set("image", om.valueToTree(this.getImage()));
if (this.getCommand() != null) {
data.set("command", om.valueToTree(this.getCommand()));
}
if (this.getEnv() != null) {
data.set("env", om.valueToTree(this.getEnv()));
}
if (this.getName() != null) {
data.set("name", om.valueToTree(this.getName()));
}
if (this.getPort() != null) {
data.set("port", om.valueToTree(this.getPort()));
}
if (this.getVolumeMounts() != null) {
data.set("volumeMounts", om.valueToTree(this.getVolumeMounts()));
}
if (this.getWorkingDir() != null) {
data.set("workingDir", om.valueToTree(this.getWorkingDir()));
}
final com.fasterxml.jackson.databind.node.ObjectNode struct = com.fasterxml.jackson.databind.node.JsonNodeFactory.instance.objectNode();
struct.set("fqn", om.valueToTree("cdk8s-plus.ContainerProps"));
struct.set("data", data);
final com.fasterxml.jackson.databind.node.ObjectNode obj = com.fasterxml.jackson.databind.node.JsonNodeFactory.instance.objectNode();
obj.set("$jsii.struct", struct);
return obj;
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
ContainerProps.Jsii$Proxy that = (ContainerProps.Jsii$Proxy) o;
if (!image.equals(that.image)) return false;
if (this.command != null ? !this.command.equals(that.command) : that.command != null) return false;
if (this.env != null ? !this.env.equals(that.env) : that.env != null) return false;
if (this.name != null ? !this.name.equals(that.name) : that.name != null) return false;
if (this.port != null ? !this.port.equals(that.port) : that.port != null) return false;
if (this.volumeMounts != null ? !this.volumeMounts.equals(that.volumeMounts) : that.volumeMounts != null) return false;
return this.workingDir != null ? this.workingDir.equals(that.workingDir) : that.workingDir == null;
}
@Override
public int hashCode() {
int result = this.image.hashCode();
result = 31 * result + (this.command != null ? this.command.hashCode() : 0);
result = 31 * result + (this.env != null ? this.env.hashCode() : 0);
result = 31 * result + (this.name != null ? this.name.hashCode() : 0);
result = 31 * result + (this.port != null ? this.port.hashCode() : 0);
result = 31 * result + (this.volumeMounts != null ? this.volumeMounts.hashCode() : 0);
result = 31 * result + (this.workingDir != null ? this.workingDir.hashCode() : 0);
return result;
}
}
}