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 booleancreateLatestTagSpecified whether a container image should *ALSO* be tagged 'latest'.protected static StringDEFAULT_CONTAINERFILEThe default name of the Containerfile to build.protected 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 BooleanpullConfigures whether from-images should be pulled so that the image will always be build on the latest base.protected BooleanpullAlwaysConfigures whether from-images should always be pulled from the first registry it is found in.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 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 imageContainerFormatgetFormat()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<Boolean>getPull()Returns if the --pull property should be usedOptional<Boolean>getPullAlways()Returns if the --pull-always 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 Containerfileprotected 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 validvoidsetContainerFile(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).voidsetCreateLatestTag(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.voidsetPull(Boolean pull)Configures whether from-images should be pulled so that the image will always be build on the latest base.voidsetPullAlways(Boolean pullAlways)Configures whether from-images should always be pulled from the first registry it is found in.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 versionvoidvalidate(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
-
containerFileDir
@Parameter protected File containerFileDir
Directory containing the Containerfile
-
noCache
@Parameter protected boolean noCache
Configures whether caching should be used to build images.
-
pull
@Parameter protected Boolean pull
Configures whether from-images should be pulled so that the image will always be build on the latest base.
-
pullAlways
@Parameter protected Boolean pullAlways
Configures whether from-images should always be pulled from the first registry it is found in.From Podman docs: Pull the image from the first registry it is found in as listed in registries.conf. Raise an error if not found in the registries, even if the image is present locally.
- See Also:
- --pull-always on docs.podman.io
-
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"
-
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
-
getPull
public Optional<Boolean> getPull()
Returns if the --pull property should be used- Returns:
- When set to true, podman will build with --pull
-
getPullAlways
public Optional<Boolean> getPullAlways()
Returns if the --pull-always property should be used- Returns:
- When set to true, podman will build with --pull-always
-
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
-
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.
-
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
-
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.
-
setPull
public void setPull(Boolean pull)
Configures whether from-images should be pulled so that the image will always be build on the latest base.- Parameters:
pull- The value to set
-
setPullAlways
public void setPullAlways(Boolean pullAlways)
Configures whether from-images should always be pulled from the first registry it is found in.- Parameters:
pullAlways- 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
-
setContainerFileDir
public void setContainerFileDir(File containerFileDir)
Sets the directory where the Containerfile is located (copied from BatchImageBuildCOnfiguration).- Parameters:
containerFileDir- The directory to set
-
-