Skip to content

Commit

Permalink
Merge pull request #176 from jacobweinstock/insecure-registry-digest
Browse files Browse the repository at this point in the history
update Digest to match Get for insecure registries
  • Loading branch information
rusenask authored Mar 30, 2018
2 parents b8b3669 + 4a249ef commit cf8d4d3
Showing 1 changed file with 17 additions and 6 deletions.
23 changes: 17 additions & 6 deletions registry/registry.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ type Repository struct {
// Client - generic docker registry client
type Client interface {
Get(opts Opts) (*Repository, error)
Digest(opts Opts) (digest string, err error)
Digest(opts Opts) (string, error)
}

// New - new registry client
Expand Down Expand Up @@ -82,7 +82,7 @@ func (c *DefaultClient) Get(opts Opts) (*Repository, error) {
}

// Digest - get digest for repo
func (c *DefaultClient) Digest(opts Opts) (digest string, err error) {
func (c *DefaultClient) Digest(opts Opts) (string, error) {
if opts.Tag == "" {
return "", ErrTagNotSupplied
}
Expand All @@ -93,15 +93,26 @@ func (c *DefaultClient) Digest(opts Opts) (digest string, err error) {
"tag": opts.Tag,
}).Debug("registry client: getting digest")

hub, err := registry.New(opts.Registry, opts.Username, opts.Password)
if err != nil {
return
var hub *registry.Registry
var err error

if os.Getenv(EnvInsecure) == "true" {
hub, err = registry.NewInsecure(opts.Registry, opts.Username, opts.Password)
if err != nil {
return "", err
}
} else {
hub, err = registry.New(opts.Registry, opts.Username, opts.Password)
if err != nil {
return "", err
}
}

hub.Logf = LogFormatter

manifestDigest, err := hub.ManifestDigest(opts.Name, opts.Tag)
if err != nil {
return
return "", err
}

return manifestDigest.String(), nil
Expand Down

0 comments on commit cf8d4d3

Please sign in to comment.