Merge pull request #46594 from regisb/36598-regisb/registry-mirror-path

registry: allow mirror paths in config
This commit is contained in:
Sebastiaan van Stijn 2023-10-12 20:37:52 +02:00 committed by GitHub
commit 3e43f8e9f4
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 5 deletions

View file

@ -330,8 +330,8 @@ func ValidateMirror(val string) (string, error) {
if uri.Scheme != "http" && uri.Scheme != "https" { if uri.Scheme != "http" && uri.Scheme != "https" {
return "", invalidParamf("invalid mirror: unsupported scheme %q in %q", uri.Scheme, uri) return "", invalidParamf("invalid mirror: unsupported scheme %q in %q", uri.Scheme, uri)
} }
if (uri.Path != "" && uri.Path != "/") || uri.RawQuery != "" || uri.Fragment != "" { if uri.RawQuery != "" || uri.Fragment != "" {
return "", invalidParamf("invalid mirror: path, query, or fragment at end of the URI %q", uri) return "", invalidParamf("invalid mirror: query or fragment at end of the URI %q", uri)
} }
if uri.User != nil { if uri.User != nil {
// strip password from output // strip password from output

View file

@ -142,21 +142,21 @@ func TestValidateMirror(t *testing.T) {
"https://127.0.0.1", "https://127.0.0.1",
"http://127.0.0.1:5000", "http://127.0.0.1:5000",
"https://127.0.0.1:5000", "https://127.0.0.1:5000",
"http://mirror-1.example.com/v1/",
"https://mirror-1.example.com/v1/",
} }
invalid := []string{ invalid := []string{
"!invalid!://%as%", "!invalid!://%as%",
"ftp://mirror-1.example.com", "ftp://mirror-1.example.com",
"http://mirror-1.example.com/?q=foo", "http://mirror-1.example.com/?q=foo",
"http://mirror-1.example.com/v1/",
"http://mirror-1.example.com/v1/?q=foo", "http://mirror-1.example.com/v1/?q=foo",
"http://mirror-1.example.com/v1/?q=foo#frag", "http://mirror-1.example.com/v1/?q=foo#frag",
"http://mirror-1.example.com?q=foo", "http://mirror-1.example.com?q=foo",
"https://mirror-1.example.com#frag", "https://mirror-1.example.com#frag",
"https://mirror-1.example.com/#frag", "https://mirror-1.example.com/#frag",
"http://foo:bar@mirror-1.example.com/", "http://foo:bar@mirror-1.example.com/",
"https://mirror-1.example.com/v1/", "https://mirror-1.example.com/v1/#frag",
"https://mirror-1.example.com/v1/#",
"https://mirror-1.example.com?q", "https://mirror-1.example.com?q",
} }