Add source-watcher to the install and bootstrap commands
Signed-off-by: Stefan Prodan <stefan.prodan@gmail.com>
This commit is contained in:
@@ -97,7 +97,7 @@ func init() {
|
||||
bootstrapCmd.PersistentFlags().StringSliceVar(&bootstrapArgs.defaultComponents, "components", rootArgs.defaults.Components,
|
||||
"list of components, accepts comma-separated values")
|
||||
bootstrapCmd.PersistentFlags().StringSliceVar(&bootstrapArgs.extraComponents, "components-extra", nil,
|
||||
"list of components in addition to those supplied or defaulted, accepts values such as 'image-reflector-controller,image-automation-controller'")
|
||||
"list of components in addition to those supplied or defaulted, accepts values such as 'image-reflector-controller,image-automation-controller,source-watcher'")
|
||||
|
||||
bootstrapCmd.PersistentFlags().StringVar(&bootstrapArgs.registry, "registry", "ghcr.io/fluxcd",
|
||||
"container registry where the Flux controller images are published")
|
||||
|
||||
@@ -83,7 +83,7 @@ type installFlags struct {
|
||||
force bool
|
||||
}
|
||||
|
||||
var installArgs = NewInstallFlags()
|
||||
var installArgs = newInstallFlags()
|
||||
|
||||
func init() {
|
||||
installCmd.Flags().BoolVar(&installArgs.export, "export", false,
|
||||
@@ -93,7 +93,7 @@ func init() {
|
||||
installCmd.Flags().StringSliceVar(&installArgs.defaultComponents, "components", rootArgs.defaults.Components,
|
||||
"list of components, accepts comma-separated values")
|
||||
installCmd.Flags().StringSliceVar(&installArgs.extraComponents, "components-extra", nil,
|
||||
"list of components in addition to those supplied or defaulted, accepts values such as 'image-reflector-controller,image-automation-controller'")
|
||||
"list of components in addition to those supplied or defaulted, accepts values such as 'image-reflector-controller,image-automation-controller,source-watcher'")
|
||||
installCmd.Flags().StringVar(&installArgs.manifestsPath, "manifests", "", "path to the manifest directory")
|
||||
installCmd.Flags().StringVar(&installArgs.registry, "registry", rootArgs.defaults.Registry,
|
||||
"container registry where the toolkit images are published")
|
||||
@@ -115,9 +115,14 @@ func init() {
|
||||
rootCmd.AddCommand(installCmd)
|
||||
}
|
||||
|
||||
func NewInstallFlags() installFlags {
|
||||
func newInstallFlags() installFlags {
|
||||
return installFlags{
|
||||
logLevel: flags.LogLevel(rootArgs.defaults.LogLevel),
|
||||
logLevel: flags.LogLevel(rootArgs.defaults.LogLevel),
|
||||
defaultComponents: rootArgs.defaults.Components,
|
||||
registry: rootArgs.defaults.Registry,
|
||||
watchAllNamespaces: rootArgs.defaults.WatchAllNamespaces,
|
||||
networkPolicy: rootArgs.defaults.NetworkPolicy,
|
||||
clusterDomain: rootArgs.defaults.ClusterDomain,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -195,10 +200,13 @@ func installCmdRun(cmd *cobra.Command, args []string) error {
|
||||
}
|
||||
|
||||
if installArgs.export {
|
||||
fmt.Print(manifest.Content)
|
||||
return nil
|
||||
_, err = rootCmd.OutOrStdout().Write([]byte(manifest.Content))
|
||||
return err
|
||||
} else if rootArgs.verbose {
|
||||
fmt.Print(manifest.Content)
|
||||
_, err = rootCmd.OutOrStdout().Write([]byte(manifest.Content))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
logger.Successf("manifests build completed")
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright 2022 The Flux authors
|
||||
Copyright 2025 The Flux authors
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
@@ -16,7 +16,17 @@ limitations under the License.
|
||||
|
||||
package main
|
||||
|
||||
import "testing"
|
||||
import (
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
. "github.com/onsi/gomega"
|
||||
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
|
||||
|
||||
ssautil "github.com/fluxcd/pkg/ssa/utils"
|
||||
|
||||
"github.com/fluxcd/flux2/v2/pkg/manifestgen/install"
|
||||
)
|
||||
|
||||
func TestInstall(t *testing.T) {
|
||||
// The pointer to kubeconfigArgs.Namespace is shared across
|
||||
@@ -59,3 +69,43 @@ func TestInstall(t *testing.T) {
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestInstall_ComponentsExtra(t *testing.T) {
|
||||
g := NewWithT(t)
|
||||
command := "install --export --components-extra=" +
|
||||
strings.Join(install.MakeDefaultOptions().ComponentsExtra, ",")
|
||||
|
||||
output, err := executeCommand(command)
|
||||
g.Expect(err).NotTo(HaveOccurred())
|
||||
|
||||
manifests, err := ssautil.ReadObjects(strings.NewReader(output))
|
||||
g.Expect(err).NotTo(HaveOccurred())
|
||||
|
||||
foundImageAutomation := false
|
||||
foundImageReflector := false
|
||||
foundSourceWatcher := false
|
||||
foundExternalArtifact := false
|
||||
for _, obj := range manifests {
|
||||
if obj.GetKind() == "Deployment" && obj.GetName() == "image-automation-controller" {
|
||||
foundImageAutomation = true
|
||||
}
|
||||
if obj.GetKind() == "Deployment" && obj.GetName() == "image-reflector-controller" {
|
||||
foundImageReflector = true
|
||||
}
|
||||
if obj.GetKind() == "Deployment" && obj.GetName() == "source-watcher" {
|
||||
foundSourceWatcher = true
|
||||
}
|
||||
if obj.GetKind() == "Deployment" &&
|
||||
(obj.GetName() == "kustomize-controller" || obj.GetName() == "helm-controller") {
|
||||
containers, _, _ := unstructured.NestedSlice(obj.Object, "spec", "template", "spec", "containers")
|
||||
g.Expect(containers).ToNot(BeEmpty())
|
||||
args, _, _ := unstructured.NestedSlice(containers[0].(map[string]any), "args")
|
||||
g.Expect(args).To(ContainElement("--feature-gates=ExternalArtifact=true"))
|
||||
foundExternalArtifact = true
|
||||
}
|
||||
}
|
||||
g.Expect(foundImageAutomation).To(BeTrue(), "image-automation-controller deployment not found")
|
||||
g.Expect(foundImageReflector).To(BeTrue(), "image-reflector-controller deployment not found")
|
||||
g.Expect(foundSourceWatcher).To(BeTrue(), "source-watcher deployment not found")
|
||||
g.Expect(foundExternalArtifact).To(BeTrue(), "ExternalArtifact feature gate not found")
|
||||
}
|
||||
|
||||
@@ -447,6 +447,7 @@ func resetCmdArgs() {
|
||||
imagePolicyArgs = imagePolicyFlags{}
|
||||
imageRepoArgs = imageRepoFlags{}
|
||||
imageUpdateArgs = imageUpdateFlags{}
|
||||
installArgs = newInstallFlags()
|
||||
kustomizationArgs = NewKustomizationFlags()
|
||||
receiverArgs = receiverFlags{}
|
||||
resumeArgs = ResumeFlags{}
|
||||
|
||||
Reference in New Issue
Block a user