avoid provider check in init (#3764)
<!-- PR description--> do not check for provider in init command #### Does this PR need a docs update or release note? - [ ] ⛔ No #### Type of change <!--- Please check the type of change your PR introduces: ---> - [ ] 🐛 Bugfix #### Issue(s) <!-- Can reference multiple issues. Use one of the following "magic words" - "closes, fixes" to auto-close the Github issue. --> * #<issue> #### Test Plan <!-- How will this be tested prior to merging.--> - [ ] ⚡ Unit test
This commit is contained in:
parent
19d56b1e29
commit
73a6ff7839
@ -117,7 +117,7 @@ func (suite *ExchangeCMDWithFlagsE2ESuite) TestBackupCreateExchange_azureIDFromC
|
|||||||
"--config-file", suite.cfgFP)
|
"--config-file", suite.cfgFP)
|
||||||
cli.BuildCommandTree(cmd)
|
cli.BuildCommandTree(cmd)
|
||||||
|
|
||||||
cmd.SetErr(&suite.recorder)
|
cmd.SetOut(&suite.recorder)
|
||||||
|
|
||||||
ctx = print.SetRootCmd(ctx, cmd)
|
ctx = print.SetRootCmd(ctx, cmd)
|
||||||
|
|
||||||
@ -143,10 +143,11 @@ func (suite *ExchangeCMDWithFlagsE2ESuite) TestExchangeBackupValueFromEnvCmd_emp
|
|||||||
|
|
||||||
cmd := cliTD.StubRootCmd(
|
cmd := cliTD.StubRootCmd(
|
||||||
"backup", "create", "exchange",
|
"backup", "create", "exchange",
|
||||||
"--user", suite.m365UserID)
|
"--user", suite.m365UserID,
|
||||||
|
"--config-file", suite.cfgFP)
|
||||||
cli.BuildCommandTree(cmd)
|
cli.BuildCommandTree(cmd)
|
||||||
|
|
||||||
cmd.SetErr(&suite.recorder)
|
cmd.SetOut(&suite.recorder)
|
||||||
|
|
||||||
ctx = print.SetRootCmd(ctx, cmd)
|
ctx = print.SetRootCmd(ctx, cmd)
|
||||||
|
|
||||||
@ -178,7 +179,7 @@ func (suite *ExchangeCMDWithFlagsE2ESuite) TestExchangeBackupInvalidAWSClientIDC
|
|||||||
)
|
)
|
||||||
cli.BuildCommandTree(cmd)
|
cli.BuildCommandTree(cmd)
|
||||||
|
|
||||||
cmd.SetErr(&suite.recorder)
|
cmd.SetOut(&suite.recorder)
|
||||||
|
|
||||||
ctx = print.SetRootCmd(ctx, cmd)
|
ctx = print.SetRootCmd(ctx, cmd)
|
||||||
|
|
||||||
@ -199,10 +200,12 @@ func (suite *ExchangeCMDWithFlagsE2ESuite) TestExchangeBackupAWSValueFromEnvCmd_
|
|||||||
|
|
||||||
cmd := cliTD.StubRootCmd(
|
cmd := cliTD.StubRootCmd(
|
||||||
"backup", "create", "exchange",
|
"backup", "create", "exchange",
|
||||||
"--user", suite.m365UserID)
|
"--user", suite.m365UserID,
|
||||||
|
"--config-file", suite.cfgFP)
|
||||||
|
|
||||||
cli.BuildCommandTree(cmd)
|
cli.BuildCommandTree(cmd)
|
||||||
|
|
||||||
cmd.SetErr(&suite.recorder)
|
cmd.SetOut(&suite.recorder)
|
||||||
|
|
||||||
ctx = print.SetRootCmd(ctx, cmd)
|
ctx = print.SetRootCmd(ctx, cmd)
|
||||||
|
|
||||||
|
|||||||
@ -20,11 +20,6 @@ import (
|
|||||||
func s3ConfigsFromViper(vpr *viper.Viper) (storage.S3Config, error) {
|
func s3ConfigsFromViper(vpr *viper.Viper) (storage.S3Config, error) {
|
||||||
var s3Config storage.S3Config
|
var s3Config storage.S3Config
|
||||||
|
|
||||||
providerType := vpr.GetString(StorageProviderTypeKey)
|
|
||||||
if providerType != storage.ProviderS3.String() {
|
|
||||||
return s3Config, clues.New("unsupported storage provider: " + providerType)
|
|
||||||
}
|
|
||||||
|
|
||||||
s3Config.Bucket = vpr.GetString(BucketNameKey)
|
s3Config.Bucket = vpr.GetString(BucketNameKey)
|
||||||
s3Config.Endpoint = vpr.GetString(EndpointKey)
|
s3Config.Endpoint = vpr.GetString(EndpointKey)
|
||||||
s3Config.Prefix = vpr.GetString(PrefixKey)
|
s3Config.Prefix = vpr.GetString(PrefixKey)
|
||||||
@ -83,6 +78,11 @@ func configureStorage(
|
|||||||
}
|
}
|
||||||
|
|
||||||
if matchFromConfig {
|
if matchFromConfig {
|
||||||
|
providerType := vpr.GetString(StorageProviderTypeKey)
|
||||||
|
if providerType != storage.ProviderS3.String() {
|
||||||
|
return store, clues.New("unsupported storage provider: " + providerType)
|
||||||
|
}
|
||||||
|
|
||||||
if err := mustMatchConfig(vpr, s3Overrides(overrides)); err != nil {
|
if err := mustMatchConfig(vpr, s3Overrides(overrides)); err != nil {
|
||||||
return store, clues.Wrap(err, "verifying s3 configs in corso config file")
|
return store, clues.Wrap(err, "verifying s3 configs in corso config file")
|
||||||
}
|
}
|
||||||
|
|||||||
@ -132,7 +132,11 @@ func (suite *S3E2ESuite) TestInitS3Cmd_missingBucket() {
|
|||||||
cfg, err := st.S3Config()
|
cfg, err := st.S3Config()
|
||||||
require.NoError(t, err, clues.ToCore(err))
|
require.NoError(t, err, clues.ToCore(err))
|
||||||
|
|
||||||
vpr, configFP := tconfig.MakeTempTestConfigClone(t, nil)
|
force := map[string]string{
|
||||||
|
tconfig.TestCfgBucket: "",
|
||||||
|
}
|
||||||
|
|
||||||
|
vpr, configFP := tconfig.MakeTempTestConfigClone(t, force)
|
||||||
|
|
||||||
ctx = config.SetViper(ctx, vpr)
|
ctx = config.SetViper(ctx, vpr)
|
||||||
|
|
||||||
|
|||||||
3
src/pkg/storage/testdata/storage.go
vendored
3
src/pkg/storage/testdata/storage.go
vendored
@ -7,7 +7,6 @@ import (
|
|||||||
"github.com/alcionai/clues"
|
"github.com/alcionai/clues"
|
||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
|
|
||||||
"github.com/alcionai/corso/src/cli/flags"
|
|
||||||
"github.com/alcionai/corso/src/internal/common/str"
|
"github.com/alcionai/corso/src/internal/common/str"
|
||||||
"github.com/alcionai/corso/src/internal/tester"
|
"github.com/alcionai/corso/src/internal/tester"
|
||||||
"github.com/alcionai/corso/src/internal/tester/tconfig"
|
"github.com/alcionai/corso/src/internal/tester/tconfig"
|
||||||
@ -58,7 +57,7 @@ func NewPrefixedS3Storage(t *testing.T) storage.Storage {
|
|||||||
func GetAndInsertCorso(passphase string) credentials.Corso {
|
func GetAndInsertCorso(passphase string) credentials.Corso {
|
||||||
// fetch data from flag, env var or func param giving priority to func param
|
// fetch data from flag, env var or func param giving priority to func param
|
||||||
// Func param generally will be value fetched from config file using viper.
|
// Func param generally will be value fetched from config file using viper.
|
||||||
corsoPassph := str.First(flags.CorsoPassphraseFV, os.Getenv(credentials.CorsoPassphrase), passphase)
|
corsoPassph := str.First(os.Getenv(credentials.CorsoPassphrase), passphase)
|
||||||
|
|
||||||
return credentials.Corso{
|
return credentials.Corso{
|
||||||
CorsoPassphrase: corsoPassph,
|
CorsoPassphrase: corsoPassph,
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user