Package nl.lexemmens.podman.config.image
Class AbstractImageConfiguration<T extends AbstractImageBuildConfiguration>
- java.lang.Object
-
- nl.lexemmens.podman.config.image.AbstractImageConfiguration<T>
-
- Direct Known Subclasses:
BatchImageConfiguration,SingleImageConfiguration
public abstract class AbstractImageConfiguration<T extends AbstractImageBuildConfiguration> extends Object
-
-
Field Summary
Fields Modifier and Type Field Description protected booleancustomImageNameForMultiStageContainerfileWhen set to trueprotected StringnameThe name of the image without the target registry.protected StageConfiguration[]stagesAllows specifying a custom image name per stage in case of a multistage Containerfile.
-
Constructor Summary
Constructors Constructor Description AbstractImageConfiguration()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description abstract TgetBuild()Returns the build configurationOptional<String>getFinalImageHash()Returns an Optional that may or may not hold the image hashMap<String,String>getImageHashPerStage()Returns a Map containing all image hashes per stage as listed in the ContainerfileStringgetImageName()Returns the name of the image without the tag and registryList<String>getImageNames()Returns a list of image names formatted as the image name [colon] tag.List<String>getImageNamesByStage(String stageName)Returns a list of image names (without the registry) for a specific stage name.StageConfiguration[]getStages()Returns the stage configuration for naming imagesvoidinitAndValidate(org.apache.maven.plugin.logging.Log log)Initialises and validates this configurationbooleanisValid()Returns a boolean indicating whether this configuration is validvoidsetCustomImageNameForMultiStageContainerfile(boolean customImageNameForMultiStageContainerfile)Sets whether a custom image name should be used for each stage in the Containerfile.voidsetFinalImageHash(String finalImageHash)Sets the image hash to a specific valuevoidsetImageName(String name)Sets the name of this image.voidsetStages(StageConfiguration[] stages)Sets the customStageConfigurationsbooleanuseCustomImageNameForMultiStageContainerfile()Returns whether a custom image name per stage should be used (when using a multistage Containerfile).
-
-
-
Field Detail
-
name
@Parameter protected String name
The name of the image without the target registry. May contain the repository. Must be all lowercase and no special characters. Must be required when customImageNameForMultiStageContainerfile is set to false or not specified.
-
customImageNameForMultiStageContainerfile
@Parameter(defaultValue="false") protected boolean customImageNameForMultiStageContainerfile
When set to true
-
stages
@Parameter protected StageConfiguration[] stages
Allows specifying a custom image name per stage in case of a multistage Containerfile. When customImageNameForMultiStageContainerfile is set to true this must be specified.
-
-
Method Detail
-
getBuild
public abstract T getBuild()
Returns the build configuration
- Returns:
- the configuration used for building the image
-
getFinalImageHash
public final Optional<String> getFinalImageHash()
Returns an Optional that may or may not hold the image hash
- Returns:
- An
Optionalthat may hold the image hash
-
getImageHashPerStage
public final Map<String,String> getImageHashPerStage()
Returns a Map containing all image hashes per stage as listed in the Containerfile- Returns:
- Returns a Map of the final image hash for each stage.
-
setFinalImageHash
public final void setFinalImageHash(String finalImageHash)
Sets the image hash to a specific value
- Parameters:
finalImageHash- The image hash to set. This should be a SHA256 hash.
-
useCustomImageNameForMultiStageContainerfile
public boolean useCustomImageNameForMultiStageContainerfile()
Returns whether a custom image name per stage should be used (when using a multistage Containerfile).- Returns:
- true when certain stages in a multistage Containerfile should have unique names.
-
getStages
public StageConfiguration[] getStages()
Returns the stage configuration for naming images- Returns:
- the configuration for naming images when using a multistage Containerfile.
-
getImageNames
public List<String> getImageNames()
Returns a list of image names formatted as the image name [colon] tag.
Note that registry information is not prepended to this image name
- Returns:
- A list of image names
-
getImageNamesByStage
public List<String> getImageNamesByStage(String stageName)
Returns a list of image names (without the registry) for a specific stage name. The list that is returned is based on the tags that are configured.- Parameters:
stageName- The name of the stage to retrieve the image name for- Returns:
- A list of image names for the specific stage.
-
initAndValidate
public void initAndValidate(org.apache.maven.plugin.logging.Log log) throws org.apache.maven.plugin.MojoExecutionExceptionInitialises and validates this configuration- Parameters:
log- The log class for logging- Throws:
org.apache.maven.plugin.MojoExecutionException- In case validation fails.
-
getImageName
public String getImageName()
Returns the name of the image without the tag and registry
- Returns:
- The name of the image
-
isValid
public boolean isValid()
Returns a boolean indicating whether this configuration is valid- Returns:
- true if this configuration is valid. False otherwise.
-
setImageName
public void setImageName(String name)
Sets the name of this image.- Parameters:
name- The name of this image
-
setCustomImageNameForMultiStageContainerfile
public void setCustomImageNameForMultiStageContainerfile(boolean customImageNameForMultiStageContainerfile)
Sets whether a custom image name should be used for each stage in the Containerfile.- Parameters:
customImageNameForMultiStageContainerfile- true if a custom name should be used for each stage in the Containerfile.
-
setStages
public void setStages(StageConfiguration[] stages)
Sets the customStageConfigurations- Parameters:
stages- TheStageConfigurations to set.
-
-