Only match with viper config if it was read (#3860)

Fix a regression introduced in 1ba103523ae. The `matchFromConfig` block should only be entered if we read config from viper.

---

#### Does this PR need a docs update or release note?

- [x]  Yes, it's included
- [ ] 🕐 Yes, but in a later PR
- [ ]  No

#### Type of change

<!--- Please check the type of change your PR introduces: --->
- [ ] 🌻 Feature
- [x] 🐛 Bugfix
- [ ] 🗺️ Documentation
- [ ] 🤖 Supportability/Tests
- [ ] 💻 CI/Deployment
- [ ] 🧹 Tech Debt/Cleanup

#### Issue(s)

<!-- Can reference multiple issues. Use one of the following "magic words" - "closes, fixes" to auto-close the Github issue. -->
* #3856 

#### Test Plan

<!-- How will this be tested prior to merging.-->
- [ ] 💪 Manual
- [ ]  Unit test
- [x] 💚 E2E
This commit is contained in:
Vaibhav Kamra 2023-07-19 22:19:10 -07:00 committed by GitHub
parent 2c6417d2eb
commit fa79cd5a72
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 21 additions and 17 deletions

View File

@ -7,12 +7,16 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## [Unreleased] (beta)
### Fixed
- Allow repo connect to succeed when a `corso.toml` file was not provided but configuration is specified using environment variables and flags.
## [v0.11.0] (beta) - 2023-07-18
### Added
- Drive items backup and restore link shares
- Restore commands now accept an optional top-level restore destination with the `--destination` flag. Setting the destination to '/' will restore items back into their original location.
- Restore commands can specify item collision behavior. Options are Skip (default), Replace, and Copy.
- Introduced repository maintenance commands to help optimize the repository as well as unreferenced data.
### Fixed
- Return a ServiceNotEnabled error when a tenant has no active SharePoint license.

View File

@ -50,16 +50,16 @@ func configureAccount(
if err != nil {
return acct, clues.Wrap(err, "reading m365 configs from corso config file")
}
}
if matchFromConfig {
providerType := vpr.GetString(AccountProviderTypeKey)
if providerType != account.ProviderM365.String() {
return acct, clues.New("unsupported account provider: " + providerType)
}
if matchFromConfig {
providerType := vpr.GetString(AccountProviderTypeKey)
if providerType != account.ProviderM365.String() {
return acct, clues.New("unsupported account provider: " + providerType)
}
if err := mustMatchConfig(vpr, m365Overrides(overrides)); err != nil {
return acct, clues.Wrap(err, "verifying m365 configs in corso config file")
if err := mustMatchConfig(vpr, m365Overrides(overrides)); err != nil {
return acct, clues.Wrap(err, "verifying m365 configs in corso config file")
}
}
}

View File

@ -450,7 +450,7 @@ func (suite *ConfigIntegrationSuite) TestGetStorageAndAccount_noFileOnlyOverride
StorageProviderTypeKey: storage.ProviderS3.String(),
}
cfg, err := getStorageAndAccountWithViper(vpr, false, false, overrides)
cfg, err := getStorageAndAccountWithViper(vpr, false, true, overrides)
require.NoError(t, err, "getting storage and account from config", clues.ToCore(err))
readS3Cfg, err := cfg.Storage.S3Config()

View File

@ -75,16 +75,16 @@ func configureStorage(
if p, ok := overrides[storage.Prefix]; ok {
overrides[storage.Prefix] = common.NormalizePrefix(p)
}
}
if matchFromConfig {
providerType := vpr.GetString(StorageProviderTypeKey)
if providerType != storage.ProviderS3.String() {
return store, clues.New("unsupported storage provider: " + providerType)
}
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 {
return store, clues.Wrap(err, "verifying s3 configs in corso config file")
if err := mustMatchConfig(vpr, s3Overrides(overrides)); err != nil {
return store, clues.Wrap(err, "verifying s3 configs in corso config file")
}
}
}