Skip to content

Commit

Permalink
Ensure writeConnectionSecretToRef is always set
Browse files Browse the repository at this point in the history
This commit will ensure that every resource's
`spec.writeConnectionSecretToRef.name` is set (to a default value of
`serviceName+"-creds"`).

Resolves: APPX-88
Signed-off-by: Manuel Hutter <[email protected]>
  • Loading branch information
martini-source authored and mhutter committed Aug 10, 2023
1 parent f5f79ec commit 4643db3
Show file tree
Hide file tree
Showing 42 changed files with 220 additions and 28 deletions.
4 changes: 3 additions & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,9 +86,11 @@ func Main(apps applications.AppMap, args []string, out io.Writer) int {
printUsage(args[0], apps)
return 1
}
////appcat-cli serviceKind

service := app.GetDefault()
parameters = append(parameters, util.Input{ParameterHierarchy: []string{"ObjectMeta", "Name"}, Value: resourceName, Unset: false})
parameters = append([]util.Input{{ParameterHierarchy: []string{"Spec", "WriteConnectionSecretToRef", "Name"}, Value: resourceName + "-creds", Unset: false}}, parameters...)

_, err = util.DecorateType(service, parameters)
if err != nil {
logrus.Errorf("failed setting parameters: %s", err)
Expand Down
1 change: 1 addition & 0 deletions tests/golden/exoKafka.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"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",
"secret-ref": "kafka-secret-ref --kind ExoscaleKafka --spec.writeconnectionsecrettoref.name new-cred",
"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\"}"
}
3 changes: 2 additions & 1 deletion tests/golden/exoKafka/default.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,6 @@ spec:
zone: ch-dk-2
size:
plan: startup-2
writeConnectionSecretToRef: {}
writeConnectionSecretToRef:
name: kafka-default-creds
status: {}
3 changes: 2 additions & 1 deletion tests/golden/exoKafka/jsonInput.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,6 @@ spec:
zone: ch-fr-99
size:
plan: '{"Foo":"Bar"}'
writeConnectionSecretToRef: {}
writeConnectionSecretToRef:
name: kafka-jsonInput-creds
status: {}
3 changes: 2 additions & 1 deletion tests/golden/exoKafka/parameters.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,6 @@ spec:
zone: ch-fr-1
size:
plan: enterprise-large
writeConnectionSecretToRef: {}
writeConnectionSecretToRef:
name: kafka-parameters-creds
status: {}
20 changes: 20 additions & 0 deletions tests/golden/exoKafka/secret-ref.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
apiVersion: exoscale.appcat.vshn.io/v1
kind: ExoscaleKafka
metadata:
creationTimestamp: null
name: kafka-secret-ref
spec:
parameters:
maintenance:
dayOfWeek: sunday
timeOfDay: "00:00:00"
network: {}
service:
kafkaSettings: null
version: 3.4.0
zone: ch-dk-2
size:
plan: startup-2
writeConnectionSecretToRef:
name: new-cred
status: {}
3 changes: 2 additions & 1 deletion tests/golden/exoKafka/unset.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,6 @@ spec:
service:
kafkaSettings: null
size: {}
writeConnectionSecretToRef: {}
writeConnectionSecretToRef:
name: kafka-unset-creds
status: {}
1 change: 1 addition & 0 deletions tests/golden/exoMySQL.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"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",
"secret-ref": "mysql-secret-ref --kind ExoscaleMySQL --spec.writeconnectionsecrettoref.name new-cred",
"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\"}"
}
3 changes: 2 additions & 1 deletion tests/golden/exoMySQL/default.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,6 @@ spec:
zone: ch-dk-2
size:
plan: hobbyist-2
writeConnectionSecretToRef: {}
writeConnectionSecretToRef:
name: mysql-default-creds
status: {}
3 changes: 2 additions & 1 deletion tests/golden/exoMySQL/jsonInput.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,6 @@ spec:
zone: ch-fr-99
size:
plan: '{"Foo":"Bar"}'
writeConnectionSecretToRef: {}
writeConnectionSecretToRef:
name: mysql-jsonInput-creds
status: {}
3 changes: 2 additions & 1 deletion tests/golden/exoMySQL/parameters.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,6 @@ spec:
zone: ch-dk-2
size:
plan: hobbyist-2
writeConnectionSecretToRef: {}
writeConnectionSecretToRef:
name: mysql-parameters-creds
status: {}
22 changes: 22 additions & 0 deletions tests/golden/exoMySQL/secret-ref.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
apiVersion: exoscale.appcat.vshn.io/v1
kind: ExoscaleMySQL
metadata:
creationTimestamp: null
name: mysql-secret-ref
spec:
parameters:
backup:
timeOfDay: "12:00:00"
maintenance:
dayOfWeek: sunday
timeOfDay: "00:00:00"
network: {}
service:
majorVersion: "8"
mysqlSettings: null
zone: ch-dk-2
size:
plan: hobbyist-2
writeConnectionSecretToRef:
name: new-cred
status: {}
3 changes: 2 additions & 1 deletion tests/golden/exoMySQL/unset.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,6 @@ spec:
service:
mysqlSettings: null
size: {}
writeConnectionSecretToRef: {}
writeConnectionSecretToRef:
name: mysql-unset-creds
status: {}
1 change: 1 addition & 0 deletions tests/golden/exoOpenSearch.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"default": "opensearch-default --kind ExoscaleOpenSearch",
"secret-ref": "opensearch-secret-ref --kind ExoscaleOpenSearch --spec.writeconnectionsecrettoref.name new-cred",
"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\"}"
Expand Down
3 changes: 2 additions & 1 deletion tests/golden/exoOpenSearch/default.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,6 @@ spec:
zone: ch-dk-2
size:
plan: hobbyist-2
writeConnectionSecretToRef: {}
writeConnectionSecretToRef:
name: opensearch-default-creds
status: {}
3 changes: 2 additions & 1 deletion tests/golden/exoOpenSearch/jsonInput.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,6 @@ spec:
zone: ch-fr-99
size:
plan: '{"Foo":"Bar"}'
writeConnectionSecretToRef: {}
writeConnectionSecretToRef:
name: opensearch-jsonInput-creds
status: {}
3 changes: 2 additions & 1 deletion tests/golden/exoOpenSearch/parameters.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,6 @@ spec:
zone: ch-dk-2
size:
plan: enterprise-large
writeConnectionSecretToRef: {}
writeConnectionSecretToRef:
name: opensearch-parameters-creds
status: {}
22 changes: 22 additions & 0 deletions tests/golden/exoOpenSearch/secret-ref.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
apiVersion: exoscale.appcat.vshn.io/v1
kind: ExoscaleOpenSearch
metadata:
creationTimestamp: null
name: opensearch-secret-ref
spec:
parameters:
backup:
timeOfDay: "12:00:00"
maintenance:
dayOfWeek: sunday
timeOfDay: "00:00:00"
network: {}
service:
majorVersion: "2"
opensearchSettings: null
zone: ch-dk-2
size:
plan: hobbyist-2
writeConnectionSecretToRef:
name: new-cred
status: {}
3 changes: 2 additions & 1 deletion tests/golden/exoOpenSearch/unset.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,6 @@ spec:
service:
opensearchSettings: null
size: {}
writeConnectionSecretToRef: {}
writeConnectionSecretToRef:
name: opensearch-unset-creds
status: {}
1 change: 1 addition & 0 deletions tests/golden/exoPostgreSQL.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"default": "postgres-default --kind ExoscalePostgreSQL",
"secret-ref": "postgres-secret-ref --kind ExoscalePostgreSQL --spec.writeconnectionsecrettoref.name new-cred",
"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\"}"
Expand Down
3 changes: 2 additions & 1 deletion tests/golden/exoPostgreSQL/default.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,6 @@ spec:
zone: ch-dk-2
size:
plan: hobbyist-2
writeConnectionSecretToRef: {}
writeConnectionSecretToRef:
name: postgres-default-creds
status: {}
3 changes: 2 additions & 1 deletion tests/golden/exoPostgreSQL/jsonInput.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,6 @@ spec:
zone: ch-fr-99
size:
plan: '{"Foo":"Bar"}'
writeConnectionSecretToRef: {}
writeConnectionSecretToRef:
name: postgres-jsonInput-creds
status: {}
3 changes: 2 additions & 1 deletion tests/golden/exoPostgreSQL/parameters.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,6 @@ spec:
zone: ch-dk-2
size:
plan: enterprise-large
writeConnectionSecretToRef: {}
writeConnectionSecretToRef:
name: postgres-parameters-creds
status: {}
22 changes: 22 additions & 0 deletions tests/golden/exoPostgreSQL/secret-ref.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
apiVersion: exoscale.appcat.vshn.io/v1
kind: ExoscalePostgreSQL
metadata:
creationTimestamp: null
name: postgres-secret-ref
spec:
parameters:
backup:
timeOfDay: "12:00:00"
maintenance:
dayOfWeek: sunday
timeOfDay: "00:00:00"
network: {}
service:
majorVersion: "15"
pgSettings: null
zone: ch-dk-2
size:
plan: hobbyist-2
writeConnectionSecretToRef:
name: new-cred
status: {}
3 changes: 2 additions & 1 deletion tests/golden/exoPostgreSQL/unset.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,6 @@ spec:
service:
pgSettings: null
size: {}
writeConnectionSecretToRef: {}
writeConnectionSecretToRef:
name: postgres-unset-creds
status: {}
1 change: 1 addition & 0 deletions tests/golden/exoRedis.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"default": "redis-default --kind ExoscaleRedis",
"secret-ref": "redis-secret-ref --kind ExoscaleRedis --spec.writeconnectionsecrettoref.name new-cred",
"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\"}"
Expand Down
3 changes: 2 additions & 1 deletion tests/golden/exoRedis/default.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,6 @@ spec:
redisSettings: null
zone: ch-dk-2
size: {}
writeConnectionSecretToRef: {}
writeConnectionSecretToRef:
name: redis-default-creds
status: {}
3 changes: 2 additions & 1 deletion tests/golden/exoRedis/jsonInput.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,6 @@ spec:
zone: ch-fr-99
size:
plan: '{"Foo":"Bar"}'
writeConnectionSecretToRef: {}
writeConnectionSecretToRef:
name: redis-jsonInput-creds
status: {}
3 changes: 2 additions & 1 deletion tests/golden/exoRedis/parameters.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,6 @@ spec:
zone: ch-fr-1
size:
plan: enterprise-large
writeConnectionSecretToRef: {}
writeConnectionSecretToRef:
name: redis-parameters-creds
status: {}
18 changes: 18 additions & 0 deletions tests/golden/exoRedis/secret-ref.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
apiVersion: exoscale.appcat.vshn.io/v1
kind: ExoscaleRedis
metadata:
creationTimestamp: null
name: redis-secret-ref
spec:
parameters:
maintenance:
dayOfWeek: sunday
timeOfDay: "00:00:00"
network: {}
service:
redisSettings: null
zone: ch-dk-2
size: {}
writeConnectionSecretToRef:
name: new-cred
status: {}
3 changes: 2 additions & 1 deletion tests/golden/exoRedis/unset.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,6 @@ spec:
service:
redisSettings: null
size: {}
writeConnectionSecretToRef: {}
writeConnectionSecretToRef:
name: redis-unset-creds
status: {}
1 change: 1 addition & 0 deletions tests/golden/vshnPostgreSQL.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"default": "postgres-default --kind VSHNPostgreSQL",
"secret-ref": "postgres-secret-ref --kind VSHNPostgreSQL --spec.writeconnectionsecrettoref.name new-cred",
"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\"}"
Expand Down
3 changes: 2 additions & 1 deletion tests/golden/vshnPostgreSQL/default.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,6 @@ spec:
requests:
cpu: 300m
memory: 1000Mi
writeConnectionSecretToRef: {}
writeConnectionSecretToRef:
name: postgres-default-creds
status: {}
3 changes: 2 additions & 1 deletion tests/golden/vshnPostgreSQL/jsonInput.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,6 @@ spec:
memory: 9999Gi
requests:
memory: 9999Gi
writeConnectionSecretToRef: {}
writeConnectionSecretToRef:
name: postgres-jsonInput-creds
status: {}
3 changes: 2 additions & 1 deletion tests/golden/vshnPostgreSQL/parameters.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,6 @@ spec:
requests:
cpu: 300m
memory: 1000Mi
writeConnectionSecretToRef: {}
writeConnectionSecretToRef:
name: postgres-parameters-creds
status: {}
29 changes: 29 additions & 0 deletions tests/golden/vshnPostgreSQL/secret-ref.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
apiVersion: vshn.appcat.vshn.io/v1
kind: VSHNPostgreSQL
metadata:
creationTimestamp: null
name: postgres-secret-ref
spec:
parameters:
backup:
retention: 12
schedule: 30 23 * * *
maintenance: {}
network: {}
restore: {}
scheduling:
nodeSelector:
appuio.io/node-class: plus
service:
majorVersion: "15"
pgSettings: null
size:
cpu: 600m
disk: 80Gi
memory: 3500Mi
requests:
cpu: 300m
memory: 1000Mi
writeConnectionSecretToRef:
name: new-cred
status: {}
3 changes: 2 additions & 1 deletion tests/golden/vshnPostgreSQL/unset.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,6 @@ spec:
requests:
cpu: 300m
memory: 1000Mi
writeConnectionSecretToRef: {}
writeConnectionSecretToRef:
name: postgres-unset-creds
status: {}
1 change: 1 addition & 0 deletions tests/golden/vshnRedis.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"default": "redis-default --kind VSHNRedis",
"secret-ref": "redis-secret-ref --kind VSHNRedis --spec.writeconnectionsecrettoref.name new-cred",
"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\"}"
Expand Down
Loading

0 comments on commit 4643db3

Please sign in to comment.