Class MultiStageBuildOutputHelper


  • public final class MultiStageBuildOutputHelper
    extends Object
    Utility class that helps to determine the image hashes in case of a multiline Containerfile
    • Constructor Detail

      • MultiStageBuildOutputHelper

        public MultiStageBuildOutputHelper()
    • Method Detail

      • recordImageHashes

        public void recordImageHashes​(org.apache.maven.plugin.logging.Log log,
                                      SingleImageConfiguration image,
                                      List<String> processOutput)

        Tries to determine the image hashes from the output of a Podman build command when using multistage containerfiles.

        This method uses a lookahead strategy to determine the image hashes. It does not care about individual steps but only looks for stages and image hashes. Image hashes must be either 11 or 64 characters in length in order to be detected.

        Identification starts at a line that defines a stage, i.e. FROM [something] AS stageName. From there it will process every next line until it hits the next stage or reaches the last line, whatever comes first. During reading of lines, the last image hash found will be recorded. When a next stage has been found, the last image hash found will be associated with the stage that was being processed.

        To be more specific, the following steps are taken by this method, in the order as listed below:

        • Read the first line of the output
        • Retrieve the current stage from the the line. If the stage is null, then continue with the next line
        • If a stage has been found, find the image hash
        • Record the image hash for the current stage

        This method allows STEP definitions in a Containerfile to produce multiline output.

        Parameters:
        log - Maven's logger for log output
        image - The image configuration
        processOutput - The output of a Podman build command