diff --git a/cmd/gotk/create_helmrelease.go b/cmd/gotk/create_helmrelease.go index d99c58c1..60120890 100644 --- a/cmd/gotk/create_helmrelease.go +++ b/cmd/gotk/create_helmrelease.go @@ -115,11 +115,12 @@ func createHelmReleaseCmdRun(cmd *cobra.Command, args []string) error { } hrSourceElements := strings.Split(hrSource, "/") if len(hrSourceElements) != 2 { - return fmt.Errorf("source must be in format /") + return fmt.Errorf("invalid source '%s', must be in format /", hrSource) } hrSourceKind, hrSourceName := hrSourceElements[0], hrSourceElements[1] - if hrSourceKind != sourcev1.HelmRepositoryKind && hrSourceKind != sourcev1.GitRepositoryKind { - return fmt.Errorf("source kind must be one of: %s", []string{sourcev1.HelmRepositoryKind, sourcev1.GitRepositoryKind}) + if !utils.containsItemString(supportedHelmChartSourceKinds, hrSourceKind) { + return fmt.Errorf("source kind %s is not supported, can be %v", + hrSourceKind, supportedHelmChartSourceKinds) } if hrChart == "" { return fmt.Errorf("chart name or path is required") diff --git a/cmd/gotk/main.go b/cmd/gotk/main.go index 03e1afbc..4bf6e3dc 100644 --- a/cmd/gotk/main.go +++ b/cmd/gotk/main.go @@ -26,6 +26,8 @@ import ( "github.com/spf13/cobra/doc" _ "k8s.io/client-go/plugin/pkg/client/auth" + sourcev1 "github.com/fluxcd/source-controller/api/v1alpha1" + gotklog "github.com/fluxcd/toolkit/pkg/log" ) @@ -104,12 +106,13 @@ var ( ) var ( - defaultComponents = []string{"source-controller", "kustomize-controller", "helm-controller", "notification-controller"} - defaultVersion = "latest" - defaultNamespace = "gitops-system" - defaultNotification = "notification-controller" - supportedArch = []string{"arm64", "amd64"} - supportedDecryptionProviders = []string{"sops"} + defaultComponents = []string{"source-controller", "kustomize-controller", "helm-controller", "notification-controller"} + defaultVersion = "latest" + defaultNamespace = "gitops-system" + defaultNotification = "notification-controller" + supportedArch = []string{"arm64", "amd64"} + supportedDecryptionProviders = []string{"sops"} + supportedHelmChartSourceKinds = []string{sourcev1.HelmRepositoryKind, sourcev1.GitRepositoryKind} ) func init() {