fix getting official registry manifest

closes #164

Signed-off-by: Jess Frazelle <acidburn@github.com>
This commit is contained in:
Jess Frazelle 2019-01-02 11:15:51 -05:00
parent 32589e90be
commit 067711f90e
No known key found for this signature in database
GPG key ID: 18F3685C0022BFF3
3 changed files with 16 additions and 1 deletions

View file

@ -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,

View file

@ -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)
}
}

View file

@ -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, "/")