Class ImageNameValidator

java.lang.Object
org.jenkinsci.plugins.docker.commons.credentials.ImageNameValidator

public class ImageNameValidator extends Object
  • Field Details

    • VALID_DIGEST

      public static final Pattern VALID_DIGEST
      A content digest specified by open container spec.
      See Also:
    • VALID_DIGEST_SHA256

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

      public static final Pattern VALID_DIGEST_SHA512
      A SHA-512 content digest specified by open container spec.
      See Also:
    • 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:
    • 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:
  • Constructor Details

    • ImageNameValidator

      public ImageNameValidator()
  • Method Details

    • skipped

      public static boolean skipped()
      If the validation is set to be skipped. I.e. the system property org.jenkinsci.plugins.docker.commons.credentials.ImageNameValidator.SKIP is set to true. When this is se to true validateName(String), validateTag(String) and validateUserAndRepo(String) returns FormValidation.ok() immediately without performing the validation.
      Returns:
      true if validation is skipped.
    • 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:
    • checkUserAndRepo

      public static void checkUserAndRepo(@NonNull String userAndRepo) throws FormValidation
      Calls validateUserAndRepo(String) and if the result is not OK throws it as an exception.
      Parameters:
      userAndRepo - the image id
      Throws:
      FormValidation - if not OK
    • 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:
    • 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:
    • checkTag

      public static void checkTag(@CheckForNull String tag) throws FormValidation
      Calls validateTag(String) and if not OK throws the exception.
      Parameters:
      tag - the tag
      Throws:
      FormValidation - if not OK
    • 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:
    • checkName

      public static void checkName(String name) throws FormValidation
      Calls validateName(String) and if not OK throws the exception.
      Parameters:
      name - the name
      Throws:
      FormValidation - if not OK