provider changes
This commit is contained in:
parent
57ee18c847
commit
62b466ca39
@ -291,7 +291,6 @@ func getStorageAndAccountWithViper(
|
|||||||
err error
|
err error
|
||||||
)
|
)
|
||||||
|
|
||||||
overrides := S3Overrides(pfs)
|
|
||||||
readConfigFromViper := readFromFile
|
readConfigFromViper := readFromFile
|
||||||
|
|
||||||
// possibly read the prior config from a .corso file
|
// possibly read the prior config from a .corso file
|
||||||
@ -309,12 +308,12 @@ func getStorageAndAccountWithViper(
|
|||||||
config.RepoID = vpr.GetString(RepoID)
|
config.RepoID = vpr.GetString(RepoID)
|
||||||
}
|
}
|
||||||
|
|
||||||
config.Account, err = configureAccount(vpr, readConfigFromViper, mustMatchFromConfig, overrides)
|
config.Account, err = configureAccount(vpr, readConfigFromViper, mustMatchFromConfig, nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return config, clues.Wrap(err, "retrieving account configuration details")
|
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 {
|
if err != nil {
|
||||||
return config, clues.Wrap(err, "retrieving storage provider details")
|
return config, clues.Wrap(err, "retrieving storage provider details")
|
||||||
}
|
}
|
||||||
|
|||||||
@ -104,7 +104,7 @@ func configureStorage(
|
|||||||
vpr *viper.Viper,
|
vpr *viper.Viper,
|
||||||
readConfigFromViper bool,
|
readConfigFromViper bool,
|
||||||
matchFromConfig bool,
|
matchFromConfig bool,
|
||||||
overrides map[string]string,
|
pfs *pflag.FlagSet,
|
||||||
) (storage.Storage, error) {
|
) (storage.Storage, error) {
|
||||||
var (
|
var (
|
||||||
s3Cfg storage.S3Config
|
s3Cfg storage.S3Config
|
||||||
@ -112,6 +112,8 @@ func configureStorage(
|
|||||||
err error
|
err error
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// Read storage provider first
|
||||||
|
|
||||||
if readConfigFromViper {
|
if readConfigFromViper {
|
||||||
if s3Cfg, err = s3ConfigsFromViper(vpr); err != nil {
|
if s3Cfg, err = s3ConfigsFromViper(vpr); err != nil {
|
||||||
return store, clues.Wrap(err, "reading s3 configs from corso config file")
|
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")
|
return store, clues.Wrap(err, "reading s3 configs from corso config file")
|
||||||
}
|
}
|
||||||
|
|
||||||
s3Overrides(overrides)
|
|
||||||
aws := credentials.GetAWS(overrides)
|
aws := credentials.GetAWS(overrides)
|
||||||
|
|
||||||
if len(aws.AccessKey) <= 0 || len(aws.SecretKey) <= 0 {
|
if len(aws.AccessKey) <= 0 || len(aws.SecretKey) <= 0 {
|
||||||
|
|||||||
@ -8,12 +8,12 @@ import (
|
|||||||
"github.com/alcionai/corso/src/internal/common"
|
"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 (
|
const (
|
||||||
ProviderUnknown storageProvider = 0 // Unknown Provider
|
ProviderUnknown StorageProvider = 0 // Unknown Provider
|
||||||
ProviderS3 storageProvider = 1 // S3
|
ProviderS3 StorageProvider = 1 // S3
|
||||||
)
|
)
|
||||||
|
|
||||||
// storage parsing errors
|
// storage parsing errors
|
||||||
@ -24,7 +24,7 @@ var (
|
|||||||
// Storage defines a storage provider, along with any configuration
|
// Storage defines a storage provider, along with any configuration
|
||||||
// required to set up or communicate with that provider.
|
// required to set up or communicate with that provider.
|
||||||
type Storage struct {
|
type Storage struct {
|
||||||
Provider storageProvider
|
Provider StorageProvider
|
||||||
Config map[string]string
|
Config map[string]string
|
||||||
// TODO: These are AWS S3 specific -> move these out
|
// TODO: These are AWS S3 specific -> move these out
|
||||||
SessionTags map[string]string
|
SessionTags map[string]string
|
||||||
@ -34,7 +34,7 @@ type Storage struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// NewStorage aggregates all the supplied configurations into a single configuration.
|
// 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...)
|
cs, err := common.UnionStringConfigs(cfgs...)
|
||||||
|
|
||||||
return Storage{
|
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
|
// NewStorageUsingRole supports specifying an AWS IAM role the storage provider
|
||||||
// should assume.
|
// should assume.
|
||||||
func NewStorageUsingRole(
|
func NewStorageUsingRole(
|
||||||
p storageProvider,
|
p StorageProvider,
|
||||||
roleARN string,
|
roleARN string,
|
||||||
sessionName string,
|
sessionName string,
|
||||||
sessionTags map[string]string,
|
sessionTags map[string]string,
|
||||||
|
|||||||
@ -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
|
package storage
|
||||||
|
|
||||||
@ -12,13 +12,13 @@ func _() {
|
|||||||
_ = x[ProviderS3-1]
|
_ = 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 {
|
func (i StorageProvider) String() string {
|
||||||
if i < 0 || i >= storageProvider(len(_storageProvider_index)-1) {
|
if i < 0 || i >= StorageProvider(len(_StorageProvider_index)-1) {
|
||||||
return "storageProvider(" + strconv.FormatInt(int64(i), 10) + ")"
|
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]]
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user