stashed changes

This commit is contained in:
Abhishek Pandey 2023-09-12 22:22:58 +05:30
parent 62b466ca39
commit c2e09688db
5 changed files with 45 additions and 12 deletions

View File

@ -291,6 +291,8 @@ func getStorageAndAccountWithViper(
err error
)
//overrides := repo.S3Overrides(pfs)
overrides := make(map[string]string)
readConfigFromViper := readFromFile
// possibly read the prior config from a .corso file

View File

@ -52,7 +52,7 @@ func s3Overrides(in map[string]string) map[string]string {
}
}
// Make it local
// Moved from repo/s3.go pkg
func S3Overrides(pfs *pflag.FlagSet) map[string]string {
fs := flags.GetPopulatedFlags(pfs)
return PopulateS3Flags(fs)
@ -76,23 +76,23 @@ func PopulateS3Flags(flagset flags.PopulatedFlags) map[string]string {
}
if _, ok := flagset[flags.BucketFN]; ok {
s3Overrides[storage.Bucket] = flags.BucketFV
s3Overrides[storage.Bucket] = bucket
}
if _, ok := flagset[flags.PrefixFN]; ok {
s3Overrides[storage.Prefix] = flags.PrefixFV
if _, ok := flagset[prefixFN]; ok {
s3Overrides[storage.Prefix] = prefix
}
if _, ok := flagset[flags.DoNotUseTLSFN]; ok {
s3Overrides[storage.DoNotUseTLS] = strconv.FormatBool(flags.DoNotUseTLSFV)
if _, ok := flagset[doNotUseTLSFN]; ok {
s3Overrides[storage.DoNotUseTLS] = strconv.FormatBool(doNotUseTLS)
}
if _, ok := flagset[flags.DoNotVerifyTLSFN]; ok {
s3Overrides[storage.DoNotVerifyTLS] = strconv.FormatBool(flags.DoNotVerifyTLSFV)
if _, ok := flagset[doNotVerifyTLSFN]; ok {
s3Overrides[storage.DoNotVerifyTLS] = strconv.FormatBool(doNotVerifyTLS)
}
if _, ok := flagset[flags.EndpointFN]; ok {
s3Overrides[storage.Endpoint] = flags.EndpointFV
if _, ok := flagset[endpointFN]; ok {
s3Overrides[storage.Endpoint] = endpoint
}
return s3Overrides

View File

@ -24,7 +24,7 @@ func (fs PopulatedFlags) populate(pf *pflag.Flag) {
func GetPopulatedFlags(pfs *pflag.FlagSet) PopulatedFlags {
pop := PopulatedFlags{}
// fs := cmd.Flags()
//fs := cmd.Flags()
if pfs == nil {
return pop
}

View File

@ -14,6 +14,15 @@ const (
CorsoPassphraseFN = "passphrase"
)
// s3 bucket flags
const (
BucketFN = "bucket"
EndpointFN = "endpoint"
PrefixFN = "prefix"
DoNotUseTLSFN = "disable-tls"
DoNotVerifyTLSFN = "disable-tls-verification"
)
var (
BackupIDFV string
AWSAccessKeyFV string

View File

@ -15,6 +15,16 @@ import (
"github.com/alcionai/corso/src/pkg/repository"
)
// s3 bucket info from flags
var (
succeedIfExists bool
bucket string
endpoint string
prefix string
doNotUseTLS bool
doNotVerifyTLS bool
)
// called by repo.go to map subcommands to provider-specific handling.
func addS3Commands(cmd *cobra.Command) *cobra.Command {
var c *cobra.Command
@ -35,7 +45,19 @@ func addS3Commands(cmd *cobra.Command) *cobra.Command {
flags.AddAWSCredsFlags(c)
flags.AddAzureCredsFlags(c)
flags.AddCorsoPassphaseFlags(c)
flags.AddS3BucketFlags(c)
// Flags addition ordering should follow the order we want them to appear in help and docs:
// More generic and more frequently used flags take precedence.
fs.StringVar(&bucket, flags.BucketFN, "", "Name of S3 bucket for repo. (required)")
fs.StringVar(&prefix, flags.PrefixFN, "", "Repo prefix within bucket.")
fs.StringVar(&endpoint, flags.EndpointFN, "", "S3 service endpoint.")
fs.BoolVar(&doNotUseTLS, flags.DoNotUseTLSFN, false, "Disable TLS (HTTPS)")
fs.BoolVar(&doNotVerifyTLS, flags.DoNotVerifyTLSFN, false, "Disable TLS (HTTPS) certificate verification.")
// In general, we don't want to expose this flag to users and have them mistake it
// for a broad-scale idempotency solution. We can un-hide it later the need arises.
fs.BoolVar(&succeedIfExists, "succeed-if-exists", false, "Exit with success if the repo has already been initialized.")
cobra.CheckErr(fs.MarkHidden("succeed-if-exists"))
return c
}