Skip to content

Commit

Permalink
minimize diff
Browse files Browse the repository at this point in the history
  • Loading branch information
h3nryc0ding committed Dec 23, 2024
1 parent 57c0683 commit ee59d5f
Show file tree
Hide file tree
Showing 16 changed files with 23 additions and 23 deletions.
2 changes: 1 addition & 1 deletion cmd/flux/create_helmrelease_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
2 changes: 1 addition & 1 deletion cmd/flux/create_source_chart_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
4 changes: 2 additions & 2 deletions cmd/flux/create_source_git_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
4 changes: 2 additions & 2 deletions internal/flags/crds.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
5 changes: 2 additions & 3 deletions internal/flags/decryption_provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion internal/flags/ecdsa_curve.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
3 changes: 2 additions & 1 deletion internal/flags/gitlab_visibility.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion internal/flags/helm_chart_source.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion internal/flags/kustomization_source.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion internal/flags/local_helm_chart_source.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions internal/flags/log_level.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion internal/flags/public_key_algorithm.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion internal/flags/source_bucket_provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions internal/flags/source_git_provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion internal/flags/source_oci_provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion internal/flags/source_oci_verify_provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit ee59d5f

Please sign in to comment.