Class PodTemplateUtils


  • public class PodTemplateUtils
    extends Object
    • Field Detail

      • SUBSTITUTE_ENV

        public static boolean SUBSTITUTE_ENV
      • DISABLE_OCTAL_MODES

        public static boolean DISABLE_OCTAL_MODES
        If true, all modes permissions provided to pods are expected to be provided in decimal notation. Otherwise, the plugin will consider they are written in octal notation.
    • Constructor Detail

      • PodTemplateUtils

        public PodTemplateUtils()
    • Method Detail

      • combine

        public static io.fabric8.kubernetes.api.model.Container combine​(@CheckForNull
                                                                        io.fabric8.kubernetes.api.model.Container parent,
                                                                        @NonNull
                                                                        io.fabric8.kubernetes.api.model.Container template)
        Combines a Container with its parent.
        Parameters:
        parent - The parent container (nullable).
        template - The actual container
        Returns:
        The combined container.
      • combine

        public static io.fabric8.kubernetes.api.model.Pod combine​(List<io.fabric8.kubernetes.api.model.Pod> pods)
        Combines all given pods together in order.
        Parameters:
        pods - the pods to combine
      • combine

        public static io.fabric8.kubernetes.api.model.Pod combine​(io.fabric8.kubernetes.api.model.Pod parent,
                                                                  io.fabric8.kubernetes.api.model.Pod template)
        Combines a Pod with its parent.
        Parameters:
        parent - The parent Pod (nullable).
        template - The child Pod
      • combine

        public static PodTemplate combine​(PodTemplate parent,
                                          PodTemplate template)
        Combines a PodTemplate with its parent.
        Parameters:
        parent - The parent container template (nullable).
        template - The actual container template
        Returns:
        The combined container template.
      • getTemplateByLabel

        @CheckForNull
        public static PodTemplate getTemplateByLabel​(@CheckForNull
                                                     Label label,
                                                     Collection<PodTemplate> templates)
        Gets the PodTemplate by Label.
        Parameters:
        label - The label.
        templates - The list of all templates.
        Returns:
        The first pod template from the collection that has a matching label.
      • getTemplateByName

        public static PodTemplate getTemplateByName​(@CheckForNull
                                                    String name,
                                                    Collection<PodTemplate> templates)
        Gets the PodTemplate by name.
        Parameters:
        name - The name.
        templates - The list of all templates.
        Returns:
        The first pod template from the collection that has a matching name.
      • substituteEnv

        @Deprecated
        public static String substituteEnv​(String s)
        Deprecated.
        Potentially insecure; a no-op by default.
        Substitutes a placeholder with a value found in the environment.
        Parameters:
        s - The placeholder. Should be use the format: ${placeholder}.
        Returns:
        The substituted value if found, or the input value otherwise.
      • substitute

        @Deprecated
        public static String substitute​(String s,
                                        Map<String,​String> properties)
        Substitutes a placeholder with a value found in the specified map.
        Parameters:
        s - The placeholder. Should be use the format: ${placeholder}.
        properties - The map with the key value pairs to use for substitution.
        Returns:
        The substituted value if found, or the input value otherwise.
      • substitute

        @Deprecated
        public static String substitute​(String s,
                                        Map<String,​String> properties,
                                        String defaultValue)
        Deprecated.
        check if it is null or empty in the caller method, then use substitute(String,Map)
        Substitutes a placeholder with a value found in the specified map.
        Parameters:
        s - The placeholder. Should be use the format: ${placeholder}.
        properties - The map with the key value pairs to use for substitution.
        defaultValue - The default value to return if no match is found.
        Returns:
        The substituted value if found, or the default value otherwise.
      • parseFromYaml

        public static io.fabric8.kubernetes.api.model.Pod parseFromYaml​(String yaml)
      • validateContainerName

        public static boolean validateContainerName​(String name)
      • validateLabel

        public static boolean validateLabel​(String label)
      • validateImage

        public static boolean validateImage​(String image)
        TODO perhaps enforce https://docs.docker.com/engine/reference/commandline/tag/#extended-description
      • isNullOrEmpty

        public static boolean isNullOrEmpty​(@Nullable
                                            String string)
      • emptyToNull

        @Nullable
        public static String emptyToNull​(@Nullable
                                         String string)