Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion charts/rstudio-library/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ apiVersion: v2
name: rstudio-library
description: Helm library helpers for use by official RStudio charts
type: library
version: 0.1.38
version: 0.1.39
appVersion: 0.1.35

icon: https://raw.githubusercontent.com/rstudio/helm/main/images/posit-icon-fullcolor.svg
Expand Down
7 changes: 7 additions & 0 deletions charts/rstudio-library/NEWS.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# Changelog

## 0.1.39

- Add Gateway API helpers in `_gateway.tpl` (`apiVersion`, path match mapping, HTTPRoute naming, service `backendRef`).
- Fail the render for the `ImplementationSpecific` path type and for unknown path types. Gateway API has no equivalent for `ImplementationSpecific`.
- Add a hash to HTTPRoute names that exceed 63 characters, so long names that share a prefix stay unique.
- Fail the render if the `backendRef` service port is not a number, instead of rendering port 0.

## 0.1.38

- Add a namespaced `configmaps` rule (`create`, `get`, `list`, `patch`, `delete`) to the `rstudio-library.rbac` Role, so the Job Launcher Kubernetes plugin can mount inline files into session pods from a per-job ConfigMap.
Expand Down
2 changes: 1 addition & 1 deletion charts/rstudio-library/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# rstudio-library

![Version: 0.1.38](https://img.shields.io/badge/Version-0.1.38-informational?style=flat-square) ![Type: library](https://img.shields.io/badge/Type-library-informational?style=flat-square) ![AppVersion: 0.1.35](https://img.shields.io/badge/AppVersion-0.1.35-informational?style=flat-square)
![Version: 0.1.39](https://img.shields.io/badge/Version-0.1.39-informational?style=flat-square) ![Type: library](https://img.shields.io/badge/Type-library-informational?style=flat-square) ![AppVersion: 0.1.35](https://img.shields.io/badge/AppVersion-0.1.35-informational?style=flat-square)

#### _Helm library helpers for use by official RStudio charts_

Expand Down
82 changes: 82 additions & 0 deletions charts/rstudio-library/templates/_gateway.tpl
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 -}}
Comment thread
jaygalvin marked this conversation as resolved.
Resolved
{{- 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 -}}
6 changes: 3 additions & 3 deletions other-charts/rstudio-library-test/Chart.lock
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"
2 changes: 1 addition & 1 deletion other-charts/rstudio-library-test/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ apiVersion: v2
name: rstudio-library-test
description: Test harness for rstudio-library templates
type: application
version: 0.1.2
version: 0.1.3
appVersion: "0.1.0"

maintainers:
Expand Down
5 changes: 5 additions & 0 deletions other-charts/rstudio-library-test/NEWS.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# NEWS

## 0.1.3

- Update rstudio-library dependency to 0.1.39
- Add unit tests for the Gateway API helpers (`testGateway`)

## 0.1.2

- Update rstudio-library dependency to 0.1.38
Expand Down
10 changes: 9 additions & 1 deletion other-charts/rstudio-library-test/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

# rstudio-library-test

![Version: 0.1.2](https://img.shields.io/badge/Version-0.1.2-informational?style=flat-square) ![Type: application](https://img.shields.io/badge/Type-application-informational?style=flat-square) ![AppVersion: 0.1.0](https://img.shields.io/badge/AppVersion-0.1.0-informational?style=flat-square)
![Version: 0.1.3](https://img.shields.io/badge/Version-0.1.3-informational?style=flat-square) ![Type: application](https://img.shields.io/badge/Type-application-informational?style=flat-square) ![AppVersion: 0.1.0](https://img.shields.io/badge/AppVersion-0.1.0-informational?style=flat-square)

Test harness for rstudio-library templates

Expand Down Expand Up @@ -53,6 +53,14 @@ Test harness for rstudio-library templates
| testDebug.sliceValue[0] | string | `"item1"` | |
| testDebug.sliceValue[1] | string | `"item2"` | |
| testDebug.stringValue | string | `"test string"` | |
| testGateway.fullName | string | `"my-release-rstudio-connect"` | |
| testGateway.index | int | `0` | |
| testGateway.path | string | `"/test"` | |
| testGateway.pathType | string | `"Prefix"` | |
| testGateway.pathTypes[0] | string | `"Prefix"` | |
| testGateway.pathTypes[1] | string | `"Exact"` | |
| testGateway.serviceName | string | `"test-service"` | |
| testGateway.servicePort | int | `8080` | |
| testIngress.path | string | `"/test"` | |
| testIngress.pathType | string | `"Prefix"` | |
| testIngress.serviceName | string | `"test-service"` | |
Expand Down
76 changes: 76 additions & 0 deletions other-charts/rstudio-library-test/templates/test-gateway.yaml
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 }}
2 changes: 2 additions & 0 deletions other-charts/rstudio-library-test/tests/_base_values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ testConfig:

testIngress: null

testGateway: null

testLicense: null

testRbac: null
Expand Down
Loading
Loading