Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add bootstrap CLI controllers configurations #3647

Merged
merged 39 commits into from
Dec 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
2409dc7
add controllers configurations with acceptance and unit tests
waleedhammam Nov 19, 2023
8da012a
silent mode doesn't ask for extra controllers
waleedhammam Nov 28, 2023
b8606fb
use components-extra instead of extra-controllers
waleedhammam Nov 28, 2023
2c5af01
install components before check ui domain
waleedhammam Nov 28, 2023
33aae21
remove example
waleedhammam Nov 28, 2023
c2d46dc
use empty quotes instead of none value
waleedhammam Dec 3, 2023
dff196e
remove creation timestamp
waleedhammam Dec 3, 2023
7d1cc72
Merge branch 'main' into 3276-cli-controllers
waleedhammam Dec 3, 2023
15cdc02
Merge branch 'main' into 3276-cli-controllers
waleedhammam Dec 4, 2023
1716b62
add flag to bootstrap flux to ensure the default behaviour
waleedhammam Dec 4, 2023
7ac0f28
remove all of above option
waleedhammam Dec 4, 2023
19ef3b0
add case for one or more controllers
waleedhammam Dec 4, 2023
427d346
add case for silent mode
waleedhammam Dec 4, 2023
78c2bb9
fix terraform controller test
waleedhammam Dec 4, 2023
1c0ffab
fix target namespace
waleedhammam Dec 4, 2023
38cfb06
Merge branch 'main' into 3276-cli-controllers
waleedhammam Dec 6, 2023
6b5c565
handle update scenario
waleedhammam Dec 6, 2023
ace8486
rename extra components to componetes extra to align with flag
waleedhammam Dec 6, 2023
68ef627
fix flags
waleedhammam Dec 6, 2023
0fbf5e6
add test case for bootstrap flux in silent mode
waleedhammam Dec 6, 2023
c3b9291
don't use yes as default and fail if no defaults set
waleedhammam Dec 6, 2023
eec4102
Merge branch 'main' into 3276-cli-controllers
waleedhammam Dec 6, 2023
7853602
remove capi controller and refactor configuration
waleedhammam Dec 6, 2023
0bfedba
add case for silent mode
waleedhammam Dec 6, 2023
c56804f
add test case for silent mode
waleedhammam Dec 6, 2023
9e91b8c
rename comment
waleedhammam Dec 6, 2023
8306cc0
remove capi leftovers
waleedhammam Dec 6, 2023
2c21cf3
use policy agent from url in the repository
waleedhammam Dec 6, 2023
d3ba2d6
Merge branch 'main' into 3276-cli-controllers
waleedhammam Dec 6, 2023
30a4da3
fix comment
waleedhammam Dec 6, 2023
09c6e99
add update logic to extra components
waleedhammam Dec 6, 2023
f5ddec0
Merge branch 'main' into 3276-cli-controllers
waleedhammam Dec 6, 2023
a61370d
update acceptance testing wge version
waleedhammam Dec 6, 2023
04a7f92
Merge branch 'main' into 3276-cli-controllers
waleedhammam Dec 7, 2023
2acd174
restore empty input instead of nil
waleedhammam Dec 7, 2023
507dabe
fix flux bootstrap
waleedhammam Dec 7, 2023
eec87da
some wording suggestions
enekofb Dec 7, 2023
b110a07
using none instead of empty string
enekofb Dec 7, 2023
995d6bd
update messages
waleedhammam Dec 7, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 15 additions & 2 deletions cmd/gitops/app/bootstrap/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,13 @@ gitops bootstrap --password=hell0!
gitops bootstrap --client-id <client-id> --client-secret <client-secret> --discovery-url <discovery-url>

# Start WGE installation with OIDC and flux bootstrap with https
gitops bootstrap --version=<version> --password=<admin-password> --discovery-url=<oidc-discovery-url> --client-id=<oidc-client-id> --git-username=<git-username-https> -gitPassword=<gitPassword>--branch=<git-branch> --repo-path=<path-in-repo-for-management-cluster> --repo-url=https://<repo-url> --client-secret=<oidc-secret> -s
gitops bootstrap --version=<version> --password=<admin-password> --discovery-url=<oidc-discovery-url> --client-id=<oidc-client-id> --git-username=<git-username-https> --gitPassword=<gitPassword> --bootstrap-flux --branch=<git-branch> --repo-path=<path-in-repo-for-management-cluster> --repo-url=https://<repo-url> --client-secret=<oidc-secret> -s

# Start WGE installation with OIDC and flux bootstrap with ssh
gitops bootstrap --version=<version> --password=<admin-password> --discovery-url=<oidc-discovery-url> --client-id=<oidc-client-id> --private-key-path=<private-key-path> --private-key-password=<private-key-password> --branch=<git-branch> --repo-path=<path-in-repo-for-management-cluster> --repo-url=ssh://<repo-url> --client-secret=<oidc-secret> -s

# Start WGE installation with more than one extra controller
gitops bootstrap --components-extra="policy-agent,tf-controller"
`
)

Expand Down Expand Up @@ -65,6 +68,12 @@ type bootstrapFlags struct {

// modes flags
silent bool

// flux flag
bootstrapFlux bool
waleedhammam marked this conversation as resolved.
Show resolved Hide resolved

// extra controllers
componentsExtra []string
}

var flags bootstrapFlags
Expand All @@ -79,7 +88,9 @@ func Command(opts *config.Options) *cobra.Command {
}

cmd.Flags().StringVarP(&flags.version, "version", "v", "", "version of Weave GitOps Enterprise (should be from the latest 3 versions)")
cmd.PersistentFlags().BoolVarP(&flags.silent, "bootstrap-flux", "s", false, "always choose yes for interactive questions")
cmd.Flags().StringSliceVar(&flags.componentsExtra, "components-extra", nil, "extra components to be installed. Supported components: none, policy-agent, tf-controller")
cmd.PersistentFlags().BoolVarP(&flags.silent, "silent", "s", false, "non-interactive session: it will not ask questions but rather to use default values to complete the introduced flags")
cmd.PersistentFlags().BoolVarP(&flags.bootstrapFlux, "bootstrap-flux", "", false, "flags that you want to bootstrap Flux in case is not detected")
cmd.PersistentFlags().StringVarP(&flags.gitUsername, "git-username", "", "", "git username used in https authentication type")
cmd.PersistentFlags().StringVarP(&flags.gitPassword, "git-password", "", "", "git password/token used in https authentication type")
cmd.PersistentFlags().StringVarP(&flags.branch, "branch", "b", "", "git branch for your flux repository (example: main)")
Expand Down Expand Up @@ -115,6 +126,8 @@ func getBootstrapCmdRun(opts *config.Options) func(*cobra.Command, []string) err
).
WithOIDCConfig(flags.discoveryURL, flags.clientID, flags.clientSecret, true).
WithSilentFlag(flags.silent).
WithBootstrapFluxFlag(flags.bootstrapFlux).
WithComponentsExtra(flags.componentsExtra).
Build()

if err != nil {
Expand Down
20 changes: 11 additions & 9 deletions cmd/gitops/app/bootstrap/cmd_acceptance_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,6 @@ func TestBootstrapCmd(t *testing.T) {
privateKeyFile := os.Getenv("GIT_PRIVATEKEY_PATH")
g.Expect(privateKeyFile).NotTo(BeEmpty())

privateKeyPassword := os.Getenv("GIT_PRIVATEKEY_PASSWORD")

repoURLSSH := os.Getenv("GIT_REPO_URL_SSH")
g.Expect(repoURLSSH).NotTo(BeEmpty())
repoURLHTTPS := os.Getenv("GIT_REPO_URL_HTTPS")
Expand All @@ -89,6 +87,10 @@ func TestBootstrapCmd(t *testing.T) {
g.Expect(gitBranch).NotTo(BeEmpty())
gitRepoPath := os.Getenv("GIT_REPO_PATH")
g.Expect(gitRepoPath).NotTo(BeEmpty())
privateKeyPassword := os.Getenv("GIT_PRIVATEKEY_PASSWORD")
g.Expect(privateKeyPassword).NotTo(BeEmpty())
oidcClientSecret := os.Getenv("OIDC_CLIENT_SECRET")
g.Expect(oidcClientSecret).NotTo(BeEmpty())

privateKeyFlag := fmt.Sprintf("--private-key=%s", privateKeyFile)
privateKeyPasswordFlag := fmt.Sprintf("--private-key-password=%s", privateKeyPassword)
Expand All @@ -103,8 +105,6 @@ func TestBootstrapCmd(t *testing.T) {
gitBranchFlag := fmt.Sprintf("--branch=%s", gitBranch)
gitRepoPathFlag := fmt.Sprintf("--repo-path=%s", gitRepoPath)

oidcClientSecret := os.Getenv("OIDC_CLIENT_SECRET")
g.Expect(oidcClientSecret).NotTo(BeEmpty())
oidcClientSecretFlag := fmt.Sprintf("--client-secret=%s", oidcClientSecret)

_ = k8sClient.Create(context.Background(), &fluxSystemNamespace)
Expand All @@ -119,12 +119,13 @@ func TestBootstrapCmd(t *testing.T) {
{
name: "journey flux exists: should bootstrap with valid arguments",
flags: []string{kubeconfigFlag,
"--version=0.35.0",
"--version=0.37.0",
privateKeyFlag, privateKeyPasswordFlag,
"--password=admin123",
"--discovery-url=https://dex-01.wge.dev.weave.works/.well-known/openid-configuration",
"--client-id=weave-gitops-enterprise",
oidcClientSecretFlag,
"-s",
},
setup: func(t *testing.T) {
bootstrapFluxSsh(g, kubeconfigFlag)
Expand All @@ -140,14 +141,15 @@ func TestBootstrapCmd(t *testing.T) {
{
name: "journey flux does not exist: should bootstrap with valid arguments",
flags: []string{kubeconfigFlag,
"--version=0.35.0",
privateKeyFlag, privateKeyPasswordFlag,
"--version=0.37.0",
"--password=admin123",
"--discovery-url=https://dex-01.wge.dev.weave.works/.well-known/openid-configuration",
"--client-id=weave-gitops-enterprise",
gitUsernameFlag, gitPasswordFlag, gitBranchFlag, gitRepoPathFlag,
repoHTTPSURLFlag,
oidcClientSecretFlag, "-s",
"--components-extra=policy-agent,tf-controller",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested that acceptance test passed

◎ reconciling changes
=== RUN   TestBootstrapCmd/journey_flux_does_not_exist:_should_bootstrap_with_valid_arguments
✔ changes are reconciled successfully!
◎ install extra components
⚠️ please note that the Policy Agent requires cert-manager to be installed!
► installing Policy Agent ...
✔ Policy Agent is installed successfully
► write file to repo: policy-agent-helmrelease.yaml
► cloning flux git repo: flux-system/flux-system
✔ cloned flux git repo: flux-system/flux-system
✔ file committed to repo: policy-agent-helmrelease.yaml
◎ reconciling changes
✔ changes are reconciled successfully!
► installing Terraform Controller ...
► rendered WGE HelmRelease file
► updating HelmRelease file
✔ Terraform Controller is installed successfully
► write file to repo: tf-controller.yaml
► cloning flux git repo: flux-system/flux-system
✔ cloned flux git repo: flux-system/flux-system
✔ file committed to repo: tf-controller.yaml
◎ reconciling changes
✔ changes are reconciled successfully!
► write file to repo: wge-hrelease.yaml
► cloning flux git repo: flux-system/flux-system
✔ cloned flux git repo: flux-system/flux-system
✔ file committed to repo: wge-hrelease.yaml
◎ reconciling changes
✔ changes are reconciled successfully!
◎ preparing dashboard domain
✔ WGE v0.37.0 is installed successfully. To access the dashboard, run the following command to create portforward to the dasboard local domain http://localhost:8000
► credentials for accessing the admin dashboard  username: `wego-admin`
kubectl -n flux-system port-forward svc/clusters-service 8000:8000
    cmd_acceptance_test.go:291: "level"=0 "msg"="deleted object" "name"="weave-gitops-enterprise-credentials" "ns"="flux-system" "kind"="Secret"
    cmd_acceptance_test.go:291: "level"=0 "msg"="deleted object" "name"="cluster-user-auth" "ns"="flux-system" "kind"="Secret"
--- PASS: TestBootstrapCmd (130.15s)
    --- PASS: TestBootstrapCmd/journey_flux_does_not_exist:_should_bootstrap_with_valid_arguments (130.14s)

"--bootstrap-flux",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i could see the following pods

➜  weave-gitops-enterprise git:(3276-cli-controllers-eneko) ✗ k get pods                                                                    <aws:sts>
NAME                                                            READY   STATUS    RESTARTS   AGE
cluster-bootstrap-controller-manager-79cbb5dfbc-dz5rd           2/2     Running   0          76s
cluster-controller-manager-86c496b9f7-5tk4k                     2/2     Running   0          76s
gitopssets-controller-manager-5cc97766b9-knvb4                  2/2     Running   0          76s
helm-controller-b957fcf89-9ptqk                                 1/1     Running   0          2m2s
kustomize-controller-644f79985c-tqbdp                           1/1     Running   0          2m2s
notification-controller-ddf44665d-r6q8f                         1/1     Running   0          2m2s
source-controller-9dfbc5cd-cbs9x                                1/1     Running   0          2m2s
tf-controller-7975f69b86-psdmx                                  1/1     Running   0          58s
tf-controller-7975f69b86-s9pm5                                  1/1     Running   0          58s
tf-controller-7975f69b86-w5bmt                                  1/1     Running   0          58s
weave-gitops-enterprise-mccp-cluster-service-756cc58859-kqt45   1/1     Running   0          20s
weave-gitops-enterprise-pipeline-controller-85bf5c67d6-459km    1/1     Running   0          76s

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I could login
Screenshot 2023-12-07 at 09 34 24

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

policy agent is reconciled but fails because cert-manager

Screenshot 2023-12-07 at 09 35 33

after installing cert-manager, policy agent reconciles fine:

Screenshot 2023-12-07 at 09 42 48

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

deployed terraform resource

Screenshot 2023-12-07 at 09 47 36

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i could see policy too

Screenshot 2023-12-07 at 09 49 19

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tested invalid path

     --repo-path=clusters/management --components-extra=tf-controller2
► creating client to cluster
✔ created client to cluster: https://127.0.0.1:51388
Error: cannot config bootstrap: cannot create components extra configuration: unsupported component selected: tf-controller2
exit status 1

},
setup: func(t *testing.T) {
createEntitlements(t, testLog)
Expand All @@ -162,7 +164,6 @@ func TestBootstrapCmd(t *testing.T) {
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {

if tt.setup != nil {
tt.setup(t)
}
Expand Down Expand Up @@ -200,8 +201,9 @@ func bootstrapFluxSsh(g *WithT, kubeconfigFlag string) {
fmt.Println(privateKeyFile)

privateKeyPassword := os.Getenv("GIT_PRIVATEKEY_PASSWORD")
g.Expect(privateKeyFile).NotTo(BeEmpty())

args := []string{"bootstrap", "git", kubeconfigFlag, "-s", fmt.Sprintf("--url=%s", repoUrl), fmt.Sprintf("--password=%s", privateKeyPassword), fmt.Sprintf("--private-key-file=%s", privateKeyFile), "--path=clusters/management"}
args := []string{"bootstrap", "git", kubeconfigFlag, "-s", fmt.Sprintf("--url=%s", repoUrl), fmt.Sprintf("--private-key-file=%s", privateKeyFile), fmt.Sprintf("--password=%s", privateKeyPassword), "--path=clusters/management"}
fmt.Println(args)

s, err := cliRunner.Run("flux", args...)
Expand Down
7 changes: 7 additions & 0 deletions docs/cli/bootstrap.md
Original file line number Diff line number Diff line change
Expand Up @@ -274,9 +274,16 @@ func selectWgeVersion(input []StepInput, c *Config) ([]StepOutput, error) {

```

## Default Behaviours (default value in inputs)
waleedhammam marked this conversation as resolved.
Show resolved Hide resolved

CLI take the decisions that considered safe to user by using the information provided by user in which no mutation could happen on the user's cluster.

The default values in the step input will be used while silent mode is on by providing `-s`, `--silent`

Examples:
- Using existing credentials this will not replace the user's data and it's safe
- Not to install extra controllers unless provided otherwise
- Not to install OIDC unless provided otherwise

## Error management

Expand Down
3 changes: 3 additions & 0 deletions pkg/bootstrap/bootstrap.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ func Bootstrap(config steps.Config) error {

repositoryConfig := steps.NewGitRepositoryConfigStep(config.GitRepository)

componentesExtra := steps.NewInstallExtraComponentsStep(config.ComponentsExtra, config.Silent)

// TODO have a single workflow source of truth and documented in https://docs.gitops.weave.works/docs/0.33.0/enterprise/getting-started/install-enterprise/
var steps = []steps.BootstrapStep{
steps.VerifyFluxInstallation,
Expand All @@ -28,6 +30,7 @@ func Bootstrap(config steps.Config) error {
steps.NewInstallWGEStep(),
steps.NewInstallOIDCStep(config),
steps.NewOIDCConfigStep(config),
componentesExtra,
steps.CheckUIDomainStep,
}

Expand Down
5 changes: 2 additions & 3 deletions pkg/bootstrap/steps/admin_password.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,12 @@ import (
const (
adminPasswordMsg = "dashboard admin password (minimum characters: 6)"
secretConfirmationMsg = "admin login credentials has been created successfully!"
adminSecretExistsErrorMsgFormat = "admin login credentials already exist on the cluster. To reset admin credentials please remove secret '%s' in namespace '%s'."
useExistingMessageFormat = "using existing admin login credentials from secret '%s' in namespace '%s'. To reset admin credentials please remove the secret."
adminSecretExistsErrorMsgFormat = "admin login credentials already exist on the cluster. To reset admin credentials please remove secret '%s' in namespace '%s'"
useExistingMessageFormat = " using existing admin login credentials from secret '%s' in namespace '%s'. To reset admin credentials please remove the secret"
)

const (
adminSecretName = "cluster-user-auth"
confirmYes = "y"
defaultAdminUsername = "wego-admin"
)

Expand Down
2 changes: 1 addition & 1 deletion pkg/bootstrap/steps/admin_password_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ func TestNewAskAdminCredsSecretStep(t *testing.T) {
Password: "password123",
},
want: BootstrapStep{},
wantErr: "admin login credentials already exist on the cluster. To reset admin credentials please remove secret 'cluster-user-auth' in namespace 'flux-system'.",
wantErr: "admin login credentials already exist on the cluster. To reset admin credentials please remove secret 'cluster-user-auth' in namespace 'flux-system'",
},
}
for _, tt := range tests {
Expand Down
22 changes: 15 additions & 7 deletions pkg/bootstrap/steps/ask_bootstrap_flux.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,20 +7,24 @@ const (
)

var (
bootstrapFLuxQuestion = StepInput{
Name: inBootstrapFlux,
Type: confirmInput,
Msg: bootstrapFluxMsg,
Enabled: canAskForFluxBootstrap,
bootstrapFluxQuestion = StepInput{
Name: inBootstrapFlux,
Type: confirmInput,
Msg: bootstrapFluxMsg,
Enabled: canAskForFluxBootstrap,
DefaultValue: confirmNo,
}
)

// NewAskBootstrapFluxStep step for asking if user want to install flux using generic method
func NewAskBootstrapFluxStep(config Config) BootstrapStep {
if config.BootstrapFlux {
bootstrapFluxQuestion.DefaultValue = confirmYes
}
return BootstrapStep{
Name: "bootstrap flux",
Input: []StepInput{
bootstrapFLuxQuestion,
bootstrapFluxQuestion,
},
Step: askBootstrapFlux,
}
Expand All @@ -30,12 +34,16 @@ func askBootstrapFlux(input []StepInput, c *Config) ([]StepOutput, error) {
if !canAskForFluxBootstrap(input, c) {
return []StepOutput{}, nil
}
if c.BootstrapFlux && c.Silent {
waleedhammam marked this conversation as resolved.
Show resolved Hide resolved
c.Logger.Actionf("bootstrapping flux in the generic way")
return []StepOutput{}, nil
}
for _, param := range input {
if param.Name == inBootstrapFlux {
fluxBootstrapRes, ok := param.Value.(string)
if ok {
if fluxBootstrapRes != "y" {
return []StepOutput{}, fmt.Errorf("flux bootstrapped error: %s", fluxFatalErrorMsg)
return []StepOutput{}, fmt.Errorf("flux error: %s", fluxFatalErrorMsg)
}

}
Expand Down
13 changes: 12 additions & 1 deletion pkg/bootstrap/steps/ask_bootstrap_flux_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ func TestAskBootstrapFlux(t *testing.T) {
input: []StepInput{
{
Name: inBootstrapFlux,
Value: "n",
Value: confirmNo,
},
},
config: &Config{
Expand All @@ -51,6 +51,17 @@ func TestAskBootstrapFlux(t *testing.T) {
err: false,
canAsk: true,
},
{
name: "check with silent mode and bootstrap flux flag available",
input: []StepInput{},
config: &Config{
FluxInstallated: false,
BootstrapFlux: true,
Silent: true,
},
err: false,
canAsk: true,
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
Expand Down
86 changes: 86 additions & 0 deletions pkg/bootstrap/steps/common_tests.go
Original file line number Diff line number Diff line change
@@ -1,9 +1,16 @@
package steps

import (
"encoding/json"
"fmt"
"testing"
"time"

helmv2 "github.com/fluxcd/helm-controller/api/v2beta1"
sourcev1beta2 "github.com/fluxcd/source-controller/api/v1beta2"
"github.com/weaveworks/weave-gitops-enterprise/test/utils"
apiextensionsv1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1"
v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime"
"sigs.k8s.io/controller-runtime/pkg/client"
)
Expand Down Expand Up @@ -56,5 +63,84 @@ func makeTestConfig(t *testing.T, config Config, objects ...runtime.Object) Conf
ClientSecret: config.ClientSecret,
RedirectURL: config.RedirectURL,
PromptedForDiscoveryURL: config.PromptedForDiscoveryURL,
Silent: config.Silent,
ComponentsExtra: config.ComponentsExtra,
}
}

func createWGEHelmReleaseFakeObject(version string) (helmv2.HelmRelease, error) {
values := valuesFile{
TLS: map[string]interface{}{
"enabled": false,
},
GitOpsSets: map[string]interface{}{
"enabled": true,
"controllerManager": map[string]interface{}{
"manager": map[string]interface{}{
"args": []string{
fmt.Sprintf("--health-probe-bind-address=%s", gitopssetsHealthBindAddress),
fmt.Sprintf("--metrics-bind-address=%s", gitopssetsBindAddress),
"--leader-elect",
fmt.Sprintf("--enabled-generators=%s", gitopssetsEnabledGenerators),
},
},
},
},
EnablePipelines: true,
ClusterController: clusterController{
Enabled: true,
FullNameOverride: clusterControllerFullOverrideName,
ControllerManager: clusterControllerManager{
Manager: clusterControllerManagerManager{
Image: clusterControllerImage{
Repository: clusterControllerImageName,
Tag: clusterControllerImageTag,
},
},
}},
}

valuesBytes, err := json.Marshal(values)
if err != nil {
return helmv2.HelmRelease{}, err
}

wgeHRObject := helmv2.HelmRelease{
ObjectMeta: v1.ObjectMeta{
Name: WgeHelmReleaseName,
Namespace: WGEDefaultNamespace,
}, Spec: helmv2.HelmReleaseSpec{
Chart: helmv2.HelmChartTemplate{
Spec: helmv2.HelmChartTemplateSpec{
Chart: wgeChartName,
ReconcileStrategy: sourcev1beta2.ReconcileStrategyChartVersion,
SourceRef: helmv2.CrossNamespaceObjectReference{
Name: wgeHelmRepositoryName,
Namespace: WGEDefaultNamespace,
},
Version: version,
},
},
Install: &helmv2.Install{
CRDs: helmv2.CreateReplace,
},
Upgrade: &helmv2.Upgrade{
CRDs: helmv2.CreateReplace,
},
Interval: v1.Duration{
Duration: time.Hour,
},
Values: &apiextensionsv1.JSON{Raw: valuesBytes},
},
}
return wgeHRObject, nil
}

func getControllerHelmReleaseTestFile(url string) string {
tfHelmFile, err := doBasicAuthGetRequest(url, "", "")
if err != nil {
fmt.Printf("error getting: %s HelmRelease: %v", url, err)
return ""
}
return string(tfHelmFile)
}
Loading