Package io.fabric8.maven.docker.util
Class ImageName
- java.lang.Object
-
- io.fabric8.maven.docker.util.ImageName
-
public class ImageName extends Object
Helper class for parsing docker repository/image names:- If the first part before the slash contains a "." or a ":" it is considered to be a registry URL
- A last part starting with a ":" is considered to be a tag
- The rest is considered the repository name (which might be separated via slashes)
- consol/tomcat-8.0
- consol/tomcat-8.0:8.0.9
- docker.consol.de:5000/tomcat-8.0
- docker.consol.de:5000/jolokia/tomcat-8.0:8.0.9
- Since:
- 22.07.14
- Author:
- roland
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description StringgetDigest()StringgetFullName()Get the full name of this image, including the registry and tag (e.g.StringgetFullName(String optionalRegistry)Get the full name of this image likegetFullName(String)does, but allow an optional registry.StringgetNameWithOptionalRepository(String optionalRepository)StringgetNameWithoutTag()Get the full name of this image, including the registry but without any tag (e.g.StringgetNameWithoutTag(String optionalRegistry)Get the full name of this image likegetNameWithoutTag()does, but allow an optional registry.StringgetRegistry()StringgetRepository()StringgetSimpleName()Get the simple name of the image, which is the repository sans the user parts.StringgetTag()StringgetUser()Get the user (or "project") part of the image name.booleanhasRegistry()static voidvalidate(String image)Check whether the given name validates agains the Docker rules for names
-
-
-
Constructor Detail
-
ImageName
public ImageName(String fullName)
Create an image name- Parameters:
fullName- The fullname of the image in Docker format.
-
ImageName
public ImageName(String fullName, String givenTag)
Create an image name with a tag. If a tag is provided (i.e. is not null) then this tag is used. Otherwise the tag of the provided name is used (if any).- Parameters:
fullName- The fullname of the image in Docker format. IgivenTag- tag to use. Can be null in which case the tag specified in fullName is used.
-
-
Method Detail
-
getRepository
public String getRepository()
-
getRegistry
public String getRegistry()
-
getTag
public String getTag()
-
getDigest
public String getDigest()
-
hasRegistry
public boolean hasRegistry()
-
getNameWithoutTag
public String getNameWithoutTag()
Get the full name of this image, including the registry but without any tag (e.g.privateregistry:fabric8io/java)- Returns:
- full name with the original registry
-
getNameWithoutTag
public String getNameWithoutTag(String optionalRegistry)
Get the full name of this image likegetNameWithoutTag()does, but allow an optional registry. This registry is used when this image does not already contain a registry.- Parameters:
optionalRegistry- optional registry to use when this image does not provide a registry. Can be null in which case no optional registry is used*- Returns:
- full name with original registry (if set) or optional registry (if not
null)
-
getFullName
public String getFullName()
Get the full name of this image, including the registry and tag (e.g.privateregistry:fabric8io/java:7u53)- Returns:
- full name with the original registry and the original tag given (if any).
-
getFullName
public String getFullName(String optionalRegistry)
Get the full name of this image likegetFullName(String)does, but allow an optional registry. This registry is used when this image does not already contain a registry. If no tag was provided in the initial name,latestis used.- Parameters:
optionalRegistry- optional registry to use when this image does not provide a registry. Can be null in which case no optional registry is used*- Returns:
- full name with original registry (if set) or optional registry (if not
null).
-
getUser
public String getUser()
Get the user (or "project") part of the image name. This is the part after the registry and before the image name- Returns:
- user part or
nullif no user is present in the name
-
getSimpleName
public String getSimpleName()
Get the simple name of the image, which is the repository sans the user parts.- Returns:
- simple name of the image
-
getNameWithOptionalRepository
public String getNameWithOptionalRepository(String optionalRepository)
-
validate
public static void validate(String image)
Check whether the given name validates agains the Docker rules for names- Parameters:
image- image name to validate d@throws IllegalArgumentException if the name doesnt validate
-
-