From 75023011d3fe7a6459ce27ed5b7baf3189c96650 Mon Sep 17 00:00:00 2001 From: Michael Bridgen Date: Thu, 10 Dec 2020 17:50:01 +0000 Subject: [PATCH] Add argument for adding to default install If you want to install the default set of controllers and the image-* controllers, at present you have to list every single one of them. An improvement on this is to let people specify what they want _in addition_ to the default controllers. This commit adds an argument `--extra-components` which appends to the (most likely, default value) slice of `--components`. Signed-off-by: Michael Bridgen --- cmd/flux/install.go | 11 ++++++++--- docs/cmd/flux_install.md | 1 + 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/cmd/flux/install.go b/cmd/flux/install.go index 9c150a77..3bcd6911 100644 --- a/cmd/flux/install.go +++ b/cmd/flux/install.go @@ -57,6 +57,7 @@ var ( installManifestsPath string installVersion string installComponents []string + installExtraComponents []string installRegistry string installImagePullSecret string installWatchAllNamespaces bool @@ -74,6 +75,8 @@ func init() { "toolkit version") installCmd.Flags().StringSliceVar(&installComponents, "components", defaults.Components, "list of components, accepts comma-separated values") + installCmd.Flags().StringSliceVar(&installExtraComponents, "extra-components", nil, + "list of components in addition to those supplied or defaulted, accepts comma-separated values") installCmd.Flags().StringVar(&installManifestsPath, "manifests", "", "path to the manifest directory") installCmd.Flags().MarkHidden("manifests") installCmd.Flags().StringVar(&installRegistry, "registry", defaults.Registry, @@ -103,11 +106,13 @@ func installCmdRun(cmd *cobra.Command, args []string) error { logger.Generatef("generating manifests") } + components := append(installComponents, installExtraComponents...) + opts := install.Options{ BaseURL: installManifestsPath, Version: installVersion, Namespace: namespace, - Components: installComponents, + Components: components, Registry: installRegistry, ImagePullSecret: installImagePullSecret, Arch: installArch.String(), @@ -137,7 +142,7 @@ func installCmdRun(cmd *cobra.Command, args []string) error { } else if installExport { fmt.Println("---") fmt.Println("# GitOps Toolkit revision", installVersion) - fmt.Println("# Components:", strings.Join(installComponents, ",")) + fmt.Println("# Components:", strings.Join(components, ",")) fmt.Print(manifest.Content) fmt.Println("---") return nil @@ -167,7 +172,7 @@ func installCmdRun(cmd *cobra.Command, args []string) error { } logger.Waitingf("verifying installation") - for _, deployment := range installComponents { + for _, deployment := range components { kubectlArgs = []string{"-n", namespace, "rollout", "status", "deployment", deployment, "--timeout", timeout.String()} if _, err := utils.ExecKubectlCommand(ctx, applyOutput, kubeconfig, kubecontext, kubectlArgs...); err != nil { return fmt.Errorf("install failed") diff --git a/docs/cmd/flux_install.md b/docs/cmd/flux_install.md index fbdab64f..61bfb00f 100644 --- a/docs/cmd/flux_install.md +++ b/docs/cmd/flux_install.md @@ -35,6 +35,7 @@ flux install [flags] --components strings list of components, accepts comma-separated values (default [source-controller,kustomize-controller,helm-controller,notification-controller]) --dry-run only print the object that would be applied --export write the install manifests to stdout and exit + --extra-components strings list of components in addition to those supplied or defaulted, accepts comma-separated values -h, --help help for install --image-pull-secret string Kubernetes secret name used for pulling the toolkit images from a private registry --log-level logLevel log level, available options are: (debug, info, error) (default info)