From 97871d174edc2a6e04b42354f2ca32ad3630d2f4 Mon Sep 17 00:00:00 2001 From: Billy Zha Date: Wed, 26 Apr 2023 15:16:36 +0000 Subject: [PATCH] resolve comments Signed-off-by: Billy Zha --- internal/credential/store.go | 23 ++++++++++------------- 1 file changed, 10 insertions(+), 13 deletions(-) diff --git a/internal/credential/store.go b/internal/credential/store.go index 6ed4e113b..5c61d8726 100644 --- a/internal/credential/store.go +++ b/internal/credential/store.go @@ -22,21 +22,18 @@ import ( // NewStore generates a store based on the passed-in config file paths. func NewStore(configPaths ...string) (credentials.Store, error) { opts := credentials.StoreOptions{AllowPlaintextPut: true} - var store credentials.Store - var err error if len(configPaths) == 0 { // use default docker config file path - store, err = credentials.NewStoreFromDocker(opts) - } else { - var stores []credentials.Store - for _, config := range configPaths { - store, err := credentials.NewStore(config, opts) - if err != nil { - return nil, err - } - stores = append(stores, store) + return credentials.NewStoreFromDocker(opts) + } + + var stores []credentials.Store + for _, config := range configPaths { + store, err := credentials.NewStore(config, opts) + if err != nil { + return nil, err } - store, err = credentials.NewStoreWithFallbacks(stores[0], stores[1:]...), nil + stores = append(stores, store) } - return store, err + return credentials.NewStoreWithFallbacks(stores[0], stores[1:]...), nil }