From de7e9ff61939dade9a675f9703e636c25de5c37b Mon Sep 17 00:00:00 2001
From: h3nryc0ding
Date: Sun, 10 Nov 2024 02:37:33 +0000
Subject: [PATCH 1/5] improve flag descriptions to show allowed values instead
of internal type names
Signed-off-by: h3nryc0ding
---
internal/flags/crds.go | 2 +-
internal/flags/decryption_provider.go | 2 +-
internal/flags/ecdsa_curve.go | 2 +-
internal/flags/gitlab_visibility.go | 6 +++++-
internal/flags/helm_chart_source.go | 2 +-
internal/flags/kustomization_source.go | 2 +-
internal/flags/local_helm_chart_source.go | 2 +-
internal/flags/log_level.go | 2 +-
internal/flags/public_key_algorithm.go | 2 +-
internal/flags/source_bucket_provider.go | 2 +-
internal/flags/source_oci_provider.go | 2 +-
internal/flags/source_oci_verify_provider.go | 2 +-
12 files changed, 16 insertions(+), 12 deletions(-)
diff --git a/internal/flags/crds.go b/internal/flags/crds.go
index 81f6d604c8..850688dd8e 100644
--- a/internal/flags/crds.go
+++ b/internal/flags/crds.go
@@ -52,7 +52,7 @@ func (a *CRDsPolicy) Set(str string) error {
}
func (a *CRDsPolicy) Type() string {
- return "crds"
+ return strings.Join(supportedCRDsPolicies, "|")
}
func (a *CRDsPolicy) Description() string {
diff --git a/internal/flags/decryption_provider.go b/internal/flags/decryption_provider.go
index 085340aba7..8ad3c30222 100644
--- a/internal/flags/decryption_provider.go
+++ b/internal/flags/decryption_provider.go
@@ -46,7 +46,7 @@ func (d *DecryptionProvider) Set(str string) error {
}
func (d *DecryptionProvider) Type() string {
- return "decryptionProvider"
+ return strings.Join(supportedDecryptionProviders, "|")
}
func (d *DecryptionProvider) Description() string {
diff --git a/internal/flags/ecdsa_curve.go b/internal/flags/ecdsa_curve.go
index 9be8469bfe..2d9c332425 100644
--- a/internal/flags/ecdsa_curve.go
+++ b/internal/flags/ecdsa_curve.go
@@ -49,7 +49,7 @@ func (c *ECDSACurve) Set(str string) error {
}
func (c *ECDSACurve) Type() string {
- return "ecdsaCurve"
+ return strings.Join(ecdsaCurves(), "|")
}
func (c *ECDSACurve) Description() string {
diff --git a/internal/flags/gitlab_visibility.go b/internal/flags/gitlab_visibility.go
index 924dd898d1..ec0c2aec53 100644
--- a/internal/flags/gitlab_visibility.go
+++ b/internal/flags/gitlab_visibility.go
@@ -58,7 +58,11 @@ func (d *GitLabVisibility) Set(str string) error {
}
func (d *GitLabVisibility) Type() string {
- return "gitLabVisibility"
+ visibilities := make([]string, 0, len(supportedGitLabVisibilities))
+ for visibility := range supportedGitLabVisibilities {
+ visibilities = append(visibilities, string(visibility))
+ }
+ return strings.Join(visibilities, "|")
}
func (d *GitLabVisibility) Description() string {
diff --git a/internal/flags/helm_chart_source.go b/internal/flags/helm_chart_source.go
index 079ca4d3d1..a2a925c751 100644
--- a/internal/flags/helm_chart_source.go
+++ b/internal/flags/helm_chart_source.go
@@ -64,7 +64,7 @@ func (s *HelmChartSource) Set(str string) error {
}
func (s *HelmChartSource) Type() string {
- return "helmChartSource"
+ return strings.Join(supportedHelmChartSourceKinds, "|")
}
func (s *HelmChartSource) Description() string {
diff --git a/internal/flags/kustomization_source.go b/internal/flags/kustomization_source.go
index 4dc124ab76..88ecc3b068 100644
--- a/internal/flags/kustomization_source.go
+++ b/internal/flags/kustomization_source.go
@@ -71,7 +71,7 @@ func (s *KustomizationSource) Set(str string) error {
}
func (s *KustomizationSource) Type() string {
- return "kustomizationSource"
+ return strings.Join(supportedKustomizationSourceKinds, "|")
}
func (s *KustomizationSource) Description() string {
diff --git a/internal/flags/local_helm_chart_source.go b/internal/flags/local_helm_chart_source.go
index 19d2e5305c..bbb7a592ba 100644
--- a/internal/flags/local_helm_chart_source.go
+++ b/internal/flags/local_helm_chart_source.go
@@ -58,7 +58,7 @@ func (s *LocalHelmChartSource) Set(str string) error {
}
func (s *LocalHelmChartSource) Type() string {
- return "helmChartSource"
+ return strings.Join(supportedHelmChartSourceKinds, "|")
}
func (s *LocalHelmChartSource) Description() string {
diff --git a/internal/flags/log_level.go b/internal/flags/log_level.go
index 4101a90296..5b26d0c0e0 100644
--- a/internal/flags/log_level.go
+++ b/internal/flags/log_level.go
@@ -46,7 +46,7 @@ func (l *LogLevel) Set(str string) error {
}
func (l *LogLevel) Type() string {
- return "logLevel"
+ return strings.Join(supportedLogLevels, "|")
}
func (l *LogLevel) Description() string {
diff --git a/internal/flags/public_key_algorithm.go b/internal/flags/public_key_algorithm.go
index ed4902a7a5..325ff6b40e 100644
--- a/internal/flags/public_key_algorithm.go
+++ b/internal/flags/public_key_algorithm.go
@@ -45,7 +45,7 @@ func (a *PublicKeyAlgorithm) Set(str string) error {
}
func (a *PublicKeyAlgorithm) Type() string {
- return "publicKeyAlgorithm"
+ return strings.Join(supportedPublicKeyAlgorithms, "|")
}
func (a *PublicKeyAlgorithm) Description() string {
diff --git a/internal/flags/source_bucket_provider.go b/internal/flags/source_bucket_provider.go
index bd93b41dfc..9c8aaa1932 100644
--- a/internal/flags/source_bucket_provider.go
+++ b/internal/flags/source_bucket_provider.go
@@ -52,7 +52,7 @@ func (p *SourceBucketProvider) Set(str string) error {
}
func (p *SourceBucketProvider) Type() string {
- return "sourceBucketProvider"
+ return strings.Join(supportedSourceBucketProviders, "|")
}
func (p *SourceBucketProvider) Description() string {
diff --git a/internal/flags/source_oci_provider.go b/internal/flags/source_oci_provider.go
index 77ff044183..6624c0de77 100644
--- a/internal/flags/source_oci_provider.go
+++ b/internal/flags/source_oci_provider.go
@@ -59,7 +59,7 @@ func (p *SourceOCIProvider) Set(str string) error {
}
func (p *SourceOCIProvider) Type() string {
- return "sourceOCIProvider"
+ return strings.Join(supportedSourceOCIProviders, "|")
}
func (p *SourceOCIProvider) Description() string {
diff --git a/internal/flags/source_oci_verify_provider.go b/internal/flags/source_oci_verify_provider.go
index acd57a9d2f..57c8cdde45 100644
--- a/internal/flags/source_oci_verify_provider.go
+++ b/internal/flags/source_oci_verify_provider.go
@@ -47,7 +47,7 @@ func (p *SourceOCIVerifyProvider) Set(str string) error {
}
func (p *SourceOCIVerifyProvider) Type() string {
- return "sourceOCIVerifyProvider"
+ return strings.Join(supportedSourceOCIVerifyProviders, "|")
}
func (p *SourceOCIVerifyProvider) Description() string {
From 64739b40196d9670c0b23c62fd10fc7e3fcd95c3 Mon Sep 17 00:00:00 2001
From: h3nryc0ding
Date: Sun, 10 Nov 2024 03:10:52 +0000
Subject: [PATCH 2/5] unify parsing errors
Signed-off-by: h3nryc0ding
---
cmd/flux/create_helmrelease_test.go | 2 +-
cmd/flux/create_source_chart_test.go | 2 +-
cmd/flux/create_source_git_test.go | 2 +-
internal/flags/crds.go | 6 +++---
internal/flags/decryption_provider.go | 6 +++---
internal/flags/ecdsa_curve.go | 4 ++--
internal/flags/gitlab_visibility.go | 7 +++++--
internal/flags/helm_chart_source.go | 4 ++--
internal/flags/kustomization_source.go | 4 ++--
internal/flags/local_helm_chart_source.go | 4 ++--
internal/flags/log_level.go | 6 +++---
internal/flags/public_key_algorithm.go | 6 +++---
internal/flags/source_bucket_provider.go | 4 ++--
internal/flags/source_git_provider.go | 5 ++++-
internal/flags/source_oci_provider.go | 4 ++--
internal/flags/source_oci_verify_provider.go | 4 ++--
16 files changed, 38 insertions(+), 32 deletions(-)
diff --git a/cmd/flux/create_helmrelease_test.go b/cmd/flux/create_helmrelease_test.go
index ffdef081d0..d5d76d3668 100644
--- a/cmd/flux/create_helmrelease_test.go
+++ b/cmd/flux/create_helmrelease_test.go
@@ -45,7 +45,7 @@ func TestCreateHelmRelease(t *testing.T) {
{
name: "unknown source kind",
args: "create helmrelease podinfo --source foobar/podinfo --chart podinfo --export",
- assert: assertError(`invalid argument "foobar/podinfo" for "--source" flag: source kind 'foobar' is not supported, must be one of: HelmRepository, GitRepository, Bucket`),
+ assert: assertError(`invalid argument "foobar/podinfo" for "--source" flag: source kind 'foobar' is not supported, must be one of: HelmRepository|GitRepository|Bucket`),
},
{
name: "unknown chart reference kind",
diff --git a/cmd/flux/create_source_chart_test.go b/cmd/flux/create_source_chart_test.go
index 9566708636..87d0e3fd78 100644
--- a/cmd/flux/create_source_chart_test.go
+++ b/cmd/flux/create_source_chart_test.go
@@ -50,7 +50,7 @@ func TestCreateSourceChart(t *testing.T) {
{
name: "unknown source kind",
args: "create source chart podinfo --source foobar/podinfo --export",
- assert: assertError(`invalid argument "foobar/podinfo" for "--source" flag: source kind 'foobar' is not supported, must be one of: HelmRepository, GitRepository, Bucket`),
+ assert: assertError(`invalid argument "foobar/podinfo" for "--source" flag: source kind 'foobar' is not supported, must be one of: HelmRepository|GitRepository|Bucket`),
},
{
name: "basic chart",
diff --git a/cmd/flux/create_source_git_test.go b/cmd/flux/create_source_git_test.go
index d2ece63651..7c1e40d44a 100644
--- a/cmd/flux/create_source_git_test.go
+++ b/cmd/flux/create_source_git_test.go
@@ -152,7 +152,7 @@ func TestCreateSourceGitExport(t *testing.T) {
{
name: "source with empty provider",
args: "create source git podinfo --namespace=flux-system --url=https://dev.azure.com/foo/bar/_git/podinfo --provider \"\" --branch=test --interval=1m0s --export",
- assert: assertError("invalid argument \"\" for \"--provider\" flag: no source Git provider given, please specify the Git provider name"),
+ assert: assertError("invalid argument \"\" for \"--provider\" flag: no source Git provider given, please specify the Git provider name, available options are: (generic|azure)"),
},
{
name: "source with no provider",
diff --git a/internal/flags/crds.go b/internal/flags/crds.go
index 850688dd8e..e3664f8ac2 100644
--- a/internal/flags/crds.go
+++ b/internal/flags/crds.go
@@ -40,11 +40,11 @@ func (a *CRDsPolicy) String() string {
func (a *CRDsPolicy) Set(str string) error {
if strings.TrimSpace(str) == "" {
return fmt.Errorf("no upgrade CRDs policy given, must be one of: %s",
- strings.Join(supportedCRDsPolicies, ", "))
+ a.Type())
}
if !utils.ContainsItemString(supportedCRDsPolicies, str) {
return fmt.Errorf("unsupported upgrade CRDs policy '%s', must be one of: %s",
- str, strings.Join(supportedCRDsPolicies, ", "))
+ str, a.Type())
}
*a = CRDsPolicy(str)
@@ -56,5 +56,5 @@ func (a *CRDsPolicy) Type() string {
}
func (a *CRDsPolicy) Description() string {
- return fmt.Sprintf("upgrade CRDs policy, available options are: (%s)", strings.Join(supportedCRDsPolicies, ", "))
+ return fmt.Sprintf("upgrade CRDs policy, available options are: (%s)", a.Type())
}
diff --git a/internal/flags/decryption_provider.go b/internal/flags/decryption_provider.go
index 8ad3c30222..3f25d67885 100644
--- a/internal/flags/decryption_provider.go
+++ b/internal/flags/decryption_provider.go
@@ -34,11 +34,11 @@ func (d *DecryptionProvider) String() string {
func (d *DecryptionProvider) Set(str string) error {
if strings.TrimSpace(str) == "" {
return fmt.Errorf("no decryption provider given, must be one of: %s",
- strings.Join(supportedDecryptionProviders, ", "))
+ d.Type())
}
if !utils.ContainsItemString(supportedDecryptionProviders, str) {
return fmt.Errorf("unsupported decryption provider '%s', must be one of: %s",
- str, strings.Join(supportedDecryptionProviders, ", "))
+ str, d.Type())
}
*d = DecryptionProvider(str)
@@ -50,5 +50,5 @@ func (d *DecryptionProvider) Type() string {
}
func (d *DecryptionProvider) Description() string {
- return fmt.Sprintf("decryption provider, available options are: (%s)", strings.Join(supportedDecryptionProviders, ", "))
+ return fmt.Sprintf("decryption provider, available options are: (%s)", d.Type())
}
diff --git a/internal/flags/ecdsa_curve.go b/internal/flags/ecdsa_curve.go
index 2d9c332425..ee0157a66e 100644
--- a/internal/flags/ecdsa_curve.go
+++ b/internal/flags/ecdsa_curve.go
@@ -45,7 +45,7 @@ func (c *ECDSACurve) Set(str string) error {
*c = ECDSACurve{v}
return nil
}
- return fmt.Errorf("unsupported curve '%s', must be one of: %s", str, strings.Join(ecdsaCurves(), ", "))
+ return fmt.Errorf("unsupported curve '%s', must be one of: %s", str, c.Type())
}
func (c *ECDSACurve) Type() string {
@@ -53,7 +53,7 @@ func (c *ECDSACurve) Type() string {
}
func (c *ECDSACurve) Description() string {
- return fmt.Sprintf("SSH ECDSA public key curve (%s)", strings.Join(ecdsaCurves(), ", "))
+ return fmt.Sprintf("SSH ECDSA public key curve, available options are: (%s)", c.Type())
}
func ecdsaCurves() []string {
diff --git a/internal/flags/gitlab_visibility.go b/internal/flags/gitlab_visibility.go
index ec0c2aec53..249c0f20ee 100644
--- a/internal/flags/gitlab_visibility.go
+++ b/internal/flags/gitlab_visibility.go
@@ -51,7 +51,7 @@ func (d *GitLabVisibility) Set(str string) error {
}
var visibility = gitprovider.RepositoryVisibility(str)
if ValidateRepositoryVisibility(visibility) != nil {
- return fmt.Errorf("unsupported visibility '%s'", str)
+ return fmt.Errorf("unsupported visibility '%s', must be one of: %s", str, d.Type())
}
*d = GitLabVisibility(visibility)
return nil
@@ -66,5 +66,8 @@ func (d *GitLabVisibility) Type() string {
}
func (d *GitLabVisibility) Description() string {
- return fmt.Sprintf("specifies the visibility of the repository. Valid values are public, private, internal")
+ return fmt.Sprintf(
+ "specifies the visibility of the repository, available options are: (%s)",
+ d.Type(),
+ )
}
diff --git a/internal/flags/helm_chart_source.go b/internal/flags/helm_chart_source.go
index a2a925c751..37f727f209 100644
--- a/internal/flags/helm_chart_source.go
+++ b/internal/flags/helm_chart_source.go
@@ -53,7 +53,7 @@ func (s *HelmChartSource) Set(str string) error {
cleanSourceKind, ok := utils.ContainsEqualFoldItemString(supportedHelmChartSourceKinds, sourceKind)
if !ok {
return fmt.Errorf("source kind '%s' is not supported, must be one of: %s",
- sourceKind, strings.Join(supportedHelmChartSourceKinds, ", "))
+ sourceKind, s.Type())
}
s.Kind = cleanSourceKind
@@ -71,6 +71,6 @@ func (s *HelmChartSource) Description() string {
return fmt.Sprintf(
"source that contains the chart in the format '/.', "+
"where kind must be one of: (%s)",
- strings.Join(supportedHelmChartSourceKinds, ", "),
+ s.Type(),
)
}
diff --git a/internal/flags/kustomization_source.go b/internal/flags/kustomization_source.go
index 88ecc3b068..34c0798bd3 100644
--- a/internal/flags/kustomization_source.go
+++ b/internal/flags/kustomization_source.go
@@ -60,7 +60,7 @@ func (s *KustomizationSource) Set(str string) error {
cleanSourceKind, ok := utils.ContainsEqualFoldItemString(supportedKustomizationSourceKinds, sourceKind)
if !ok {
return fmt.Errorf("source kind '%s' is not supported, must be one of: %s",
- sourceKind, strings.Join(supportedKustomizationSourceKinds, ", "))
+ sourceKind, s.Type())
}
s.Kind = cleanSourceKind
@@ -78,6 +78,6 @@ func (s *KustomizationSource) Description() string {
return fmt.Sprintf(
"source that contains the Kubernetes manifests in the format '[/].', "+
"where kind must be one of: (%s), if kind is not specified it defaults to GitRepository",
- strings.Join(supportedKustomizationSourceKinds, ", "),
+ s.Type(),
)
}
diff --git a/internal/flags/local_helm_chart_source.go b/internal/flags/local_helm_chart_source.go
index bbb7a592ba..072edcc8ad 100644
--- a/internal/flags/local_helm_chart_source.go
+++ b/internal/flags/local_helm_chart_source.go
@@ -48,7 +48,7 @@ func (s *LocalHelmChartSource) Set(str string) error {
cleanSourceKind, ok := utils.ContainsEqualFoldItemString(supportedHelmChartSourceKinds, sourceKind)
if !ok {
return fmt.Errorf("source kind '%s' is not supported, must be one of: %s",
- sourceKind, strings.Join(supportedHelmChartSourceKinds, ", "))
+ sourceKind, s.Type())
}
s.Kind = cleanSourceKind
@@ -65,6 +65,6 @@ func (s *LocalHelmChartSource) Description() string {
return fmt.Sprintf(
"source that contains the chart in the format '/', "+
"where kind must be one of: (%s)",
- strings.Join(supportedHelmChartSourceKinds, ", "),
+ s.Type(),
)
}
diff --git a/internal/flags/log_level.go b/internal/flags/log_level.go
index 5b26d0c0e0..bd150bdf56 100644
--- a/internal/flags/log_level.go
+++ b/internal/flags/log_level.go
@@ -34,11 +34,11 @@ func (l *LogLevel) String() string {
func (l *LogLevel) Set(str string) error {
if strings.TrimSpace(str) == "" {
return fmt.Errorf("no log level given, must be one of: %s",
- strings.Join(supportedLogLevels, ", "))
+ l.Type())
}
if !utils.ContainsItemString(supportedLogLevels, str) {
return fmt.Errorf("unsupported log level '%s', must be one of: %s",
- str, strings.Join(supportedLogLevels, ", "))
+ str, l.Type())
}
*l = LogLevel(str)
@@ -50,5 +50,5 @@ func (l *LogLevel) Type() string {
}
func (l *LogLevel) Description() string {
- return fmt.Sprintf("log level, available options are: (%s)", strings.Join(supportedLogLevels, ", "))
+ return fmt.Sprintf("log level, available options are: (%s)", l.Type())
}
diff --git a/internal/flags/public_key_algorithm.go b/internal/flags/public_key_algorithm.go
index 325ff6b40e..c0a5791241 100644
--- a/internal/flags/public_key_algorithm.go
+++ b/internal/flags/public_key_algorithm.go
@@ -32,7 +32,7 @@ func (a *PublicKeyAlgorithm) String() string {
func (a *PublicKeyAlgorithm) Set(str string) error {
if strings.TrimSpace(str) == "" {
return fmt.Errorf("no public key algorithm given, must be one of: %s",
- strings.Join(supportedPublicKeyAlgorithms, ", "))
+ a.Type())
}
for _, v := range supportedPublicKeyAlgorithms {
if str == v {
@@ -41,7 +41,7 @@ func (a *PublicKeyAlgorithm) Set(str string) error {
}
}
return fmt.Errorf("unsupported public key algorithm '%s', must be one of: %s",
- str, strings.Join(supportedPublicKeyAlgorithms, ", "))
+ str, a.Type())
}
func (a *PublicKeyAlgorithm) Type() string {
@@ -49,5 +49,5 @@ func (a *PublicKeyAlgorithm) Type() string {
}
func (a *PublicKeyAlgorithm) Description() string {
- return fmt.Sprintf("SSH public key algorithm (%s)", strings.Join(supportedPublicKeyAlgorithms, ", "))
+ return fmt.Sprintf("SSH public key algorithm, available options are: (%s)", a.Type())
}
diff --git a/internal/flags/source_bucket_provider.go b/internal/flags/source_bucket_provider.go
index 9c8aaa1932..3408a648c3 100644
--- a/internal/flags/source_bucket_provider.go
+++ b/internal/flags/source_bucket_provider.go
@@ -45,7 +45,7 @@ func (p *SourceBucketProvider) Set(str string) error {
}
if !utils.ContainsItemString(supportedSourceBucketProviders, str) {
return fmt.Errorf("source bucket provider '%s' is not supported, must be one of: %v",
- str, strings.Join(supportedSourceBucketProviders, ", "))
+ str, p.Type())
}
*p = SourceBucketProvider(str)
return nil
@@ -58,6 +58,6 @@ func (p *SourceBucketProvider) Type() string {
func (p *SourceBucketProvider) Description() string {
return fmt.Sprintf(
"the S3 compatible storage provider name, available options are: (%s)",
- strings.Join(supportedSourceBucketProviders, ", "),
+ p.Type(),
)
}
diff --git a/internal/flags/source_git_provider.go b/internal/flags/source_git_provider.go
index 63cec33e91..74da3c308f 100644
--- a/internal/flags/source_git_provider.go
+++ b/internal/flags/source_git_provider.go
@@ -53,5 +53,8 @@ func (p *SourceGitProvider) Type() string {
}
func (p *SourceGitProvider) Description() string {
- return "the Git provider name"
+ return fmt.Sprintf(
+ "the Git provider name, available options are: (%s)",
+ p.Type(),
+ )
}
diff --git a/internal/flags/source_oci_provider.go b/internal/flags/source_oci_provider.go
index 6624c0de77..339000a094 100644
--- a/internal/flags/source_oci_provider.go
+++ b/internal/flags/source_oci_provider.go
@@ -52,7 +52,7 @@ func (p *SourceOCIProvider) Set(str string) error {
}
if !utils.ContainsItemString(supportedSourceOCIProviders, str) {
return fmt.Errorf("source OCI provider '%s' is not supported, must be one of: %v",
- str, strings.Join(supportedSourceOCIProviders, ", "))
+ str, p.Type())
}
*p = SourceOCIProvider(str)
return nil
@@ -65,7 +65,7 @@ func (p *SourceOCIProvider) Type() string {
func (p *SourceOCIProvider) Description() string {
return fmt.Sprintf(
"the OCI provider name, available options are: (%s)",
- strings.Join(supportedSourceOCIProviders, ", "),
+ p.Type(),
)
}
diff --git a/internal/flags/source_oci_verify_provider.go b/internal/flags/source_oci_verify_provider.go
index 57c8cdde45..52f5ccdc65 100644
--- a/internal/flags/source_oci_verify_provider.go
+++ b/internal/flags/source_oci_verify_provider.go
@@ -40,7 +40,7 @@ func (p *SourceOCIVerifyProvider) Set(str string) error {
}
if !utils.ContainsItemString(supportedSourceOCIVerifyProviders, str) {
return fmt.Errorf("source OCI verify provider '%s' is not supported, must be one of: %v",
- str, strings.Join(supportedSourceOCIVerifyProviders, ", "))
+ str, p.Type())
}
*p = SourceOCIVerifyProvider(str)
return nil
@@ -53,6 +53,6 @@ func (p *SourceOCIVerifyProvider) Type() string {
func (p *SourceOCIVerifyProvider) Description() string {
return fmt.Sprintf(
"the OCI verify provider name to use for signature verification, available options are: (%s)",
- strings.Join(supportedSourceOCIVerifyProviders, ", "),
+ p.Type(),
)
}
From 4404634331a0fbe0e9f2da8ec0a982eb9ab046fb Mon Sep 17 00:00:00 2001
From: h3nryc0ding
Date: Wed, 13 Nov 2024 00:32:21 +0000
Subject: [PATCH 3/5] remove duplicated available options from description
Signed-off-by: h3nryc0ding
---
cmd/flux/create_source_git_test.go | 2 +-
internal/flags/crds.go | 2 +-
internal/flags/decryption_provider.go | 2 +-
internal/flags/ecdsa_curve.go | 2 +-
internal/flags/gitlab_visibility.go | 19 +++++++++++--------
internal/flags/helm_chart_source.go | 6 +-----
internal/flags/kustomization_source.go | 6 +-----
internal/flags/local_helm_chart_source.go | 6 +-----
internal/flags/log_level.go | 2 +-
internal/flags/public_key_algorithm.go | 2 +-
internal/flags/rsa_key_bits.go | 2 +-
internal/flags/source_bucket_provider.go | 5 +----
internal/flags/source_git_provider.go | 9 +++------
internal/flags/source_oci_provider.go | 5 +----
internal/flags/source_oci_verify_provider.go | 5 +----
15 files changed, 27 insertions(+), 48 deletions(-)
diff --git a/cmd/flux/create_source_git_test.go b/cmd/flux/create_source_git_test.go
index 7c1e40d44a..a652429cf1 100644
--- a/cmd/flux/create_source_git_test.go
+++ b/cmd/flux/create_source_git_test.go
@@ -152,7 +152,7 @@ func TestCreateSourceGitExport(t *testing.T) {
{
name: "source with empty provider",
args: "create source git podinfo --namespace=flux-system --url=https://dev.azure.com/foo/bar/_git/podinfo --provider \"\" --branch=test --interval=1m0s --export",
- assert: assertError("invalid argument \"\" for \"--provider\" flag: no source Git provider given, please specify the Git provider name, available options are: (generic|azure)"),
+ assert: assertError("invalid argument \"\" for \"--provider\" flag: no source Git provider given, must be one of: generic|azure"),
},
{
name: "source with no provider",
diff --git a/internal/flags/crds.go b/internal/flags/crds.go
index e3664f8ac2..22f1c87757 100644
--- a/internal/flags/crds.go
+++ b/internal/flags/crds.go
@@ -56,5 +56,5 @@ func (a *CRDsPolicy) Type() string {
}
func (a *CRDsPolicy) Description() string {
- return fmt.Sprintf("upgrade CRDs policy, available options are: (%s)", a.Type())
+ return "upgrade CRDs policy"
}
diff --git a/internal/flags/decryption_provider.go b/internal/flags/decryption_provider.go
index 3f25d67885..c92c2d46a5 100644
--- a/internal/flags/decryption_provider.go
+++ b/internal/flags/decryption_provider.go
@@ -50,5 +50,5 @@ func (d *DecryptionProvider) Type() string {
}
func (d *DecryptionProvider) Description() string {
- return fmt.Sprintf("decryption provider, available options are: (%s)", d.Type())
+ return "decryption provider"
}
diff --git a/internal/flags/ecdsa_curve.go b/internal/flags/ecdsa_curve.go
index ee0157a66e..f38e53f2cd 100644
--- a/internal/flags/ecdsa_curve.go
+++ b/internal/flags/ecdsa_curve.go
@@ -53,7 +53,7 @@ func (c *ECDSACurve) Type() string {
}
func (c *ECDSACurve) Description() string {
- return fmt.Sprintf("SSH ECDSA public key curve, available options are: (%s)", c.Type())
+ return "SSH ECDSA public key curve"
}
func ecdsaCurves() []string {
diff --git a/internal/flags/gitlab_visibility.go b/internal/flags/gitlab_visibility.go
index 249c0f20ee..e2b52698e8 100644
--- a/internal/flags/gitlab_visibility.go
+++ b/internal/flags/gitlab_visibility.go
@@ -18,6 +18,7 @@ package flags
import (
"fmt"
+ "sort"
"strings"
"github.com/fluxcd/go-git-providers/gitprovider"
@@ -58,16 +59,18 @@ func (d *GitLabVisibility) Set(str string) error {
}
func (d *GitLabVisibility) Type() string {
+ return strings.Join(gitLabVisibilities(), "|")
+}
+
+func (d *GitLabVisibility) Description() string {
+ return "specifies the visibility of the repository"
+}
+
+func gitLabVisibilities() []string {
visibilities := make([]string, 0, len(supportedGitLabVisibilities))
for visibility := range supportedGitLabVisibilities {
visibilities = append(visibilities, string(visibility))
}
- return strings.Join(visibilities, "|")
-}
-
-func (d *GitLabVisibility) Description() string {
- return fmt.Sprintf(
- "specifies the visibility of the repository, available options are: (%s)",
- d.Type(),
- )
+ sort.Strings(visibilities)
+ return visibilities
}
diff --git a/internal/flags/helm_chart_source.go b/internal/flags/helm_chart_source.go
index 37f727f209..246decee9f 100644
--- a/internal/flags/helm_chart_source.go
+++ b/internal/flags/helm_chart_source.go
@@ -68,9 +68,5 @@ func (s *HelmChartSource) Type() string {
}
func (s *HelmChartSource) Description() string {
- return fmt.Sprintf(
- "source that contains the chart in the format '/.', "+
- "where kind must be one of: (%s)",
- s.Type(),
- )
+ return "source that contains the chart in the format '/.'"
}
diff --git a/internal/flags/kustomization_source.go b/internal/flags/kustomization_source.go
index 34c0798bd3..408371ab50 100644
--- a/internal/flags/kustomization_source.go
+++ b/internal/flags/kustomization_source.go
@@ -75,9 +75,5 @@ func (s *KustomizationSource) Type() string {
}
func (s *KustomizationSource) Description() string {
- return fmt.Sprintf(
- "source that contains the Kubernetes manifests in the format '[/].', "+
- "where kind must be one of: (%s), if kind is not specified it defaults to GitRepository",
- s.Type(),
- )
+ return "source that contains the Kubernetes manifests in the format '[/].', if kind is not specified it defaults to GitRepository"
}
diff --git a/internal/flags/local_helm_chart_source.go b/internal/flags/local_helm_chart_source.go
index 072edcc8ad..cdf7e6896b 100644
--- a/internal/flags/local_helm_chart_source.go
+++ b/internal/flags/local_helm_chart_source.go
@@ -62,9 +62,5 @@ func (s *LocalHelmChartSource) Type() string {
}
func (s *LocalHelmChartSource) Description() string {
- return fmt.Sprintf(
- "source that contains the chart in the format '/', "+
- "where kind must be one of: (%s)",
- s.Type(),
- )
+ return "source that contains the chart in the format '/'"
}
diff --git a/internal/flags/log_level.go b/internal/flags/log_level.go
index bd150bdf56..6464e1961d 100644
--- a/internal/flags/log_level.go
+++ b/internal/flags/log_level.go
@@ -50,5 +50,5 @@ func (l *LogLevel) Type() string {
}
func (l *LogLevel) Description() string {
- return fmt.Sprintf("log level, available options are: (%s)", l.Type())
+ return "log level"
}
diff --git a/internal/flags/public_key_algorithm.go b/internal/flags/public_key_algorithm.go
index c0a5791241..1bdb70233e 100644
--- a/internal/flags/public_key_algorithm.go
+++ b/internal/flags/public_key_algorithm.go
@@ -49,5 +49,5 @@ func (a *PublicKeyAlgorithm) Type() string {
}
func (a *PublicKeyAlgorithm) Description() string {
- return fmt.Sprintf("SSH public key algorithm, available options are: (%s)", a.Type())
+ return "SSH public key algorithm"
}
diff --git a/internal/flags/rsa_key_bits.go b/internal/flags/rsa_key_bits.go
index 716a461771..d8ec7d98f5 100644
--- a/internal/flags/rsa_key_bits.go
+++ b/internal/flags/rsa_key_bits.go
@@ -50,7 +50,7 @@ func (b *RSAKeyBits) Set(str string) error {
}
func (b *RSAKeyBits) Type() string {
- return "rsaKeyBits"
+ return "int"
}
func (b *RSAKeyBits) Description() string {
diff --git a/internal/flags/source_bucket_provider.go b/internal/flags/source_bucket_provider.go
index 3408a648c3..e83c3835ef 100644
--- a/internal/flags/source_bucket_provider.go
+++ b/internal/flags/source_bucket_provider.go
@@ -56,8 +56,5 @@ func (p *SourceBucketProvider) Type() string {
}
func (p *SourceBucketProvider) Description() string {
- return fmt.Sprintf(
- "the S3 compatible storage provider name, available options are: (%s)",
- p.Type(),
- )
+ return "the S3 compatible storage provider name"
}
diff --git a/internal/flags/source_git_provider.go b/internal/flags/source_git_provider.go
index 74da3c308f..144b7865df 100644
--- a/internal/flags/source_git_provider.go
+++ b/internal/flags/source_git_provider.go
@@ -37,8 +37,8 @@ func (p *SourceGitProvider) String() string {
func (p *SourceGitProvider) Set(str string) error {
if strings.TrimSpace(str) == "" {
- return fmt.Errorf("no source Git provider given, please specify %s",
- p.Description())
+ return fmt.Errorf("no source Git provider given, must be one of: %s",
+ p.Type())
}
if !utils.ContainsItemString(supportedSourceGitProviders, str) {
return fmt.Errorf("source Git provider '%s' is not supported, must be one of: %v",
@@ -53,8 +53,5 @@ func (p *SourceGitProvider) Type() string {
}
func (p *SourceGitProvider) Description() string {
- return fmt.Sprintf(
- "the Git provider name, available options are: (%s)",
- p.Type(),
- )
+ return "the Git provider name"
}
diff --git a/internal/flags/source_oci_provider.go b/internal/flags/source_oci_provider.go
index 339000a094..a21c337a93 100644
--- a/internal/flags/source_oci_provider.go
+++ b/internal/flags/source_oci_provider.go
@@ -63,10 +63,7 @@ func (p *SourceOCIProvider) Type() string {
}
func (p *SourceOCIProvider) Description() string {
- return fmt.Sprintf(
- "the OCI provider name, available options are: (%s)",
- p.Type(),
- )
+ return "the OCI provider name"
}
func (p *SourceOCIProvider) ToOCIProvider() (oci.Provider, error) {
diff --git a/internal/flags/source_oci_verify_provider.go b/internal/flags/source_oci_verify_provider.go
index 52f5ccdc65..b2fdaba4b1 100644
--- a/internal/flags/source_oci_verify_provider.go
+++ b/internal/flags/source_oci_verify_provider.go
@@ -51,8 +51,5 @@ func (p *SourceOCIVerifyProvider) Type() string {
}
func (p *SourceOCIVerifyProvider) Description() string {
- return fmt.Sprintf(
- "the OCI verify provider name to use for signature verification, available options are: (%s)",
- p.Type(),
- )
+ return "the OCI verify provider name to use for signature verification"
}
From 8093ad7fefd07c73e4f1b3260cc56507f9f3876b Mon Sep 17 00:00:00 2001
From: h3nryc0ding
Date: Mon, 23 Dec 2024 23:13:17 +0100
Subject: [PATCH 4/5] implement recommended changes
Signed-off-by: h3nryc0ding
---
internal/flags/helm_chart_source.go | 5 +++--
internal/flags/kustomization_source.go | 5 +++--
internal/flags/local_helm_chart_source.go | 5 +++--
3 files changed, 9 insertions(+), 6 deletions(-)
diff --git a/internal/flags/helm_chart_source.go b/internal/flags/helm_chart_source.go
index 246decee9f..30f2e379eb 100644
--- a/internal/flags/helm_chart_source.go
+++ b/internal/flags/helm_chart_source.go
@@ -64,9 +64,10 @@ func (s *HelmChartSource) Set(str string) error {
}
func (s *HelmChartSource) Type() string {
- return strings.Join(supportedHelmChartSourceKinds, "|")
+ return "/."
}
func (s *HelmChartSource) Description() string {
- return "source that contains the chart in the format '/.'"
+ return fmt.Sprintf("source that contains the chart, where kind must be one of: (%s)",
+ strings.Join(supportedHelmChartSourceKinds, ", "))
}
diff --git a/internal/flags/kustomization_source.go b/internal/flags/kustomization_source.go
index 408371ab50..cb65c64d41 100644
--- a/internal/flags/kustomization_source.go
+++ b/internal/flags/kustomization_source.go
@@ -71,9 +71,10 @@ func (s *KustomizationSource) Set(str string) error {
}
func (s *KustomizationSource) Type() string {
- return strings.Join(supportedKustomizationSourceKinds, "|")
+ return "[/]."
}
func (s *KustomizationSource) Description() string {
- return "source that contains the Kubernetes manifests in the format '[/].', if kind is not specified it defaults to GitRepository"
+ return fmt.Sprintf("source that contains the Kubernetes manifests, where kind must be one of: (%s), if kind is not specified it defaults to %s",
+ strings.Join(supportedKustomizationSourceKinds, ", "), sourcev1.GitRepositoryKind)
}
diff --git a/internal/flags/local_helm_chart_source.go b/internal/flags/local_helm_chart_source.go
index cdf7e6896b..a47221dd97 100644
--- a/internal/flags/local_helm_chart_source.go
+++ b/internal/flags/local_helm_chart_source.go
@@ -58,9 +58,10 @@ func (s *LocalHelmChartSource) Set(str string) error {
}
func (s *LocalHelmChartSource) Type() string {
- return strings.Join(supportedHelmChartSourceKinds, "|")
+ return "/"
}
func (s *LocalHelmChartSource) Description() string {
- return "source that contains the chart in the format '/'"
+ return fmt.Sprintf("source that contains the chart, where kind must be one of: (%s)",
+ strings.Join(supportedHelmChartSourceKinds, ", "))
}
From 92e5884664c4380db63ce50a8304e3b0a049c26d Mon Sep 17 00:00:00 2001
From: h3nryc0ding
Date: Mon, 23 Dec 2024 23:13:50 +0100
Subject: [PATCH 5/5] minimize diff
Signed-off-by: h3nryc0ding
---
cmd/flux/create_helmrelease_test.go | 2 +-
cmd/flux/create_source_chart_test.go | 2 +-
cmd/flux/create_source_git_test.go | 4 ++--
internal/flags/crds.go | 4 ++--
internal/flags/decryption_provider.go | 5 ++---
internal/flags/ecdsa_curve.go | 2 +-
internal/flags/gitlab_visibility.go | 3 ++-
internal/flags/helm_chart_source.go | 2 +-
internal/flags/kustomization_source.go | 2 +-
internal/flags/local_helm_chart_source.go | 2 +-
internal/flags/log_level.go | 4 ++--
internal/flags/public_key_algorithm.go | 4 ++--
internal/flags/source_bucket_provider.go | 2 +-
internal/flags/source_git_provider.go | 6 +++---
internal/flags/source_oci_provider.go | 2 +-
internal/flags/source_oci_verify_provider.go | 2 +-
16 files changed, 24 insertions(+), 24 deletions(-)
diff --git a/cmd/flux/create_helmrelease_test.go b/cmd/flux/create_helmrelease_test.go
index d5d76d3668..ffdef081d0 100644
--- a/cmd/flux/create_helmrelease_test.go
+++ b/cmd/flux/create_helmrelease_test.go
@@ -45,7 +45,7 @@ func TestCreateHelmRelease(t *testing.T) {
{
name: "unknown source kind",
args: "create helmrelease podinfo --source foobar/podinfo --chart podinfo --export",
- assert: assertError(`invalid argument "foobar/podinfo" for "--source" flag: source kind 'foobar' is not supported, must be one of: HelmRepository|GitRepository|Bucket`),
+ assert: assertError(`invalid argument "foobar/podinfo" for "--source" flag: source kind 'foobar' is not supported, must be one of: HelmRepository, GitRepository, Bucket`),
},
{
name: "unknown chart reference kind",
diff --git a/cmd/flux/create_source_chart_test.go b/cmd/flux/create_source_chart_test.go
index 87d0e3fd78..9566708636 100644
--- a/cmd/flux/create_source_chart_test.go
+++ b/cmd/flux/create_source_chart_test.go
@@ -50,7 +50,7 @@ func TestCreateSourceChart(t *testing.T) {
{
name: "unknown source kind",
args: "create source chart podinfo --source foobar/podinfo --export",
- assert: assertError(`invalid argument "foobar/podinfo" for "--source" flag: source kind 'foobar' is not supported, must be one of: HelmRepository|GitRepository|Bucket`),
+ assert: assertError(`invalid argument "foobar/podinfo" for "--source" flag: source kind 'foobar' is not supported, must be one of: HelmRepository, GitRepository, Bucket`),
},
{
name: "basic chart",
diff --git a/cmd/flux/create_source_git_test.go b/cmd/flux/create_source_git_test.go
index a652429cf1..f8ebb16765 100644
--- a/cmd/flux/create_source_git_test.go
+++ b/cmd/flux/create_source_git_test.go
@@ -147,12 +147,12 @@ func TestCreateSourceGitExport(t *testing.T) {
{
name: "source with invalid provider",
args: "create source git podinfo --namespace=flux-system --url=https://dev.azure.com/foo/bar/_git/podinfo --provider dummy --branch=test --interval=1m0s --export",
- assert: assertError("invalid argument \"dummy\" for \"--provider\" flag: source Git provider 'dummy' is not supported, must be one of: generic|azure"),
+ assert: assertError("invalid argument \"dummy\" for \"--provider\" flag: source Git provider 'dummy' is not supported, must be one of: generic, azure"),
},
{
name: "source with empty provider",
args: "create source git podinfo --namespace=flux-system --url=https://dev.azure.com/foo/bar/_git/podinfo --provider \"\" --branch=test --interval=1m0s --export",
- assert: assertError("invalid argument \"\" for \"--provider\" flag: no source Git provider given, must be one of: generic|azure"),
+ assert: assertError("invalid argument \"\" for \"--provider\" flag: no source Git provider given, please specify the Git provider name"),
},
{
name: "source with no provider",
diff --git a/internal/flags/crds.go b/internal/flags/crds.go
index 22f1c87757..3eeba92bb7 100644
--- a/internal/flags/crds.go
+++ b/internal/flags/crds.go
@@ -40,11 +40,11 @@ func (a *CRDsPolicy) String() string {
func (a *CRDsPolicy) Set(str string) error {
if strings.TrimSpace(str) == "" {
return fmt.Errorf("no upgrade CRDs policy given, must be one of: %s",
- a.Type())
+ strings.Join(supportedCRDsPolicies, ", "))
}
if !utils.ContainsItemString(supportedCRDsPolicies, str) {
return fmt.Errorf("unsupported upgrade CRDs policy '%s', must be one of: %s",
- str, a.Type())
+ str, strings.Join(supportedCRDsPolicies, ", "))
}
*a = CRDsPolicy(str)
diff --git a/internal/flags/decryption_provider.go b/internal/flags/decryption_provider.go
index c92c2d46a5..ad4a90bcee 100644
--- a/internal/flags/decryption_provider.go
+++ b/internal/flags/decryption_provider.go
@@ -34,12 +34,11 @@ func (d *DecryptionProvider) String() string {
func (d *DecryptionProvider) Set(str string) error {
if strings.TrimSpace(str) == "" {
return fmt.Errorf("no decryption provider given, must be one of: %s",
- d.Type())
+ strings.Join(supportedDecryptionProviders, ", "))
}
if !utils.ContainsItemString(supportedDecryptionProviders, str) {
return fmt.Errorf("unsupported decryption provider '%s', must be one of: %s",
- str, d.Type())
-
+ str, strings.Join(supportedDecryptionProviders, ", "))
}
*d = DecryptionProvider(str)
return nil
diff --git a/internal/flags/ecdsa_curve.go b/internal/flags/ecdsa_curve.go
index f38e53f2cd..fba3c1493e 100644
--- a/internal/flags/ecdsa_curve.go
+++ b/internal/flags/ecdsa_curve.go
@@ -45,7 +45,7 @@ func (c *ECDSACurve) Set(str string) error {
*c = ECDSACurve{v}
return nil
}
- return fmt.Errorf("unsupported curve '%s', must be one of: %s", str, c.Type())
+ return fmt.Errorf("unsupported curve '%s', must be one of: %s", str, strings.Join(ecdsaCurves(), ", "))
}
func (c *ECDSACurve) Type() string {
diff --git a/internal/flags/gitlab_visibility.go b/internal/flags/gitlab_visibility.go
index e2b52698e8..e729cb3d53 100644
--- a/internal/flags/gitlab_visibility.go
+++ b/internal/flags/gitlab_visibility.go
@@ -52,7 +52,8 @@ func (d *GitLabVisibility) Set(str string) error {
}
var visibility = gitprovider.RepositoryVisibility(str)
if ValidateRepositoryVisibility(visibility) != nil {
- return fmt.Errorf("unsupported visibility '%s', must be one of: %s", str, d.Type())
+ return fmt.Errorf("unsupported visibility '%s', must be one of: %s",
+ str, strings.Join(gitLabVisibilities(), ", "))
}
*d = GitLabVisibility(visibility)
return nil
diff --git a/internal/flags/helm_chart_source.go b/internal/flags/helm_chart_source.go
index 30f2e379eb..2b32188628 100644
--- a/internal/flags/helm_chart_source.go
+++ b/internal/flags/helm_chart_source.go
@@ -53,7 +53,7 @@ func (s *HelmChartSource) Set(str string) error {
cleanSourceKind, ok := utils.ContainsEqualFoldItemString(supportedHelmChartSourceKinds, sourceKind)
if !ok {
return fmt.Errorf("source kind '%s' is not supported, must be one of: %s",
- sourceKind, s.Type())
+ sourceKind, strings.Join(supportedHelmChartSourceKinds, ", "))
}
s.Kind = cleanSourceKind
diff --git a/internal/flags/kustomization_source.go b/internal/flags/kustomization_source.go
index cb65c64d41..24ddbc2af8 100644
--- a/internal/flags/kustomization_source.go
+++ b/internal/flags/kustomization_source.go
@@ -60,7 +60,7 @@ func (s *KustomizationSource) Set(str string) error {
cleanSourceKind, ok := utils.ContainsEqualFoldItemString(supportedKustomizationSourceKinds, sourceKind)
if !ok {
return fmt.Errorf("source kind '%s' is not supported, must be one of: %s",
- sourceKind, s.Type())
+ sourceKind, strings.Join(supportedKustomizationSourceKinds, ", "))
}
s.Kind = cleanSourceKind
diff --git a/internal/flags/local_helm_chart_source.go b/internal/flags/local_helm_chart_source.go
index a47221dd97..ac28bb5ecb 100644
--- a/internal/flags/local_helm_chart_source.go
+++ b/internal/flags/local_helm_chart_source.go
@@ -48,7 +48,7 @@ func (s *LocalHelmChartSource) Set(str string) error {
cleanSourceKind, ok := utils.ContainsEqualFoldItemString(supportedHelmChartSourceKinds, sourceKind)
if !ok {
return fmt.Errorf("source kind '%s' is not supported, must be one of: %s",
- sourceKind, s.Type())
+ sourceKind, strings.Join(supportedHelmChartSourceKinds, ", "))
}
s.Kind = cleanSourceKind
diff --git a/internal/flags/log_level.go b/internal/flags/log_level.go
index 6464e1961d..6fb1c2c531 100644
--- a/internal/flags/log_level.go
+++ b/internal/flags/log_level.go
@@ -34,11 +34,11 @@ func (l *LogLevel) String() string {
func (l *LogLevel) Set(str string) error {
if strings.TrimSpace(str) == "" {
return fmt.Errorf("no log level given, must be one of: %s",
- l.Type())
+ strings.Join(supportedLogLevels, ", "))
}
if !utils.ContainsItemString(supportedLogLevels, str) {
return fmt.Errorf("unsupported log level '%s', must be one of: %s",
- str, l.Type())
+ str, strings.Join(supportedLogLevels, ", "))
}
*l = LogLevel(str)
diff --git a/internal/flags/public_key_algorithm.go b/internal/flags/public_key_algorithm.go
index 1bdb70233e..d2bda1c89c 100644
--- a/internal/flags/public_key_algorithm.go
+++ b/internal/flags/public_key_algorithm.go
@@ -32,7 +32,7 @@ func (a *PublicKeyAlgorithm) String() string {
func (a *PublicKeyAlgorithm) Set(str string) error {
if strings.TrimSpace(str) == "" {
return fmt.Errorf("no public key algorithm given, must be one of: %s",
- a.Type())
+ strings.Join(supportedPublicKeyAlgorithms, ", "))
}
for _, v := range supportedPublicKeyAlgorithms {
if str == v {
@@ -41,7 +41,7 @@ func (a *PublicKeyAlgorithm) Set(str string) error {
}
}
return fmt.Errorf("unsupported public key algorithm '%s', must be one of: %s",
- str, a.Type())
+ str, strings.Join(supportedPublicKeyAlgorithms, ", "))
}
func (a *PublicKeyAlgorithm) Type() string {
diff --git a/internal/flags/source_bucket_provider.go b/internal/flags/source_bucket_provider.go
index e83c3835ef..7b1c4fe59f 100644
--- a/internal/flags/source_bucket_provider.go
+++ b/internal/flags/source_bucket_provider.go
@@ -45,7 +45,7 @@ func (p *SourceBucketProvider) Set(str string) error {
}
if !utils.ContainsItemString(supportedSourceBucketProviders, str) {
return fmt.Errorf("source bucket provider '%s' is not supported, must be one of: %v",
- str, p.Type())
+ str, strings.Join(supportedSourceBucketProviders, ", "))
}
*p = SourceBucketProvider(str)
return nil
diff --git a/internal/flags/source_git_provider.go b/internal/flags/source_git_provider.go
index 144b7865df..9de1ce93cf 100644
--- a/internal/flags/source_git_provider.go
+++ b/internal/flags/source_git_provider.go
@@ -37,12 +37,12 @@ func (p *SourceGitProvider) String() string {
func (p *SourceGitProvider) Set(str string) error {
if strings.TrimSpace(str) == "" {
- return fmt.Errorf("no source Git provider given, must be one of: %s",
- p.Type())
+ return fmt.Errorf("no source Git provider given, please specify %s",
+ p.Description())
}
if !utils.ContainsItemString(supportedSourceGitProviders, str) {
return fmt.Errorf("source Git provider '%s' is not supported, must be one of: %v",
- str, p.Type())
+ str, strings.Join(supportedSourceGitProviders, ", "))
}
*p = SourceGitProvider(str)
return nil
diff --git a/internal/flags/source_oci_provider.go b/internal/flags/source_oci_provider.go
index a21c337a93..013619fe4e 100644
--- a/internal/flags/source_oci_provider.go
+++ b/internal/flags/source_oci_provider.go
@@ -52,7 +52,7 @@ func (p *SourceOCIProvider) Set(str string) error {
}
if !utils.ContainsItemString(supportedSourceOCIProviders, str) {
return fmt.Errorf("source OCI provider '%s' is not supported, must be one of: %v",
- str, p.Type())
+ str, strings.Join(supportedSourceOCIProviders, ", "))
}
*p = SourceOCIProvider(str)
return nil
diff --git a/internal/flags/source_oci_verify_provider.go b/internal/flags/source_oci_verify_provider.go
index b2fdaba4b1..5cd68b493f 100644
--- a/internal/flags/source_oci_verify_provider.go
+++ b/internal/flags/source_oci_verify_provider.go
@@ -40,7 +40,7 @@ func (p *SourceOCIVerifyProvider) Set(str string) error {
}
if !utils.ContainsItemString(supportedSourceOCIVerifyProviders, str) {
return fmt.Errorf("source OCI verify provider '%s' is not supported, must be one of: %v",
- str, p.Type())
+ str, strings.Join(supportedSourceOCIVerifyProviders, ", "))
}
*p = SourceOCIVerifyProvider(str)
return nil