Package io.fabric8.maven.docker.util
Class NamePatternUtil
- java.lang.Object
-
- io.fabric8.maven.docker.util.NamePatternUtil
-
public class NamePatternUtil extends Object
Helper functions for pattern matching for image and container names.
-
-
Field Summary
Fields Modifier and Type Field Description static StringIMAGE_FIELDstatic StringNAME_FIELD
-
Constructor Summary
Constructors Constructor Description NamePatternUtil()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static StringconvertNamePattern(String pattern)Accepts an Ant-ish or regular expression pattern and compiles to a regular expression.static StringconvertNamePatternList(String patternList)Take a string that represents a list of patterns, possibly a mixture of regular expressions and Ant-style patterns, and return a single regular expression that matches any of the alternatives.static StringconvertNamePatternList(String patternList, String fieldName, boolean includeUnnamed)Take a string that represents a list of patterns, possibly a mixture of regular expressions and Ant-style patterns, and return a single regular expression that matches any of the alternatives.
-
-
-
Field Detail
-
IMAGE_FIELD
public static final String IMAGE_FIELD
- See Also:
- Constant Field Values
-
NAME_FIELD
public static final String NAME_FIELD
- See Also:
- Constant Field Values
-
-
Method Detail
-
convertNamePattern
public static String convertNamePattern(String pattern)
Accepts an Ant-ish or regular expression pattern and compiles to a regular expression. This is similar to SelectorUtils in the Maven codebase, but there the code uses the platform File.separator, while here we always want to work with forward slashes. Also, for a more natural fit with repository tags, both * and ** should stop at the colon that precedes the tag. Like SelectorUtils, wrapping a pattern in %regex[pattern] will create a regex from the pattern provided without translation. Otherwise, or if wrapped in %ant[pattern], then a regular expression will be created that is anchored at beginning and end, converts ? to [^/:], * to ([^/:]|:(?=.*:)) and ** to ([^:]|:(?=.*:))*. If ** is followed by /, the / is converted to a negative lookbehind for anything apart from a slash.- Returns:
- a regular expression pattern created from the input pattern
-
convertNamePatternList
public static String convertNamePatternList(String patternList)
Take a string that represents a list of patterns, possibly a mixture of regular expressions and Ant-style patterns, and return a single regular expression that matches any of the alternatives. To allow users to target some parts of the filter list to some fields on the object to which the pattern is ultimately applied, it is possible to prefix patterns in the list with fieldName=pattern, and then the pattern can be excluded from use on unrelated fields.- Parameters:
patternList- the pattern list specification to convert- Returns:
- the combined pattern, or null if there is are no patterns for the field.
- Throws:
PatternSyntaxException- if any of the individual patterns fails to compile as a regular expression.
-
convertNamePatternList
public static String convertNamePatternList(String patternList, String fieldName, boolean includeUnnamed)
Take a string that represents a list of patterns, possibly a mixture of regular expressions and Ant-style patterns, and return a single regular expression that matches any of the alternatives. To allow users to target some parts of the filter list to some fields on the object to which the pattern is ultimately applied, it is possible to prefix patterns in the list with fieldName=pattern, and then the pattern can be excluded from use on unrelated fields.- Parameters:
patternList- the pattern list specification to convertfieldName- the field name for which patterns should be selectedincludeUnnamed- if true, include patterns that do not specify a field name- Returns:
- the combined pattern, or null if there is are no patterns for the field.
- Throws:
PatternSyntaxException- if any of the individual patterns fails to compile as a regular expression.
-
-