From cec0edc058162e0ebf341854fb3830c49b0048bb Mon Sep 17 00:00:00 2001 From: martini-source <62108979+martini-source@users.noreply.github.com> Date: Wed, 9 Aug 2023 16:25:58 +0200 Subject: [PATCH] Refactor: APPX-87: Fix input passing (#12) Refactor: use --kind flag for serviceDiscovery use first argument passed by args as serviceName --- go.mod | 1 + go.sum | 2 + internal/defaults/exoscalev1.go | 5 -- internal/defaults/vshnv1.go | 2 - internal/util/argParser.go | 61 +++++++++++++-------- main.go | 54 ++++++++++-------- tests/golden/exoKafka.json | 8 +-- tests/golden/exoKafka/default.yaml | 2 +- tests/golden/exoKafka/jsonInput.yaml | 2 +- tests/golden/exoKafka/parameters.yaml | 2 +- tests/golden/exoKafka/unset.yaml | 2 +- tests/golden/exoMySQL.json | 8 +-- tests/golden/exoMySQL/default.yaml | 2 +- tests/golden/exoMySQL/jsonInput.yaml | 2 +- tests/golden/exoMySQL/parameters.yaml | 2 +- tests/golden/exoMySQL/unset.yaml | 2 +- tests/golden/exoOpenSearch.json | 8 +-- tests/golden/exoOpenSearch/default.yaml | 2 +- tests/golden/exoOpenSearch/jsonInput.yaml | 2 +- tests/golden/exoOpenSearch/parameters.yaml | 2 +- tests/golden/exoOpenSearch/unset.yaml | 2 +- tests/golden/exoPostgreSQL.json | 8 +-- tests/golden/exoPostgreSQL/default.yaml | 2 +- tests/golden/exoPostgreSQL/jsonInput.yaml | 2 +- tests/golden/exoPostgreSQL/parameters.yaml | 2 +- tests/golden/exoPostgreSQL/unset.yaml | 2 +- tests/golden/exoRedis.json | 8 +-- tests/golden/exoRedis/default.yaml | 2 +- tests/golden/exoRedis/jsonInput.yaml | 2 +- tests/golden/exoRedis/parameters.yaml | 2 +- tests/golden/exoRedis/unset.yaml | 2 +- tests/golden/vshnPostgreSQL.json | 8 +-- tests/golden/vshnPostgreSQL/default.yaml | 2 +- tests/golden/vshnPostgreSQL/jsonInput.yaml | 2 +- tests/golden/vshnPostgreSQL/parameters.yaml | 2 +- tests/golden/vshnPostgreSQL/unset.yaml | 2 +- tests/golden/vshnRedis.json | 8 +-- tests/golden/vshnRedis/default.yaml | 2 +- tests/golden/vshnRedis/jsonInput.yaml | 2 +- tests/golden/vshnRedis/parameters.yaml | 2 +- tests/golden/vshnRedis/unset.yaml | 2 +- 41 files changed, 127 insertions(+), 110 deletions(-) diff --git a/go.mod b/go.mod index 0da305d..6f8ab9c 100644 --- a/go.mod +++ b/go.mod @@ -5,6 +5,7 @@ go 1.20 require ( github.com/sirupsen/logrus v1.9.0 github.com/vshn/component-appcat/apis v0.0.0-20230411090651-b0418f5ceb5c + golang.org/x/exp v0.0.0-20230809094429-853ea248256d k8s.io/apimachinery v0.26.3 sigs.k8s.io/yaml v1.3.0 ) diff --git a/go.sum b/go.sum index 3dbd8b4..53131ff 100644 --- a/go.sum +++ b/go.sum @@ -45,6 +45,8 @@ github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9dec golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= +golang.org/x/exp v0.0.0-20230809094429-853ea248256d h1:wu5bD43Ana/nF1ZmaLr3lW/FQeJU8CcI+Ln7yWHViXE= +golang.org/x/exp v0.0.0-20230809094429-853ea248256d/go.mod h1:FXUEEKJgO7OQYeo8N01OfiKP8RXMtf6e8aTskBGqWdc= golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= diff --git a/internal/defaults/exoscalev1.go b/internal/defaults/exoscalev1.go index be2a7bd..2bdb7b7 100644 --- a/internal/defaults/exoscalev1.go +++ b/internal/defaults/exoscalev1.go @@ -13,7 +13,6 @@ func (d *Defaults) GetExoscalePostgreSQLDefault() *exoscalev1.ExoscalePostgreSQL postgreSQLdefault.Spec.Parameters.Backup.TimeOfDay = "12:00:00" postgreSQLdefault.Spec.Parameters.Maintenance.DayOfWeek = "Sunday" postgreSQLdefault.Spec.Parameters.Maintenance.TimeOfDay = "24:00:00" - postgreSQLdefault.Name = "ExoscalePostgreSQL" return &postgreSQLdefault } @@ -25,7 +24,6 @@ func (d *Defaults) GetExoscaleRedisDefault() *exoscalev1.ExoscaleRedis { redisDefault.Spec.Parameters.Maintenance.TimeOfDay = "24:00:00" redisDefault.Spec.Parameters.Service.Zone = "ch-dk-2" - redisDefault.Name = "ExoscaleRedis" return &redisDefault } @@ -38,7 +36,6 @@ func (d *Defaults) GetExoscaleKafkaDefault() *exoscalev1.ExoscaleKafka { kafkaDefault.Spec.Parameters.Maintenance.DayOfWeek = "Sunday" kafkaDefault.Spec.Parameters.Maintenance.TimeOfDay = "24:00:00" - kafkaDefault.Name = "ExoscaleKafka" return &kafkaDefault } @@ -52,7 +49,6 @@ func (d *Defaults) GetExoscaleMySQLDefault() *exoscalev1.ExoscaleMySQL { mySQLdefault.Spec.Parameters.Maintenance.DayOfWeek = "Sunday" mySQLdefault.Spec.Parameters.Maintenance.TimeOfDay = "24:00:00" - mySQLdefault.Name = "ExoscaleMySQL" return &mySQLdefault } @@ -66,6 +62,5 @@ func (d *Defaults) GetExoscaleOpenSearchDefault() *exoscalev1.ExoscaleOpenSearch openSearchDefault.Spec.Parameters.Maintenance.DayOfWeek = "Sunday" openSearchDefault.Spec.Parameters.Maintenance.TimeOfDay = "24:00:00" - openSearchDefault.Name = "ExoscaleOpenSearch" return &openSearchDefault } diff --git a/internal/defaults/vshnv1.go b/internal/defaults/vshnv1.go index 6a88fea..8240631 100644 --- a/internal/defaults/vshnv1.go +++ b/internal/defaults/vshnv1.go @@ -17,7 +17,6 @@ func (d *Defaults) GetVSHNPostgreSQLDefault() *vshnv1.VSHNPostgreSQL { postgreSQLdefault.Spec.Parameters.Backup.Retention = 12 postgreSQLdefault.Spec.Parameters.Scheduling.NodeSelector = map[string]string{"appuio.io/node-class": "plus"} - postgreSQLdefault.Name = "VSHNPostgreSQL" return &postgreSQLdefault } @@ -34,6 +33,5 @@ func (d *Defaults) GetVSHNRedisDefault() *vshnv1.VSHNRedis { redisDefault.Spec.Parameters.Size.MemoryRequests = "500Mi" redisDefault.Spec.Parameters.Size.MemoryLimits = "1Gi" - redisDefault.Name = "VSHNRedis" return &redisDefault } diff --git a/internal/util/argParser.go b/internal/util/argParser.go index 3402ad7..f096ff7 100644 --- a/internal/util/argParser.go +++ b/internal/util/argParser.go @@ -3,6 +3,8 @@ package util import ( "fmt" "strings" + + "golang.org/x/exp/slices" ) type Input struct { @@ -16,6 +18,7 @@ const ( PARAMETER_PREFIX = "--" HIERARCHY_DELIMITER = "." PARAM_VALUE_INFIX = "=" + K8S_SERVICE_KIND = "kind" ) // Takes the input arguments and outputs them as separate Input structs @@ -31,30 +34,6 @@ func ParseArgs(args []string) ([]Input, error) { return inputList, nil } -// Takes the input arguments and outputs them as separate Input structs -func mapArgsToInput(args []string) []Input { - var inputList []Input - input := Input{} - for _, arg := range args { - if isParameter(arg) { - input.ParameterHierarchy = strings.Split(strings.TrimPrefix(arg, PARAMETER_PREFIX), HIERARCHY_DELIMITER) - } else if isParamToUnset(arg) { - param := strings.TrimPrefix(arg, PARAMETER_PREFIX) - param = strings.TrimSuffix(param, UNSET_PARAMETER_SUFFIX) - input.ParameterHierarchy = strings.Split(param, HIERARCHY_DELIMITER) - input.Unset = true - inputList = append(inputList, input) - input = Input{} - } else { - input.Value = arg - inputList = append(inputList, input) - input = Input{} - } - - } - return inputList -} - // Parses raw cli input parameters and returns a list of arguments // if a "=" is used in any form of "key=value" pair, the "=" needs to be the suffix of the key or the separator between key and value // if the "=" is the prefix of the value it is interpreted as part of the value @@ -122,6 +101,40 @@ func CheckForMissingValues(arguments []string) error { return nil } +func FilterServiceKind(input []Input) (string, error) { + serviceKindIndex := slices.IndexFunc(input, func(input Input) bool { + return input.ParameterHierarchy[0] == K8S_SERVICE_KIND + }) + if serviceKindIndex == -1 { + return "", fmt.Errorf("ServiceKind is missing") + } else { + return input[serviceKindIndex].Value, nil + } +} + +// Takes the input arguments and outputs them as separate Input structs +func mapArgsToInput(args []string) []Input { + var inputList []Input + input := Input{} + for _, arg := range args { + if isParameter(arg) { + input.ParameterHierarchy = strings.Split(strings.TrimPrefix(arg, PARAMETER_PREFIX), HIERARCHY_DELIMITER) + } else if isParamToUnset(arg) { + param := strings.TrimPrefix(arg, PARAMETER_PREFIX) + param = strings.TrimSuffix(param, UNSET_PARAMETER_SUFFIX) + input.ParameterHierarchy = strings.Split(param, HIERARCHY_DELIMITER) + input.Unset = true + inputList = append(inputList, input) + input = Input{} + } else { + input.Value = arg + inputList = append(inputList, input) + input = Input{} + } + + } + return inputList +} func isValue(arg string) bool { if !isParamToUnset(arg) && !isParameter(arg) && !isParameterValuePair(arg) { diff --git a/main.go b/main.go index fd5664c..352fd61 100644 --- a/main.go +++ b/main.go @@ -17,11 +17,11 @@ func init() { } func printUsage(cmd string, apps applications.AppMap) { - out := fmt.Sprintf(`usage: %s [options] + out := fmt.Sprintf(`usage: %s --kind [options] Generate AppCat YAML manifests -Known types: +Known service kinds: `, cmd) names := apps.Names() @@ -56,36 +56,44 @@ func main() { // If during execution, an unrecoverable error occurs (usually due to a bug), // an error message is logged and the program will panic. func Main(apps applications.AppMap, args []string, out io.Writer) int { - if len(args) < 2 { + if len(args) < 3 { printUsage(args[0], apps) return 1 } - plainArgs := args[1:] - parsedType := util.NormalizeName(plainArgs[0]) - app, ok := apps[parsedType] + + var err error + var parameters []util.Input + + // args[0] is the binary + resourceName := args[1] + parameters, err = util.ParseArgs(args[2:]) + + if err != nil { + logrus.Errorf("Failed parsing arguments: %s", err) + return 1 + } + + serviceKind, err := util.FilterServiceKind(parameters) + if err != nil { + logrus.Errorf("%s", err) + printUsage(args[0], apps) + return 1 + } + serviceKind = util.NormalizeName(serviceKind) + app, ok := apps[serviceKind] if !ok { - logrus.Errorf("service type '%s' is not supported", parsedType) + logrus.Errorf("service type '%s' is not supported", serviceKind) printUsage(args[0], apps) return 1 } - - var err error + ////appcat-cli serviceKind service := app.GetDefault() - - if len(plainArgs) >= 2 { - parameters, err := util.ParseArgs(plainArgs[1:]) - if err != nil { - logrus.Errorf("Failed parsing arguments: %s", err) - return 1 - } - - _, err = util.DecorateType(service, parameters) - if err != nil { - logrus.Errorf("failed setting parameters: %s", err) - return 1 - } + parameters = append(parameters, util.Input{ParameterHierarchy: []string{"ObjectMeta", "Name"}, Value: resourceName, Unset: false}) + _, err = util.DecorateType(service, parameters) + if err != nil { + logrus.Errorf("failed setting parameters: %s", err) + return 1 } - err = writeYAML(service, out) if err != nil { logrus.Panicf("failed writing YAML: %s", err) diff --git a/tests/golden/exoKafka.json b/tests/golden/exoKafka.json index b15b2e2..f07aa95 100644 --- a/tests/golden/exoKafka.json +++ b/tests/golden/exoKafka.json @@ -1,6 +1,6 @@ { - "default": "ExoscaleKafka", - "parameters": "ExoscaleKafka --spec.parameters.maintenance.dayOfWeek=Monday --spec.parameters.service.zone ch-fr-1 --spec.parameters.size.plan enterprise-large", - "unset": "ExoscaleKafka --spec.parameters.maintenance.dayOfWeek- --spec.parameters.service- --spec.parameters.size.plan-", - "jsonInput": "ExoscaleKafka --spec.parameters.maintenance={\"DayOfWeek\":\"Monday\",\"TimeOfDay\":\"00:00:00\"} --spec.parameters.service {\"Zone\":\"ch-fr-99\"} --spec.parameters.size.plan {\"Foo\":\"Bar\"}" + "default": "kafka-default --kind ExoscaleKafka", + "parameters": "kafka-parameters --kind ExoscaleKafka --spec.parameters.maintenance.dayOfWeek=Monday --spec.parameters.service.zone ch-fr-1 --spec.parameters.size.plan enterprise-large", + "unset": "kafka-unset --kind ExoscaleKafka --spec.parameters.maintenance.dayOfWeek- --spec.parameters.service- --spec.parameters.size.plan-", + "jsonInput": "kafka-jsonInput --kind ExoscaleKafka --spec.parameters.maintenance={\"DayOfWeek\":\"Monday\",\"TimeOfDay\":\"00:00:00\"} --spec.parameters.service {\"Zone\":\"ch-fr-99\"} --spec.parameters.size.plan {\"Foo\":\"Bar\"}" } diff --git a/tests/golden/exoKafka/default.yaml b/tests/golden/exoKafka/default.yaml index d001a54..7741c26 100644 --- a/tests/golden/exoKafka/default.yaml +++ b/tests/golden/exoKafka/default.yaml @@ -2,7 +2,7 @@ apiVersion: exoscale.appcat.vshn.io/v1 kind: ExoscaleKafka metadata: creationTimestamp: null - name: ExoscaleKafka + name: kafka-default spec: parameters: maintenance: diff --git a/tests/golden/exoKafka/jsonInput.yaml b/tests/golden/exoKafka/jsonInput.yaml index 69b4424..9aa3328 100644 --- a/tests/golden/exoKafka/jsonInput.yaml +++ b/tests/golden/exoKafka/jsonInput.yaml @@ -2,7 +2,7 @@ apiVersion: exoscale.appcat.vshn.io/v1 kind: ExoscaleKafka metadata: creationTimestamp: null - name: ExoscaleKafka + name: kafka-jsonInput spec: parameters: maintenance: diff --git a/tests/golden/exoKafka/parameters.yaml b/tests/golden/exoKafka/parameters.yaml index cad089b..259dbbf 100644 --- a/tests/golden/exoKafka/parameters.yaml +++ b/tests/golden/exoKafka/parameters.yaml @@ -2,7 +2,7 @@ apiVersion: exoscale.appcat.vshn.io/v1 kind: ExoscaleKafka metadata: creationTimestamp: null - name: ExoscaleKafka + name: kafka-parameters spec: parameters: maintenance: diff --git a/tests/golden/exoKafka/unset.yaml b/tests/golden/exoKafka/unset.yaml index 97df058..71ad742 100644 --- a/tests/golden/exoKafka/unset.yaml +++ b/tests/golden/exoKafka/unset.yaml @@ -2,7 +2,7 @@ apiVersion: exoscale.appcat.vshn.io/v1 kind: ExoscaleKafka metadata: creationTimestamp: null - name: ExoscaleKafka + name: kafka-unset spec: parameters: maintenance: diff --git a/tests/golden/exoMySQL.json b/tests/golden/exoMySQL.json index 147c211..6e56c36 100644 --- a/tests/golden/exoMySQL.json +++ b/tests/golden/exoMySQL.json @@ -1,6 +1,6 @@ { - "default": "ExoscaleMySQL", - "parameters": "ExoscaleMySQL --spec.parameters.backup.timeOfDay=24:00:00 --spec.parameters.maintenance.dayOfWeek Monday --spec.parameters.service.majorVersion 9999", - "unset": "ExoscaleMySQL --spec.parameters.maintenance.dayOfWeek- --spec.parameters.service- --spec.parameters.size.plan-", - "jsonInput": "ExoscaleMySQL --spec.parameters.maintenance={\"DayOfWeek\":\"Monday\",\"TimeOfDay\":\"00:00:00\"} --spec.parameters.service {\"Zone\":\"ch-fr-99\"} --spec.parameters.size.plan {\"Foo\":\"Bar\"}" + "default": "mysql-default --kind ExoscaleMySQL", + "parameters": "mysql-parameters --kind ExoscaleMySQL --spec.parameters.backup.timeOfDay=24:00:00 --spec.parameters.maintenance.dayOfWeek Monday --spec.parameters.service.majorVersion 9999", + "unset": "mysql-unset --kind ExoscaleMySQL --spec.parameters.maintenance.dayOfWeek- --spec.parameters.service- --spec.parameters.size.plan-", + "jsonInput": "mysql-jsonInput --kind ExoscaleMySQL --spec.parameters.maintenance={\"DayOfWeek\":\"Monday\",\"TimeOfDay\":\"00:00:00\"} --spec.parameters.service {\"Zone\":\"ch-fr-99\"} --spec.parameters.size.plan {\"Foo\":\"Bar\"}" } diff --git a/tests/golden/exoMySQL/default.yaml b/tests/golden/exoMySQL/default.yaml index 70e2ce9..22a3ee9 100644 --- a/tests/golden/exoMySQL/default.yaml +++ b/tests/golden/exoMySQL/default.yaml @@ -2,7 +2,7 @@ apiVersion: exoscale.appcat.vshn.io/v1 kind: ExoscaleMySQL metadata: creationTimestamp: null - name: ExoscaleMySQL + name: mysql-default spec: parameters: backup: diff --git a/tests/golden/exoMySQL/jsonInput.yaml b/tests/golden/exoMySQL/jsonInput.yaml index 85f09f1..6d227a8 100644 --- a/tests/golden/exoMySQL/jsonInput.yaml +++ b/tests/golden/exoMySQL/jsonInput.yaml @@ -2,7 +2,7 @@ apiVersion: exoscale.appcat.vshn.io/v1 kind: ExoscaleMySQL metadata: creationTimestamp: null - name: ExoscaleMySQL + name: mysql-jsonInput spec: parameters: backup: diff --git a/tests/golden/exoMySQL/parameters.yaml b/tests/golden/exoMySQL/parameters.yaml index 0917b0f..d6b43bc 100644 --- a/tests/golden/exoMySQL/parameters.yaml +++ b/tests/golden/exoMySQL/parameters.yaml @@ -2,7 +2,7 @@ apiVersion: exoscale.appcat.vshn.io/v1 kind: ExoscaleMySQL metadata: creationTimestamp: null - name: ExoscaleMySQL + name: mysql-parameters spec: parameters: backup: diff --git a/tests/golden/exoMySQL/unset.yaml b/tests/golden/exoMySQL/unset.yaml index 97b6d33..531948e 100644 --- a/tests/golden/exoMySQL/unset.yaml +++ b/tests/golden/exoMySQL/unset.yaml @@ -2,7 +2,7 @@ apiVersion: exoscale.appcat.vshn.io/v1 kind: ExoscaleMySQL metadata: creationTimestamp: null - name: ExoscaleMySQL + name: mysql-unset spec: parameters: backup: diff --git a/tests/golden/exoOpenSearch.json b/tests/golden/exoOpenSearch.json index 6bbeb7f..4a28d79 100644 --- a/tests/golden/exoOpenSearch.json +++ b/tests/golden/exoOpenSearch.json @@ -1,6 +1,6 @@ { - "default": "ExoscaleOpenSearch", - "parameters": "ExoscaleOpenSearch --spec.parameters.backup.timeOfDay=24:00:00 --spec.parameters.size.plan enterprise-large --spec.parameters.service.majorVersion 9999", - "unset": "ExoscaleOpenSearch --spec.parameters.maintenance.dayOfWeek- --spec.parameters.service- --spec.parameters.size.plan-", - "jsonInput": "ExoscaleOpenSearch --spec.parameters.maintenance={\"DayOfWeek\":\"Monday\",\"TimeOfDay\":\"00:00:00\"} --spec.parameters.service {\"Zone\":\"ch-fr-99\"} --spec.parameters.size.plan {\"Foo\":\"Bar\"}" + "default": "opensearch-default --kind ExoscaleOpenSearch", + "parameters": "opensearch-parameters --kind ExoscaleOpenSearch --spec.parameters.backup.timeOfDay=24:00:00 --spec.parameters.size.plan enterprise-large --spec.parameters.service.majorVersion 9999", + "unset": "opensearch-unset --kind ExoscaleOpenSearch --spec.parameters.maintenance.dayOfWeek- --spec.parameters.service- --spec.parameters.size.plan-", + "jsonInput": "opensearch-jsonInput --kind ExoscaleOpenSearch --spec.parameters.maintenance={\"DayOfWeek\":\"Monday\",\"TimeOfDay\":\"00:00:00\"} --spec.parameters.service {\"Zone\":\"ch-fr-99\"} --spec.parameters.size.plan {\"Foo\":\"Bar\"}" } diff --git a/tests/golden/exoOpenSearch/default.yaml b/tests/golden/exoOpenSearch/default.yaml index dceb35e..f0e3113 100644 --- a/tests/golden/exoOpenSearch/default.yaml +++ b/tests/golden/exoOpenSearch/default.yaml @@ -2,7 +2,7 @@ apiVersion: exoscale.appcat.vshn.io/v1 kind: ExoscaleOpenSearch metadata: creationTimestamp: null - name: ExoscaleOpenSearch + name: opensearch-default spec: parameters: backup: diff --git a/tests/golden/exoOpenSearch/jsonInput.yaml b/tests/golden/exoOpenSearch/jsonInput.yaml index cadbc53..9352699 100644 --- a/tests/golden/exoOpenSearch/jsonInput.yaml +++ b/tests/golden/exoOpenSearch/jsonInput.yaml @@ -2,7 +2,7 @@ apiVersion: exoscale.appcat.vshn.io/v1 kind: ExoscaleOpenSearch metadata: creationTimestamp: null - name: ExoscaleOpenSearch + name: opensearch-jsonInput spec: parameters: backup: diff --git a/tests/golden/exoOpenSearch/parameters.yaml b/tests/golden/exoOpenSearch/parameters.yaml index a414bc1..1a5ba96 100644 --- a/tests/golden/exoOpenSearch/parameters.yaml +++ b/tests/golden/exoOpenSearch/parameters.yaml @@ -2,7 +2,7 @@ apiVersion: exoscale.appcat.vshn.io/v1 kind: ExoscaleOpenSearch metadata: creationTimestamp: null - name: ExoscaleOpenSearch + name: opensearch-parameters spec: parameters: backup: diff --git a/tests/golden/exoOpenSearch/unset.yaml b/tests/golden/exoOpenSearch/unset.yaml index 6e2e5b9..9caa31b 100644 --- a/tests/golden/exoOpenSearch/unset.yaml +++ b/tests/golden/exoOpenSearch/unset.yaml @@ -2,7 +2,7 @@ apiVersion: exoscale.appcat.vshn.io/v1 kind: ExoscaleOpenSearch metadata: creationTimestamp: null - name: ExoscaleOpenSearch + name: opensearch-unset spec: parameters: backup: diff --git a/tests/golden/exoPostgreSQL.json b/tests/golden/exoPostgreSQL.json index a51e6ab..bde83ef 100644 --- a/tests/golden/exoPostgreSQL.json +++ b/tests/golden/exoPostgreSQL.json @@ -1,7 +1,7 @@ { - "default": "ExoscalePostgreSQL", - "parameters": "ExoscalePostgreSQL --spec.parameters.backup.timeOfDay=24:00:00 --spec.parameters.service.majorVersion 13 --spec.parameters.size.plan enterprise-large", - "unset": "ExoscalePostgreSQL --spec.parameters.maintenance.dayOfWeek- --spec.parameters.service- --spec.parameters.size.plan-", - "jsonInput": "ExoscalePostgreSQL --spec.parameters.maintenance={\"DayOfWeek\":\"Monday\",\"TimeOfDay\":\"00:00:00\"} --spec.parameters.service {\"Zone\":\"ch-fr-99\"} --spec.parameters.size.plan {\"Foo\":\"Bar\"}" + "default": "postgres-default --kind ExoscalePostgreSQL", + "parameters": "postgres-parameters --kind ExoscalePostgreSQL --spec.parameters.backup.timeOfDay=24:00:00 --spec.parameters.service.majorVersion 13 --spec.parameters.size.plan enterprise-large", + "unset": "postgres-unset --kind ExoscalePostgreSQL --spec.parameters.maintenance.dayOfWeek- --spec.parameters.service- --spec.parameters.size.plan-", + "jsonInput": "postgres-jsonInput --kind ExoscalePostgreSQL --spec.parameters.maintenance={\"DayOfWeek\":\"Monday\",\"TimeOfDay\":\"00:00:00\"} --spec.parameters.service {\"Zone\":\"ch-fr-99\"} --spec.parameters.size.plan {\"Foo\":\"Bar\"}" } diff --git a/tests/golden/exoPostgreSQL/default.yaml b/tests/golden/exoPostgreSQL/default.yaml index 8b2c16f..c024a54 100644 --- a/tests/golden/exoPostgreSQL/default.yaml +++ b/tests/golden/exoPostgreSQL/default.yaml @@ -2,7 +2,7 @@ apiVersion: exoscale.appcat.vshn.io/v1 kind: ExoscalePostgreSQL metadata: creationTimestamp: null - name: ExoscalePostgreSQL + name: postgres-default spec: parameters: backup: diff --git a/tests/golden/exoPostgreSQL/jsonInput.yaml b/tests/golden/exoPostgreSQL/jsonInput.yaml index e6adac0..665279e 100644 --- a/tests/golden/exoPostgreSQL/jsonInput.yaml +++ b/tests/golden/exoPostgreSQL/jsonInput.yaml @@ -2,7 +2,7 @@ apiVersion: exoscale.appcat.vshn.io/v1 kind: ExoscalePostgreSQL metadata: creationTimestamp: null - name: ExoscalePostgreSQL + name: postgres-jsonInput spec: parameters: backup: diff --git a/tests/golden/exoPostgreSQL/parameters.yaml b/tests/golden/exoPostgreSQL/parameters.yaml index b1e3215..86edfda 100644 --- a/tests/golden/exoPostgreSQL/parameters.yaml +++ b/tests/golden/exoPostgreSQL/parameters.yaml @@ -2,7 +2,7 @@ apiVersion: exoscale.appcat.vshn.io/v1 kind: ExoscalePostgreSQL metadata: creationTimestamp: null - name: ExoscalePostgreSQL + name: postgres-parameters spec: parameters: backup: diff --git a/tests/golden/exoPostgreSQL/unset.yaml b/tests/golden/exoPostgreSQL/unset.yaml index c8b396c..578b038 100644 --- a/tests/golden/exoPostgreSQL/unset.yaml +++ b/tests/golden/exoPostgreSQL/unset.yaml @@ -2,7 +2,7 @@ apiVersion: exoscale.appcat.vshn.io/v1 kind: ExoscalePostgreSQL metadata: creationTimestamp: null - name: ExoscalePostgreSQL + name: postgres-unset spec: parameters: backup: diff --git a/tests/golden/exoRedis.json b/tests/golden/exoRedis.json index 6171700..25411e3 100644 --- a/tests/golden/exoRedis.json +++ b/tests/golden/exoRedis.json @@ -1,7 +1,7 @@ { - "default": "ExoscaleRedis", - "parameters": "ExoscaleRedis --spec.parameters.size.plan=enterprise-large --spec.parameters.service.zone ch-fr-1 --spec.parameters.maintenance.timeOfDay 24:00:00", - "unset": "ExoscaleRedis --spec.parameters.maintenance.dayOfWeek- --spec.parameters.service- --spec.parameters.service.redisSettings-", - "jsonInput": "ExoscaleRedis --spec.parameters.maintenance={\"DayOfWeek\":\"Monday\",\"TimeOfDay\":\"00:00:00\"} --spec.parameters.service {\"Zone\":\"ch-fr-99\"} --spec.parameters.size.plan {\"Foo\":\"Bar\"}" + "default": "redis-default --kind ExoscaleRedis", + "parameters": "redis-parameters --kind ExoscaleRedis --spec.parameters.size.plan=enterprise-large --spec.parameters.service.zone ch-fr-1 --spec.parameters.maintenance.timeOfDay 24:00:00", + "unset": "redis-unset --kind ExoscaleRedis --spec.parameters.maintenance.dayOfWeek- --spec.parameters.service- --spec.parameters.service.redisSettings-", + "jsonInput": "redis-jsonInput --kind ExoscaleRedis --spec.parameters.maintenance={\"DayOfWeek\":\"Monday\",\"TimeOfDay\":\"00:00:00\"} --spec.parameters.service {\"Zone\":\"ch-fr-99\"} --spec.parameters.size.plan {\"Foo\":\"Bar\"}" } diff --git a/tests/golden/exoRedis/default.yaml b/tests/golden/exoRedis/default.yaml index 318b791..6881572 100644 --- a/tests/golden/exoRedis/default.yaml +++ b/tests/golden/exoRedis/default.yaml @@ -2,7 +2,7 @@ apiVersion: exoscale.appcat.vshn.io/v1 kind: ExoscaleRedis metadata: creationTimestamp: null - name: ExoscaleRedis + name: redis-default spec: parameters: maintenance: diff --git a/tests/golden/exoRedis/jsonInput.yaml b/tests/golden/exoRedis/jsonInput.yaml index 4afb733..cf073f9 100644 --- a/tests/golden/exoRedis/jsonInput.yaml +++ b/tests/golden/exoRedis/jsonInput.yaml @@ -2,7 +2,7 @@ apiVersion: exoscale.appcat.vshn.io/v1 kind: ExoscaleRedis metadata: creationTimestamp: null - name: ExoscaleRedis + name: redis-jsonInput spec: parameters: maintenance: diff --git a/tests/golden/exoRedis/parameters.yaml b/tests/golden/exoRedis/parameters.yaml index aa994dc..1e288b0 100644 --- a/tests/golden/exoRedis/parameters.yaml +++ b/tests/golden/exoRedis/parameters.yaml @@ -2,7 +2,7 @@ apiVersion: exoscale.appcat.vshn.io/v1 kind: ExoscaleRedis metadata: creationTimestamp: null - name: ExoscaleRedis + name: redis-parameters spec: parameters: maintenance: diff --git a/tests/golden/exoRedis/unset.yaml b/tests/golden/exoRedis/unset.yaml index 22bca40..10aaf1c 100644 --- a/tests/golden/exoRedis/unset.yaml +++ b/tests/golden/exoRedis/unset.yaml @@ -2,7 +2,7 @@ apiVersion: exoscale.appcat.vshn.io/v1 kind: ExoscaleRedis metadata: creationTimestamp: null - name: ExoscaleRedis + name: redis-unset spec: parameters: maintenance: diff --git a/tests/golden/vshnPostgreSQL.json b/tests/golden/vshnPostgreSQL.json index b05f14a..8d0121c 100644 --- a/tests/golden/vshnPostgreSQL.json +++ b/tests/golden/vshnPostgreSQL.json @@ -1,7 +1,7 @@ { - "default": "VSHNPostgreSQL", - "parameters": "VSHNPostgreSQL --spec.parameters.backup.retention=9999 --spec.parameters.backup.schedule \"1 1 1 1 1\" --spec.parameters.size.CPU 100000m", - "unset": "VSHNPostgreSQL --spec.parameters.size.disk- --spec.parameters.service- --spec.parameters.scheduling.nodeSelector-", - "jsonInput": "VSHNPostgreSQL --spec.parameters.size={\"cpu\":\"99999m\",\"Memory\":\"9999Gi\",\"disk\":\"9999Gi\",\"Requests\":{\"Memory\":\"9999Gi\"}} --spec.parameters.scheduling.nodeSelector {\"appuio.io/node-class\":\"testing\"} --spec.parameters.backup.schedule {\"Foo\":\"Bar\"}" + "default": "postgres-default --kind VSHNPostgreSQL", + "parameters": "postgres-parameters --kind VSHNPostgreSQL --spec.parameters.backup.retention=9999 --spec.parameters.backup.schedule \"1 1 1 1 1\" --spec.parameters.size.CPU 100000m", + "unset": "postgres-unset --kind VSHNPostgreSQL --spec.parameters.size.disk- --spec.parameters.service- --spec.parameters.scheduling.nodeSelector-", + "jsonInput": "postgres-jsonInput --kind VSHNPostgreSQL --spec.parameters.size={\"cpu\":\"99999m\",\"Memory\":\"9999Gi\",\"disk\":\"9999Gi\",\"Requests\":{\"Memory\":\"9999Gi\"}} --spec.parameters.scheduling.nodeSelector {\"appuio.io/node-class\":\"testing\"} --spec.parameters.backup.schedule {\"Foo\":\"Bar\"}" } diff --git a/tests/golden/vshnPostgreSQL/default.yaml b/tests/golden/vshnPostgreSQL/default.yaml index 5160288..1de2ab8 100644 --- a/tests/golden/vshnPostgreSQL/default.yaml +++ b/tests/golden/vshnPostgreSQL/default.yaml @@ -2,7 +2,7 @@ apiVersion: vshn.appcat.vshn.io/v1 kind: VSHNPostgreSQL metadata: creationTimestamp: null - name: VSHNPostgreSQL + name: postgres-default spec: parameters: backup: diff --git a/tests/golden/vshnPostgreSQL/jsonInput.yaml b/tests/golden/vshnPostgreSQL/jsonInput.yaml index 29226a6..3308e5a 100644 --- a/tests/golden/vshnPostgreSQL/jsonInput.yaml +++ b/tests/golden/vshnPostgreSQL/jsonInput.yaml @@ -2,7 +2,7 @@ apiVersion: vshn.appcat.vshn.io/v1 kind: VSHNPostgreSQL metadata: creationTimestamp: null - name: VSHNPostgreSQL + name: postgres-jsonInput spec: parameters: backup: diff --git a/tests/golden/vshnPostgreSQL/parameters.yaml b/tests/golden/vshnPostgreSQL/parameters.yaml index 3669303..6230efc 100644 --- a/tests/golden/vshnPostgreSQL/parameters.yaml +++ b/tests/golden/vshnPostgreSQL/parameters.yaml @@ -2,7 +2,7 @@ apiVersion: vshn.appcat.vshn.io/v1 kind: VSHNPostgreSQL metadata: creationTimestamp: null - name: VSHNPostgreSQL + name: postgres-parameters spec: parameters: backup: diff --git a/tests/golden/vshnPostgreSQL/unset.yaml b/tests/golden/vshnPostgreSQL/unset.yaml index def1d70..cd5aa78 100644 --- a/tests/golden/vshnPostgreSQL/unset.yaml +++ b/tests/golden/vshnPostgreSQL/unset.yaml @@ -2,7 +2,7 @@ apiVersion: vshn.appcat.vshn.io/v1 kind: VSHNPostgreSQL metadata: creationTimestamp: null - name: VSHNPostgreSQL + name: postgres-unset spec: parameters: backup: diff --git a/tests/golden/vshnRedis.json b/tests/golden/vshnRedis.json index 93674a2..9fd7446 100644 --- a/tests/golden/vshnRedis.json +++ b/tests/golden/vshnRedis.json @@ -1,7 +1,7 @@ { - "default": "VSHNRedis", - "parameters": "VSHNRedis --spec.writeConnectionSecretToRef.Name=redisSecret --spec.parameters.tls.tlsauthClients false --spec.parameters.tls.tlsenabled false --spec.parameters.service.version 9999", - "unset": "VSHNRedis --spec.parameters.size.disk- --spec.parameters.tls- --spec.parameters.service.redisSettings-", - "jsonInput": "VSHNRedis --spec.parameters.size={\"cpuLimits\":\"99999m\",\"memoryLimits\":\"9999Gi\"} --spec.parameters.service {\"redisSettings\":\"| activedefrag no\"} --spec.parameters.service.version {\"Foo\":\"Bar\"}" + "default": "redis-default --kind VSHNRedis", + "parameters": "redis-parameters --kind VSHNRedis --spec.writeConnectionSecretToRef.Name=redisSecret --spec.parameters.tls.tlsauthClients false --spec.parameters.tls.tlsenabled false --spec.parameters.service.version 9999", + "unset": "redis-unset --kind VSHNRedis --spec.parameters.size.disk- --spec.parameters.tls- --spec.parameters.service.redisSettings-", + "jsonInput": "redis-jsonInput --kind VSHNRedis --spec.parameters.size={\"cpuLimits\":\"99999m\",\"memoryLimits\":\"9999Gi\"} --spec.parameters.service {\"redisSettings\":\"| activedefrag no\"} --spec.parameters.service.version {\"Foo\":\"Bar\"}" } diff --git a/tests/golden/vshnRedis/default.yaml b/tests/golden/vshnRedis/default.yaml index f0522ea..e2c9f55 100644 --- a/tests/golden/vshnRedis/default.yaml +++ b/tests/golden/vshnRedis/default.yaml @@ -2,7 +2,7 @@ apiVersion: vshn.appcat.vshn.io/v1 kind: VSHNRedis metadata: creationTimestamp: null - name: VSHNRedis + name: redis-default spec: parameters: scheduling: {} diff --git a/tests/golden/vshnRedis/jsonInput.yaml b/tests/golden/vshnRedis/jsonInput.yaml index 0b7dcc2..367018c 100644 --- a/tests/golden/vshnRedis/jsonInput.yaml +++ b/tests/golden/vshnRedis/jsonInput.yaml @@ -2,7 +2,7 @@ apiVersion: vshn.appcat.vshn.io/v1 kind: VSHNRedis metadata: creationTimestamp: null - name: VSHNRedis + name: redis-jsonInput spec: parameters: scheduling: {} diff --git a/tests/golden/vshnRedis/parameters.yaml b/tests/golden/vshnRedis/parameters.yaml index 2afc888..9898ddf 100644 --- a/tests/golden/vshnRedis/parameters.yaml +++ b/tests/golden/vshnRedis/parameters.yaml @@ -2,7 +2,7 @@ apiVersion: vshn.appcat.vshn.io/v1 kind: VSHNRedis metadata: creationTimestamp: null - name: VSHNRedis + name: redis-parameters spec: parameters: scheduling: {} diff --git a/tests/golden/vshnRedis/unset.yaml b/tests/golden/vshnRedis/unset.yaml index 9306fc2..3a0c1e9 100644 --- a/tests/golden/vshnRedis/unset.yaml +++ b/tests/golden/vshnRedis/unset.yaml @@ -2,7 +2,7 @@ apiVersion: vshn.appcat.vshn.io/v1 kind: VSHNRedis metadata: creationTimestamp: null - name: VSHNRedis + name: redis-unset spec: parameters: scheduling: {}