mirror of
https://github.com/fluxcd/flux2.git
synced 2026-02-20 14:41:47 +00:00
Merge pull request #212 from fluxcd/refactor-hr-source-kind-validation
Refactor HelmRelease chart source kind validation
This commit is contained in:
commit
9dbfca3d7a
2 changed files with 13 additions and 9 deletions
|
|
@ -115,11 +115,12 @@ func createHelmReleaseCmdRun(cmd *cobra.Command, args []string) error {
|
||||||
}
|
}
|
||||||
hrSourceElements := strings.Split(hrSource, "/")
|
hrSourceElements := strings.Split(hrSource, "/")
|
||||||
if len(hrSourceElements) != 2 {
|
if len(hrSourceElements) != 2 {
|
||||||
return fmt.Errorf("source must be in format <kind>/<name>")
|
return fmt.Errorf("invalid source '%s', must be in format <kind>/<name>", hrSource)
|
||||||
}
|
}
|
||||||
hrSourceKind, hrSourceName := hrSourceElements[0], hrSourceElements[1]
|
hrSourceKind, hrSourceName := hrSourceElements[0], hrSourceElements[1]
|
||||||
if hrSourceKind != sourcev1.HelmRepositoryKind && hrSourceKind != sourcev1.GitRepositoryKind {
|
if !utils.containsItemString(supportedHelmChartSourceKinds, hrSourceKind) {
|
||||||
return fmt.Errorf("source kind must be one of: %s", []string{sourcev1.HelmRepositoryKind, sourcev1.GitRepositoryKind})
|
return fmt.Errorf("source kind %s is not supported, can be %v",
|
||||||
|
hrSourceKind, supportedHelmChartSourceKinds)
|
||||||
}
|
}
|
||||||
if hrChart == "" {
|
if hrChart == "" {
|
||||||
return fmt.Errorf("chart name or path is required")
|
return fmt.Errorf("chart name or path is required")
|
||||||
|
|
|
||||||
|
|
@ -26,6 +26,8 @@ import (
|
||||||
"github.com/spf13/cobra/doc"
|
"github.com/spf13/cobra/doc"
|
||||||
_ "k8s.io/client-go/plugin/pkg/client/auth"
|
_ "k8s.io/client-go/plugin/pkg/client/auth"
|
||||||
|
|
||||||
|
sourcev1 "github.com/fluxcd/source-controller/api/v1alpha1"
|
||||||
|
|
||||||
gotklog "github.com/fluxcd/toolkit/pkg/log"
|
gotklog "github.com/fluxcd/toolkit/pkg/log"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
@ -104,12 +106,13 @@ var (
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
defaultComponents = []string{"source-controller", "kustomize-controller", "helm-controller", "notification-controller"}
|
defaultComponents = []string{"source-controller", "kustomize-controller", "helm-controller", "notification-controller"}
|
||||||
defaultVersion = "latest"
|
defaultVersion = "latest"
|
||||||
defaultNamespace = "gitops-system"
|
defaultNamespace = "gitops-system"
|
||||||
defaultNotification = "notification-controller"
|
defaultNotification = "notification-controller"
|
||||||
supportedArch = []string{"arm64", "amd64"}
|
supportedArch = []string{"arm64", "amd64"}
|
||||||
supportedDecryptionProviders = []string{"sops"}
|
supportedDecryptionProviders = []string{"sops"}
|
||||||
|
supportedHelmChartSourceKinds = []string{sourcev1.HelmRepositoryKind, sourcev1.GitRepositoryKind}
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue