mirror of
https://github.com/bjw-s-labs/helm-charts.git
synced 2025-07-03 08:37:03 +02:00
feat(common): Release 3.7.3 (#393)
This commit is contained in:
parent
ade6955579
commit
245e1631c9
14 changed files with 167 additions and 99 deletions
|
@ -3,7 +3,7 @@ apiVersion: v2
|
||||||
name: common
|
name: common
|
||||||
description: Function library for Helm charts
|
description: Function library for Helm charts
|
||||||
type: library
|
type: library
|
||||||
version: 3.7.2
|
version: 3.7.3
|
||||||
kubeVersion: ">=1.22.0-0"
|
kubeVersion: ">=1.22.0-0"
|
||||||
keywords:
|
keywords:
|
||||||
- common
|
- common
|
||||||
|
@ -12,12 +12,13 @@ home: https://github.com/bjw-s/helm-charts/tree/main/charts/library/common
|
||||||
maintainers:
|
maintainers:
|
||||||
- name: bjw-s
|
- name: bjw-s
|
||||||
email: me@bjw-s.dev
|
email: me@bjw-s.dev
|
||||||
|
sources:
|
||||||
|
- https://github.com/bjw-s/helm-charts
|
||||||
annotations:
|
annotations:
|
||||||
org.opencontainers.image.source: "https://github.com/bjw-s/helm-charts"
|
|
||||||
artifacthub.io/changes: |-
|
artifacthub.io/changes: |-
|
||||||
- kind: fixed
|
- kind: fixed
|
||||||
description: |-
|
description: |-
|
||||||
The Apache 2.0 LICENSE file has been added to the chart.
|
Fixed name suffix for HTTPRoute
|
||||||
- kind: fixed
|
- kind: fixed
|
||||||
description: |-
|
description: |-
|
||||||
Fixed non-deterministic selection of primary service and port.
|
Fixed incorrect default backendRefs values in HTTPRoute
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
# common
|
# common
|
||||||
|
|
||||||
 
|
 
|
||||||
|
|
||||||
Function library for Helm charts
|
Function library for Helm charts
|
||||||
|
|
||||||
|
@ -27,7 +27,7 @@ Include this chart as a dependency in your `Chart.yaml` e.g.
|
||||||
# Chart.yaml
|
# Chart.yaml
|
||||||
dependencies:
|
dependencies:
|
||||||
- name: common
|
- name: common
|
||||||
version: 3.7.2
|
version: 3.7.3
|
||||||
repository: https://bjw-s.github.io/helm-charts/
|
repository: https://bjw-s.github.io/helm-charts/
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
|
@ -43,8 +43,8 @@ metadata:
|
||||||
spec:
|
spec:
|
||||||
parentRefs:
|
parentRefs:
|
||||||
{{- range $routeObject.parentRefs }}
|
{{- range $routeObject.parentRefs }}
|
||||||
- group: {{ default "gateway.networking.k8s.io" .group }}
|
- group: {{ .group | default "gateway.networking.k8s.io" }}
|
||||||
kind: {{ default "Gateway" .kind }}
|
kind: {{ .kind | default "Gateway" }}
|
||||||
name: {{ required (printf "parentRef name is required for %v %v" $routeKind $routeObject.name) .name }}
|
name: {{ required (printf "parentRef name is required for %v %v" $routeKind $routeObject.name) .name }}
|
||||||
namespace: {{ required (printf "parentRef namespace is required for %v %v" $routeKind $routeObject.name) .namespace }}
|
namespace: {{ required (printf "parentRef namespace is required for %v %v" $routeKind $routeObject.name) .namespace }}
|
||||||
{{- if .sectionName }}
|
{{- if .sectionName }}
|
||||||
|
@ -66,11 +66,11 @@ spec:
|
||||||
{{ if $service -}}
|
{{ if $service -}}
|
||||||
{{ $servicePrimaryPort = include "bjw-s.common.lib.service.primaryPort" (dict "rootContext" $rootContext "serviceObject" $service) | fromYaml -}}
|
{{ $servicePrimaryPort = include "bjw-s.common.lib.service.primaryPort" (dict "rootContext" $rootContext "serviceObject" $service) | fromYaml -}}
|
||||||
{{- end }}
|
{{- end }}
|
||||||
- group: {{ default "" .group | quote}}
|
- group: {{ .group | default "" | quote}}
|
||||||
kind: {{ default "Service" .kind }}
|
kind: {{ .kind | default "Service" }}
|
||||||
name: {{ default .name $service.name }}
|
name: {{ $service.name | default .name }}
|
||||||
namespace: {{ default $rootContext.Release.Namespace .namespace }}
|
namespace: {{ .namespace | default $rootContext.Release.Namespace }}
|
||||||
port: {{ default .port $servicePrimaryPort.port }}
|
port: {{ .port | default $servicePrimaryPort.port }}
|
||||||
weight: {{ include "bjw-s.common.lib.defaultKeepNonNullValue" (dict "value" .weight "default" 1) }}
|
weight: {{ include "bjw-s.common.lib.defaultKeepNonNullValue" (dict "value" .weight "default" 1) }}
|
||||||
{{- end }}
|
{{- end }}
|
||||||
{{- if or (eq $routeKind "HTTPRoute") (eq $routeKind "GRPCRoute") }}
|
{{- if or (eq $routeKind "HTTPRoute") (eq $routeKind "GRPCRoute") }}
|
||||||
|
|
|
@ -9,7 +9,7 @@ Validate Role values
|
||||||
{{- $rules := $roleValues.rules -}}
|
{{- $rules := $roleValues.rules -}}
|
||||||
|
|
||||||
{{- if not (mustHas $type $typeList) -}}
|
{{- if not (mustHas $type $typeList) -}}
|
||||||
{{- fail (printf "You selected: `%s`. Type must be one of:\n%s\n" $type ($typeList|toYaml)) -}}
|
{{- fail (printf "\nYou selected: `%s`. Type must be one of:\n%s\n" $type ($typeList|toYaml)) -}}
|
||||||
{{- end -}}
|
{{- end -}}
|
||||||
{{- if not $rules -}}
|
{{- if not $rules -}}
|
||||||
{{- fail "Rules can't be empty" -}}
|
{{- fail "Rules can't be empty" -}}
|
||||||
|
|
|
@ -10,7 +10,7 @@ Validate RoleBinding values
|
||||||
{{- $roleRef := required "A roleRef is required" $roleBindingValues.roleRef -}}
|
{{- $roleRef := required "A roleRef is required" $roleBindingValues.roleRef -}}
|
||||||
|
|
||||||
{{- if not (mustHas $type $typeList) -}}
|
{{- if not (mustHas $type $typeList) -}}
|
||||||
{{- fail (printf "You selected: `%s`. Type must be one of:\n%s\n" $type ($typeList|toYaml)) -}}
|
{{- fail (printf "\nYou selected: `%s`. Type must be one of:\n%s\n" $type ($typeList|toYaml)) -}}
|
||||||
{{- end -}}
|
{{- end -}}
|
||||||
|
|
||||||
{{- if not (hasKey $roleRef "identifier") -}}
|
{{- if not (hasKey $roleRef "identifier") -}}
|
||||||
|
|
|
@ -0,0 +1,23 @@
|
||||||
|
{{/*
|
||||||
|
Return the enabled routes.
|
||||||
|
*/}}
|
||||||
|
{{- define "bjw-s.common.lib.route.enabledRoutes" -}}
|
||||||
|
{{- $rootContext := .rootContext -}}
|
||||||
|
{{- $enabledRoutes := dict -}}
|
||||||
|
|
||||||
|
{{- range $name, $route := $rootContext.Values.route -}}
|
||||||
|
{{- if kindIs "map" $route -}}
|
||||||
|
{{- /* Enable Route by default, but allow override */ -}}
|
||||||
|
{{- $routeEnabled := true -}}
|
||||||
|
{{- if hasKey $route "enabled" -}}
|
||||||
|
{{- $routeEnabled = $route.enabled -}}
|
||||||
|
{{- end -}}
|
||||||
|
|
||||||
|
{{- if $routeEnabled -}}
|
||||||
|
{{- $_ := set $enabledRoutes $name . -}}
|
||||||
|
{{- end -}}
|
||||||
|
{{- end -}}
|
||||||
|
{{- end -}}
|
||||||
|
|
||||||
|
{{- $enabledRoutes | toYaml -}}
|
||||||
|
{{- end -}}
|
|
@ -1,21 +0,0 @@
|
||||||
{{/* Return the name of the primary route object */}}
|
|
||||||
{{- define "bjw-s.common.lib.route.primary" -}}
|
|
||||||
{{- $enabledRoutes := dict -}}
|
|
||||||
{{- range $name, $route := .Values.route -}}
|
|
||||||
{{- if $route.enabled -}}
|
|
||||||
{{- $_ := set $enabledRoutes $name . -}}
|
|
||||||
{{- end -}}
|
|
||||||
{{- end -}}
|
|
||||||
|
|
||||||
{{- $result := "" -}}
|
|
||||||
{{- range $name, $route := $enabledRoutes -}}
|
|
||||||
{{- if and (hasKey $route "primary") $route.primary -}}
|
|
||||||
{{- $result = $name -}}
|
|
||||||
{{- end -}}
|
|
||||||
{{- end -}}
|
|
||||||
|
|
||||||
{{- if not $result -}}
|
|
||||||
{{- $result = keys $enabledRoutes | first -}}
|
|
||||||
{{- end -}}
|
|
||||||
{{- $result -}}
|
|
||||||
{{- end -}}
|
|
|
@ -15,7 +15,8 @@ Convert Route values to an object
|
||||||
{{- $objectName = printf "%s-%s" $objectName $override -}}
|
{{- $objectName = printf "%s-%s" $objectName $override -}}
|
||||||
{{- end -}}
|
{{- end -}}
|
||||||
{{- else -}}
|
{{- else -}}
|
||||||
{{- if ne $identifier (include "bjw-s.common.lib.route.primary" $rootContext) -}}
|
{{- $enabledRoutes := (include "bjw-s.common.lib.route.enabledRoutes" (dict "rootContext" $rootContext) | fromYaml ) }}
|
||||||
|
{{- if and (not $objectValues.primary) (gt (len $enabledRoutes) 1) -}}
|
||||||
{{- if not (eq $objectName $identifier) -}}
|
{{- if not (eq $objectName $identifier) -}}
|
||||||
{{- $objectName = printf "%s-%s" $objectName $identifier -}}
|
{{- $objectName = printf "%s-%s" $objectName $identifier -}}
|
||||||
{{- end -}}
|
{{- end -}}
|
||||||
|
|
|
@ -1,14 +1,10 @@
|
||||||
{{/* Renders the Route objects required by the chart */}}
|
{{/*
|
||||||
|
Renders the Route objects required by the chart
|
||||||
|
*/}}
|
||||||
{{- define "bjw-s.common.render.routes" -}}
|
{{- define "bjw-s.common.render.routes" -}}
|
||||||
{{- /* Generate named routes as required */ -}}
|
{{- /* Generate named routes as required */ -}}
|
||||||
{{- range $key, $route := .Values.route }}
|
{{- $enabledRoutes := (include "bjw-s.common.lib.route.enabledRoutes" (dict "rootContext" $) | fromYaml ) -}}
|
||||||
{{- /* Enable Route by default, but allow override */ -}}
|
{{- range $key, $route := $enabledRoutes -}}
|
||||||
{{- $routeEnabled := true -}}
|
|
||||||
{{- if hasKey $route "enabled" -}}
|
|
||||||
{{- $routeEnabled = $route.enabled -}}
|
|
||||||
{{- end -}}
|
|
||||||
|
|
||||||
{{- if $routeEnabled -}}
|
|
||||||
{{- $routeValues := (mustDeepCopy $route) -}}
|
{{- $routeValues := (mustDeepCopy $route) -}}
|
||||||
|
|
||||||
{{- /* Create object from the raw Route values */ -}}
|
{{- /* Create object from the raw Route values */ -}}
|
||||||
|
@ -19,6 +15,5 @@
|
||||||
|
|
||||||
{{- /* Include the Route class */ -}}
|
{{- /* Include the Route class */ -}}
|
||||||
{{- include "bjw-s.common.class.route" (dict "rootContext" $ "object" $routeObject) | nindent 0 -}}
|
{{- include "bjw-s.common.class.route" (dict "rootContext" $ "object" $routeObject) | nindent 0 -}}
|
||||||
{{- end }}
|
{{- end -}}
|
||||||
{{- end }}
|
{{- end -}}
|
||||||
{{- end }}
|
|
||||||
|
|
|
@ -19,7 +19,10 @@ tests:
|
||||||
rules: {}
|
rules: {}
|
||||||
asserts:
|
asserts:
|
||||||
- failedTemplate:
|
- failedTemplate:
|
||||||
errorMessage: "You selected: `InvalidRole`. Type must be one of:"
|
errorMessage: |
|
||||||
|
You selected: `InvalidRole`. Type must be one of:
|
||||||
|
- Role
|
||||||
|
- ClusterRole
|
||||||
|
|
||||||
- it: role rules can't be empty
|
- it: role rules can't be empty
|
||||||
set:
|
set:
|
||||||
|
|
|
@ -0,0 +1,74 @@
|
||||||
|
---
|
||||||
|
# yaml-language-server: $schema=https://raw.githubusercontent.com/helm-unittest/helm-unittest/main/schema/helm-testsuite.json
|
||||||
|
suite: route names
|
||||||
|
templates:
|
||||||
|
- common.yaml
|
||||||
|
values:
|
||||||
|
- ../_values/controllers_main_default_container.yaml
|
||||||
|
tests:
|
||||||
|
- it: default name
|
||||||
|
set:
|
||||||
|
route.main:
|
||||||
|
enabled: true
|
||||||
|
parentRefs:
|
||||||
|
- name: test
|
||||||
|
namespace: test
|
||||||
|
documentSelector:
|
||||||
|
path: $[?(@.kind == "HTTPRoute")].metadata.name
|
||||||
|
value: RELEASE-NAME
|
||||||
|
asserts:
|
||||||
|
- exists:
|
||||||
|
path: metadata.name
|
||||||
|
|
||||||
|
- it: custom name suffix
|
||||||
|
set:
|
||||||
|
route.main:
|
||||||
|
enabled: true
|
||||||
|
parentRefs:
|
||||||
|
- name: test
|
||||||
|
namespace: test
|
||||||
|
nameOverride: http
|
||||||
|
documentSelector:
|
||||||
|
path: $[?(@.kind == "HTTPRoute")].metadata.name
|
||||||
|
value: RELEASE-NAME-http
|
||||||
|
asserts:
|
||||||
|
- exists:
|
||||||
|
path: metadata.name
|
||||||
|
|
||||||
|
- it: custom name suffix with template
|
||||||
|
set:
|
||||||
|
route.main:
|
||||||
|
enabled: true
|
||||||
|
parentRefs:
|
||||||
|
- name: test
|
||||||
|
namespace: test
|
||||||
|
nameOverride: "{{ .Chart.Name }}"
|
||||||
|
documentSelector:
|
||||||
|
path: $[?(@.kind == "HTTPRoute")].metadata.name
|
||||||
|
value: RELEASE-NAME-common-test
|
||||||
|
asserts:
|
||||||
|
- exists:
|
||||||
|
path: metadata.name
|
||||||
|
|
||||||
|
- it: multiple routes
|
||||||
|
set:
|
||||||
|
route:
|
||||||
|
main:
|
||||||
|
parentRefs:
|
||||||
|
- name: main
|
||||||
|
namespace: main
|
||||||
|
test:
|
||||||
|
parentRefs:
|
||||||
|
- name: test
|
||||||
|
namespace: test
|
||||||
|
asserts:
|
||||||
|
- documentSelector:
|
||||||
|
path: $[?(@.kind == "HTTPRoute")].metadata.name
|
||||||
|
value: RELEASE-NAME-main
|
||||||
|
exists:
|
||||||
|
path: metadata.name
|
||||||
|
- documentSelector:
|
||||||
|
path: $[?(@.kind == "HTTPRoute")].metadata.name
|
||||||
|
value: RELEASE-NAME-test
|
||||||
|
exists:
|
||||||
|
path: metadata.name
|
|
@ -6,45 +6,39 @@ templates:
|
||||||
values:
|
values:
|
||||||
- ../_values/controllers_main_default_container.yaml
|
- ../_values/controllers_main_default_container.yaml
|
||||||
tests:
|
tests:
|
||||||
- it: default should pass
|
- it: an HTTPRoute is not created by default
|
||||||
asserts:
|
asserts:
|
||||||
- hasDocuments:
|
- not: true
|
||||||
count: 1
|
containsDocument:
|
||||||
- documentIndex: 0
|
kind: HTTPRoute
|
||||||
not: true
|
apiVersion: gateway.networking.k8s.io/v1alpha2
|
||||||
isKind:
|
name: RELEASE-NAME
|
||||||
of: HTTPRoute
|
|
||||||
|
|
||||||
- it: explicitly disabled should pass
|
- it: an HTTPRoute is not created when disabled
|
||||||
set:
|
set:
|
||||||
route.main.enabled: false
|
route.main.enabled: false
|
||||||
asserts:
|
asserts:
|
||||||
- hasDocuments:
|
- not: true
|
||||||
count: 1
|
containsDocument:
|
||||||
- documentIndex: 0
|
kind: HTTPRoute
|
||||||
not: true
|
apiVersion: gateway.networking.k8s.io/v1alpha2
|
||||||
isKind:
|
name: RELEASE-NAME
|
||||||
of: HTTPRoute
|
|
||||||
|
|
||||||
- it: explicitly enabled should pass
|
- it: an HTTPRoute is created when explicitly enabled
|
||||||
set:
|
set:
|
||||||
route.main:
|
route.main:
|
||||||
enabled: true
|
enabled: true
|
||||||
parentRefs:
|
parentRefs:
|
||||||
- name: test
|
- name: test
|
||||||
namespace: test
|
namespace: test
|
||||||
|
documentSelector:
|
||||||
|
path: $[?(@.kind == "HTTPRoute")].metadata.name
|
||||||
|
value: RELEASE-NAME
|
||||||
asserts:
|
asserts:
|
||||||
- hasDocuments:
|
- exists:
|
||||||
count: 2
|
path: metadata.name
|
||||||
- documentIndex: 0
|
|
||||||
not: true
|
|
||||||
isKind:
|
|
||||||
of: HTTPRoute
|
|
||||||
- documentIndex: 1
|
|
||||||
isKind:
|
|
||||||
of: HTTPRoute
|
|
||||||
|
|
||||||
- it: multiple enabled should pass
|
- it: multiple HTTPRoute are created when configured
|
||||||
set:
|
set:
|
||||||
route:
|
route:
|
||||||
main:
|
main:
|
||||||
|
@ -56,15 +50,13 @@ tests:
|
||||||
- name: test
|
- name: test
|
||||||
namespace: test
|
namespace: test
|
||||||
asserts:
|
asserts:
|
||||||
- hasDocuments:
|
- documentSelector:
|
||||||
count: 3
|
path: $[?(@.kind == "HTTPRoute")].metadata.name
|
||||||
- documentIndex: 0
|
value: RELEASE-NAME-main
|
||||||
not: true
|
exists:
|
||||||
isKind:
|
path: metadata.name
|
||||||
of: HTTPRoute
|
- documentSelector:
|
||||||
- documentIndex: 1
|
path: $[?(@.kind == "HTTPRoute")].metadata.name
|
||||||
isKind:
|
value: RELEASE-NAME-test
|
||||||
of: HTTPRoute
|
exists:
|
||||||
- documentIndex: 2
|
path: metadata.name
|
||||||
isKind:
|
|
||||||
of: HTTPRoute
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"$schema": "http://json-schema.org/draft-07/schema",
|
"$schema": "http://json-schema.org/draft-07/schema",
|
||||||
"$id": "https://raw.githubusercontent.com/bjw-s/helm-charts/common-3.7.2/charts/library/common/values.schema.json",
|
"$id": "https://raw.githubusercontent.com/bjw-s/helm-charts/common-3.7.3/charts/library/common/values.schema.json",
|
||||||
"type": "object",
|
"type": "object",
|
||||||
"properties": {
|
"properties": {
|
||||||
"global": {
|
"global": {
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
apiVersion: v2
|
apiVersion: v2
|
||||||
description: A common powered chart template. This can be useful for small projects that don't have their own chart.
|
description: A common powered chart template. This can be useful for small projects that don't have their own chart.
|
||||||
name: app-template
|
name: app-template
|
||||||
version: 3.7.2
|
version: 3.7.3
|
||||||
kubeVersion: ">=1.22.0-0"
|
kubeVersion: ">=1.22.0-0"
|
||||||
maintainers:
|
maintainers:
|
||||||
- name: bjw-s
|
- name: bjw-s
|
||||||
|
@ -10,14 +10,14 @@ maintainers:
|
||||||
dependencies:
|
dependencies:
|
||||||
- name: common
|
- name: common
|
||||||
repository: https://bjw-s.github.io/helm-charts
|
repository: https://bjw-s.github.io/helm-charts
|
||||||
version: 3.7.2
|
version: 3.7.3
|
||||||
sources:
|
sources:
|
||||||
- https://github.com/bjw-s/helm-charts
|
- https://github.com/bjw-s/helm-charts
|
||||||
annotations:
|
annotations:
|
||||||
artifacthub.io/changes: |-
|
artifacthub.io/changes: |-
|
||||||
- kind: fixed
|
- kind: fixed
|
||||||
description: |-
|
description: |-
|
||||||
The Apache 2.0 LICENSE file has been added to the chart.
|
Fixed name suffix for HTTPRoute
|
||||||
- kind: fixed
|
- kind: fixed
|
||||||
description: |-
|
description: |-
|
||||||
Fixed non-deterministic selection of primary service and port.
|
Fixed incorrect default backendRefs values in HTTPRoute
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue