Skip to content

Commit

Permalink
fea: make SplitDockerDomain public
Browse files Browse the repository at this point in the history
SplitDockerDomain is very useful function  to get the docker images name with out domain,  so this PR wish to make it public.
  • Loading branch information
tanguofu authored Apr 20, 2022
1 parent d2d961d commit d467522
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions docker/reference/normalize.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ func ParseNormalizedNamed(s string) (Named, error) {
if ok := anchoredIdentifierRegexp.MatchString(s); ok {
return nil, fmt.Errorf("invalid repository name (%s), cannot specify 64-byte hexadecimal strings", s)
}
domain, remainder := splitDockerDomain(s)
domain, remainder := SplitDockerDomain(s)
var remoteName string
if tagSep := strings.IndexRune(remainder, ':'); tagSep > -1 {
remoteName = remainder[:tagSep]
Expand Down Expand Up @@ -84,10 +84,10 @@ func ParseDockerRef(ref string) (Named, error) {
return TagNameOnly(named), nil
}

// splitDockerDomain splits a repository name to domain and remotename string.
// SplitDockerDomain splits a repository name to domain and remotename string.
// If no valid domain is found, the default domain is used. Repository name
// needs to be already validated before.
func splitDockerDomain(name string) (domain, remainder string) {
func SplitDockerDomain(name string) (domain, remainder string) {
i := strings.IndexRune(name, '/')
if i == -1 || (!strings.ContainsAny(name[:i], ".:") && name[:i] != "localhost") {
domain, remainder = defaultDomain, name
Expand Down

0 comments on commit d467522

Please sign in to comment.