diff --git a/library/common-test/tests/ingress/rules_test.yaml b/library/common-test/tests/ingress/rules_test.yaml index db3c6876..572423a4 100644 --- a/library/common-test/tests/ingress/rules_test.yaml +++ b/library/common-test/tests/ingress/rules_test.yaml @@ -77,7 +77,8 @@ tests: - path: /test-other-path - path: /test-other-path2 overrideService: - name: other-service + name: some-other-service + expandObjectName: false port: 8080 integrations: *integrations asserts: @@ -116,7 +117,7 @@ tests: pathType: Prefix backend: service: - name: other-service + name: some-other-service port: number: 8080 @@ -194,6 +195,6 @@ tests: pathType: Prefix backend: service: - name: other-service + name: test-release-name-common-test-other-service port: number: 8080 diff --git a/library/common/Chart.yaml b/library/common/Chart.yaml index cd8eaac2..fcb93695 100644 --- a/library/common/Chart.yaml +++ b/library/common/Chart.yaml @@ -15,4 +15,4 @@ maintainers: name: common sources: null type: library -version: 16.2.24 +version: 17.0.0 diff --git a/library/common/templates/class/_ingress.tpl b/library/common/templates/class/_ingress.tpl index ea3f9a11..dd25cda3 100644 --- a/library/common/templates/class/_ingress.tpl +++ b/library/common/templates/class/_ingress.tpl @@ -61,9 +61,9 @@ spec: http: paths: {{- range $p := $h.paths -}} - {{- with $p.overrideService -}} - {{- $svcData = (dict "name" .name "port" .port) -}} - {{- end }} + {{- $svcData = (include "tc.v1.common.lib.ingress.backend.data" (dict + "rootCtx" $rootCtx "svcData" $svcData "override" $p.overrideService)) | fromYaml + }} - path: {{ tpl $p.path $rootCtx }} pathType: {{ tpl ($p.pathType | default "Prefix") $rootCtx }} backend: diff --git a/library/common/templates/lib/ingress/_serviceData.tpl b/library/common/templates/lib/ingress/_serviceData.tpl new file mode 100644 index 00000000..3b66494d --- /dev/null +++ b/library/common/templates/lib/ingress/_serviceData.tpl @@ -0,0 +1,22 @@ +{{- define "tc.v1.common.lib.ingress.backend.data" -}} + {{- $rootCtx := .rootCtx -}} + {{- $svcData := .svcData -}} + {{- $override := .override -}} + + {{- $fullname := include "tc.v1.common.lib.chart.names.fullname" $rootCtx -}} + + {{- with $override -}} + {{- $name := .name -}} + {{- $expandName := (include "tc.v1.common.lib.util.expandName" (dict + "rootCtx" $rootCtx "objectData" . "name" .name + "caller" "Ingress" "key" "overrideService" + )) -}} + + {{- if eq $expandName "true" -}} + {{- $name = (printf "%s-%s" $fullname .name) -}} + {{- end -}} + {{- $svcData = (dict "name" $name "port" .port) -}} + {{- end -}} + + {{- $svcData | toYaml -}} +{{- end -}}