remove getting s3 config from envvars (#3757)

<!-- PR description-->

S3 configs like BUCKET and PREFIX are common env vars and can cause overkills. Remove these S3 configs to avoid confusion.

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

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

#### Type of change

<!--- Please check the type of change your PR introduces: --->
- [x] 🌻 Feature
- [ ] 🐛 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. -->
* #<issue>

#### Test Plan

<!-- How will this be tested prior to merging.-->
- [x] 💪 Manual
- [ ]  Unit test
- [ ] 💚 E2E
This commit is contained in:
neha_gupta 2023-07-07 11:45:18 +05:30 committed by GitHub
parent 83e56ed396
commit 9f334f7d30
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 0 additions and 28 deletions

View File

@ -1,7 +1,6 @@
package repo package repo
import ( import (
"os"
"strconv" "strconv"
"strings" "strings"
@ -14,7 +13,6 @@ import (
"github.com/alcionai/corso/src/cli/flags" "github.com/alcionai/corso/src/cli/flags"
. "github.com/alcionai/corso/src/cli/print" . "github.com/alcionai/corso/src/cli/print"
"github.com/alcionai/corso/src/cli/utils" "github.com/alcionai/corso/src/cli/utils"
"github.com/alcionai/corso/src/internal/common/str"
"github.com/alcionai/corso/src/internal/events" "github.com/alcionai/corso/src/internal/events"
"github.com/alcionai/corso/src/pkg/account" "github.com/alcionai/corso/src/pkg/account"
"github.com/alcionai/corso/src/pkg/credentials" "github.com/alcionai/corso/src/pkg/credentials"
@ -126,8 +124,6 @@ func initS3Cmd(cmd *cobra.Command, args []string) error {
// s3 values from flags // s3 values from flags
s3Override := S3Overrides(cmd) s3Override := S3Overrides(cmd)
// s3 values from envs
s3Override = S3UpdateFromEnvVar(cmd, s3Override)
cfg, err := config.GetConfigRepoDetails(ctx, true, false, s3Override) cfg, err := config.GetConfigRepoDetails(ctx, true, false, s3Override)
if err != nil { if err != nil {
@ -202,8 +198,6 @@ func connectS3Cmd(cmd *cobra.Command, args []string) error {
// s3 values from flags // s3 values from flags
s3Override := S3Overrides(cmd) s3Override := S3Overrides(cmd)
// s3 values from envs
s3Override = S3UpdateFromEnvVar(cmd, s3Override)
cfg, err := config.GetConfigRepoDetails(ctx, true, true, s3Override) cfg, err := config.GetConfigRepoDetails(ctx, true, true, s3Override)
if err != nil { if err != nil {
@ -292,15 +286,3 @@ func PopulateS3Flags(flagset flags.PopulatedFlags) map[string]string {
return s3Overrides return s3Overrides
} }
func S3UpdateFromEnvVar(cmd *cobra.Command, s3Flag map[string]string) map[string]string {
s3Flag[storage.Bucket] = str.First(s3Flag[storage.Bucket], os.Getenv(storage.BucketKey))
s3Flag[storage.Endpoint] = str.First(s3Flag[storage.Endpoint], os.Getenv(storage.EndpointKey))
s3Flag[storage.Prefix] = str.First(s3Flag[storage.Prefix], os.Getenv(storage.PrefixKey))
s3Flag[storage.DoNotUseTLS] = str.First(s3Flag[storage.DoNotUseTLS], os.Getenv(storage.DisableTLSKey))
s3Flag[storage.DoNotVerifyTLS] = str.First(
s3Flag[storage.DoNotVerifyTLS],
os.Getenv(storage.DisableTLSVerificationKey))
return s3Flag
}

View File

@ -21,16 +21,6 @@ var (
errMissingRequired = clues.New("missing required storage configuration") errMissingRequired = clues.New("missing required storage configuration")
) )
// envvar consts
// TODO: Remove these and leverage Viper AutomaticEnv() instead
const (
BucketKey = "BUCKET"
EndpointKey = "ENDPOINT"
PrefixKey = "PREFIX"
DisableTLSKey = "DISABLE_TLS"
DisableTLSVerificationKey = "DISABLE_TLS_VERIFICATION"
)
// Storage defines a storage provider, along with any configuration // Storage defines a storage provider, along with any configuration
// required to set up or communicate with that provider. // required to set up or communicate with that provider.
type Storage struct { type Storage struct {