Skip to content
This repository has been archived by the owner on Oct 11, 2024. It is now read-only.

Commit

Permalink
Only match with viper config if it was read (#3860)
Browse files Browse the repository at this point in the history
Fix a regression introduced in 1ba1035. 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
  • Loading branch information
vkamra authored Jul 20, 2023
1 parent 2c6417d commit fa79cd5
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 17 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
16 changes: 8 additions & 8 deletions src/cli/config/account.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
}
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/cli/config/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
16 changes: 8 additions & 8 deletions src/cli/config/storage.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
}
}
}

Expand Down

0 comments on commit fa79cd5

Please sign in to comment.