diff --git a/cmd/flux/bootstrap.go b/cmd/flux/bootstrap.go index 55b80e93..7f92ca51 100644 --- a/cmd/flux/bootstrap.go +++ b/cmd/flux/bootstrap.go @@ -104,6 +104,11 @@ func bootstrapValidate() error { return fmt.Errorf("component %s is required", component) } } + + if err := utils.ValidateComponents(components); err != nil { + return err + } + return nil } diff --git a/cmd/flux/install.go b/cmd/flux/install.go index ad96d883..2550976c 100644 --- a/cmd/flux/install.go +++ b/cmd/flux/install.go @@ -110,6 +110,10 @@ func installCmdRun(cmd *cobra.Command, args []string) error { components := append(installDefaultComponents, installExtraComponents...) + if err := utils.ValidateComponents(components); err != nil { + return err + } + opts := install.Options{ BaseURL: installManifestsPath, Version: installVersion, diff --git a/internal/utils/utils.go b/internal/utils/utils.go index fd38a9d9..8eb3f239 100644 --- a/internal/utils/utils.go +++ b/internal/utils/utils.go @@ -21,6 +21,7 @@ import ( "bytes" "context" "fmt" + "github.com/fluxcd/flux2/pkg/manifestgen/install" "io" "io/ioutil" "os" @@ -380,3 +381,15 @@ func PrintTable(writer io.Writer, header []string, rows [][]string) { table.AppendBulk(rows) table.Render() } + +func ValidateComponents(components []string) error { + defaults := install.MakeDefaultOptions() + bootstrapAllComponents := append(defaults.Components, defaults.ComponentsExtra...) + for _, component := range components { + if !ContainsItemString(bootstrapAllComponents, component) { + return fmt.Errorf("component %s is not available", component) + } + } + + return nil +} diff --git a/pkg/manifestgen/install/options.go b/pkg/manifestgen/install/options.go index 1197b59b..6689a7f7 100644 --- a/pkg/manifestgen/install/options.go +++ b/pkg/manifestgen/install/options.go @@ -23,6 +23,7 @@ type Options struct { Version string Namespace string Components []string + ComponentsExtra []string EventsAddr string Registry string ImagePullSecret string @@ -42,6 +43,7 @@ func MakeDefaultOptions() Options { Version: "latest", Namespace: "flux-system", Components: []string{"source-controller", "kustomize-controller", "helm-controller", "notification-controller"}, + ComponentsExtra: []string{"image-reflector-controller", "image-automation-controller"}, EventsAddr: "", Registry: "ghcr.io/fluxcd", ImagePullSecret: "",