Class ImageNameValidator


  • public class ImageNameValidator
    extends Object
    • Field Detail

      • VALID_DIGEST_SHA256

        public static final Pattern VALID_DIGEST_SHA256
        A SHA-256 content digest specified by open container spec.
        See Also:
        Content Digests OCI Digests
      • VALID_DIGEST_SHA512

        public static final Pattern VALID_DIGEST_SHA512
        A SHA-512 content digest specified by open container spec.
        See Also:
        Content Digests OCI Digests
      • VALID_TAG

        public static final Pattern 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:
        docker tag
      • VALID_NAME_COMPONENT

        public static final Pattern 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:
        docker tag
    • Constructor Detail

      • ImageNameValidator

        public ImageNameValidator()
    • Method Detail

      • splitUserAndRepo

        @NonNull
        public static String[] splitUserAndRepo​(@NonNull
                                                String userAndRepo)
        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

        @NonNull
        public static FormValidation validateUserAndRepo​(@NonNull
                                                         String userAndRepo)
        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:
        VALID_NAME_COMPONENT, VALID_TAG
      • validateDigest

        @NonNull
        public static FormValidation validateDigest​(@CheckForNull
                                                    String digest)
        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:
        VALID_DIGEST
      • validateTag

        @NonNull
        public static FormValidation validateTag​(@CheckForNull
                                                 String tag)
        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:
        VALID_TAG
      • validateName

        @NonNull
        public static FormValidation validateName​(@CheckForNull
                                                  String name)
        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:
        VALID_NAME_COMPONENT