You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
watchtower/pkg/registry/helpers/helpers.go

29 lines
672 B
Go

package helpers
import (
"github.com/docker/distribution/reference"
)
// domains for Docker Hub, the default registry
const (
DefaultRegistryDomain = "docker.io"
DefaultRegistryHost = "index.docker.io"
LegacyDefaultRegistryDomain = "index.docker.io"
)
// GetRegistryAddress parses an image name
// and returns the address of the specified registry
func GetRegistryAddress(imageRef string) (string, error) {
normalizedRef, err := reference.ParseNormalizedNamed(imageRef)
if err != nil {
return "", err
}
address := reference.Domain(normalizedRef)
if address == DefaultRegistryDomain {
address = DefaultRegistryHost
}
return address, nil
}