fix(service-monitor): invalid config.metrics.TOKEN for nil and empty gitea.metrics.token

This commit is contained in:
Hitesh Nayak 2024-10-24 02:42:06 +05:30
parent c0fdc1ea0b
commit a8984b9a98
No known key found for this signature in database
GPG Key ID: D1EE65392CD1E987
2 changed files with 27 additions and 1 deletions

View File

@ -278,7 +278,7 @@ https
{{- if not (hasKey .Values.gitea.config.metrics "ENABLED") -}}
{{- $_ := set .Values.gitea.config.metrics "ENABLED" .Values.gitea.metrics.enabled -}}
{{- end -}}
{{- if not (hasKey .Values.gitea.config.metrics "TOKEN") -}}
{{- if and (not (hasKey .Values.gitea.config.metrics "TOKEN")) (.Values.gitea.metrics.token) -}}
{{- $_ := set .Values.gitea.config.metrics "TOKEN" .Values.gitea.metrics.token -}}
{{- end -}}
{{- /* redis queue */ -}}

View File

@ -17,3 +17,29 @@ tests:
value: |-
ENABLED=true
TOKEN=somepassword
- it: metrics token is empty
template: templates/gitea/config.yaml
set:
gitea:
metrics:
enabled: true
token: ""
asserts:
- documentIndex: 0
equal:
path: stringData.metrics
value: |-
ENABLED=true
- it: metrics token is nil
template: templates/gitea/config.yaml
set:
gitea:
metrics:
enabled: true
token:
asserts:
- documentIndex: 0
equal:
path: stringData.metrics
value: |-
ENABLED=true