<!-- PR description--> Follow the pattern used elsewhere for declaring flag names & values. No logic change, just moving code. Added a unit test for flags. --- #### 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: ---> - [ ] 🌻 Feature - [ ] 🐛 Bugfix - [ ] 🗺️ Documentation - [ ] 🤖 Supportability/Tests - [ ] 💻 CI/Deployment - [x] 🧹 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.--> - [ ] 💪 Manual - [x] ⚡ Unit test - [ ] 💚 E2E
42 lines
1.4 KiB
Go
42 lines
1.4 KiB
Go
package flags
|
|
|
|
import "github.com/spf13/cobra"
|
|
|
|
// S3 bucket flags
|
|
const (
|
|
BucketFN = "bucket"
|
|
EndpointFN = "endpoint"
|
|
PrefixFN = "prefix"
|
|
DoNotUseTLSFN = "disable-tls"
|
|
DoNotVerifyTLSFN = "disable-tls-verification"
|
|
SucceedIfExistsFN = "succeed-if-exists"
|
|
)
|
|
|
|
// S3 bucket flag values
|
|
var (
|
|
BucketFV string
|
|
EndpointFV string
|
|
PrefixFV string
|
|
DoNotUseTLSFV bool
|
|
DoNotVerifyTLSFV bool
|
|
SucceedIfExistsFV bool
|
|
)
|
|
|
|
// S3 bucket flags
|
|
func AddS3BucketFlags(cmd *cobra.Command) {
|
|
fs := cmd.Flags()
|
|
|
|
// 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(&BucketFV, BucketFN, "", "Name of S3 bucket for repo. (required)")
|
|
fs.StringVar(&PrefixFV, PrefixFN, "", "Repo prefix within bucket.")
|
|
fs.StringVar(&EndpointFV, EndpointFN, "", "S3 service endpoint.")
|
|
fs.BoolVar(&DoNotUseTLSFV, DoNotUseTLSFN, false, "Disable TLS (HTTPS)")
|
|
fs.BoolVar(&DoNotVerifyTLSFV, 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(&SucceedIfExistsFV, SucceedIfExistsFN, false, "Exit with success if the repo has already been initialized.")
|
|
cobra.CheckErr(fs.MarkHidden("succeed-if-exists"))
|
|
}
|