Package nl.lexemmens.podman.config.image
Class AbstractImageBuildConfiguration
- java.lang.Object
-
- nl.lexemmens.podman.config.image.AbstractImageBuildConfiguration
-
- Direct Known Subclasses:
BatchImageBuildConfiguration,SingleImageBuildConfiguration
public abstract class AbstractImageBuildConfiguration extends Object
Contains the shared configuration used by both single image configurations as well as batch configurations.
-
-
Field Summary
Fields Modifier and Type Field Description protected StringcontainerFileName of the Containerfile to use.protected FilecontainerFileDirDirectory containing the Containerfileprotected StringcontextDirThe context directory to useprotected booleancreateLatestTagSpecified whether a container image should *ALSO* be tagged 'latest'.protected static StringDEFAULT_CONTAINERFILEThe default name of the Containerfile to build.protected static StringDEFAULT_CONTEXT_DIRThe default context directoryprotected ContainerFormatformatSpecifies the format of the Container image to useprotected Map<String,String>labelsSpecify any labels to be applied to the imageprotected BooleanlayersCache intermediate images during the build process (Default is true).protected StringmavenProjectVersionThe Maven project version to use (only when useMavenProjectVersion is set to true)protected static PatternMULTISTAGE_CONTAINERFILE_REGEXThis is the regular expression to be used to determine a multistage Containerfile.protected booleannoCacheConfigures whether caching should be used to build images.protected FileoutputDirectoryWill be set when this class is validated using the #initAndValidate() methodprotected StringplatformSpecify the resulting image platform by being passed to the "--platform" option of podman.protected PullPolicypullPolicyConfigures whether from-images should be pulled so that the image will always be build on the latest base.protected BooleansquashSquash all of the image’s new layers into a single new layer; any preexisting layers are not squashed.protected BooleansquashAllSquash all of the new image’s layers (including those inherited from a base image) into a single new layer.protected String[]tagsArray consisting of one or more tags to attach to a container image.protected booleantagWithMavenProjectVersionSpecifies whether a version of the container image should be based on the version of this Maven project.protected StringtargetStageSpecify the final target stage to build.protected booleanvalidRepresents the validity of this configuration
-
Constructor Summary
Constructors Constructor Description AbstractImageBuildConfiguration()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected voiddetermineBuildStages(org.apache.maven.plugin.logging.Log log, Path fullContainerFilePath)List<String>getAllTags()Returns the tags to be applied for this imageMap<String,String>getArgs()Retrieves a collection of build arguments to provide to podman build using --build-argOptional<String>getContextDir()Returns the context directory pathContainerFormatgetFormat()Returns the format for the built image's manifest and configuration data.Map<String,String>getLabels()Returns the labels to be applied to the container imageBooleangetLayers()Returns true if intermediate layers should be cached during a Podman build.PatterngetMultistageContainerfilePattern()Returns the Pattern that is used to determine if a line matches a multi-stage ContainerfileFilegetOutputDirectory()Returns the project's output directoryOptional<String>getPlatform()Returns the platform that Podman should be told to build for.Optional<PullPolicy>getPullPolicy()Returns if the --pull property should be usedBooleangetSquash()Returns true when all of the image’s new layers should be squashed into a single new layer; any preexisting layers are not squashed.BooleangetSquashAll()Returns true when all of the image’s new layers, including those inherited from a base image, into a single new layer.PathgetTargetContainerFile()Returns the path to the target ContainerfileOptional<String>getTargetStage()Returns the final target stage to build.Map<String,String>getUlimits()Retrieves a collection of user limtis to provide to podman build using --ulimitsprotected booleanisContainerFileEmpty(org.apache.maven.plugin.logging.Log log, Path fullContainerFilePath)booleanisCreateLatestTag()Returns true when a latest tag should be createdbooleanisMultistageContainerFile()Returns true when the Containerfile is a multistage ContainerfilebooleanisNoCache()Returns which value should be used for the --no-cache propertybooleanisValid()Returns a boolean indicating whether this configuration is validvoidsetArgs(Map<String,String> args)The build arguments to set for use during Podman buildvoidsetContainerFile(String containerFile)Sets the name of the Containerfile (defaults to Containerfile)voidsetContainerFileDir(File containerFileDir)Sets the directory where the Containerfile is located (copied from BatchImageBuildCOnfiguration).voidsetContextDir(String contextDir)Sets the context directory to usevoidsetCreateLatestTag(boolean createLatestTag)Specifies whether a latest tag should be createdvoidsetFormat(ContainerFormat format)The format of the container image to use.voidsetLabels(Map<String,String> labels)Sets the labels to add to the container image.voidsetLayers(Boolean layers)Configures whether to cache intermediate images during the build process.voidsetNoCache(boolean noCache)Sets the noCache option.voidsetPlatform(String platform)Used to set the platform to be passed to Podman when building the image.voidsetPullPolicy(PullPolicy pullPolicy)Configures whether from-images should be pulled so that the image will always be build on the latest base.voidsetSquash(Boolean squash)Configures whether to squash all newly created layers into one layer.voidsetSquashAll(Boolean squashAll)Configures whether to squash all layers into one layer, this includes the base layer(s).voidsetTags(String[] tags)Sets the tags that should be used for this imagevoidsetTagWithMavenProjectVersion(boolean tagWithMavenProjectVersion)Specifies whether the image should be tagged with the Maven Project versionvoidsetTargetStage(String targetStage)Sets the final target stage to build.voidsetUlimits(Map<String,String> ulimits)The user limits to set for use during Podman buildvoidvalidate(org.apache.maven.project.MavenProject project)
-
-
-
Field Detail
-
MULTISTAGE_CONTAINERFILE_REGEX
protected static final Pattern MULTISTAGE_CONTAINERFILE_REGEX
This is the regular expression to be used to determine a multistage Containerfile. For now we only support named stages.
-
DEFAULT_CONTAINERFILE
protected static final String DEFAULT_CONTAINERFILE
The default name of the Containerfile to build.- See Also:
- Constant Field Values
-
DEFAULT_CONTEXT_DIR
protected static final String DEFAULT_CONTEXT_DIR
The default context directory- See Also:
- Constant Field Values
-
contextDir
@Parameter protected String contextDir
The context directory to use
-
containerFileDir
@Parameter protected File containerFileDir
Directory containing the Containerfile
-
noCache
@Parameter protected boolean noCache
Configures whether caching should be used to build images.
-
pullPolicy
@Parameter protected PullPolicy pullPolicy
Configures whether from-images should be pulled so that the image will always be build on the latest base.
-
tags
@Parameter protected String[] tags
Array consisting of one or more tags to attach to a container image. Tags will be appended at the end of the image name
-
containerFile
@Parameter protected String containerFile
Name of the Containerfile to use. Defaults to Containerfile
-
labels
@Parameter protected Map<String,String> labels
Specify any labels to be applied to the image
-
tagWithMavenProjectVersion
@Parameter protected boolean tagWithMavenProjectVersion
Specifies whether a version of the container image should be based on the version of this Maven project. Defaults to true. When set to false, 'podman.image.tag.version' must be specified.
-
mavenProjectVersion
protected String mavenProjectVersion
The Maven project version to use (only when useMavenProjectVersion is set to true)
-
createLatestTag
@Parameter protected boolean createLatestTag
Specified whether a container image should *ALSO* be tagged 'latest'. This defaults to false.
-
format
@Parameter protected ContainerFormat format
Specifies the format of the Container image to use
-
squash
@Parameter protected Boolean squash
Squash all of the image’s new layers into a single new layer; any preexisting layers are not squashed.- See Also:
- "http://docs.podman.io/en/latest/markdown/podman-build.1.html"
-
squashAll
@Parameter protected Boolean squashAll
Squash all of the new image’s layers (including those inherited from a base image) into a single new layer.- See Also:
- "http://docs.podman.io/en/latest/markdown/podman-build.1.html"
-
layers
@Parameter protected Boolean layers
Cache intermediate images during the build process (Default is true).Note: You can also override the default value of layers by setting the BUILDAH_LAYERS environment variable. export BUILDAH_LAYERS=true
- See Also:
- "http://docs.podman.io/en/latest/markdown/podman-build.1.html"
-
platform
@Parameter protected String platform
Specify the resulting image platform by being passed to the "--platform" option of podman.- See Also:
- "https://docs.podman.io/en/latest/markdown/podman-build.1.html"
-
targetStage
@Parameter protected String targetStage
Specify the final target stage to build. It is passed to the "--target" option of podman.- See Also:
- "https://docs.podman.io/en/latest/markdown/podman-build.1.html"
-
outputDirectory
protected File outputDirectory
Will be set when this class is validated using the #initAndValidate() method
-
valid
protected boolean valid
Represents the validity of this configuration
-
-
Method Detail
-
isNoCache
public boolean isNoCache()
Returns which value should be used for the --no-cache property- Returns:
- When set to true, podman will run with --no-cache=true
-
getPullPolicy
public Optional<PullPolicy> getPullPolicy()
Returns if the --pull property should be used- Returns:
- When set to true, podman will build with --pull
-
validate
public void validate(org.apache.maven.project.MavenProject project)
-
getAllTags
public List<String> getAllTags()
Returns the tags to be applied for this image- Returns:
- The tags to be applied
-
getContextDir
public Optional<String> getContextDir()
Returns the context directory path- Returns:
- Returns the context directory path
-
getTargetContainerFile
public Path getTargetContainerFile()
Returns the path to the target Containerfile- Returns:
- Returns a path to the target Containerfile
-
getLabels
public Map<String,String> getLabels()
Returns the labels to be applied to the container image
All specified labels will be added to the Containerfile after filtering.
- Returns:
- All labels to be added to the Containerfile
-
getOutputDirectory
public File getOutputDirectory()
Returns the project's output directory- Returns:
- The configured output directory
-
getFormat
public ContainerFormat getFormat()
Returns the format for the built image's manifest and configuration data.- Returns:
- The format for the built image's manifest and configuration data
-
isMultistageContainerFile
public boolean isMultistageContainerFile()
Returns true when the Containerfile is a multistage Containerfile- Returns:
- true when a multistage Containerfile is used
-
getMultistageContainerfilePattern
public Pattern getMultistageContainerfilePattern()
Returns the Pattern that is used to determine if a line matches a multi-stage Containerfile- Returns:
- The pattern to determine if a line matches the expected pattern for a multi-stage Containerfile.
-
getSquash
public Boolean getSquash()
Returns true when all of the image’s new layers should be squashed into a single new layer; any preexisting layers are not squashed.- Returns:
- true when all of the images's new layers should be squashed into a new layer. False otherwise.
-
getSquashAll
public Boolean getSquashAll()
Returns true when all of the image’s new layers, including those inherited from a base image, into a single new layer.- Returns:
- true when all of the images's new layers should be squashed into a new layer. False otherwise.
-
getLayers
public Boolean getLayers()
Returns true if intermediate layers should be cached during a Podman build.- Returns:
- true, when intermediate layers should be cached. False otherwise.
-
getPlatform
public Optional<String> getPlatform()
Returns the platform that Podman should be told to build for.- Returns:
- When set, a string in the format of GO OS/GO ARCH (because GO is the language of Podman) for example: linux/arm64
-
getTargetStage
public Optional<String> getTargetStage()
Returns the final target stage to build.- Returns:
- if set, the final target stage to build defined in Containerfile.
-
isValid
public boolean isValid()
Returns a boolean indicating whether this configuration is valid- Returns:
- true if this configuration is valid. False otherwise.
-
isCreateLatestTag
public boolean isCreateLatestTag()
Returns true when a latest tag should be created- Returns:
- true if an image should be tagged 'latest'
-
isContainerFileEmpty
protected boolean isContainerFileEmpty(org.apache.maven.plugin.logging.Log log, Path fullContainerFilePath) throws org.apache.maven.plugin.MojoExecutionException- Throws:
org.apache.maven.plugin.MojoExecutionException
-
determineBuildStages
protected void determineBuildStages(org.apache.maven.plugin.logging.Log log, Path fullContainerFilePath) throws org.apache.maven.plugin.MojoExecutionException- Throws:
org.apache.maven.plugin.MojoExecutionException
-
setLayers
public void setLayers(Boolean layers)
Configures whether to cache intermediate images during the build process.- Parameters:
layers- The value to set
-
setPlatform
public void setPlatform(String platform)
Used to set the platform to be passed to Podman when building the image.- Parameters:
platform- String in the format of GO OS/GO ARCH (because GO is the language of Podman) for example: linux/arm64
-
setNoCache
public void setNoCache(boolean noCache)
Sets the noCache option. Allows configuring whether caching should be used to cache images- Parameters:
noCache- Sets the noCache option on and off.
-
setPullPolicy
public void setPullPolicy(PullPolicy pullPolicy)
Configures whether from-images should be pulled so that the image will always be build on the latest base.- Parameters:
pullPolicy- The value to set
-
setSquash
public void setSquash(Boolean squash)
Configures whether to squash all newly created layers into one layer.- Parameters:
squash- The value to set
-
setSquashAll
public void setSquashAll(Boolean squashAll)
Configures whether to squash all layers into one layer, this includes the base layer(s).- Parameters:
squashAll- The value to set
-
setTags
public void setTags(String[] tags)
Sets the tags that should be used for this image- Parameters:
tags- The tags this image should receive
-
setContainerFile
public void setContainerFile(String containerFile)
Sets the name of the Containerfile (defaults to Containerfile)- Parameters:
containerFile- The name of the Containerfile to set
-
setLabels
public void setLabels(Map<String,String> labels)
Sets the labels to add to the container image.- Parameters:
labels- The labels to set.
-
setTagWithMavenProjectVersion
public void setTagWithMavenProjectVersion(boolean tagWithMavenProjectVersion)
Specifies whether the image should be tagged with the Maven Project version- Parameters:
tagWithMavenProjectVersion- whether the image should be tagged with the Maven project version
-
setCreateLatestTag
public void setCreateLatestTag(boolean createLatestTag)
Specifies whether a latest tag should be created- Parameters:
createLatestTag- If true, the image will receive the tag 'latest'
-
setFormat
public void setFormat(ContainerFormat format)
The format of the container image to use.- Parameters:
format- The format to use
-
setContextDir
public void setContextDir(String contextDir)
Sets the context directory to use- Parameters:
contextDir- The directory to set
-
setContainerFileDir
public void setContainerFileDir(File containerFileDir)
Sets the directory where the Containerfile is located (copied from BatchImageBuildCOnfiguration).- Parameters:
containerFileDir- The directory to set
-
setTargetStage
public void setTargetStage(String targetStage)
Sets the final target stage to build.- Parameters:
targetStage- The final target stage to build.
-
getArgs
public Map<String,String> getArgs()
Retrieves a collection of build arguments to provide to podman build using --build-arg- Returns:
- A collection of build arguments to provide to podman build
-
setArgs
public void setArgs(Map<String,String> args)
The build arguments to set for use during Podman build- Parameters:
args- The arguments to set
-
getUlimits
public Map<String,String> getUlimits()
Retrieves a collection of user limtis to provide to podman build using --ulimits- Returns:
- A collection of user limits to provide to podman build
-
-