google / google/go-containerregistry

ggcr: Posibility to skip validation steps

Open
#2,086 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Go
Stars
4k
Forks
686
Avg merge
2d 12h
Merged PRs (30d)
26

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):

```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

Contributor guide

Open the contributing guide

Research direction

Start in pkg/name/repository.go by tracing ParseReference through checkRepository and checkElement, then identify the corresponding tag validation path. The issue describes an ignoreValidation option that defaults to false and permits literal environment-variable placeholders in repository or tag references when enabled; confirm the affected parsing paths and their existing tests before making changes.

Written by the indexing model from the issue text.

Assessment

Tech stack
go
Domain
devops
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.