default registry name change

pull/26/head
Karolis Rusenas 2017-07-03 09:06:56 +01:00
parent 319b009004
commit a59e9ce634
4 changed files with 19 additions and 11 deletions

View File

@ -116,7 +116,6 @@ func (p *Provider) checkDeployment(newVersion *types.Version, repo *types.Reposi
// updating digest if available
if repo.Digest != "" {
// labels[types.KeelDigestLabel] = hash.GetShort(repo.Digest)
}
log.WithFields(log.Fields{

View File

@ -4,6 +4,8 @@ import (
"errors"
"github.com/rusenask/docker-registry-client/registry"
log "github.com/Sirupsen/logrus"
)
// errors
@ -58,6 +60,12 @@ func (c *DefaultClient) Digest(opts Opts) (digest string, err error) {
return "", ErrTagNotSupplied
}
log.WithFields(log.Fields{
"registry": opts.Registry,
"repository": opts.Name,
"tag": opts.Tag,
}).Info("registry client: getting digest")
hub, err := registry.New(opts.Registry, opts.Username, opts.Password)
if err != nil {
return

View File

@ -12,7 +12,7 @@ func TestShortParseWithTag(t *testing.T) {
t.Errorf("error while parsing tag: %s", err)
}
if reference.Remote() != DefaultHostname+"/foo/bar:1.1" {
if reference.Remote() != DefaultRegistryHostname+"/foo/bar:1.1" {
t.Errorf("unexpected remote: %s", reference.Remote())
}
@ -20,7 +20,7 @@ func TestShortParseWithTag(t *testing.T) {
t.Errorf("unexpected tag: %s", reference.Tag())
}
if reference.Registry() != DefaultHostname {
if reference.Registry() != DefaultRegistryHostname {
t.Errorf("unexpected registry: %s", reference.Registry())
}
@ -31,6 +31,7 @@ func TestShortParseWithTag(t *testing.T) {
if reference.Name() != "foo/bar:1.1" {
t.Errorf("unexpected name: %s", reference.Name())
}
}
func TestParseRepo(t *testing.T) {
@ -48,9 +49,9 @@ func TestParseRepo(t *testing.T) {
args: args{remote: "foo/bar:1.1"},
want: &Repository{
Name: "foo/bar:1.1",
Repository: "docker.io/foo/bar",
Remote: "docker.io/foo/bar:1.1",
Registry: DefaultHostname,
Repository: "index.docker.io/foo/bar",
Remote: "index.docker.io/foo/bar:1.1",
Registry: DefaultRegistryHostname,
ShortName: "foo/bar",
Tag: "1.1",
Scheme: "https",

View File

@ -12,8 +12,8 @@ import (
const (
// DefaultTag defines the default tag used when performing images related actions and no tag or digest is specified
DefaultTag = "latest"
// DefaultHostname is the default built-in hostname
DefaultHostname = "index.docker.io"
// DefaultRegistryHostname is the default built-in hostname
DefaultRegistryHostname = "index.docker.io"
// DefaultScheme is default scheme for registries
DefaultScheme = "https"
@ -176,14 +176,14 @@ func IsNameOnly(ref Named) bool {
func splitHostname(name string) (hostname, remoteName string) {
i := strings.IndexRune(name, '/')
if i == -1 || (!strings.ContainsAny(name[:i], ".:") && name[:i] != "localhost") {
hostname, remoteName = DefaultHostname, name
hostname, remoteName = DefaultRegistryHostname, name
} else {
hostname, remoteName = name[:i], name[i+1:]
}
// if hostname == LegacyDefaultHostname {
// hostname = DefaultHostname
// }
if hostname == DefaultHostname && !strings.ContainsRune(remoteName, '/') {
if hostname == DefaultRegistryHostname && !strings.ContainsRune(remoteName, '/') {
remoteName = DefaultRepoPrefix + remoteName
}
@ -197,7 +197,7 @@ func normalize(name string) (string, error) {
if strings.ToLower(remoteName) != remoteName {
return "", errors.New("invalid reference format: repository name must be lowercase")
}
if host == DefaultHostname {
if host == DefaultRegistryHostname {
if strings.HasPrefix(remoteName, DefaultRepoPrefix) {
return strings.TrimPrefix(remoteName, DefaultRepoPrefix), nil
}