|
| 1 | +{{/* vim: set filetype=mustache: */}} |
| 2 | +{{/* |
| 3 | +Expand the name of the chart. |
| 4 | +*/}} |
| 5 | +{{- define "nri-prometheus.name" -}} |
| 6 | +{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" -}} |
| 7 | +{{- end -}} |
| 8 | + |
| 9 | +{{/* |
| 10 | +Create a default fully qualified app name. |
| 11 | +We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec). |
| 12 | +If release name contains chart name it will be used as a full name. |
| 13 | +*/}} |
| 14 | +{{- define "nri-prometheus.fullname" -}} |
| 15 | +{{- if .Values.fullnameOverride -}} |
| 16 | +{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" -}} |
| 17 | +{{- else -}} |
| 18 | +{{- $name := default .Chart.Name .Values.nameOverride -}} |
| 19 | +{{- if contains $name .Release.Name -}} |
| 20 | +{{- .Release.Name | trunc 63 | trimSuffix "-" -}} |
| 21 | +{{- else -}} |
| 22 | +{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" -}} |
| 23 | +{{- end -}} |
| 24 | +{{- end -}} |
| 25 | +{{- end -}} |
| 26 | + |
| 27 | +{{/* |
| 28 | +Create chart name and version as used by the chart label. |
| 29 | +*/}} |
| 30 | +{{- define "nri-prometheus.chart" -}} |
| 31 | +{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" -}} |
| 32 | +{{- end -}} |
| 33 | + |
| 34 | +{{/* |
| 35 | +Common labels |
| 36 | +*/}} |
| 37 | +{{- define "nri-prometheus.labels" -}} |
| 38 | +app.kubernetes.io/name: {{ include "nri-prometheus.name" . }} |
| 39 | +helm.sh/chart: {{ include "nri-prometheus.chart" . }} |
| 40 | +app.kubernetes.io/instance: {{ .Release.Name }} |
| 41 | +{{- if .Chart.AppVersion }} |
| 42 | +app.kubernetes.io/version: {{ .Chart.AppVersion | quote }} |
| 43 | +{{- end }} |
| 44 | +app.kubernetes.io/managed-by: {{ .Release.Service }} |
| 45 | +{{- end -}} |
| 46 | + |
| 47 | +{{/* |
| 48 | +Create the name of the service account to use |
| 49 | +*/}} |
| 50 | +{{- define "nri-prometheus.serviceAccountName" -}} |
| 51 | +{{- if .Values.serviceAccount.create -}} |
| 52 | +{{ default (include "nri-prometheus.name" .) .Values.serviceAccount.name }} |
| 53 | +{{- else -}} |
| 54 | +{{ default "default" .Values.serviceAccount.name }} |
| 55 | +{{- end -}} |
| 56 | +{{- end -}} |
| 57 | + |
| 58 | +{{/* |
| 59 | +Return the licenseKey |
| 60 | +*/}} |
| 61 | +{{- define "nri-prometheus.licenseKey" -}} |
| 62 | +{{- if .Values.global}} |
| 63 | + {{- if .Values.global.licenseKey }} |
| 64 | + {{- .Values.global.licenseKey -}} |
| 65 | + {{- else -}} |
| 66 | + {{- .Values.licenseKey | default "" -}} |
| 67 | + {{- end -}} |
| 68 | +{{- else -}} |
| 69 | + {{- .Values.licenseKey | default "" -}} |
| 70 | +{{- end -}} |
| 71 | +{{- end -}} |
| 72 | + |
| 73 | +{{/* |
| 74 | +Return the cluster |
| 75 | +*/}} |
| 76 | +{{- define "nri-prometheus.cluster" -}} |
| 77 | +{{- if .Values.global -}} |
| 78 | + {{- if .Values.global.cluster -}} |
| 79 | + {{- .Values.global.cluster -}} |
| 80 | + {{- else -}} |
| 81 | + {{- .Values.cluster | default "" -}} |
| 82 | + {{- end -}} |
| 83 | +{{- else -}} |
| 84 | + {{- .Values.cluster | default "" -}} |
| 85 | +{{- end -}} |
| 86 | +{{- end -}} |
| 87 | + |
| 88 | +{{/* |
| 89 | +Return the customSecretName |
| 90 | +*/}} |
| 91 | +{{- define "nri-prometheus.customSecretName" -}} |
| 92 | +{{- if .Values.global }} |
| 93 | + {{- if .Values.global.customSecretName }} |
| 94 | + {{- .Values.global.customSecretName -}} |
| 95 | + {{- else -}} |
| 96 | + {{- .Values.customSecretName | default "" -}} |
| 97 | + {{- end -}} |
| 98 | +{{- else -}} |
| 99 | + {{- .Values.customSecretName | default "" -}} |
| 100 | +{{- end -}} |
| 101 | +{{- end -}} |
| 102 | + |
| 103 | +{{/* |
| 104 | +Return the customSecretLicenseKey |
| 105 | +*/}} |
| 106 | +{{- define "nri-prometheus.customSecretLicenseKey" -}} |
| 107 | +{{- if .Values.global }} |
| 108 | + {{- if .Values.global.customSecretLicenseKey }} |
| 109 | + {{- .Values.global.customSecretLicenseKey -}} |
| 110 | + {{- else -}} |
| 111 | + {{- .Values.customSecretLicenseKey | default "" -}} |
| 112 | + {{- end -}} |
| 113 | +{{- else -}} |
| 114 | + {{- .Values.customSecretLicenseKey | default "" -}} |
| 115 | +{{- end -}} |
| 116 | +{{- end -}} |
| 117 | + |
| 118 | +{{/* |
| 119 | +Returns if the template should render, it checks if the required values |
| 120 | +licenseKey and cluster are set. |
| 121 | +*/}} |
| 122 | +{{- define "nri-prometheus.areValuesValid" -}} |
| 123 | +{{- $cluster := include "nri-prometheus.cluster" . -}} |
| 124 | +{{- $licenseKey := include "nri-prometheus.licenseKey" . -}} |
| 125 | +{{- $customSecretName := include "nri-prometheus.customSecretName" . -}} |
| 126 | +{{- $customSecretLicenseKey := include "nri-prometheus.customSecretLicenseKey" . -}} |
| 127 | +{{- and (or $licenseKey (and $customSecretName $customSecretLicenseKey)) $cluster}} |
| 128 | +{{- end -}} |
0 commit comments