X-Git-Url: https://gerrit.onap.org/r/gitweb?a=blobdiff_plain;f=kubernetes%2Fcommon%2Fcommon%2Ftemplates%2F_labels.tpl;h=a690acd141f2db78ae35a4a012a1296a01555936;hb=refs%2Fheads%2Fmaster;hp=854019c1977400bbed74d7b04ed87bdeee0790c8;hpb=8af6e787bd1bde1bfbcfc662643982c1ab4ee8a2;p=oom.git diff --git a/kubernetes/common/common/templates/_labels.tpl b/kubernetes/common/common/templates/_labels.tpl index 854019c197..a690acd141 100644 --- a/kubernetes/common/common/templates/_labels.tpl +++ b/kubernetes/common/common/templates/_labels.tpl @@ -1,5 +1,6 @@ {{/* # Copyright © 2019 Orange +# Modifications Copyright (C) 2022 Bell Canada # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -25,12 +26,20 @@ The function takes several arguments (inside a dictionary): {{- define "common.labels" -}} {{- $dot := default . .dot -}} app.kubernetes.io/name: {{ include "common.name" $dot }} +app: {{ include "common.name" $dot }} +{{- if $dot.Chart.AppVersion }} +version: "{{ $dot.Chart.AppVersion | replace "+" "_" }}" +{{- else }} +version: "{{ $dot.Chart.Version | replace "+" "_" }}" +{{- end }} +{{ if not .ignoreHelmChart }} helm.sh/chart: {{ include "common.chart" $dot }} +{{- end }} app.kubernetes.io/instance: {{ include "common.release" $dot }} app.kubernetes.io/managed-by: {{ $dot.Release.Service }} {{ if .labels }} {{- include "common.tplValue" (dict "value" .labels "context" $dot) }} -{{- end -}} +{{- end }} {{- end -}} {{/* @@ -41,14 +50,15 @@ The function takes several arguments (inside a dictionary): */}} {{- define "common.matchLabels" -}} {{- $dot := default . .dot -}} -{{- if not .matchLabels.nameNoMatch -}} +{{- $matchLabels := default (dict) .matchLabels -}} +{{- if not $matchLabels.nameNoMatch -}} app.kubernetes.io/name: {{ include "common.name" $dot }} {{- end }} app.kubernetes.io/instance: {{ include "common.release" $dot }} -{{ if .matchLabels }} -{{$_ := unset .matchLabels "nameNoMatch"}} -{{- include "common.tplValue" (dict "value" .matchLabels "context" $dot) }} -{{- end -}} +{{- if $matchLabels }} +{{$_ := unset $matchLabels "nameNoMatch"}} +{{- include "common.tplValue" (dict "value" $matchLabels "context" $dot) }} +{{- end }} {{- end -}} {{/* @@ -63,10 +73,13 @@ app.kubernetes.io/instance: {{ include "common.release" $dot }} {{- $dot := default . .dot -}} {{- $suffix := default "" .suffix -}} {{- $labels := default (dict) .labels -}} - +{{- $annotations := default (dict) .annotations -}} name: {{ include "common.fullname" (dict "suffix" $suffix "dot" $dot )}} namespace: {{ include "common.namespace" $dot }} -labels: {{- include "common.labels" (dict "labels" $labels "dot" $dot ) | nindent 2 }} +labels: {{- include "common.labels" (dict "labels" $labels "ignoreHelmChart" .ignoreHelmChart "dot" $dot ) | nindent 2 }} +{{- if $annotations }} +annotations: {{- include "common.tplValue" (dict "value" $annotations "context" $dot) | nindent 2}} +{{- end }} {{- end -}} {{/* @@ -91,8 +104,8 @@ matchLabels: {{- include "common.matchLabels" (dict "matchLabels" $matchLabels " {{- $dot := default . .dot -}} {{- $labels := default (dict) .labels -}} {{- if $dot.Values.podAnnotations }} -annotations: {{- include "common.tplValue" (dict "value" $dot.Values.podAnnotations "context" $) | nindent 2 }} +annotations: {{- include "common.tplValue" (dict "value" $dot.Values.podAnnotations "context" $dot) | nindent 2 }} {{- end }} -labels: {{- include "common.labels" (dict "labels" $labels "dot" $dot) | nindent 2 }} +labels: {{- include "common.labels" (dict "labels" $labels "ignoreHelmChart" .ignoreHelmChart "dot" $dot) | nindent 2 }} name: {{ include "common.name" $dot }} {{- end -}}