From 067711f90e53f19e5fbf2f83fee300e93548d374 Mon Sep 17 00:00:00 2001 From: Jess Frazelle Date: Wed, 2 Jan 2019 11:15:51 -0500 Subject: [PATCH] fix getting official registry manifest closes #164 Signed-off-by: Jess Frazelle --- main.go | 2 ++ manifest_test.go | 13 +++++++++++++ registry/registry.go | 2 +- 3 files changed, 16 insertions(+), 1 deletion(-) diff --git a/main.go b/main.go index 12968c92..e550d567 100644 --- a/main.go +++ b/main.go @@ -119,6 +119,8 @@ func createRegistryClient(ctx context.Context, domain string) (*registry.Registr } // Create the registry client. + logrus.Infof("domain: %s", domain) + logrus.Infof("server address: %s", auth.ServerAddress) return registry.New(ctx, auth, registry.Opt{ Domain: domain, Insecure: insecure, diff --git a/manifest_test.go b/manifest_test.go index 3f06263c..6212c511 100644 --- a/manifest_test.go +++ b/manifest_test.go @@ -29,3 +29,16 @@ func TestManifestV1(t *testing.T) { t.Fatalf("expected: %s\ngot: %s", expected, out) } } + +func TestManifestWithHubDomain(t *testing.T) { + // Regression test for https://github.com/genuinetools/reg/issues/164 + out, err := run("manifest", "busybox") + if err != nil { + t.Fatalf("output: %s, error: %v", out, err) + } + + expected := `"schemaVersion": 2,` + if !strings.Contains(out, expected) { + t.Fatalf("expected: %s\ngot: %s", expected, out) + } +} diff --git a/registry/registry.go b/registry/registry.go index 3e49fb9a..9840b7a8 100644 --- a/registry/registry.go +++ b/registry/registry.go @@ -67,7 +67,7 @@ func New(ctx context.Context, auth types.AuthConfig, opt Opt) (*Registry, error) } func newFromTransport(ctx context.Context, auth types.AuthConfig, transport http.RoundTripper, opt Opt) (*Registry, error) { - if len(opt.Domain) < 1 { + if len(opt.Domain) < 1 || opt.Domain == "docker.io" { opt.Domain = auth.ServerAddress } url := strings.TrimSuffix(opt.Domain, "/")