github.com/verrazzano/verrazzano@v1.7.0/platform-operator/thirdparty/charts/prometheus-community/prometheus-adapter/templates/_helpers.tpl (about)

     1  {{/* vim: set filetype=mustache: */}}
     2  {{/*
     3  Expand the name of the chart.
     4  */}}
     5  {{- define "k8s-prometheus-adapter.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 "k8s-prometheus-adapter.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  Allow the release namespace to be overridden for multi-namespace deployments in combined charts
    29  */}}
    30  {{- define "k8s-prometheus-adapter.namespace" -}}
    31  {{- default .Release.Namespace .Values.namespaceOverride -}}
    32  {{- end -}}
    33  
    34  {{/*
    35  Create chart name and version as used by the chart label.
    36  */}}
    37  {{- define "k8s-prometheus-adapter.chart" -}}
    38  {{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" -}}
    39  {{- end -}}
    40  
    41  {{/*
    42  Generate basic labels
    43  */}}
    44  {{- define "k8s-prometheus-adapter.labels" }}
    45  helm.sh/chart: {{ include "k8s-prometheus-adapter.chart" . }}
    46  app.kubernetes.io/managed-by: {{ .Release.Service }}
    47  app.kubernetes.io/component: metrics
    48  app.kubernetes.io/part-of: {{ template "k8s-prometheus-adapter.name" . }}
    49  {{- include "k8s-prometheus-adapter.selectorLabels" . }}
    50  {{- if .Chart.AppVersion }}
    51  app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
    52  {{- end }}
    53  {{- if .Values.customLabels }}
    54  {{ toYaml .Values.customLabels }}
    55  {{- end }}
    56  {{- end }}
    57  
    58  {{/*
    59  Selector labels
    60  */}}
    61  {{- define "k8s-prometheus-adapter.selectorLabels" }}
    62  app.kubernetes.io/name: {{ include "k8s-prometheus-adapter.name" . }}
    63  app.kubernetes.io/instance: {{ .Release.Name }}
    64  {{- end }}
    65  
    66  {{/*
    67  Create the name of the service account to use
    68  */}}
    69  {{- define "k8s-prometheus-adapter.serviceAccountName" -}}
    70  {{- if .Values.serviceAccount.create -}}
    71      {{ default (include "k8s-prometheus-adapter.fullname" .) .Values.serviceAccount.name }}
    72  {{- else -}}
    73      {{ default "default" .Values.serviceAccount.name }}
    74  {{- end -}}
    75  {{- end -}}
    76  
    77  {{/* Get Policy API Version */}}
    78  {{- define "k8s-prometheus-adapter.pdb.apiVersion" -}}
    79  {{- if and (.Capabilities.APIVersions.Has "policy/v1") (semverCompare ">= 1.21-0" .Capabilities.KubeVersion.Version) -}}
    80      {{- print "policy/v1" -}}
    81  {{- else -}}
    82      {{- print "policy/v1beta1" -}}
    83  {{- end -}}
    84  {{- end -}}