Validates components set

Signed-off-by: Somtochi Onyekwere <somtochionyekwere@gmail.com>

Signed-off-by: Somtochi Onyekwere <somtochionyekwere@gmail.com>
pull/647/head
Somtochi Onyekwere 4 years ago
parent ed09dd57b6
commit dd0b807fe4

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

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

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

@ -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: "",

Loading…
Cancel
Save