Validates components set
Signed-off-by: Somtochi Onyekwere <somtochionyekwere@gmail.com> Signed-off-by: Somtochi Onyekwere <somtochionyekwere@gmail.com>
This commit is contained in:
@@ -104,6 +104,11 @@ func bootstrapValidate() error {
|
|||||||
return fmt.Errorf("component %s is required", component)
|
return fmt.Errorf("component %s is required", component)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if err := utils.ValidateComponents(components); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -110,6 +110,10 @@ func installCmdRun(cmd *cobra.Command, args []string) error {
|
|||||||
|
|
||||||
components := append(installDefaultComponents, installExtraComponents...)
|
components := append(installDefaultComponents, installExtraComponents...)
|
||||||
|
|
||||||
|
if err := utils.ValidateComponents(components); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
opts := install.Options{
|
opts := install.Options{
|
||||||
BaseURL: installManifestsPath,
|
BaseURL: installManifestsPath,
|
||||||
Version: installVersion,
|
Version: installVersion,
|
||||||
|
|||||||
@@ -21,6 +21,7 @@ import (
|
|||||||
"bytes"
|
"bytes"
|
||||||
"context"
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"github.com/fluxcd/flux2/pkg/manifestgen/install"
|
||||||
"io"
|
"io"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"os"
|
"os"
|
||||||
@@ -380,3 +381,15 @@ func PrintTable(writer io.Writer, header []string, rows [][]string) {
|
|||||||
table.AppendBulk(rows)
|
table.AppendBulk(rows)
|
||||||
table.Render()
|
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
|
Version string
|
||||||
Namespace string
|
Namespace string
|
||||||
Components []string
|
Components []string
|
||||||
|
ComponentsExtra []string
|
||||||
EventsAddr string
|
EventsAddr string
|
||||||
Registry string
|
Registry string
|
||||||
ImagePullSecret string
|
ImagePullSecret string
|
||||||
@@ -42,6 +43,7 @@ func MakeDefaultOptions() Options {
|
|||||||
Version: "latest",
|
Version: "latest",
|
||||||
Namespace: "flux-system",
|
Namespace: "flux-system",
|
||||||
Components: []string{"source-controller", "kustomize-controller", "helm-controller", "notification-controller"},
|
Components: []string{"source-controller", "kustomize-controller", "helm-controller", "notification-controller"},
|
||||||
|
ComponentsExtra: []string{"image-reflector-controller", "image-automation-controller"},
|
||||||
EventsAddr: "",
|
EventsAddr: "",
|
||||||
Registry: "ghcr.io/fluxcd",
|
Registry: "ghcr.io/fluxcd",
|
||||||
ImagePullSecret: "",
|
ImagePullSecret: "",
|
||||||
|
|||||||
Reference in New Issue
Block a user