File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -346,6 +346,10 @@ linters:
346346 path : " libnetwork/cmd/networkdb-test/dbclient"
347347 linters :
348348 - forbidigo
349+ - text : ' use of `regexp.MustCompile` forbidden'
350+ path : " registry/"
351+ linters :
352+ - forbidigo
349353
350354 # Log a warning if an exclusion rule is unused.
351355 # Default: false
Original file line number Diff line number Diff line change 1+ // FIXME(thaJeztah): remove once we are a module; the go:build directive prevents go from downgrading language version to go1.16:
2+ //go:build go1.23
3+
14package registry
25
36import (
@@ -6,13 +9,14 @@ import (
69 "net/url"
710 "os"
811 "path/filepath"
12+ "regexp"
913 "runtime"
1014 "strconv"
1115 "strings"
16+ "sync"
1217
1318 "github.com/containerd/log"
1419 "github.com/distribution/reference"
15- "github.com/docker/docker/internal/lazyregexp"
1620 "github.com/moby/moby/api/types/registry"
1721)
1822
5761 Host : DefaultRegistryHost ,
5862 }
5963
60- validHostPortRegex = lazyregexp .New (`^` + reference .DomainRegexp .String () + `$` )
64+ validHostPortRegex = sync .OnceValue (func () * regexp.Regexp {
65+ return regexp .MustCompile (`^` + reference .DomainRegexp .String () + `$` )
66+ })
6167)
6268
6369// runningWithRootlessKit is a fork of [rootless.RunningWithRootlessKit],
@@ -334,7 +340,7 @@ func validateHostPort(s string) error {
334340 }
335341 // If match against the `host:port` pattern fails,
336342 // it might be `IPv6:port`, which will be captured by net.ParseIP(host)
337- if ! validHostPortRegex .MatchString (s ) && net .ParseIP (host ) == nil {
343+ if ! validHostPortRegex () .MatchString (s ) && net .ParseIP (host ) == nil {
338344 return invalidParamf ("invalid host %q" , host )
339345 }
340346 if port != "" {
You can’t perform that action at this time.
0 commit comments