Skip to content

Commit 92e5884

Browse files
committed
minimize diff
Signed-off-by: h3nryc0ding <[email protected]>
1 parent 8093ad7 commit 92e5884

16 files changed

+24
-24
lines changed

cmd/flux/create_helmrelease_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ func TestCreateHelmRelease(t *testing.T) {
4545
{
4646
name: "unknown source kind",
4747
args: "create helmrelease podinfo --source foobar/podinfo --chart podinfo --export",
48-
assert: assertError(`invalid argument "foobar/podinfo" for "--source" flag: source kind 'foobar' is not supported, must be one of: HelmRepository|GitRepository|Bucket`),
48+
assert: assertError(`invalid argument "foobar/podinfo" for "--source" flag: source kind 'foobar' is not supported, must be one of: HelmRepository, GitRepository, Bucket`),
4949
},
5050
{
5151
name: "unknown chart reference kind",

cmd/flux/create_source_chart_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ func TestCreateSourceChart(t *testing.T) {
5050
{
5151
name: "unknown source kind",
5252
args: "create source chart podinfo --source foobar/podinfo --export",
53-
assert: assertError(`invalid argument "foobar/podinfo" for "--source" flag: source kind 'foobar' is not supported, must be one of: HelmRepository|GitRepository|Bucket`),
53+
assert: assertError(`invalid argument "foobar/podinfo" for "--source" flag: source kind 'foobar' is not supported, must be one of: HelmRepository, GitRepository, Bucket`),
5454
},
5555
{
5656
name: "basic chart",

cmd/flux/create_source_git_test.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -147,12 +147,12 @@ func TestCreateSourceGitExport(t *testing.T) {
147147
{
148148
name: "source with invalid provider",
149149
args: "create source git podinfo --namespace=flux-system --url=https://dev.azure.com/foo/bar/_git/podinfo --provider dummy --branch=test --interval=1m0s --export",
150-
assert: assertError("invalid argument \"dummy\" for \"--provider\" flag: source Git provider 'dummy' is not supported, must be one of: generic|azure"),
150+
assert: assertError("invalid argument \"dummy\" for \"--provider\" flag: source Git provider 'dummy' is not supported, must be one of: generic, azure"),
151151
},
152152
{
153153
name: "source with empty provider",
154154
args: "create source git podinfo --namespace=flux-system --url=https://dev.azure.com/foo/bar/_git/podinfo --provider \"\" --branch=test --interval=1m0s --export",
155-
assert: assertError("invalid argument \"\" for \"--provider\" flag: no source Git provider given, must be one of: generic|azure"),
155+
assert: assertError("invalid argument \"\" for \"--provider\" flag: no source Git provider given, please specify the Git provider name"),
156156
},
157157
{
158158
name: "source with no provider",

internal/flags/crds.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -40,11 +40,11 @@ func (a *CRDsPolicy) String() string {
4040
func (a *CRDsPolicy) Set(str string) error {
4141
if strings.TrimSpace(str) == "" {
4242
return fmt.Errorf("no upgrade CRDs policy given, must be one of: %s",
43-
a.Type())
43+
strings.Join(supportedCRDsPolicies, ", "))
4444
}
4545
if !utils.ContainsItemString(supportedCRDsPolicies, str) {
4646
return fmt.Errorf("unsupported upgrade CRDs policy '%s', must be one of: %s",
47-
str, a.Type())
47+
str, strings.Join(supportedCRDsPolicies, ", "))
4848

4949
}
5050
*a = CRDsPolicy(str)

internal/flags/decryption_provider.go

+2-3
Original file line numberDiff line numberDiff line change
@@ -34,12 +34,11 @@ func (d *DecryptionProvider) String() string {
3434
func (d *DecryptionProvider) Set(str string) error {
3535
if strings.TrimSpace(str) == "" {
3636
return fmt.Errorf("no decryption provider given, must be one of: %s",
37-
d.Type())
37+
strings.Join(supportedDecryptionProviders, ", "))
3838
}
3939
if !utils.ContainsItemString(supportedDecryptionProviders, str) {
4040
return fmt.Errorf("unsupported decryption provider '%s', must be one of: %s",
41-
str, d.Type())
42-
41+
str, strings.Join(supportedDecryptionProviders, ", "))
4342
}
4443
*d = DecryptionProvider(str)
4544
return nil

internal/flags/ecdsa_curve.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ func (c *ECDSACurve) Set(str string) error {
4545
*c = ECDSACurve{v}
4646
return nil
4747
}
48-
return fmt.Errorf("unsupported curve '%s', must be one of: %s", str, c.Type())
48+
return fmt.Errorf("unsupported curve '%s', must be one of: %s", str, strings.Join(ecdsaCurves(), ", "))
4949
}
5050

5151
func (c *ECDSACurve) Type() string {

internal/flags/gitlab_visibility.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,8 @@ func (d *GitLabVisibility) Set(str string) error {
5252
}
5353
var visibility = gitprovider.RepositoryVisibility(str)
5454
if ValidateRepositoryVisibility(visibility) != nil {
55-
return fmt.Errorf("unsupported visibility '%s', must be one of: %s", str, d.Type())
55+
return fmt.Errorf("unsupported visibility '%s', must be one of: %s",
56+
str, strings.Join(gitLabVisibilities(), ", "))
5657
}
5758
*d = GitLabVisibility(visibility)
5859
return nil

internal/flags/helm_chart_source.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ func (s *HelmChartSource) Set(str string) error {
5353
cleanSourceKind, ok := utils.ContainsEqualFoldItemString(supportedHelmChartSourceKinds, sourceKind)
5454
if !ok {
5555
return fmt.Errorf("source kind '%s' is not supported, must be one of: %s",
56-
sourceKind, s.Type())
56+
sourceKind, strings.Join(supportedHelmChartSourceKinds, ", "))
5757
}
5858

5959
s.Kind = cleanSourceKind

internal/flags/kustomization_source.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ func (s *KustomizationSource) Set(str string) error {
6060
cleanSourceKind, ok := utils.ContainsEqualFoldItemString(supportedKustomizationSourceKinds, sourceKind)
6161
if !ok {
6262
return fmt.Errorf("source kind '%s' is not supported, must be one of: %s",
63-
sourceKind, s.Type())
63+
sourceKind, strings.Join(supportedKustomizationSourceKinds, ", "))
6464
}
6565

6666
s.Kind = cleanSourceKind

internal/flags/local_helm_chart_source.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ func (s *LocalHelmChartSource) Set(str string) error {
4848
cleanSourceKind, ok := utils.ContainsEqualFoldItemString(supportedHelmChartSourceKinds, sourceKind)
4949
if !ok {
5050
return fmt.Errorf("source kind '%s' is not supported, must be one of: %s",
51-
sourceKind, s.Type())
51+
sourceKind, strings.Join(supportedHelmChartSourceKinds, ", "))
5252
}
5353

5454
s.Kind = cleanSourceKind

internal/flags/log_level.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,11 @@ func (l *LogLevel) String() string {
3434
func (l *LogLevel) Set(str string) error {
3535
if strings.TrimSpace(str) == "" {
3636
return fmt.Errorf("no log level given, must be one of: %s",
37-
l.Type())
37+
strings.Join(supportedLogLevels, ", "))
3838
}
3939
if !utils.ContainsItemString(supportedLogLevels, str) {
4040
return fmt.Errorf("unsupported log level '%s', must be one of: %s",
41-
str, l.Type())
41+
str, strings.Join(supportedLogLevels, ", "))
4242

4343
}
4444
*l = LogLevel(str)

internal/flags/public_key_algorithm.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ func (a *PublicKeyAlgorithm) String() string {
3232
func (a *PublicKeyAlgorithm) Set(str string) error {
3333
if strings.TrimSpace(str) == "" {
3434
return fmt.Errorf("no public key algorithm given, must be one of: %s",
35-
a.Type())
35+
strings.Join(supportedPublicKeyAlgorithms, ", "))
3636
}
3737
for _, v := range supportedPublicKeyAlgorithms {
3838
if str == v {
@@ -41,7 +41,7 @@ func (a *PublicKeyAlgorithm) Set(str string) error {
4141
}
4242
}
4343
return fmt.Errorf("unsupported public key algorithm '%s', must be one of: %s",
44-
str, a.Type())
44+
str, strings.Join(supportedPublicKeyAlgorithms, ", "))
4545
}
4646

4747
func (a *PublicKeyAlgorithm) Type() string {

internal/flags/source_bucket_provider.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ func (p *SourceBucketProvider) Set(str string) error {
4545
}
4646
if !utils.ContainsItemString(supportedSourceBucketProviders, str) {
4747
return fmt.Errorf("source bucket provider '%s' is not supported, must be one of: %v",
48-
str, p.Type())
48+
str, strings.Join(supportedSourceBucketProviders, ", "))
4949
}
5050
*p = SourceBucketProvider(str)
5151
return nil

internal/flags/source_git_provider.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -37,12 +37,12 @@ func (p *SourceGitProvider) String() string {
3737

3838
func (p *SourceGitProvider) Set(str string) error {
3939
if strings.TrimSpace(str) == "" {
40-
return fmt.Errorf("no source Git provider given, must be one of: %s",
41-
p.Type())
40+
return fmt.Errorf("no source Git provider given, please specify %s",
41+
p.Description())
4242
}
4343
if !utils.ContainsItemString(supportedSourceGitProviders, str) {
4444
return fmt.Errorf("source Git provider '%s' is not supported, must be one of: %v",
45-
str, p.Type())
45+
str, strings.Join(supportedSourceGitProviders, ", "))
4646
}
4747
*p = SourceGitProvider(str)
4848
return nil

internal/flags/source_oci_provider.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ func (p *SourceOCIProvider) Set(str string) error {
5252
}
5353
if !utils.ContainsItemString(supportedSourceOCIProviders, str) {
5454
return fmt.Errorf("source OCI provider '%s' is not supported, must be one of: %v",
55-
str, p.Type())
55+
str, strings.Join(supportedSourceOCIProviders, ", "))
5656
}
5757
*p = SourceOCIProvider(str)
5858
return nil

internal/flags/source_oci_verify_provider.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ func (p *SourceOCIVerifyProvider) Set(str string) error {
4040
}
4141
if !utils.ContainsItemString(supportedSourceOCIVerifyProviders, str) {
4242
return fmt.Errorf("source OCI verify provider '%s' is not supported, must be one of: %v",
43-
str, p.Type())
43+
str, strings.Join(supportedSourceOCIVerifyProviders, ", "))
4444
}
4545
*p = SourceOCIVerifyProvider(str)
4646
return nil

0 commit comments

Comments
 (0)