Skip to content

Commit 8f4db54

Browse files
committed
add fix to not render backendRefs when we have a requestredirect
Signed-off-by: Christopher Larivière <[email protected]>
1 parent ade6955 commit 8f4db54

File tree

2 files changed

+23
-18
lines changed

2 files changed

+23
-18
lines changed

charts/library/common/Chart.yaml

+2-5
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ apiVersion: v2
33
name: common
44
description: Function library for Helm charts
55
type: library
6-
version: 3.7.2
6+
version: 3.7.3
77
kubeVersion: ">=1.22.0-0"
88
keywords:
99
- common
@@ -17,7 +17,4 @@ annotations:
1717
artifacthub.io/changes: |-
1818
- kind: fixed
1919
description: |-
20-
The Apache 2.0 LICENSE file has been added to the chart.
21-
- kind: fixed
22-
description: |-
23-
Fixed non-deterministic selection of primary service and port.
20+
fixes rendering of backendRefs with RequestRedirects filters.

charts/library/common/templates/classes/_route.tpl

+21-13
Original file line numberDiff line numberDiff line change
@@ -59,26 +59,34 @@ spec:
5959
{{- end }}
6060
rules:
6161
{{- range $routeObject.rules }}
62-
- backendRefs:
63-
{{- range .backendRefs }}
64-
{{ $service := include "bjw-s.common.lib.service.getByIdentifier" (dict "rootContext" $rootContext "id" .name) | fromYaml -}}
65-
{{ $servicePrimaryPort := dict -}}
66-
{{ if $service -}}
67-
{{ $servicePrimaryPort = include "bjw-s.common.lib.service.primaryPort" (dict "rootContext" $rootContext "serviceObject" $service) | fromYaml -}}
62+
{{- $hasRequestRedirect := false -}}
63+
{{- range .filters }}
64+
{{- if eq .type "RequestRedirect" }}
65+
{{- $hasRequestRedirect = true -}}
66+
{{- end }}
67+
{{- end }}
68+
{{- if not $hasRequestRedirect }}
69+
- backendRefs:
70+
{{- range .backendRefs }}
71+
{{ $service := include "bjw-s.common.lib.service.getByIdentifier" (dict "rootContext" $rootContext "id" .name) | fromYaml -}}
72+
{{ $servicePrimaryPort := dict -}}
73+
{{ if $service -}}
74+
{{ $servicePrimaryPort = include "bjw-s.common.lib.service.primaryPort" (dict "rootContext" $rootContext "serviceObject" $service) | fromYaml -}}
75+
{{- end }}
76+
- group: {{ default "" .group | quote}}
77+
kind: {{ default "Service" .kind }}
78+
name: {{ default .name $service.name }}
79+
namespace: {{ default $rootContext.Release.Namespace .namespace }}
80+
port: {{ default .port $servicePrimaryPort.port }}
81+
weight: {{ include "bjw-s.common.lib.defaultKeepNonNullValue" (dict "value" .weight "default" 1) }}
6882
{{- end }}
69-
- group: {{ default "" .group | quote}}
70-
kind: {{ default "Service" .kind }}
71-
name: {{ default .name $service.name }}
72-
namespace: {{ default $rootContext.Release.Namespace .namespace }}
73-
port: {{ default .port $servicePrimaryPort.port }}
74-
weight: {{ include "bjw-s.common.lib.defaultKeepNonNullValue" (dict "value" .weight "default" 1) }}
7583
{{- end }}
7684
{{- if or (eq $routeKind "HTTPRoute") (eq $routeKind "GRPCRoute") }}
7785
{{- with .matches }}
7886
matches:
7987
{{- toYaml . | nindent 6 }}
8088
{{- end }}
81-
{{- with .filters }}
89+
{{- with .filters }}
8290
filters:
8391
{{- toYaml . | nindent 6 }}
8492
{{- end }}

0 commit comments

Comments
 (0)