Description
Hi,
Currently there is an option to enable WeakValidation when using ParseReference.
However, for my particular usecase I would like to ignore the character validation part of some of the steps during ParseReference, namely I would like to parse a reference with the following example string:
${DOCKER_REGISTRY}/${DOCKER_REPOSITORY}/curl:1.1.1
It is important that for this step, the env variables remain what they are as I require them to be written as this literal string in a later step.
Relevant go code, found here (https://github.com/google/go-containerregistry/blob/main/pkg/name/repository.go):
const (
defaultNamespace = "library"
repositoryChars = "abcdefghijklmnopqrstuvwxyz0123456789_-./"
regRepoDelimiter = "/"
)
...
if err := checkRepository(repo); err != nil {
return Repository{}, err
}
...
func checkRepository(repository string) error {
return checkElement("repository", repository, repositoryChars, 2, 255)
}
...
func checkElement(name, element, allowedRunes string, minRunes, maxRunes int) error {
numRunes := utf8.RuneCountInString(element)
if (numRunes < minRunes) || (maxRunes < numRunes) {
return newErrBadName("%s must be between %d and %d characters in length: %s", name, minRunes, maxRunes, element)
} else if len(strings.Map(stripRunesFn(allowedRunes), element)) != 0 {
return newErrBadName("%s can only contain the characters `%s`: %s", name, allowedRunes, element)
}
return nil
}
For these steps, I would like to add an option ignoreValidation
for example, that will not check the chars for a tag or repository, that defaults to false, so the behavior stays the same unless somebody sets the option to true
.
Let me know what you think.
Kind regards,
Stef Graces