diff --git a/cmd/flux/create_helmrelease_test.go b/cmd/flux/create_helmrelease_test.go index d5d76d36..ffdef081 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 87d0e3fd..95667086 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 a652429c..f8ebb167 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 22f1c877..3eeba92b 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 c92c2d46..ad4a90bc 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 f38e53f2..fba3c149 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 e2b52698..e729cb3d 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 30f2e379..2b321886 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 cb65c64d..24ddbc2a 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 a47221dd..ac28bb5e 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 6464e196..6fb1c2c5 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 1bdb7023..d2bda1c8 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 e83c3835..7b1c4fe5 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 144b7865..9de1ce93 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 a21c337a..013619fe 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 b2fdaba4..5cd68b49 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