Skip to content

ggcr: Posibility to skip validation steps #2086

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
stgrace opened this issue Apr 11, 2025 · 0 comments · May be fixed by #2087
Open

ggcr: Posibility to skip validation steps #2086

stgrace opened this issue Apr 11, 2025 · 0 comments · May be fixed by #2087

Comments

@stgrace
Copy link

stgrace commented Apr 11, 2025

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

@stgrace stgrace linked a pull request Apr 14, 2025 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant