-
Notifications
You must be signed in to change notification settings - Fork 308
Expand file tree
/
Copy path_helpers.tpl
More file actions
107 lines (95 loc) · 3.21 KB
/
_helpers.tpl
File metadata and controls
107 lines (95 loc) · 3.21 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
{{/*
Expand the name of the chart.
*/}}
{{- define "nv-ingest.name" -}}
{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" }}
{{- end }}
{{/*
Create a default fully qualified app name.
We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec).
If release name contains chart name it will be used as a full name.
*/}}
{{- define "nv-ingest.fullname" -}}
{{- if .Values.fullnameOverride }}
{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" }}
{{- else }}
{{- $name := default .Chart.Name .Values.nameOverride }}
{{- if contains $name .Release.Name }}
{{- .Release.Name | trunc 63 | trimSuffix "-" }}
{{- else }}
{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" }}
{{- end }}
{{- end }}
{{- end }}
{{/*
Create chart name and version as used by the chart label.
*/}}
{{- define "nv-ingest.chart" -}}
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }}
{{- end }}
{{/*
Common labels
*/}}
{{- define "nv-ingest.labels" -}}
helm.sh/chart: {{ include "nv-ingest.chart" . }}
{{ include "nv-ingest.selectorLabels" . }}
{{- if .Chart.AppVersion }}
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
{{- end }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
{{- end }}
{{/*
Selector labels
*/}}
{{- define "nv-ingest.selectorLabels" -}}
app.kubernetes.io/name: {{ include "nv-ingest.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
{{- end }}
{{/*
Create the name of the service account to use
*/}}
{{- define "nv-ingest.serviceAccountName" -}}
{{- if .Values.serviceAccount.create }}
{{- default (include "nv-ingest.fullname" .) .Values.serviceAccount.name }}
{{- else }}
{{- default "default" .Values.serviceAccount.name }}
{{- end }}
{{- end }}
{{/*
Create secret to access docker registry
*/}}
{{- define "nv-ingest.ngcImagePullSecret" }}
{{- printf "{\"auths\": {\"%s\": {\"auth\": \"%s\"}}}" .Values.ngcImagePullSecret.registry (printf "%s:%s" .Values.ngcImagePullSecret.username .Values.ngcImagePullSecret.password | b64enc) | b64enc }}
{{- end }}
{{/*
Create secret to access NGC Api
*/}}
{{- define "nv-ingest.ngcApiSecret" }}
{{- printf "%s" .Values.ngcApiSecret.password }}
{{- end }}
{{/*
Resolve NIM image ref/repo/tag from release.yaml.
release.yaml is intended to be passed as a Helm values file and contains:
x-nv-ingest-release:
nim:
<nimOperatorKey>:
ref: "repo:tag"
*/}}
{{- define "nv-ingest.release.nimRef" -}}
{{- $root := .root -}}
{{- $key := .key -}}
{{- $release := index $root.Values "x-nv-ingest-release" -}}
{{- if and $release (hasKey $release "nim") (hasKey (index $release "nim") $key) (hasKey (index (index $release "nim") $key) "ref") -}}
{{- index (index (index $release "nim") $key) "ref" -}}
{{- else -}}
{{- fail (printf "Missing required release.yaml value: x-nv-ingest-release.nim.%s.ref (pass -f release.yaml)" $key) -}}
{{- end -}}
{{- end -}}
{{- define "nv-ingest.release.nimRepository" -}}
{{- $ref := include "nv-ingest.release.nimRef" . -}}
{{- regexReplaceAll ":([^:]*)$" $ref "" -}}
{{- end -}}
{{- define "nv-ingest.release.nimTag" -}}
{{- $ref := include "nv-ingest.release.nimRef" . -}}
{{- regexReplaceAll "^.*:" $ref "" -}}
{{- end -}}