From 4404634331a0fbe0e9f2da8ec0a982eb9ab046fb Mon Sep 17 00:00:00 2001
From: h3nryc0ding
Date: Wed, 13 Nov 2024 00:32:21 +0000
Subject: [PATCH] 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"
}