Class ImageNameValidator
java.lang.Object
org.jenkinsci.plugins.docker.commons.credentials.ImageNameValidator
-
Field Summary
Modifier and TypeFieldDescriptionstatic final Pattern
A content digest specified by open container spec.static final Pattern
A SHA-256 content digest specified by open container spec.static final Pattern
A SHA-512 content digest specified by open container spec.static final Pattern
Name components may contain lowercase letters, digits and separators.static final Pattern
A tag name must be valid ASCII and may contain lowercase and uppercase letters, digits, underscores, periods and dashes. -
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic void
CallsvalidateName(String)
and if not OK throws the exception.static void
CallsvalidateTag(String)
and if not OK throws the exception.static void
checkUserAndRepo
(String userAndRepo) CallsvalidateUserAndRepo(String)
and if the result is not OK throws it as an exception.static boolean
skipped()
If the validation is set to be skipped.static String[]
splitUserAndRepo
(String userAndRepo) Splits a repository id namespace/name into it's four components (repo/namespace[/*],name,tag, digest)static FormValidation
validateDigest
(String digest) Validates a digest is following the rules.static FormValidation
validateName
(String name) Validates a docker image name that it is following the rules as a single name component.static FormValidation
validateTag
(String tag) Validates a tag is following the rules.static FormValidation
validateUserAndRepo
(String userAndRepo) Validates the string as[registry/repo/]name[:tag]
-
Field Details
-
VALID_DIGEST
A content digest specified by open container spec.- See Also:
-
VALID_DIGEST_SHA256
A SHA-256 content digest specified by open container spec.- See Also:
-
VALID_DIGEST_SHA512
A SHA-512 content digest specified by open container spec.- See Also:
-
VALID_TAG
A tag name must be valid ASCII and may contain lowercase and uppercase letters, digits, underscores, periods and dashes. A tag name may not start with a period or a dash and may contain a maximum of 128 characters.- See Also:
-
VALID_NAME_COMPONENT
Name components may contain lowercase letters, digits and separators. A separator is defined as a period, one or two underscores, or one or more dashes. A name component may not start or end with a separator.- See Also:
-
-
Constructor Details
-
ImageNameValidator
public ImageNameValidator()
-
-
Method Details
-
skipped
public static boolean skipped()If the validation is set to be skipped. I.e. the system propertyorg.jenkinsci.plugins.docker.commons.credentials.ImageNameValidator.SKIP
is set totrue
. When this is se to truevalidateName(String)
,validateTag(String)
andvalidateUserAndRepo(String)
returnsFormValidation.ok()
immediately without performing the validation.- Returns:
- true if validation is skipped.
-
splitUserAndRepo
Splits a repository id namespace/name into it's four components (repo/namespace[/*],name,tag, digest)- Parameters:
userAndRepo
- the repository ID namespace/name (ie. "jenkinsci/workflow-demo:latest"). The namespace can have more than one path element.- Returns:
- an array where position 0 is the namespace, 1 is the name and 2 is the tag and 3 is the digest.
Any position could be
null
-
validateUserAndRepo
Validates the string as[registry/repo/]name[:tag]
- Parameters:
userAndRepo
- the image id- Returns:
- if it is valid or not, or OK if set to
SKIP
. - See Also:
-
checkUserAndRepo
CallsvalidateUserAndRepo(String)
and if the result is not OK throws it as an exception.- Parameters:
userAndRepo
- the image id- Throws:
FormValidation
- if not OK
-
validateDigest
Validates a digest is following the rules. If the tag is null or the empty string it is considered valid.- Parameters:
digest
- the digest to validate.- Returns:
- the validation result
- See Also:
-
validateTag
Validates a tag is following the rules. If the tag is null or the empty string it is considered valid.- Parameters:
tag
- the tag to validate.- Returns:
- the validation result
- See Also:
-
checkTag
CallsvalidateTag(String)
and if not OK throws the exception.- Parameters:
tag
- the tag- Throws:
FormValidation
- if not OK
-
validateName
Validates a docker image name that it is following the rules as a single name component. If the name is null or the empty string it is not considered valid.- Parameters:
name
- the name- Returns:
- the validation result
- See Also:
-
checkName
CallsvalidateName(String)
and if not OK throws the exception.- Parameters:
name
- the name- Throws:
FormValidation
- if not OK
-