Skip to content

Commit

Permalink
Initial tag listing support
Browse files Browse the repository at this point in the history
Signed-off-by: Andrew Block <andy.block@gmail.com>
  • Loading branch information
sabre1041 authored and scottrigby committed Jan 12, 2022
1 parent 39792b5 commit 9a7c362
Showing 1 changed file with 32 additions and 4 deletions.
36 changes: 32 additions & 4 deletions internal/experimental/registry/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@ import (
dockerauth "oras.land/oras-go/pkg/auth/docker"
"oras.land/oras-go/pkg/content"
"oras.land/oras-go/pkg/oras"
"oras.land/oras-go/pkg/registry"
registrremote "oras.land/oras-go/pkg/registry/remote"
registryauth "oras.land/oras-go/pkg/registry/remote/auth"

"helm.sh/helm/v3/internal/version"
"helm.sh/helm/v3/pkg/chart"
Expand All @@ -49,10 +52,11 @@ type (
Client struct {
debug bool
// path to repository config file e.g. ~/.docker/config.json
credentialsFile string
out io.Writer
authorizer auth.Client
resolver remotes.Resolver
credentialsFile string
out io.Writer
authorizer auth.Client
registryAuthorizer *registryauth.Client
resolver remotes.Resolver
}

// ClientOption allows specifying various settings configurable by the user for overriding the defaults
Expand Down Expand Up @@ -88,6 +92,15 @@ func NewClient(options ...ClientOption) (*Client, error) {
}
client.resolver = resolver
}
if client.registryAuthorizer == nil {
client.registryAuthorizer = &registryauth.Client{
Header: http.Header{
"User-Agent": {version.GetUserAgent()},
},
Cache: registryauth.DefaultCache,
}

}
return client, nil
}

Expand Down Expand Up @@ -539,3 +552,18 @@ func PushOptStrictMode(strictMode bool) PushOption {
operation.strictMode = strictMode
}
}

// Tags lists all tags for a given repository
func (c *Client) Tags(ref string) ([]string, error) {
parsedReference, err := registry.ParseReference(ref)
if err != nil {
return nil, err
}

repository := registrremote.Repository{
Reference: parsedReference,
Client: c.registryAuthorizer,
}

return registry.Tags(ctx(c.out, c.debug), &repository)
}

0 comments on commit 9a7c362

Please sign in to comment.