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(
vpr *viper.Viper,
readConfigFromViper bool,
matchFromConfig bool,
overrides map[string]string,
) (account.Account, error) {
var (
@ -49,7 +50,7 @@ func configureAccount(
err error
)
if readConfigFromViper {
if matchFromConfig {
m365Cfg, err = m365ConfigsFromViper(vpr)
if err != nil {
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.Account, err = configureAccount(vpr, readConfigFromViper, overrides)
config.Account, err = configureAccount(vpr, readConfigFromViper, mustMatchFromConfig, overrides)
if err != nil {
return config, clues.Wrap(err, "retrieving account configuration details")
}

View File

@ -270,7 +270,7 @@ func (suite *ConfigIntegrationSuite) TestGetStorageAndAccount() {
err = vpr.ReadInConfig()
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))
readS3Cfg, err := config.Storage.S3Config()

View File

@ -69,10 +69,6 @@ func configureStorage(
)
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 {
overrides[storage.Bucket] = common.NormalizeBucket(b)
}
@ -83,6 +79,10 @@ func configureStorage(
}
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 {
return store, clues.Wrap(err, "verifying s3 configs in corso config file")
}