Repository navigation
Release rstudio-library 0.1.39 with Gateway API helpers #982
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
jaygalvin
wants to merge
5
commits into
main
Choose a base branch
from
rstudio-library-0.1.38
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
95c6df7
Add Gateway API helpers to rstudio-library 0.1.38
jaygalvin 1f4be0d
Bump rstudio-library-test to 0.1.2
jaygalvin 5c5dc6c
Add unit tests for the Gateway API helpers
jaygalvin fb38194
Merge main; reject unsupported Gateway path types, keep HTTPRoute nam…
jaygalvin 2a35d21
Fail the render for a non-numeric Gateway API backendRef port
jaygalvin File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,82 @@ | ||
| {{- /* | ||
| Gateway API group/version for HTTPRoute and related resources | ||
| */ -}} | ||
| {{- define "rstudio-library.gateway.apiVersion" -}} | ||
| gateway.networking.k8s.io/v1 | ||
| {{- end -}} | ||
|
|
||
| {{- /* | ||
| Map Ingress pathType values to Gateway API HTTPPathMatch type values. | ||
| Takes the pathType string. An empty value means Prefix. | ||
| Accepted: Prefix, PathPrefix, Exact, RegularExpression. | ||
| Gateway API has no ImplementationSpecific path type, so that value fails the render, | ||
| and so does any unknown value. A typo must not silently match different paths. | ||
| */ -}} | ||
| {{- define "rstudio-library.gateway.ingressPathTypeToGateway" -}} | ||
| {{- $t := . | default "Prefix" | toString -}} | ||
| {{- if or (eq $t "Prefix") (eq $t "PathPrefix") -}} | ||
| PathPrefix | ||
| {{- else if eq $t "Exact" -}} | ||
| Exact | ||
| {{- else if eq $t "RegularExpression" -}} | ||
| RegularExpression | ||
| {{- else if eq $t "ImplementationSpecific" -}} | ||
| {{- fail "gatewayApi path type \"ImplementationSpecific\" is not supported: Gateway API has no equivalent. Use Prefix, Exact, or RegularExpression." -}} | ||
| {{- else -}} | ||
| {{- fail (printf "unknown gatewayApi path type %q: use Prefix, PathPrefix, Exact, or RegularExpression" $t) -}} | ||
| {{- end -}} | ||
| {{- end -}} | ||
|
|
||
| {{- /* | ||
| YAML body for HTTPPathMatch (path.type and path.value), indented under "path:". | ||
| Takes a dict: | ||
| "pathData" — same as ingress path entry: string or map with .path and optional .pathType | ||
| */ -}} | ||
| {{- define "rstudio-library.gateway.httpPathMatchBody" -}} | ||
| {{- $pathData := .pathData -}} | ||
| {{- $path := "/" -}} | ||
| {{- $pathType := "Prefix" -}} | ||
| {{- if kindIs "string" $pathData -}} | ||
| {{- $path = $pathData -}} | ||
| {{- else -}} | ||
| {{- $path = $pathData.path -}} | ||
| {{- if hasKey $pathData "pathType" -}} | ||
| {{- $pathType = $pathData.pathType | default "Prefix" -}} | ||
| {{- end -}} | ||
| {{- end -}} | ||
| type: {{ include "rstudio-library.gateway.ingressPathTypeToGateway" $pathType }} | ||
| value: {{ $path | quote }} | ||
| {{- end -}} | ||
|
|
||
| {{- /* | ||
| Kubernetes-safe HTTPRoute name from release fullname and host index (DNS-1123, max 63 chars). | ||
| Takes a dict: "fullName" and "index" (int). | ||
| A name that fits is "<fullName>-gw-<index>". A longer name is shortened and gets | ||
| an 8-character hash of the whole fullName, so two long names that share a prefix stay unique. | ||
| */ -}} | ||
| {{- define "rstudio-library.gateway.httpRouteName" -}} | ||
| {{- $fullName := .fullName | toString -}} | ||
| {{- $idx := int .index -}} | ||
| {{- $plain := printf "%s-gw-%d" $fullName $idx -}} | ||
| {{- if le (len $plain) 63 -}} | ||
| {{- $plain -}} | ||
| {{- else -}} | ||
| {{- $suffix := printf "-%s-gw-%d" (sha256sum $fullName | trunc 8) $idx -}} | ||
| {{- printf "%s%s" ($fullName | trunc (int (sub 63 (len $suffix))) | trimSuffix "-") $suffix -}} | ||
| {{- end -}} | ||
| {{- end -}} | ||
|
|
||
| {{- /* | ||
| Service backendRef for HTTPRoute. The port must be numeric for standard Service refs, | ||
| so a named port fails the render instead of becoming port 0. | ||
| Takes a dict: "svcName", "svcPort" | ||
| */ -}} | ||
| {{- define "rstudio-library.gateway.serviceBackendRef" -}} | ||
| {{- $svcName := .svcName -}} | ||
| {{- $svcPort := .svcPort -}} | ||
| {{- if not (regexMatch "^[0-9]+$" (toString $svcPort)) -}} | ||
| {{- fail (printf "gatewayApi backendRef service port %q must be a number. Gateway API does not accept named Service ports." (toString $svcPort)) -}} | ||
| {{- end -}} | ||
| - name: {{ $svcName }} | ||
| port: {{ $svcPort | int }} | ||
| {{- end -}} | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,6 +1,6 @@ | ||
| dependencies: | ||
| - name: rstudio-library | ||
| repository: file://../../charts/rstudio-library | ||
| version: 0.1.38 | ||
| digest: sha256:c4509e159bcf8fdb934a720ebc558bafad7db2687414568b81c76183563b6e9d | ||
| generated: "2026-12-01T14:20:35.390716-05:00" | ||
| version: 0.1.39 | ||
| digest: sha256:6fa9aff2741c37a4ce410e9e7521a0b46391da6ca5ae08e5d52c963eb034e414 | ||
| generated: "2026-12-01T14:52:49.474612-08:00" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
76 changes: 76 additions & 0 deletions
76
other-charts/rstudio-library-test/templates/test-gateway.yaml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,76 @@ | ||
| {{/* | ||
| Test templates for rstudio-library Gateway API helpers. | ||
| Outputs computed Gateway API values to ConfigMaps for testing. | ||
| */}} | ||
|
|
||
| {{- if .Values.testGateway }} | ||
| --- | ||
| apiVersion: v1 | ||
| kind: ConfigMap | ||
| metadata: | ||
| name: test-gateway-values | ||
| labels: | ||
| {{- include "rstudio-library-test.labels" . | nindent 4 }} | ||
| data: | ||
| apiVersion: {{ include "rstudio-library.gateway.apiVersion" . }} | ||
| --- | ||
| apiVersion: v1 | ||
| kind: ConfigMap | ||
| metadata: | ||
| name: test-gateway-path-types | ||
| labels: | ||
| {{- include "rstudio-library-test.labels" . | nindent 4 }} | ||
| data: | ||
| {{- range $i, $t := .Values.testGateway.pathTypes }} | ||
| type-{{ $i }}: {{ include "rstudio-library.gateway.ingressPathTypeToGateway" $t | quote }} | ||
| {{- end }} | ||
| --- | ||
| apiVersion: v1 | ||
| kind: ConfigMap | ||
| metadata: | ||
| name: test-gateway-path-string | ||
| labels: | ||
| {{- include "rstudio-library-test.labels" . | nindent 4 }} | ||
| data: | ||
| path.yaml: | | ||
| {{- include "rstudio-library.gateway.httpPathMatchBody" (dict "pathData" .Values.testGateway.path) | nindent 4 }} | ||
| --- | ||
| apiVersion: v1 | ||
| kind: ConfigMap | ||
| metadata: | ||
| name: test-gateway-path-object | ||
| labels: | ||
| {{- include "rstudio-library-test.labels" . | nindent 4 }} | ||
| data: | ||
| path.yaml: | | ||
| {{- include "rstudio-library.gateway.httpPathMatchBody" (dict "pathData" (dict "path" .Values.testGateway.path "pathType" .Values.testGateway.pathType)) | nindent 4 }} | ||
| --- | ||
| apiVersion: v1 | ||
| kind: ConfigMap | ||
| metadata: | ||
| name: test-gateway-path-object-no-type | ||
| labels: | ||
| {{- include "rstudio-library-test.labels" . | nindent 4 }} | ||
| data: | ||
| path.yaml: | | ||
| {{- include "rstudio-library.gateway.httpPathMatchBody" (dict "pathData" (dict "path" .Values.testGateway.path)) | nindent 4 }} | ||
| --- | ||
| apiVersion: v1 | ||
| kind: ConfigMap | ||
| metadata: | ||
| name: test-gateway-route-name | ||
| labels: | ||
| {{- include "rstudio-library-test.labels" . | nindent 4 }} | ||
| data: | ||
| name: {{ include "rstudio-library.gateway.httpRouteName" (dict "fullName" .Values.testGateway.fullName "index" .Values.testGateway.index) | quote }} | ||
| --- | ||
| apiVersion: v1 | ||
| kind: ConfigMap | ||
| metadata: | ||
| name: test-gateway-backend | ||
| labels: | ||
| {{- include "rstudio-library-test.labels" . | nindent 4 }} | ||
| data: | ||
| backend.yaml: | | ||
| {{- include "rstudio-library.gateway.serviceBackendRef" (dict "svcName" .Values.testGateway.serviceName "svcPort" .Values.testGateway.servicePort) | nindent 4 }} | ||
| {{- end }} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -11,6 +11,8 @@ testConfig: | |
|
|
||
| testIngress: null | ||
|
|
||
| testGateway: null | ||
|
|
||
| testLicense: null | ||
|
|
||
| testRbac: null | ||
|
|
||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.