Skip to content

Commit

Permalink
remove duplicated available options from description
Browse files Browse the repository at this point in the history
Signed-off-by: h3nryc0ding <hr.richterhenry@gmail.com>
  • Loading branch information
h3nryc0ding committed Nov 13, 2024
1 parent 64739b4 commit 4404634
Show file tree
Hide file tree
Showing 15 changed files with 27 additions and 48 deletions.
2 changes: 1 addition & 1 deletion cmd/flux/create_source_git_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
2 changes: 1 addition & 1 deletion internal/flags/crds.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
2 changes: 1 addition & 1 deletion internal/flags/decryption_provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
2 changes: 1 addition & 1 deletion internal/flags/ecdsa_curve.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
19 changes: 11 additions & 8 deletions internal/flags/gitlab_visibility.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ package flags

import (
"fmt"
"sort"
"strings"

"github.com/fluxcd/go-git-providers/gitprovider"
Expand Down Expand Up @@ -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
}
6 changes: 1 addition & 5 deletions internal/flags/helm_chart_source.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 '<kind>/<name>.<namespace>', "+
"where kind must be one of: (%s)",
s.Type(),
)
return "source that contains the chart in the format '<kind>/<name>.<namespace>'"
}
6 changes: 1 addition & 5 deletions internal/flags/kustomization_source.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 '[<kind>/]<name>.<namespace>', "+
"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 '[<kind>/]<name>.<namespace>', if kind is not specified it defaults to GitRepository"
}
6 changes: 1 addition & 5 deletions internal/flags/local_helm_chart_source.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 '<kind>/<name>', "+
"where kind must be one of: (%s)",
s.Type(),
)
return "source that contains the chart in the format '<kind>/<name>'"
}
2 changes: 1 addition & 1 deletion internal/flags/log_level.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
2 changes: 1 addition & 1 deletion internal/flags/public_key_algorithm.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
2 changes: 1 addition & 1 deletion internal/flags/rsa_key_bits.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
5 changes: 1 addition & 4 deletions internal/flags/source_bucket_provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
9 changes: 3 additions & 6 deletions internal/flags/source_git_provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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"
}
5 changes: 1 addition & 4 deletions internal/flags/source_oci_provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
5 changes: 1 addition & 4 deletions internal/flags/source_oci_verify_provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}

0 comments on commit 4404634

Please sign in to comment.