Skip to content

Commit

Permalink
feat: add persistenceSuffix
Browse files Browse the repository at this point in the history
  • Loading branch information
lenglet-k authored and eshepelyuk committed Dec 7, 2023
1 parent cfb3183 commit 1c4cc9d
Show file tree
Hide file tree
Showing 5 changed files with 79 additions and 6 deletions.
12 changes: 7 additions & 5 deletions templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,14 @@ app.kubernetes.io/instance: {{ .Release.Name }}

{{- define "apicurio-registry.image" -}}
{{- $sfx := "" -}}
{{- if hasKey . "sql" -}}
{{- $sfx = "sql" -}}
{{- if not .image.persistenceSuffix -}}
{{- $sfx = "" -}}
{{- else if hasKey . "sql" -}}
{{- $sfx = "-sql" -}}
{{- else if hasKey . "kafka" -}}
{{- $sfx = "kafkasql" -}}
{{- $sfx = "-kafkasql" -}}
{{- else -}}
{{- $sfx = "mem" -}}
{{- $sfx = "-mem" -}}
{{- end -}}
{{ printf "%s/%s-%s:%s" .image.registry .image.repository $sfx .image.tag }}
{{ printf "%s/%s%s:%s" .image.registry .image.repository $sfx .image.tag }}
{{- end -}}
11 changes: 11 additions & 0 deletions test/lint/registry.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,17 @@ suite: lint registry values
templates:
- fake.yaml
tests:
- it: persistenceSuffix is not boolean
set:
registry:
image:
persistenceSuffix: "qwe"
asserts:
- failedTemplate:
errorMessage: |
values don't meet the specifications of the schema(s) in the following chart(s):
apicurio-registry:
- registry.image.persistenceSuffix: Invalid type. Expected: boolean, given: string
- it: imagePullSecrets is not array
set:
registry:
Expand Down
54 changes: 54 additions & 0 deletions test/unit/deployment_registry.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,60 @@ suite: test deployment-registry.yaml template
templates:
- deployment-registry.yaml
tests:
- it: use mem image
set:
registry:
image:
registry: "quay.io"
repository: "apicurio/apicurio-registry"
tag: "fakeTag"
persistenceSuffix: true
asserts:
- equal:
path: spec.template.spec.containers[0].image
value: quay.io/apicurio/apicurio-registry-mem:fakeTag
- it: use sql default image
set:
registry:
sql:
username: user
password: password
url: url
image:
registry: "quay.io"
repository: "apicurio/apicurio-registry"
tag: "fakeTag"
persistenceSuffix: true
asserts:
- equal:
path: spec.template.spec.containers[0].image
value: quay.io/apicurio/apicurio-registry-sql:fakeTag
- it: use kafka default image
set:
registry:
kafka:
bootstrapServers: kafka
image:
registry: "quay.io"
repository: "apicurio/apicurio-registry"
tag: "fakeTag"
persistenceSuffix: true
asserts:
- equal:
path: spec.template.spec.containers[0].image
value: quay.io/apicurio/apicurio-registry-kafkasql:fakeTag
- it: use customImage
set:
registry:
image:
registry: "myregistry"
repository: "myrepo/myimage"
tag: "fakeTag"
persistenceSuffix: false
asserts:
- equal:
path: spec.template.spec.containers[0].image
value: myregistry/myrepo/myimage:fakeTag
- it: set imagePullSecrets
set:
registry:
Expand Down
5 changes: 4 additions & 1 deletion values.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,10 @@
"properties": {
"registry": {"type": "string", "default": "quay.io"},
"repository": {"type": "string"},
"tag": {"type": "string"}
"tag": {"type": "string"},
"persistenceSuffix": {
"type": "boolean", "title": "Autodetect image suffix based on persistence type" , "default": true
}
}
},
"podResources": {
Expand Down
3 changes: 3 additions & 0 deletions values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ registry:
registry: "quay.io"
repository: "apicurio/apicurio-registry"
tag: "2.4.14.Final"
# Autodetect image suffix based on persistence type
# the default is true, it is used by helpers.tpl to define the image to use
persistenceSuffix: true
# optional node selector
nodeSelector: {}
# optional init containers
Expand Down

0 comments on commit 1c4cc9d

Please sign in to comment.