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(
registry.ClientOptDebug(settings.Debug),
registry.ClientOptWriter(out),
registry.ClientOptCredentialsFile(settings.RepositoryConfig),
)
if err != nil {
// TODO: don't panic here, refactor newRootCmd to return error

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

@ -60,3 +60,10 @@ func ClientOptCache(cache *Cache) ClientOption {
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