added config file string

Signed-off-by: EItanya <eitan.yarmush@solo.io>
pull/7356/head
EItanya 6 years ago
parent 00769c4512
commit 17dc43f054

@ -416,6 +416,7 @@ func newRootCmd(actionConfig *action.Configuration, out io.Writer, args []string
registryClient, err := registry.NewClient( registryClient, err := registry.NewClient(
registry.ClientOptDebug(settings.Debug), registry.ClientOptDebug(settings.Debug),
registry.ClientOptWriter(out), registry.ClientOptWriter(out),
registry.ClientOptCredentialsFile(settings.RepositoryConfig),
) )
if err != nil { if err != nil {
// TODO: don't panic here, refactor newRootCmd to return error // TODO: don't panic here, refactor newRootCmd to return error

@ -41,11 +41,13 @@ const (
type ( type (
// Client works with OCI-compliant registries and local Helm chart cache // Client works with OCI-compliant registries and local Helm chart cache
Client struct { Client struct {
debug bool debug bool
out io.Writer // path to repository config file e.g. ~/.docker/config.json
authorizer *Authorizer credentialsFile string
resolver *Resolver out io.Writer
cache *Cache authorizer *Authorizer
resolver *Resolver
cache *Cache
} }
) )
@ -58,9 +60,11 @@ func NewClient(opts ...ClientOption) (*Client, error) {
opt(client) opt(client)
} }
// set defaults if fields are missing // set defaults if fields are missing
if client.credentialsFile == "" {
client.credentialsFile = helmpath.CachePath("registry", CredentialsFileBasename)
}
if client.authorizer == nil { if client.authorizer == nil {
credentialsFile := helmpath.CachePath("registry", CredentialsFileBasename) authClient, err := auth.NewClient(client.credentialsFile)
authClient, err := auth.NewClient(credentialsFile)
if err != nil { if err != nil {
return nil, err return nil, err
} }

@ -60,3 +60,10 @@ func ClientOptCache(cache *Cache) ClientOption {
client.cache = cache client.cache = cache
} }
} }
// ClientOptCache returns a function that sets the cache setting on a client options set
func ClientOptCredentialsFile(credentialsFile string) ClientOption {
return func(client *Client) {
client.credentialsFile = credentialsFile
}
}

Loading…
Cancel
Save