Class DockerFileUtil


  • public class DockerFileUtil
    extends Object
    Utility class for dealing with dockerfiles
    Since:
    21/01/16
    Author:
    roland
    • Method Detail

      • extractBaseImages

        public static List<String> extractBaseImages​(File dockerFile,
                                                     org.codehaus.plexus.interpolation.fixed.FixedStringSearchInterpolator interpolator,
                                                     Map<String,​String> argsFromBuildConfig)
                                              throws IOException
        Extract the base images from a dockerfile. All lines containing a FROM is taken.
        Parameters:
        dockerFile - file from where to extract the base image
        interpolator - interpolator for replacing properties
        Returns:
        LinkedList of base images name or empty collection if none is found.
        Throws:
        IOException
      • extractArgs

        public static Map<String,​String> extractArgs​(File dockerfile,
                                                           Map<String,​String> argsFromBuildConfig,
                                                           org.codehaus.plexus.interpolation.fixed.FixedStringSearchInterpolator interpolator)
                                                    throws IOException
        Extract Args from dockerfile. All lines containing ARG is taken.
        Parameters:
        dockerfile - Docker File
        interpolator - interpolator for replacement
        Returns:
        HashMap of arguments or empty collection if none is found
        Throws:
        IOException
      • extractLines

        public static List<String[]> extractLines​(File dockerFile,
                                                  String keyword,
                                                  org.codehaus.plexus.interpolation.fixed.FixedStringSearchInterpolator interpolator)
                                           throws IOException
        Extract all lines containing the given keyword
        Parameters:
        dockerFile - dockerfile to examine
        keyword - keyword to extract the lines for
        interpolator - interpolator for replacing properties
        Returns:
        list of matched lines or an empty list
        Throws:
        IOException
      • interpolate

        public static String interpolate​(File dockerFile,
                                         org.codehaus.plexus.interpolation.fixed.FixedStringSearchInterpolator interpolator)
                                  throws IOException
        Interpolate a docker file with the given properties and filter
        Parameters:
        dockerFile - docker file to interpolate
        interpolator - interpolator for replacing properties
        Returns:
        The interpolated contents of the file.
        Throws:
        IOException
      • createInterpolator

        public static org.codehaus.plexus.interpolation.fixed.FixedStringSearchInterpolator createInterpolator​(MojoParameters params,
                                                                                                               String filter)
        Create an interpolator for the given maven parameters and filter configuration.
        Parameters:
        params - The maven parameters.
        filter - The filter configuration.
        Returns:
        An interpolator for replacing maven properties.
      • readDockerConfig

        public static com.google.gson.JsonObject readDockerConfig()
      • extractDelimiters

        public static String[] extractDelimiters​(String filter)
      • readKubeConfig

        public static Map<String,​?> readKubeConfig()