| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112 |
- /*
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
- http://www.apache.org/licenses/LICENSE-2.0
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
- */
- package addon
- import (
- "os"
- // nolint
- . "github.com/onsi/ginkgo/v2"
- )
- type ESO struct {
- *HelmChart
- }
- func NewESO(mutators ...MutationFunc) *ESO {
- eso := &ESO{
- &HelmChart{
- Namespace: "default",
- ReleaseName: "eso",
- Chart: "/k8s/deploy/charts/external-secrets",
- Vars: []StringTuple{
- {
- Key: "image.repository",
- Value: os.Getenv("IMAGE_REGISTRY"),
- },
- {
- Key: "image.tag",
- Value: os.Getenv("VERSION"),
- },
- {
- Key: "installCRDs",
- Value: "false",
- },
- },
- },
- }
- for _, f := range mutators {
- f(eso)
- }
- return eso
- }
- type MutationFunc func(eso *ESO)
- func WithReleaseName(name string) MutationFunc {
- return func(eso *ESO) {
- eso.HelmChart.ReleaseName = name
- }
- }
- func WithNamespace(namespace string) MutationFunc {
- return func(eso *ESO) {
- eso.HelmChart.Namespace = namespace
- }
- }
- func WithNamespaceScope(namespace string) MutationFunc {
- return func(eso *ESO) {
- eso.HelmChart.Vars = append(eso.HelmChart.Vars, StringTuple{
- Key: "scopedNamespace",
- Value: namespace,
- })
- }
- }
- func WithServiceAccount(saName string) MutationFunc {
- return func(eso *ESO) {
- eso.HelmChart.Vars = append(eso.HelmChart.Vars, []StringTuple{
- {
- Key: "serviceAccount.create",
- Value: "false",
- },
- {
- Key: "serviceAccount.name",
- Value: saName,
- },
- }...)
- }
- }
- func WithControllerClass(class string) MutationFunc {
- return func(eso *ESO) {
- eso.HelmChart.Vars = append(eso.HelmChart.Vars, StringTuple{
- Key: "extraArgs.controller-class",
- Value: class,
- })
- }
- }
- func (l *ESO) Install() error {
- By("Installing eso\n")
- err := l.HelmChart.Install()
- if err != nil {
- return err
- }
- return nil
- }
|