Skip to content

Commit 211f6b8

Browse files
committed
fix: return supported values for flags when calling Values.Type()
Resolves: #5066 which requested each flags implementation of Values.Type() should return the accepted values Signed-off-by: Jesper Berg Axelsen <[email protected]>
1 parent 60e4d99 commit 211f6b8

File tree

9 files changed

+27
-32
lines changed

9 files changed

+27
-32
lines changed

internal/flags/crds.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,9 @@ func (a *CRDsPolicy) Set(str string) error {
5252
}
5353

5454
func (a *CRDsPolicy) Type() string {
55-
return "crds"
55+
return strings.Join(supportedCRDsPolicies, "|")
5656
}
5757

5858
func (a *CRDsPolicy) Description() string {
59-
return fmt.Sprintf("upgrade CRDs policy, available options are: (%s)", strings.Join(supportedCRDsPolicies, ", "))
59+
return "upgrade CRDs policy"
6060
}

internal/flags/ecdsa_curve.go

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,11 +49,16 @@ func (c *ECDSACurve) Set(str string) error {
4949
}
5050

5151
func (c *ECDSACurve) Type() string {
52-
return "ecdsaCurve"
52+
keys := make([]string, 0, len(supportedECDSACurves))
53+
for k := range supportedECDSACurves {
54+
keys = append(keys, k)
55+
}
56+
sort.Strings(keys)
57+
return strings.Join(keys, "|")
5358
}
5459

5560
func (c *ECDSACurve) Description() string {
56-
return fmt.Sprintf("SSH ECDSA public key curve (%s)", strings.Join(ecdsaCurves(), ", "))
61+
return "SSH ECDSA public key curve"
5762
}
5863

5964
func ecdsaCurves() []string {

internal/flags/gitlab_visibility.go

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,9 +58,13 @@ func (d *GitLabVisibility) Set(str string) error {
5858
}
5959

6060
func (d *GitLabVisibility) Type() string {
61-
return "gitLabVisibility"
61+
keys := make([]string, 0, len(supportedGitLabVisibilities))
62+
for v := range supportedGitLabVisibilities {
63+
keys = append(keys, string(v))
64+
}
65+
return strings.Join(keys, "|")
6266
}
6367

6468
func (d *GitLabVisibility) Description() string {
65-
return fmt.Sprintf("specifies the visibility of the repository. Valid values are public, private, internal")
69+
return "specifies the visibility of the repository. Valid values are public, private, internal"
6670
}

internal/flags/helm_chart_source.go

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -64,13 +64,9 @@ func (s *HelmChartSource) Set(str string) error {
6464
}
6565

6666
func (s *HelmChartSource) Type() string {
67-
return "helmChartSource"
67+
return strings.Join(supportedHelmChartSourceKinds, "|")
6868
}
6969

7070
func (s *HelmChartSource) Description() string {
71-
return fmt.Sprintf(
72-
"source that contains the chart in the format '<kind>/<name>.<namespace>', "+
73-
"where kind must be one of: (%s)",
74-
strings.Join(supportedHelmChartSourceKinds, ", "),
75-
)
71+
return "source that contains the chart in the format '<kind>/<name>.<namespace>'"
7672
}

internal/flags/kustomization_source.go

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -70,13 +70,9 @@ func (s *KustomizationSource) Set(str string) error {
7070
}
7171

7272
func (s *KustomizationSource) Type() string {
73-
return "kustomizationSource"
73+
return strings.Join(supportedKustomizationSourceKinds, "|")
7474
}
7575

7676
func (s *KustomizationSource) Description() string {
77-
return fmt.Sprintf(
78-
"source that contains the Kubernetes manifests in the format '[<kind>/]<name>.<namespace>', "+
79-
"where kind must be one of: (%s), if kind is not specified it defaults to GitRepository",
80-
strings.Join(supportedKustomizationSourceKinds, ", "),
81-
)
77+
return "source that contains the Kubernetes manifests in the format '[<kind>/]<name>.<namespace>'. If kind is not specified it defaults to GitRepository"
8278
}

internal/flags/log_level.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,9 @@ func (l *LogLevel) Set(str string) error {
4646
}
4747

4848
func (l *LogLevel) Type() string {
49-
return "logLevel"
49+
return strings.Join(supportedLogLevels, "|")
5050
}
5151

5252
func (l *LogLevel) Description() string {
53-
return fmt.Sprintf("log level, available options are: (%s)", strings.Join(supportedLogLevels, ", "))
53+
return "log level"
5454
}

internal/flags/public_key_algorithm.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,9 @@ func (a *PublicKeyAlgorithm) Set(str string) error {
4545
}
4646

4747
func (a *PublicKeyAlgorithm) Type() string {
48-
return "publicKeyAlgorithm"
48+
return strings.Join(supportedPublicKeyAlgorithms, "|")
4949
}
5050

5151
func (a *PublicKeyAlgorithm) Description() string {
52-
return fmt.Sprintf("SSH public key algorithm (%s)", strings.Join(supportedPublicKeyAlgorithms, ", "))
52+
return "SSH public key algorithm"
5353
}

internal/flags/source_bucket_provider.go

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -52,12 +52,9 @@ func (p *SourceBucketProvider) Set(str string) error {
5252
}
5353

5454
func (p *SourceBucketProvider) Type() string {
55-
return "sourceBucketProvider"
55+
return strings.Join(supportedSourceBucketProviders, "|")
5656
}
5757

5858
func (p *SourceBucketProvider) Description() string {
59-
return fmt.Sprintf(
60-
"the S3 compatible storage provider name, available options are: (%s)",
61-
strings.Join(supportedSourceBucketProviders, ", "),
62-
)
59+
return "the S3 compatible storage provider name"
6360
}

internal/flags/source_oci_provider.go

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -52,12 +52,9 @@ func (p *SourceOCIProvider) Set(str string) error {
5252
}
5353

5454
func (p *SourceOCIProvider) Type() string {
55-
return "sourceOCIProvider"
55+
return strings.Join(supportedSourceOCIProviders, "|")
5656
}
5757

5858
func (p *SourceOCIProvider) Description() string {
59-
return fmt.Sprintf(
60-
"the OCI provider name, available options are: (%s)",
61-
strings.Join(supportedSourceOCIProviders, ", "),
62-
)
59+
return "the OCI provider name"
6360
}

0 commit comments

Comments
 (0)