From 19f72a5dd9e2989ca0e25ce863902fa581bc3186 Mon Sep 17 00:00:00 2001 From: Moritz Rieger Date: Sat, 11 Nov 2023 03:35:31 +0100 Subject: [PATCH] Provider related custom pricing config file name (#144) * Provider related custom pricing config file name RESOLVES: #129 * Bump version --------- Co-authored-by: Moritz Rieger Co-authored-by: Tony Scott --- charts/opencost/Chart.yaml | 2 +- charts/opencost/templates/_helpers.tpl | 11 +++++++++++ .../opencost/templates/configmap-custom-pricing.yaml | 2 +- 3 files changed, 13 insertions(+), 2 deletions(-) diff --git a/charts/opencost/Chart.yaml b/charts/opencost/Chart.yaml index 38d99d3..2110c79 100755 --- a/charts/opencost/Chart.yaml +++ b/charts/opencost/Chart.yaml @@ -9,7 +9,7 @@ keywords: - kubecost - opencost - monitoring -version: 1.26.1 +version: 1.26.2 maintainers: - name: mattray url: https://mattray.dev diff --git a/charts/opencost/templates/_helpers.tpl b/charts/opencost/templates/_helpers.tpl index a2faf8a..32d46cf 100644 --- a/charts/opencost/templates/_helpers.tpl +++ b/charts/opencost/templates/_helpers.tpl @@ -123,3 +123,14 @@ Check that the config is valid {{- end -}} {{- end -}} {{- end -}} + +{{/* +Define opencost config file name +*/}} +{{- define "opencost.configFileName" -}} + {{- if eq .Values.opencost.customPricing.provider "custom" -}} + {{- print "default" -}} + {{- else -}} + {{- .Values.opencost.customPricing.provider -}} + {{- end -}} +{{- end -}} diff --git a/charts/opencost/templates/configmap-custom-pricing.yaml b/charts/opencost/templates/configmap-custom-pricing.yaml index d4f2ab6..8f2bae0 100644 --- a/charts/opencost/templates/configmap-custom-pricing.yaml +++ b/charts/opencost/templates/configmap-custom-pricing.yaml @@ -4,7 +4,7 @@ kind: ConfigMap metadata: name: {{ .Values.opencost.customPricing.configmapName }} data: - default.json: |- + {{ include "opencost.configFileName" . }}.json: |- { {{- range $key, $val := .Values.opencost.customPricing.costModel }} {{ $key | quote | indent 6}}: {{ $val | quote }},