pull/5067/merge
h3nryc0ding 2 months ago committed by GitHub
commit aa269934bc
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -147,7 +147,7 @@ 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",

@ -52,9 +52,9 @@ func (a *CRDsPolicy) Set(str string) error {
}
func (a *CRDsPolicy) Type() string {
return "crds"
return strings.Join(supportedCRDsPolicies, "|")
}
func (a *CRDsPolicy) Description() string {
return fmt.Sprintf("upgrade CRDs policy, available options are: (%s)", strings.Join(supportedCRDsPolicies, ", "))
return "upgrade CRDs policy"
}

@ -39,16 +39,15 @@ func (d *DecryptionProvider) Set(str string) error {
if !utils.ContainsItemString(supportedDecryptionProviders, str) {
return fmt.Errorf("unsupported decryption provider '%s', must be one of: %s",
str, strings.Join(supportedDecryptionProviders, ", "))
}
*d = DecryptionProvider(str)
return nil
}
func (d *DecryptionProvider) Type() string {
return "decryptionProvider"
return strings.Join(supportedDecryptionProviders, "|")
}
func (d *DecryptionProvider) Description() string {
return fmt.Sprintf("decryption provider, available options are: (%s)", strings.Join(supportedDecryptionProviders, ", "))
return "decryption provider"
}

@ -49,11 +49,11 @@ func (c *ECDSACurve) Set(str string) error {
}
func (c *ECDSACurve) Type() string {
return "ecdsaCurve"
return strings.Join(ecdsaCurves(), "|")
}
func (c *ECDSACurve) Description() string {
return fmt.Sprintf("SSH ECDSA public key curve (%s)", strings.Join(ecdsaCurves(), ", "))
return "SSH ECDSA public key curve"
}
func ecdsaCurves() []string {

@ -18,6 +18,7 @@ package flags
import (
"fmt"
"sort"
"strings"
"github.com/fluxcd/go-git-providers/gitprovider"
@ -51,16 +52,26 @@ func (d *GitLabVisibility) Set(str string) error {
}
var visibility = gitprovider.RepositoryVisibility(str)
if ValidateRepositoryVisibility(visibility) != nil {
return fmt.Errorf("unsupported visibility '%s'", str)
return fmt.Errorf("unsupported visibility '%s', must be one of: %s",
str, strings.Join(gitLabVisibilities(), ", "))
}
*d = GitLabVisibility(visibility)
return nil
}
func (d *GitLabVisibility) Type() string {
return "gitLabVisibility"
return strings.Join(gitLabVisibilities(), "|")
}
func (d *GitLabVisibility) Description() string {
return fmt.Sprintf("specifies the visibility of the repository. Valid values are public, private, internal")
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))
}
sort.Strings(visibilities)
return visibilities
}

@ -64,13 +64,10 @@ func (s *HelmChartSource) Set(str string) error {
}
func (s *HelmChartSource) Type() string {
return "helmChartSource"
return "<kind>/<name>.<namespace>"
}
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)",
strings.Join(supportedHelmChartSourceKinds, ", "),
)
return fmt.Sprintf("source that contains the chart, where kind must be one of: (%s)",
strings.Join(supportedHelmChartSourceKinds, ", "))
}

@ -71,13 +71,10 @@ func (s *KustomizationSource) Set(str string) error {
}
func (s *KustomizationSource) Type() string {
return "kustomizationSource"
return "[<kind>/]<name>.<namespace>"
}
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",
strings.Join(supportedKustomizationSourceKinds, ", "),
)
return fmt.Sprintf("source that contains the Kubernetes manifests, where kind must be one of: (%s), if kind is not specified it defaults to %s",
strings.Join(supportedKustomizationSourceKinds, ", "), sourcev1.GitRepositoryKind)
}

@ -58,13 +58,10 @@ func (s *LocalHelmChartSource) Set(str string) error {
}
func (s *LocalHelmChartSource) Type() string {
return "helmChartSource"
return "<kind>/<name>"
}
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)",
strings.Join(supportedHelmChartSourceKinds, ", "),
)
return fmt.Sprintf("source that contains the chart, where kind must be one of: (%s)",
strings.Join(supportedHelmChartSourceKinds, ", "))
}

@ -46,9 +46,9 @@ func (l *LogLevel) Set(str string) error {
}
func (l *LogLevel) Type() string {
return "logLevel"
return strings.Join(supportedLogLevels, "|")
}
func (l *LogLevel) Description() string {
return fmt.Sprintf("log level, available options are: (%s)", strings.Join(supportedLogLevels, ", "))
return "log level"
}

@ -45,9 +45,9 @@ func (a *PublicKeyAlgorithm) Set(str string) error {
}
func (a *PublicKeyAlgorithm) Type() string {
return "publicKeyAlgorithm"
return strings.Join(supportedPublicKeyAlgorithms, "|")
}
func (a *PublicKeyAlgorithm) Description() string {
return fmt.Sprintf("SSH public key algorithm (%s)", strings.Join(supportedPublicKeyAlgorithms, ", "))
return "SSH public key algorithm"
}

@ -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 {

@ -52,12 +52,9 @@ func (p *SourceBucketProvider) Set(str string) error {
}
func (p *SourceBucketProvider) Type() string {
return "sourceBucketProvider"
return strings.Join(supportedSourceBucketProviders, "|")
}
func (p *SourceBucketProvider) Description() string {
return fmt.Sprintf(
"the S3 compatible storage provider name, available options are: (%s)",
strings.Join(supportedSourceBucketProviders, ", "),
)
return "the S3 compatible storage provider name"
}

@ -42,7 +42,7 @@ func (p *SourceGitProvider) Set(str string) error {
}
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

@ -59,14 +59,11 @@ func (p *SourceOCIProvider) Set(str string) error {
}
func (p *SourceOCIProvider) Type() string {
return "sourceOCIProvider"
return strings.Join(supportedSourceOCIProviders, "|")
}
func (p *SourceOCIProvider) Description() string {
return fmt.Sprintf(
"the OCI provider name, available options are: (%s)",
strings.Join(supportedSourceOCIProviders, ", "),
)
return "the OCI provider name"
}
func (p *SourceOCIProvider) ToOCIProvider() (oci.Provider, error) {

@ -47,12 +47,9 @@ func (p *SourceOCIVerifyProvider) Set(str string) error {
}
func (p *SourceOCIVerifyProvider) Type() string {
return "sourceOCIVerifyProvider"
return strings.Join(supportedSourceOCIVerifyProviders, "|")
}
func (p *SourceOCIVerifyProvider) Description() string {
return fmt.Sprintf(
"the OCI verify provider name to use for signature verification, available options are: (%s)",
strings.Join(supportedSourceOCIVerifyProviders, ", "),
)
return "the OCI verify provider name to use for signature verification"
}

Loading…
Cancel
Save