github.com/openebs/node-disk-manager@v1.9.1-0.20230225014141-4531f06ffa1e/deploy/helm/charts/templates/_helpers.tpl (about)

     1  {{/* vim: set filetype=mustache: */}}
     2  {{/*
     3  Expand the name of the chart.
     4  This name is used for ndm daemonset
     5  */}}
     6  {{- define "openebs-ndm.name" -}}
     7  {{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" }}
     8  {{- end }}
     9  
    10  {{/*
    11  Create chart name and version as used by the chart label.
    12  */}}
    13  {{- define "openebs-ndm.chart" -}}
    14  {{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }}
    15  {{- end }}
    16  
    17  {{/*
    18  Create a default fully qualified ndm daemonset app name.
    19  We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec).
    20  If release name contains chart name it will be used as a full name.
    21  */}}
    22  {{- define "openebs-ndm.fullname" -}}
    23  {{- if .Values.fullnameOverride }}
    24  {{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" }}
    25  {{- else }}
    26  {{- $name := default .Chart.Name .Values.nameOverride }}
    27  {{- if contains .Release.Name $name }}
    28  {{- $name | trunc 63 | trimSuffix "-" }}
    29  {{- else }}
    30  {{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" }}
    31  {{- end }}
    32  {{- end }}
    33  {{- end }}
    34  
    35  {{- define "openebs-ndm.operator.name" -}}
    36  {{- $ndmName := default .Chart.Name .Values.ndmOperator.nameOverride | trunc 63 | trimSuffix "-" }}
    37  {{- $componentName := .Values.ndmOperator.name | trunc 63 | trimSuffix "-" }}
    38  {{- printf "%s-%s" $ndmName $componentName | trunc 63 | trimSuffix "-" }}
    39  {{- end }}
    40  
    41  {{/*
    42  Create a default fully qualified ndm operator app name.
    43  We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec).
    44  If release name contains chart name it will be used as a full name.
    45  */}}
    46  {{- define "openebs-ndm.operator.fullname" -}}
    47  {{- if .Values.ndmOperator.fullnameOverride }}
    48  {{- .Values.ndmOperator.fullnameOverride | trunc 63 | trimSuffix "-" }}
    49  {{- else }}
    50  {{- $ndmOperatorName := include "openebs-ndm.operator.name" .}}
    51  
    52  {{- $name := default $ndmOperatorName .Values.ndmOperator.nameOverride }}
    53  {{- if contains .Release.Name $name }}
    54  {{- $name | trunc 63 | trimSuffix "-" }}
    55  {{- else }}
    56  {{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" }}
    57  {{- end }}
    58  {{- end }}
    59  {{- end }}
    60  
    61  {{- define "openebs-ndm.cluster-exporter.name" -}}
    62  {{- $ndmName := default .Chart.Name .Values.ndmExporter.clusterExporter.nameOverride | trunc 63 | trimSuffix "-" }}
    63  {{- $componentName := .Values.ndmExporter.clusterExporter.name | trunc 63 | trimSuffix "-" }}
    64  {{- printf "%s-%s" $ndmName $componentName | trunc 63 | trimSuffix "-" }}
    65  {{- end }}
    66  
    67  {{/*
    68  Create a default fully qualified ndm cluster exporter name.
    69  We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec).
    70  If release name contains chart name it will be used as a full name.
    71  */}}
    72  {{- define "openebs-ndm.cluster-exporter.fullname" -}}
    73  {{- if .Values.ndmExporter.clusterExporter.fullnameOverride }}
    74  {{- .Values.ndmExporter.clusterExporter.fullnameOverride | trunc 63 | trimSuffix "-" }}
    75  {{- else }}
    76  {{- $ndmClusterExporterName := include "openebs-ndm.cluster-exporter.name" .}}
    77  
    78  {{- $name := default $ndmClusterExporterName .Values.ndmExporter.clusterExporter.nameOverride }}
    79  {{- if contains .Release.Name $name }}
    80  {{- $name | trunc 63 | trimSuffix "-" }}
    81  {{- else }}
    82  {{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" }}
    83  {{- end }}
    84  {{- end }}
    85  {{- end }}
    86  
    87  {{- define "openebs-ndm.exporter.name" -}}
    88  {{- $ndmName := .Chart.Name | trunc 63 | trimSuffix "-" }}
    89  {{- $componentName := "exporter" | trunc 63 | trimSuffix "-" }}
    90  {{- printf "%s-%s" $ndmName $componentName | trunc 63 | trimSuffix "-" }}
    91  {{- end }}
    92  
    93  {{- define "openebs-ndm.node-exporter.name" -}}
    94  {{- $ndmName := default .Chart.Name .Values.ndmExporter.nodeExporter.nameOverride | trunc 63 | trimSuffix "-" }}
    95  {{- $componentName := .Values.ndmExporter.nodeExporter.name | trunc 63 | trimSuffix "-" }}
    96  {{- printf "%s-%s" $ndmName $componentName | trunc 63 | trimSuffix "-" }}
    97  {{- end }}
    98  
    99  {{/*
   100  Create a default fully qualified ndm node exporter name.
   101  We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec).
   102  If release name contains chart name it will be used as a full name.
   103  */}}
   104  {{- define "openebs-ndm.node-exporter.fullname" -}}
   105  {{- if .Values.ndmExporter.nodeExporter.fullnameOverride }}
   106  {{- .Values.ndmExporter.nodeExporter.fullnameOverride | trunc 63 | trimSuffix "-" }}
   107  {{- else }}
   108  {{- $ndmNodeExporterName := include "openebs-ndm.node-exporter.name" .}}
   109  
   110  {{- $name := default $ndmNodeExporterName .Values.ndmExporter.nodeExporter.nameOverride }}
   111  {{- if contains .Release.Name $name }}
   112  {{- $name | trunc 63 | trimSuffix "-" }}
   113  {{- else }}
   114  {{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" }}
   115  {{- end }}
   116  {{- end }}
   117  {{- end }}
   118  
   119  {{/*
   120  Create the name of the service account to use
   121  */}}
   122  {{- define "openebs-ndm.serviceAccountName" -}}
   123  {{- if .Values.serviceAccount.create }}
   124  {{- default (include "openebs-ndm.fullname" .) .Values.serviceAccount.name }}
   125  {{- else }}
   126  {{- default "default" .Values.serviceAccount.name }}
   127  {{- end }}
   128  {{- end }}
   129  
   130  {{/*
   131  Define meta labels for ndm components
   132  */}}
   133  {{- define "openebs-ndm.common.metaLabels" -}}
   134  chart: {{ template "openebs-ndm.chart" . }}
   135  heritage: {{ .Release.Service }}
   136  openebs.io/version: {{ .Values.release.version | quote }}
   137  {{- end -}}
   138  
   139  
   140  {{/*
   141  Create match labels for ndm daemonset component
   142  */}}
   143  {{- define "openebs-ndm.matchLabels" -}}
   144  app: {{ template "openebs-ndm.name" . }}
   145  release: {{ .Release.Name }}
   146  component: {{ .Values.ndm.componentName | quote }}
   147  {{- end -}}
   148  
   149  {{/*
   150  Create component labels for ndm daemonset component
   151  */}}
   152  {{- define "openebs-ndm.componentLabels" -}}
   153  openebs.io/component-name: {{ .Values.ndm.componentName | quote }}
   154  {{- end -}}
   155  
   156  
   157  {{/*
   158  Create labels for ndm daemonset component
   159  */}}
   160  {{- define "openebs-ndm.labels" -}}
   161  {{ include "openebs-ndm.common.metaLabels" . }}
   162  {{ include "openebs-ndm.matchLabels" . }}
   163  {{ include "openebs-ndm.componentLabels" . }}
   164  {{- end -}}
   165  
   166  {{/*
   167  Create match labels for ndm operator deployment
   168  */}}
   169  {{- define "openebs-ndm.operator.matchLabels" -}}
   170  app: {{ template "openebs-ndm.operator.name" . }}
   171  release: {{ .Release.Name }}
   172  component: {{ default (include "openebs-ndm.operator.name" .) .Values.ndmOperator.componentName }}
   173  {{- end -}}
   174  
   175  {{/*
   176  Create component labels for ndm operator component
   177  */}}
   178  {{- define "openebs-ndm.operator.componentLabels" -}}
   179  openebs.io/component-name: {{ default (include "openebs-ndm.operator.name" .) .Values.ndmOperator.componentName }}
   180  {{- end -}}
   181  
   182  
   183  {{/*
   184  Create labels for ndm operator component
   185  */}}
   186  {{- define "openebs-ndm.operator.labels" -}}
   187  {{ include "openebs-ndm.common.metaLabels" . }}
   188  {{ include "openebs-ndm.operator.matchLabels" . }}
   189  {{ include "openebs-ndm.operator.componentLabels" . }}
   190  {{- end -}}
   191  
   192  {{/*
   193  Create match labels for ndm cluster exporter deployment
   194  */}}
   195  {{- define "openebs-ndm.cluster-exporter.matchLabels" -}}
   196  app: {{ template "openebs-ndm.exporter.name" . }}
   197  release: {{ .Release.Name }}
   198  component: {{ default (include "openebs-ndm.cluster-exporter.name" .) .Values.ndmExporter.clusterExporter.componentName }}
   199  {{- end -}}
   200  
   201  {{/*
   202  Create component labels for ndm cluster exporter component
   203  */}}
   204  {{- define "openebs-ndm.cluster-exporter.componentLabels" -}}
   205  openebs.io/component-name: {{ default (include "openebs-ndm.cluster-exporter.name" .) .Values.ndmExporter.clusterExporter.componentName }}
   206  {{- end -}}
   207  
   208  
   209  {{/*
   210  Create labels for ndm cluster exporter component
   211  */}}
   212  {{- define "openebs-ndm.cluster-exporter.labels" -}}
   213  {{ include "openebs-ndm.common.metaLabels" . }}
   214  {{ include "openebs-ndm.cluster-exporter.matchLabels" . }}
   215  {{ include "openebs-ndm.cluster-exporter.componentLabels" . }}
   216  {{- end -}}
   217  
   218  {{/*
   219  Create match labels for ndm node exporter deployment
   220  */}}
   221  {{- define "openebs-ndm.node-exporter.matchLabels" -}}
   222  app: {{ template "openebs-ndm.exporter.name" . }}
   223  release: {{ .Release.Name }}
   224  component: {{ default (include "openebs-ndm.node-exporter.name" .) .Values.ndmExporter.nodeExporter.componentName }}
   225  {{- end -}}
   226  
   227  {{/*
   228  Create component labels for ndm node exporter component
   229  */}}
   230  {{- define "openebs-ndm.node-exporter.componentLabels" -}}
   231  openebs.io/component-name: {{ default (include "openebs-ndm.node-exporter.name" .) .Values.ndmExporter.nodeExporter.componentName }}
   232  {{- end -}}
   233  
   234  
   235  {{/*
   236  Create labels for ndm cluster node component
   237  */}}
   238  {{- define "openebs-ndm.node-exporter.labels" -}}
   239  {{ include "openebs-ndm.common.metaLabels" . }}
   240  {{ include "openebs-ndm.node-exporter.matchLabels" . }}
   241  {{ include "openebs-ndm.node-exporter.componentLabels" . }}
   242  {{- end -}}