Skip to content

Commit

Permalink
refactor (jkube-kit/config) : Sort BuildConfiguration fields by build…
Browse files Browse the repository at this point in the history
…strategy

Sort all fields in BuildConfiguration class by applicable build
strategies. Fields that are applicable to any build strategy are listed
first. Then Docker specific buildstrategy fields are listed.

Signed-off-by: Rohan Kumar <[email protected]>
  • Loading branch information
rohanKanojia committed Sep 11, 2023
1 parent 55b6870 commit 0a41780
Showing 1 changed file with 161 additions and 75 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -56,67 +56,168 @@ public class BuildConfiguration implements Serializable {
public static final String DEFAULT_FILTER = "${*}";
public static final String DEFAULT_CLEANUP = "try";

// Generic fields applicable to all build strategies
/**
* The base image which should be used for this image.
*
* <p> If not given this default to <code>busybox:latest</code> and is suitable for a pure data image.
* <p>
* This field is applicable for all build strategies.
*/
private String from;
/**
* Extended definition for a base image. This field holds a map of defined in key:value format.
* <p> The known keys are:
* <ul>
* <li><b>name</b>: Name of the base image</li>
* </ul>
* <p> A provided {@link BuildConfiguration#from} takes precedence over the name given here.
* This tag is useful for extensions of this plugin.
* <p>
* This field is applicable for all build strategies.
*/
private Map<String, String> fromExt;
/**
* The exposed ports which is a list of &lt;port&gt; elements, one for each port to expose.
* Whitespace is trimmed from each element and empty elements are ignored.
*
* <p> The format can be either pure numerical (<code>8080</code>) or with the protocol attached (<code>8080/tcp</code>).
* <p>
* This field is applicable for all build strategies.
*/
@Singular
private List<String> ports;

/**
* Specific pull policy for the base image. This overrides any global image pull policy.
* <p>
* This field is applicable for all build strategies.
*/
private String imagePullPolicy;

/**
* List of &lt;volume%gt; elements to create a container volume.
* Whitespace is trimmed from each element and empty elements are ignored.
* <p>
* This field is applicable for all build strategies.
*/
@Singular
private List<String> volumes;

/**
* List of additional tag elements with which an image is to be tagged after the build.
* Whitespace is trimmed from each element and empty elements are ignored.
* <p>
* This field is applicable for all build strategies.
*/
@Singular
private List<String> tags;

/**
* Environment variables.
* <p>
* This field is applicable for all build strategies.
*/
@Singular("putEnv")
private Map<String, String> env;

/**
* Labels.
* <p>
* This field is applicable for all build strategies.
*/
@Singular
private Map<String, String> labels;

/**
* Directory to change to when starting the container.
* <p>
* This field is applicable for all build strategies.
*/
private String workdir;

/**
* A command to execute by default.
* <p>
* This field is applicable for all build strategies.
*/
private Arguments cmd;

/**
* User to which the image should switch to the end (corresponds to the <code>USER</code> Dockerfile directive).
* <p>
* This field is applicable for all build strategies.
*/
private String user;

/**
* An entrypoint allows you to configure a container that will run as an executable.
* <p>
* This field is applicable for all build strategies.
*/
private Arguments entryPoint;

/**
* Specifies the assembly configuration.
* <p>
* This field is applicable for all build strategies.
*/
private AssemblyConfiguration assembly;

/**
* If set to true disables building of the image.
* <p>
* This field is applicable for all build strategies.
*/
private Boolean skip;

// Docker build strategy specific configuration options
/**
* Path to a directory used for the build's context. You can specify the Dockerfile to use with dockerFile, which by
* default is the Dockerfile found in the contextDir.
* The Dockerfile can be also located outside of the contextDir, if provided with an absolute file path.
* The Dockerfile can be also located outside the contextDir, if provided with an absolute file path.
* <p>
* This field is applicable only for <code>docker</code> build strategy
*/
private String contextDir;
/**
* Path to a Dockerfile which also triggers Dockerfile mode.
* The Docker build context directory is set to <code>contextDir</code> if given.
* If not the directory by default is the directory in which the Dockerfile is stored.
* <p>
* This field is applicable only for <code>docker</code> build strategy
*/
private String dockerFile;
/**
* Path to a docker archive to load an image instead of building from scratch.
* If a dockerArchive is provided, no {@link BuildConfiguration#dockerFile} must be given.
* <p>
* This field is applicable only for <code>docker</code> build strategy
*/
private String dockerArchive;
/**
* Enable and set the delimiters for property replacements.
*
* <p>By default properties in the format <code>${..}</code> are replaced with Maven properties.
* When using a single char like <code>@</code> then this is used as a delimiter (e.g @…​@).
* <p>
* This field is applicable only for <code>docker</code> build strategy
*/
private String filter;
/**
* The base image which should be used for this image.
*
* <p> If not given this default to <code>busybox:latest</code> and is suitable for a pure data image.
*/
private String from;
/**
* Extended definition for a base image. This field holds a map of defined in key:value format.
* <p> The known keys are:
* <ul>
* <li><b>name</b>: Name of the base image</li>
* </ul>
* <p> A provided {@link BuildConfiguration#from} takes precedence over the name given here.
* This tag is useful for extensions of this plugin.
*/
private Map<String, String> fromExt;
/**
* The author (MAINTAINER) field for the generated image
* <p>
* This field is applicable only for <code>docker</code> build strategy
*/
private String maintainer;
/**
* The exposed ports which is a list of &lt;port&gt; elements, one for each port to expose.
* Whitespace is trimmed from each element and empty elements are ignored.
*
* <p> The format can be either pure numerical (<code>8080</code>) or with the protocol attached (<code>8080/tcp</code>).
*/
@Singular
private List<String> ports;
/**
* Shell to be used for the {@link BuildConfiguration#runCmds}. It contains arg elements which are defining the
* executable and its params.
* <p>
* This field is applicable only for <code>docker</code> build strategy
*/
private Arguments shell;
/**
* Specific pull policy for the base image. This overrides any global image pull policy.
*/
private String imagePullPolicy;

/**
* Commands to be run during the build process.
*
Expand All @@ -128,6 +229,8 @@ public class BuildConfiguration implements Serializable {
*
* <p> This setting is not to be confused with the &lt;run&gt; section for this image which specifies the runtime
* behaviour when starting containers.
* <p>
* This field is applicable only for <code>docker</code> build strategy
*/
@Singular
private List<String> runCmds;
Expand All @@ -138,79 +241,45 @@ public class BuildConfiguration implements Serializable {
* <li><b>remove</b>: removes old image or fails if it doesn't</li>
* <li><b>none</b>: No cleanup is requested</li>
* </ul>
* <p>
* This field is applicable only for <code>docker</code> build strategy
*/
private String cleanup;
/**
* Don't use Docker’s build cache.
* <p>
* This field is applicable only for <code>docker</code> build strategy
*/
private Boolean nocache;
/**
* If set to true then it will compress all the {@link BuildConfiguration#runCmds} into a single RUN directive so that
* only one image layer is created.
* <p>
* This field is applicable only for <code>docker</code> build strategy
*/
private Boolean optimise;
/**
* List of &lt;volume%gt; elements to create a container volume.
* Whitespace is trimmed from each element and empty elements are ignored.
*/
@Singular
private List<String> volumes;
/**
* List of additional tag elements with which an image is to be tagged after the build.
* Whitespace is trimmed from each element and empty elements are ignored.
*/
@Singular
private List<String> tags;
/**
* Environment variables.
*/
@Singular("putEnv")
private Map<String, String> env;
/**
* Labels.
*/
@Singular
private Map<String, String> labels;
/**
* Map specifying the value of Docker build args which should be used when building the image with an external
* Dockerfile which uses build arguments.
*
* <p> The key-value syntax is the same as when defining Maven properties (or labels or env). This argument is
* ignored when no external Dockerfile is used.
* <p>
* This field is applicable only for <code>docker</code> build strategy
*/
@Singular
private Map<String, String> args;
/**
* An entrypoint allows you to configure a container that will run as an executable.
*/
private Arguments entryPoint;
/**
* Directory to change to when starting the container.
*/
private String workdir;
/**
* A command to execute by default.
*/
private Arguments cmd;
/**
* User to which the Dockerfile should switch to the end (corresponds to the <code>USER</code> Dockerfile directive).
*/
private String user;
/**
* Health check configuration.
* <p>
* This field is applicable only for <code>docker</code> build strategy
*/
private HealthCheckConfiguration healthCheck;
/**
* Specifies the assembly configuration.
*/
private AssemblyConfiguration assembly;
/**
* If set to true disables building of the image.
*/
private Boolean skip;
/**
* The compression mode how the build archive is transmitted to the docker daemon and how docker build archives are
* attached to this build as sources.
* <p>
* This field is applicable only for <code>docker</code> build strategy
*/
private ArchiveCompression compression;
/**
Expand All @@ -220,6 +289,8 @@ public class BuildConfiguration implements Serializable {
* simple options (e.g.: memory, shmsize).
*
* @see <a href="https://docs.docker.com/engine/api/v1.41/#operation/ImageBuild">Docker Engine API v1.40</a>
* <p>
* This field is applicable only for <code>docker</code> build strategy
*/
private Map<String, String> buildOptions;
/**
Expand All @@ -229,16 +300,31 @@ public class BuildConfiguration implements Serializable {
* simple options (e.g.: fromImage, fromSrc, platform).
*
* @see <a href="https://docs.docker.com/engine/api/v1.41/#operation/ImageCreate">Docker Engine API v1.41</a>
* <p>
* This field is applicable only for <code>docker</code> build strategy
*/
private Map<String, String> createImageOptions;
/**
* Path to Dockerfile to use, initialized lazily.
* <p>
* This field is applicable only for <code>docker</code> build strategy
*/
@Setter(AccessLevel.PRIVATE)
private File dockerFileFile;
/**
* Path to archive file passed to docker daemon.
*
* <p>
* This field is applicable only for <code>docker</code> build strategy
*/
@Setter(AccessLevel.PRIVATE)
private File dockerArchiveFile;

/**
* Array of images used for build cache resolution.
* <p>
* This field is applicable only for <code>docker</code> build strategy
*/
@Singular("addCacheFrom")
private List<String> cacheFrom;

Expand Down

0 comments on commit 0a41780

Please sign in to comment.