|
124 | 124 | app.kubernetes.io/managed-by ("heritage") |
125 | 125 | */}} |
126 | 126 | {{- define "jupyterhub.commonLabels" -}} |
| 127 | +{{- if .legacyLabels -}} |
127 | 128 | app: {{ .appLabel | default (include "jupyterhub.appLabel" .) | quote }} |
128 | 129 | release: {{ .Release.Name | quote }} |
129 | 130 | {{- if not .matchLabels }} |
130 | 131 | chart: {{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }} |
131 | 132 | heritage: {{ .Release.Service }} |
| 133 | +{{- end }} |
| 134 | +{{- end }} |
| 135 | +{{- if and .legacyLabels .modernLabels -}} |
| 136 | +{{ printf "\n" }} |
| 137 | +{{- end }} |
| 138 | +{{- if .modernLabels -}} |
132 | 139 | app.kubernetes.io/name: {{ .appLabel | default (include "jupyterhub.appLabel" .) | quote }} |
133 | 140 | app.kubernetes.io/instance: {{ .Release.Name | quote }} |
| 141 | +{{- if not .matchLabels }} |
134 | 142 | helm.sh/chart: {{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }} |
135 | 143 | app.kubernetes.io/managed-by: {{ .Release.Service }} |
136 | 144 | {{- end }} |
137 | 145 | {{- end }} |
| 146 | +{{- end }} |
138 | 147 |
|
139 | 148 |
|
140 | 149 | {{- /* |
141 | 150 | jupyterhub.labels: |
142 | | - Provides old labels: |
| 151 | + Provides labels conditionally on .legacyLabels, .modernLabels, and .matchLabels, |
| 152 | + that are supposed to in the scoped passed this helper function. |
| 153 | +
|
| 154 | + The legacy labels are: |
143 | 155 | component |
144 | 156 | app |
145 | 157 | release |
146 | 158 | chart (omitted for matchLabels) |
147 | 159 | heritage (omitted for matchLabels) |
148 | | - Provides modern labels (omitted for matchLabels): |
149 | | - app.kubernetes.io/component ("component") |
150 | | - app.kubernetes.io/name ("app") |
151 | | - app.kubernetes.io/instance release ("release") |
152 | | - helm.sh/chart ("chart") |
153 | | - app.kubernetes.io/managed-by ("heritage") |
| 160 | +
|
| 161 | + The equivalent modern labels are: |
| 162 | + app.kubernetes.io/component |
| 163 | + app.kubernetes.io/name |
| 164 | + app.kubernetes.io/instance release |
| 165 | + helm.sh/chart (omitted for matchLabels) |
| 166 | + app.kubernetes.io/managed-by (omitted for matchLabels) |
154 | 167 | */}} |
155 | 168 | {{- define "jupyterhub.labels" -}} |
| 169 | +{{- /* |
| 170 | + .legacyLabels defaults to true |
| 171 | + .modernLabels defaults to false |
| 172 | +*/ -}} |
| 173 | +{{- $_ := . -}} |
| 174 | +{{- if typeIs "<nil>" .legacyLabels -}} |
| 175 | +{{- $_ = merge (dict "legacyLabels" true) $_ -}} |
| 176 | +{{- end -}} |
| 177 | +{{- if typeIs "<nil>" .modernLabels -}} |
| 178 | +{{- $_ = merge (dict "modernLabels" true) $_ -}} |
| 179 | +{{- end -}} |
| 180 | +
|
| 181 | +{{- if $_.legacyLabels -}} |
156 | 182 | component: {{ include "jupyterhub.componentLabel" . }} |
157 | | -{{- if not .matchLabels }} |
| 183 | +{{- end }} |
| 184 | +
|
| 185 | +{{- if and $_.legacyLabels $_.modernLabels -}} |
| 186 | +{{ printf "\n" }} |
| 187 | +{{- end }} |
| 188 | +
|
| 189 | +{{- if $_.modernLabels -}} |
158 | 190 | app.kubernetes.io/component: {{ include "jupyterhub.componentLabel" . }} |
159 | 191 | {{- end }} |
160 | | -{{ include "jupyterhub.commonLabels" . }} |
| 192 | +{{ include "jupyterhub.commonLabels" $_ }} |
161 | 193 | {{- end }} |
162 | 194 |
|
163 | 195 |
|
164 | 196 | {{- /* |
165 | 197 | jupyterhub.matchLabels: |
166 | | - Provides old labels: |
| 198 | + Provides legacy labels: |
167 | 199 | component |
168 | 200 | app |
169 | 201 | release |
170 | 202 | */}} |
171 | 203 | {{- define "jupyterhub.matchLabels" -}} |
172 | | -{{- $_ := merge (dict "matchLabels" true) . -}} |
| 204 | +{{- $_ := merge (dict "matchLabels" true "legacyLabels" true "modernLabels" false) . -}} |
| 205 | +{{ include "jupyterhub.labels" $_ }} |
| 206 | +{{- end }} |
| 207 | +
|
| 208 | +
|
| 209 | +{{- /* |
| 210 | + jupyterhub.matchLabelsModern: |
| 211 | + Provides modern labels: |
| 212 | + app.kubernetes.io/component |
| 213 | + app.kubernetes.io/name |
| 214 | + app.kubernetes.io/instance |
| 215 | +*/}} |
| 216 | +{{- define "jupyterhub.matchLabelsModern" -}} |
| 217 | +{{- $_ := merge (dict "matchLabels" true "legacyLabels" false "modernLabels" true) . -}} |
| 218 | +{{ include "jupyterhub.labels" $_ }} |
| 219 | +{{- end }} |
| 220 | +
|
| 221 | +
|
| 222 | +{{- /* |
| 223 | + jupyterhub.matchLabelsLegacyAndModern: |
| 224 | + Provides legacy and modern labels: |
| 225 | + component |
| 226 | + app |
| 227 | + release |
| 228 | + app.kubernetes.io/component |
| 229 | + app.kubernetes.io/name |
| 230 | + app.kubernetes.io/instance |
| 231 | +*/}} |
| 232 | +{{- define "jupyterhub.matchLabelsLegacyAndModern" -}} |
| 233 | +{{- $_ := merge (dict "matchLabels" true "legacyLabels" true "modernLabels" true) . -}} |
173 | 234 | {{ include "jupyterhub.labels" $_ }} |
174 | 235 | {{- end }} |
175 | 236 |
|
|
0 commit comments