don't match config in init repo (#3726)

<!-- PR description-->

In case of init repo - don't match values from config file.

#### 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.-->
- [ ] 💪 Manual
This commit is contained in:
neha_gupta 2023-06-30 22:50:47 +05:30 committed by GitHub
parent 84c58e9e9c
commit 9a7213baa6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 8 additions and 7 deletions

View File

@ -40,6 +40,7 @@ func m365Overrides(in map[string]string) map[string]string {
func configureAccount( func configureAccount(
vpr *viper.Viper, vpr *viper.Viper,
readConfigFromViper bool, readConfigFromViper bool,
matchFromConfig bool,
overrides map[string]string, overrides map[string]string,
) (account.Account, error) { ) (account.Account, error) {
var ( var (
@ -49,7 +50,7 @@ func configureAccount(
err error err error
) )
if readConfigFromViper { if matchFromConfig {
m365Cfg, err = m365ConfigsFromViper(vpr) m365Cfg, err = m365ConfigsFromViper(vpr)
if err != nil { if err != nil {
return acct, clues.Wrap(err, "reading m365 configs from corso config file") return acct, clues.Wrap(err, "reading m365 configs from corso config file")

View File

@ -284,7 +284,7 @@ func getStorageAndAccountWithViper(
config.RepoID = vpr.GetString(RepoID) config.RepoID = vpr.GetString(RepoID)
} }
config.Account, err = configureAccount(vpr, readConfigFromViper, overrides) config.Account, err = configureAccount(vpr, readConfigFromViper, mustMatchFromConfig, overrides)
if err != nil { if err != nil {
return config, clues.Wrap(err, "retrieving account configuration details") return config, clues.Wrap(err, "retrieving account configuration details")
} }

View File

@ -270,7 +270,7 @@ func (suite *ConfigIntegrationSuite) TestGetStorageAndAccount() {
err = vpr.ReadInConfig() err = vpr.ReadInConfig()
require.NoError(t, err, "reading repo config", clues.ToCore(err)) require.NoError(t, err, "reading repo config", clues.ToCore(err))
config, err := getStorageAndAccountWithViper(vpr, true, false, nil) config, err := getStorageAndAccountWithViper(vpr, true, true, nil)
require.NoError(t, err, "getting storage and account from config", clues.ToCore(err)) require.NoError(t, err, "getting storage and account from config", clues.ToCore(err))
readS3Cfg, err := config.Storage.S3Config() readS3Cfg, err := config.Storage.S3Config()

View File

@ -69,10 +69,6 @@ func configureStorage(
) )
if readConfigFromViper { if readConfigFromViper {
if s3Cfg, err = s3ConfigsFromViper(vpr); err != nil {
return store, clues.Wrap(err, "reading s3 configs from corso config file")
}
if b, ok := overrides[storage.Bucket]; ok { if b, ok := overrides[storage.Bucket]; ok {
overrides[storage.Bucket] = common.NormalizeBucket(b) overrides[storage.Bucket] = common.NormalizeBucket(b)
} }
@ -83,6 +79,10 @@ func configureStorage(
} }
if matchFromConfig { if matchFromConfig {
if s3Cfg, err = s3ConfigsFromViper(vpr); err != nil {
return store, clues.Wrap(err, "reading s3 configs from corso config file")
}
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")
} }