From fa79cd5a72302c451be9bceefa2692fb9e4b272c Mon Sep 17 00:00:00 2001 From: Vaibhav Kamra Date: Wed, 19 Jul 2023 22:19:10 -0700 Subject: [PATCH] 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] :white_check_mark: Yes, it's included - [ ] :clock1: Yes, but in a later PR - [ ] :no_entry: No #### Type of change - [ ] :sunflower: Feature - [x] :bug: Bugfix - [ ] :world_map: Documentation - [ ] :robot: Supportability/Tests - [ ] :computer: CI/Deployment - [ ] :broom: Tech Debt/Cleanup #### Issue(s) * #3856 #### Test Plan - [ ] :muscle: Manual - [ ] :zap: Unit test - [x] :green_heart: E2E --- CHANGELOG.md | 4 ++++ src/cli/config/account.go | 16 ++++++++-------- src/cli/config/config_test.go | 2 +- src/cli/config/storage.go | 16 ++++++++-------- 4 files changed, 21 insertions(+), 17 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 54ef6cde3..6d7fdca0d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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. diff --git a/src/cli/config/account.go b/src/cli/config/account.go index 8c0331410..2f630e6a5 100644 --- a/src/cli/config/account.go +++ b/src/cli/config/account.go @@ -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") + } } } diff --git a/src/cli/config/config_test.go b/src/cli/config/config_test.go index e58c3a99c..80fac559e 100644 --- a/src/cli/config/config_test.go +++ b/src/cli/config/config_test.go @@ -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() diff --git a/src/cli/config/storage.go b/src/cli/config/storage.go index bfa154ca1..d948e6af3 100644 --- a/src/cli/config/storage.go +++ b/src/cli/config/storage.go @@ -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") + } } }