diff --git a/src/cli/config/config.go b/src/cli/config/config.go index 561eceea9..a3f376164 100644 --- a/src/cli/config/config.go +++ b/src/cli/config/config.go @@ -291,7 +291,6 @@ func getStorageAndAccountWithViper( err error ) - overrides := S3Overrides(pfs) readConfigFromViper := readFromFile // possibly read the prior config from a .corso file @@ -309,12 +308,12 @@ func getStorageAndAccountWithViper( config.RepoID = vpr.GetString(RepoID) } - config.Account, err = configureAccount(vpr, readConfigFromViper, mustMatchFromConfig, overrides) + config.Account, err = configureAccount(vpr, readConfigFromViper, mustMatchFromConfig, nil) if err != nil { return config, clues.Wrap(err, "retrieving account configuration details") } - config.Storage, err = configureStorage(vpr, readConfigFromViper, mustMatchFromConfig, overrides) + config.Storage, err = configureStorage(vpr, readConfigFromViper, mustMatchFromConfig, pfs) if err != nil { return config, clues.Wrap(err, "retrieving storage provider details") } diff --git a/src/cli/config/storage.go b/src/cli/config/storage.go index ab5863673..52d1f99ad 100644 --- a/src/cli/config/storage.go +++ b/src/cli/config/storage.go @@ -104,7 +104,7 @@ func configureStorage( vpr *viper.Viper, readConfigFromViper bool, matchFromConfig bool, - overrides map[string]string, + pfs *pflag.FlagSet, ) (storage.Storage, error) { var ( s3Cfg storage.S3Config @@ -112,6 +112,8 @@ func configureStorage( err error ) + // Read storage provider first + if readConfigFromViper { if s3Cfg, err = s3ConfigsFromViper(vpr); err != nil { return store, clues.Wrap(err, "reading s3 configs from corso config file") @@ -141,7 +143,6 @@ func configureStorage( return store, clues.Wrap(err, "reading s3 configs from corso config file") } - s3Overrides(overrides) aws := credentials.GetAWS(overrides) if len(aws.AccessKey) <= 0 || len(aws.SecretKey) <= 0 { diff --git a/src/pkg/storage/storage.go b/src/pkg/storage/storage.go index e197f4081..70bcf61c2 100644 --- a/src/pkg/storage/storage.go +++ b/src/pkg/storage/storage.go @@ -8,12 +8,12 @@ import ( "github.com/alcionai/corso/src/internal/common" ) -type storageProvider int +type StorageProvider int -//go:generate stringer -type=storageProvider -linecomment +//go:generate stringer -type=StorageProvider -linecomment const ( - ProviderUnknown storageProvider = 0 // Unknown Provider - ProviderS3 storageProvider = 1 // S3 + ProviderUnknown StorageProvider = 0 // Unknown Provider + ProviderS3 StorageProvider = 1 // S3 ) // storage parsing errors @@ -24,7 +24,7 @@ var ( // Storage defines a storage provider, along with any configuration // required to set up or communicate with that provider. type Storage struct { - Provider storageProvider + Provider StorageProvider Config map[string]string // TODO: These are AWS S3 specific -> move these out SessionTags map[string]string @@ -34,7 +34,7 @@ type Storage struct { } // NewStorage aggregates all the supplied configurations into a single configuration. -func NewStorage(p storageProvider, cfgs ...common.StringConfigurer) (Storage, error) { +func NewStorage(p StorageProvider, cfgs ...common.StringConfigurer) (Storage, error) { cs, err := common.UnionStringConfigs(cfgs...) return Storage{ @@ -46,7 +46,7 @@ func NewStorage(p storageProvider, cfgs ...common.StringConfigurer) (Storage, er // NewStorageUsingRole supports specifying an AWS IAM role the storage provider // should assume. func NewStorageUsingRole( - p storageProvider, + p StorageProvider, roleARN string, sessionName string, sessionTags map[string]string, diff --git a/src/pkg/storage/storageprovider_string.go b/src/pkg/storage/storageprovider_string.go index 389dee37a..75a29b22e 100644 --- a/src/pkg/storage/storageprovider_string.go +++ b/src/pkg/storage/storageprovider_string.go @@ -1,4 +1,4 @@ -// Code generated by "stringer -type=storageProvider -linecomment"; DO NOT EDIT. +// Code generated by "stringer -type=StorageProvider -linecomment"; DO NOT EDIT. package storage @@ -12,13 +12,13 @@ func _() { _ = x[ProviderS3-1] } -const _storageProvider_name = "Unknown ProviderS3" +const _StorageProvider_name = "Unknown ProviderS3" -var _storageProvider_index = [...]uint8{0, 16, 18} +var _StorageProvider_index = [...]uint8{0, 16, 18} -func (i storageProvider) String() string { - if i < 0 || i >= storageProvider(len(_storageProvider_index)-1) { - return "storageProvider(" + strconv.FormatInt(int64(i), 10) + ")" +func (i StorageProvider) String() string { + if i < 0 || i >= StorageProvider(len(_StorageProvider_index)-1) { + return "StorageProvider(" + strconv.FormatInt(int64(i), 10) + ")" } - return _storageProvider_name[_storageProvider_index[i]:_storageProvider_index[i+1]] + return _StorageProvider_name[_StorageProvider_index[i]:_StorageProvider_index[i+1]] }