From d08d087cae342bc6497e458c0719ccc7e76812d7 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sat, 7 Feb 2026 16:12:20 +0000 Subject: [PATCH 1/5] Initial plan From 5f74030e42955b8194d72154c32d2350c5bb6777 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sat, 7 Feb 2026 16:17:19 +0000 Subject: [PATCH 2/5] Fix httpRoute port to be integer instead of string Co-authored-by: aslafy-z <8191198+aslafy-z@users.noreply.github.com> --- application/tests/httproute_test.yaml | 37 +++++++++++++++++++++++++++ application/values.yaml | 2 +- 2 files changed, 38 insertions(+), 1 deletion(-) diff --git a/application/tests/httproute_test.yaml b/application/tests/httproute_test.yaml index 38fb51dd..1cc7a182 100644 --- a/application/tests/httproute_test.yaml +++ b/application/tests/httproute_test.yaml @@ -280,3 +280,40 @@ tests: - equal: path: spec.rules[0].filters[0].requestRedirect.port value: 443 + + - it: renders HTTPRoute with default service port when using template expression + set: + applicationName: "test-app" + httpRoute: + enabled: true + parentRefs: + - name: my-gateway + hostnames: + - example.com + rules: + - matches: + - path: + type: PathPrefix + value: / + backendRefs: + - name: '{{ include "application.name" $ }}' + port: 8080 + service: + enabled: true + ports: + - port: 8080 + name: http + protocol: TCP + targetPort: 8080 + capabilities: + apiVersions: + - gateway.networking.k8s.io/v1 + asserts: + - equal: + path: spec.rules[0].backendRefs[0].name + value: test-app + - equal: + path: spec.rules[0].backendRefs[0].port + value: 8080 + - isKind: + of: HTTPRoute diff --git a/application/values.yaml b/application/values.yaml index 50f459da..74912817 100644 --- a/application/values.yaml +++ b/application/values.yaml @@ -641,7 +641,7 @@ httpRoute: value: / backendRefs: - name: '{{ include "application.name" $ }}' - port: '{{ (first $.Values.service.ports).port | int }}' + port: 8080 route: # -- (bool) Deploy a Route (OpenShift) resource. From 60af0fb55ffa1eeea0dd105bede8619d0482219f Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sat, 7 Feb 2026 16:18:00 +0000 Subject: [PATCH 3/5] Update README documentation for httpRoute port fix Co-authored-by: aslafy-z <8191198+aslafy-z@users.noreply.github.com> --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 9b9d3de5..1413bbc9 100644 --- a/README.md +++ b/README.md @@ -185,7 +185,7 @@ helm delete --namespace test my-application | httpRoute.hostnames | tpl/list | `nil` | Hostnames for the HTTPRoute. | | httpRoute.additionalLabels | object | `{}` | Additional labels for HTTPRoute. | | httpRoute.annotations | object | `{}` | Annotations for HTTPRoute. | -| httpRoute.rules | tpl/list | `[{"backendRefs":[{"name":"{{ include \"application.name\" $ }}","port":"{{ (first $.Values.service.ports).port | int }}"}],"matches":[{"path":{"type":"PathPrefix","value":"/"}}]}]` | Rules for HTTPRoute. | +| httpRoute.rules | tpl/list | `[{"backendRefs":[{"name":"{{ include \"application.name\" $ }}","port":8080}],"matches":[{"path":{"type":"PathPrefix","value":"/"}}]}]` | Rules for HTTPRoute. | ### Route Parameters From 440c713b7a2f599fb3a2706354b46069e611c4a1 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sat, 7 Feb 2026 16:25:21 +0000 Subject: [PATCH 4/5] Fix httpRoute port to render as integer while dynamically picking service port Co-authored-by: aslafy-z <8191198+aslafy-z@users.noreply.github.com> --- README.md | 2 +- application/templates/_helpers.tpl | 34 +++++++++++++++++++++++++++ application/templates/httproute.yaml | 2 +- application/tests/httproute_test.yaml | 2 +- application/values.yaml | 2 +- 5 files changed, 38 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 1413bbc9..866c6b3f 100644 --- a/README.md +++ b/README.md @@ -185,7 +185,7 @@ helm delete --namespace test my-application | httpRoute.hostnames | tpl/list | `nil` | Hostnames for the HTTPRoute. | | httpRoute.additionalLabels | object | `{}` | Additional labels for HTTPRoute. | | httpRoute.annotations | object | `{}` | Annotations for HTTPRoute. | -| httpRoute.rules | tpl/list | `[{"backendRefs":[{"name":"{{ include \"application.name\" $ }}","port":8080}],"matches":[{"path":{"type":"PathPrefix","value":"/"}}]}]` | Rules for HTTPRoute. | +| httpRoute.rules | tpl/list | `[{"backendRefs":[{"name":"{{ include \"application.name\" $ }}","port":"{{ (first $.Values.service.ports).port }}"}],"matches":[{"path":{"type":"PathPrefix","value":"/"}}]}]` | Rules for HTTPRoute. | ### Route Parameters diff --git a/application/templates/_helpers.tpl b/application/templates/_helpers.tpl index 76ce78ac..70905aea 100644 --- a/application/templates/_helpers.tpl +++ b/application/templates/_helpers.tpl @@ -92,3 +92,37 @@ reference: kind: Route name: {{ include "application.name" . }} {{- end }} + +{{/* +Renders httpRoute rules with proper integer type for port fields. +Usage: +{{ include "application.httpRoute.rules" . }} +*/}} +{{- define "application.httpRoute.rules" -}} +{{- $rulesYaml := include "application.tplvalues.render" ( dict "value" .Values.httpRoute.rules "context" $ ) -}} +{{- $wrappedYaml := printf "rules:\n%s" $rulesYaml -}} +{{- $parsed := $wrappedYaml | fromYaml -}} +{{- range $ruleIndex, $rule := $parsed.rules -}} +{{- if $ruleIndex }} +{{ end -}} +- {{- if $rule.matches }} + matches: {{ $rule.matches | toYaml | nindent 4 }} + {{- end }} + {{- if $rule.filters }} + filters: {{ $rule.filters | toYaml | nindent 4 }} + {{- end }} + {{- if $rule.backendRefs }} + backendRefs: + {{- range $rule.backendRefs }} + - name: {{ .name }} + port: {{ .port | int }} + {{- if .weight }} + weight: {{ .weight | int }} + {{- end }} + {{- if .namespace }} + namespace: {{ .namespace }} + {{- end }} + {{- end }} + {{- end }} +{{- end -}} +{{- end -}} diff --git a/application/templates/httproute.yaml b/application/templates/httproute.yaml index 02c4ed75..107d78a3 100644 --- a/application/templates/httproute.yaml +++ b/application/templates/httproute.yaml @@ -22,5 +22,5 @@ spec: useDefaultGateways: {{ .Values.httpRoute.useDefaultGateways }} {{- end }} hostnames: {{- include "application.tplvalues.render" ( dict "value" .Values.httpRoute.hostnames "context" $ ) | nindent 4 }} - rules: {{- include "application.tplvalues.render" ( dict "value" .Values.httpRoute.rules "context" $ ) | nindent 4 }} + rules: {{- include "application.httpRoute.rules" . | nindent 4 }} {{- end }} diff --git a/application/tests/httproute_test.yaml b/application/tests/httproute_test.yaml index 1cc7a182..877fd60a 100644 --- a/application/tests/httproute_test.yaml +++ b/application/tests/httproute_test.yaml @@ -297,7 +297,7 @@ tests: value: / backendRefs: - name: '{{ include "application.name" $ }}' - port: 8080 + port: '{{ (first $.Values.service.ports).port }}' service: enabled: true ports: diff --git a/application/values.yaml b/application/values.yaml index 74912817..7dc5d682 100644 --- a/application/values.yaml +++ b/application/values.yaml @@ -641,7 +641,7 @@ httpRoute: value: / backendRefs: - name: '{{ include "application.name" $ }}' - port: 8080 + port: '{{ (first $.Values.service.ports).port }}' route: # -- (bool) Deploy a Route (OpenShift) resource. From ddae7f135d4176af6191434b7ad6880841a9786f Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sat, 7 Feb 2026 16:26:32 +0000 Subject: [PATCH 5/5] Address code review feedback: add port validation and support more HTTPRoute fields Co-authored-by: aslafy-z <8191198+aslafy-z@users.noreply.github.com> --- application/templates/_helpers.tpl | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/application/templates/_helpers.tpl b/application/templates/_helpers.tpl index 70905aea..5691e7d3 100644 --- a/application/templates/_helpers.tpl +++ b/application/templates/_helpers.tpl @@ -99,7 +99,7 @@ Usage: {{ include "application.httpRoute.rules" . }} */}} {{- define "application.httpRoute.rules" -}} -{{- $rulesYaml := include "application.tplvalues.render" ( dict "value" .Values.httpRoute.rules "context" $ ) -}} +{{- $rulesYaml := include "application.tplvalues.render" ( dict "value" .Values.httpRoute.rules "context" . ) -}} {{- $wrappedYaml := printf "rules:\n%s" $rulesYaml -}} {{- $parsed := $wrappedYaml | fromYaml -}} {{- range $ruleIndex, $rule := $parsed.rules -}} @@ -111,17 +111,33 @@ Usage: {{- if $rule.filters }} filters: {{ $rule.filters | toYaml | nindent 4 }} {{- end }} + {{- if $rule.sessionAffinity }} + sessionAffinity: {{ $rule.sessionAffinity | toYaml | nindent 4 }} + {{- end }} + {{- if $rule.timeouts }} + timeouts: {{ $rule.timeouts | toYaml | nindent 4 }} + {{- end }} {{- if $rule.backendRefs }} backendRefs: {{- range $rule.backendRefs }} + {{- $portVal := .port | int }} + {{- if or (lt $portVal 1) (gt $portVal 65535) }} + {{- fail (printf "Invalid port value: %v. Port must be between 1 and 65535" .port) }} + {{- end }} - name: {{ .name }} - port: {{ .port | int }} + port: {{ $portVal }} {{- if .weight }} weight: {{ .weight | int }} {{- end }} {{- if .namespace }} namespace: {{ .namespace }} {{- end }} + {{- if .kind }} + kind: {{ .kind }} + {{- end }} + {{- if .group }} + group: {{ .group }} + {{- end }} {{- end }} {{- end }} {{- end -}}