Skip to content

Commit

Permalink
Fix and test PFDCM_ADDRESS
Browse files Browse the repository at this point in the history
  • Loading branch information
jennydaman committed Nov 27, 2024
1 parent ca69815 commit 648e9b6
Show file tree
Hide file tree
Showing 3 changed files with 84 additions and 5 deletions.
6 changes: 4 additions & 2 deletions charts/chris/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -75,10 +75,12 @@ pfdcm stuff
*/}}

{{- define "chris.pfdcmInternalAddress" -}}
{{- if (not (and .Values.pfdcm.enabled .Values.pfdcm.service.enabled)) -}}
{{- if (not (and .Values.pfdcm.enabled)) -}}
http://localhost
{{- else if (eq .Values.pfdcm.kind "Deployment") -}}
http://{{ include "pfdcm.fullname" . }}:{{ .Values.pfdcm.service.port }}
{{- else -}}
http://{{ .Values.pfdcm.service }}-pfdcm:{{ .Values.pfdcm.service.port }}
http://{{ include "pfdcm.fullname" . }}.{{ .Release.Namespace }}.svc
{{- end -}}
{{- end -}}

6 changes: 3 additions & 3 deletions charts/chris/templates/pfdcm/_helpers.tpl
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
{{- define "pfdcm.name" -}}
{{- default .Values.pfdcm.nameOverride "pfdcm-chris" | trunc 63 | trimSuffix "-" -}}
{{- default .Values.pfdcm.nameOverride "chris-pfdcm" | trunc 63 | trimSuffix "-" -}}
{{- end -}}

{{- define "pfdcm.fullname" -}}
{{- (dict
{{- mustMerge (dict
"Values" (dict
"nameOverride" (include "pfdcm.name" .)
"fullnameOverride" .Values.pfdcm.fullnameOverride
)
) | mustMerge (omit . "Values") | include "util.fullname" -}}
) (omit . "Values") | include "util.fullname" -}}
{{- end -}}

{{- define "pfdcm.volumes" -}}
Expand Down
77 changes: 77 additions & 0 deletions charts/chris/tests/pfdcm_address_test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
suite: pfdcm address
release:
name: tpaddy
namespace: ns
templates:
- cube-config.yml
tests:
- it: should be a dummy value (http://localhost) if pfdcm is not enabled
set:
pfdcm.enabled: false
documentSelector:
path: kind
value: ConfigMap
asserts:
- equal:
path: data.PFDCM_ADDRESS
value: http://localhost
- it: should be pfdcm's service
set:
pfdcm.enabled: true
documentSelector:
path: kind
value: ConfigMap
asserts:
- equal:
path: data.PFDCM_ADDRESS
value: http://tpaddy-chris-pfdcm:4005
- it: should be pfdcm's knative qualified domain name
set:
pfdcm.enabled: true
pfdcm.kind: Service
documentSelector:
path: kind
value: ConfigMap
asserts:
- equal:
path: data.PFDCM_ADDRESS
value: http://tpaddy-chris-pfdcm.ns.svc
- it: should be able to set a custom value using cube.config
set:
pfdcm.enabled: true
cube.config.PFDCM_ADDRESS: http://manual.value
documentSelector:
path: kind
value: ConfigMap
asserts:
- equal:
path: data.PFDCM_ADDRESS
value: http://manual.value
- it: should be able to set a value when pfdcm not enabled
set:
pfdcm.enabled: false
cube.config.PFDCM_ADDRESS: http://manual.value
documentSelector:
path: kind
value: ConfigMap
asserts:
- equal:
path: data.PFDCM_ADDRESS
value: http://manual.value
- it: should be able to set a custom value using cube.secrets
set:
pfdcm.enabled: true
cube.secrets.PFDCM_ADDRESS: http://manual.value
asserts:
- notExists:
path: data.PFDCM_ADDRESS
documentSelector:
path: kind
value: ConfigMap
- equal:
path: data.PFDCM_ADDRESS
value: http://manual.value
decodeBase64: true
documentSelector:
path: kind
value: Secret

0 comments on commit 648e9b6

Please sign in to comment.