mirror of
https://github.com/bjw-s-labs/helm-charts.git
synced 2025-07-03 00:27:04 +02:00
fix(common): Release common-4.0.1 (#415)
This commit is contained in:
parent
a01a89cb13
commit
9a478444a4
14 changed files with 163 additions and 15 deletions
|
@ -3,7 +3,7 @@ apiVersion: v2
|
|||
name: common
|
||||
description: Function library for Helm charts
|
||||
type: library
|
||||
version: 4.0.0
|
||||
version: 4.0.1
|
||||
kubeVersion: ">=1.28.0-0"
|
||||
keywords:
|
||||
- common
|
||||
|
@ -46,6 +46,9 @@ annotations:
|
|||
- kind: added
|
||||
description: |-
|
||||
Added support for automatically determining the target service for Ingress paths if there is only one enabled Service
|
||||
- kind: added
|
||||
description: |-
|
||||
Added support for automatically determining the target service for Route backends if there is only one enabled Service
|
||||
- kind: changed
|
||||
description: |-
|
||||
**Breaking**: Standardized resource name logic for all resources. This may cause changes in the generated resource names.
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
# common
|
||||
|
||||
 
|
||||
 
|
||||
|
||||
Function library for Helm charts
|
||||
|
||||
|
@ -31,7 +31,7 @@ Include this chart as a dependency in your `Chart.yaml` e.g.
|
|||
# Chart.yaml
|
||||
dependencies:
|
||||
- name: common
|
||||
version: 4.0.0
|
||||
version: 4.0.1
|
||||
repository: https://bjw-s-labs.github.io/helm-charts/
|
||||
```
|
||||
|
||||
|
|
|
@ -4,10 +4,26 @@ Return a Route object by its Identifier.
|
|||
{{- define "bjw-s.common.lib.route.getByIdentifier" -}}
|
||||
{{- $rootContext := .rootContext -}}
|
||||
{{- $identifier := .id -}}
|
||||
|
||||
{{- $enabledServices := (include "bjw-s.common.lib.service.enabledServices" (dict "rootContext" $rootContext) | fromYaml ) -}}
|
||||
{{- $enabledRoutes := (include "bjw-s.common.lib.route.enabledRoutes" (dict "rootContext" $rootContext) | fromYaml ) }}
|
||||
|
||||
{{- if (hasKey $enabledRoutes $identifier) -}}
|
||||
{{- $objectValues := get $enabledRoutes $identifier -}}
|
||||
{{- include "bjw-s.common.lib.valuesToObject" (dict "rootContext" $rootContext "id" $identifier "values" $objectValues "itemCount" (len $enabledRoutes)) -}}
|
||||
{{- $object := include "bjw-s.common.lib.valuesToObject" (dict "rootContext" $rootContext "id" $identifier "values" $objectValues "itemCount" (len $enabledRoutes)) | fromYaml -}}
|
||||
|
||||
{{- /* Try to automatically determine the default Service identifier if needed and possible */ -}}
|
||||
{{- if eq 1 (len $enabledServices) -}}
|
||||
{{- range $object.rules -}}
|
||||
{{- range .backendRefs }}
|
||||
{{- $backendRef := . -}}
|
||||
{{- if and (empty (dig "name" nil $backendRef)) (empty (dig "identifier" nil $backendRef)) -}}
|
||||
{{- $_ := set $backendRef "identifier" ($enabledServices | keys | first) -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
|
||||
{{- $object | toYaml -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
|
|
|
@ -5,6 +5,21 @@ Validate Route values
|
|||
{{- $rootContext := .rootContext -}}
|
||||
{{- $routeObject := .object -}}
|
||||
|
||||
{{- $enabledServices := (include "bjw-s.common.lib.service.enabledServices" (dict "rootContext" $rootContext) | fromYaml ) -}}
|
||||
|
||||
{{/* Verify automatic Service detection */}}
|
||||
{{- if not (eq 1 (len $enabledServices)) -}}
|
||||
{{- range $routeObject.rules -}}
|
||||
{{- $rule := . -}}
|
||||
{{- range $rule.backendRefs }}
|
||||
{{- $backendRef := . -}}
|
||||
{{- if and (empty (dig "name" nil $backendRef)) (empty (dig "identifier" nil $backendRef)) -}}
|
||||
{{- fail (printf "Either name or identifier is required because automatic Service detection is not possible. (route: %s)" $routeObject.identifier) -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
|
||||
{{/* Route Types */}}
|
||||
{{- $routeKind := $routeObject.kind | default "HTTPRoute"}}
|
||||
{{- if and (ne $routeKind "GRPCRoute") (ne $routeKind "HTTPRoute") (ne $routeKind "TCPRoute") (ne $routeKind "TLSRoute") (ne $routeKind "UDPRoute") }}
|
||||
|
|
|
@ -60,6 +60,30 @@ tests:
|
|||
port: 8080
|
||||
weight: 1
|
||||
|
||||
- it: automatic service and port reference should pass
|
||||
values:
|
||||
- ../_values/service_main_default.yaml
|
||||
set:
|
||||
route.main:
|
||||
parentRefs:
|
||||
- name: parentName
|
||||
namespace: parentNamespace
|
||||
rules:
|
||||
- backendRefs: [{}]
|
||||
documentSelector:
|
||||
path: $[?(@.kind == "HTTPRoute")].metadata.name
|
||||
value: release-name
|
||||
asserts:
|
||||
- equal:
|
||||
path: spec.rules[0].backendRefs[0]
|
||||
value:
|
||||
group: ""
|
||||
kind: Service
|
||||
name: release-name
|
||||
namespace: NAMESPACE
|
||||
port: 8081
|
||||
weight: 1
|
||||
|
||||
- it: custom service reference should pass
|
||||
set:
|
||||
route.main:
|
||||
|
|
|
@ -41,3 +41,40 @@ tests:
|
|||
asserts:
|
||||
- failedTemplate:
|
||||
errorMessage: "backend refs and request redirect filters cannot co-exist."
|
||||
|
||||
- it: automatic service determination should fail when no service is enabled
|
||||
set:
|
||||
route.main:
|
||||
parentRefs:
|
||||
- name: parentName
|
||||
namespace: parentNamespace
|
||||
rules:
|
||||
- backendRefs:
|
||||
- port: 8080
|
||||
asserts:
|
||||
- failedTemplate:
|
||||
errorMessage: "Either name or identifier is required because automatic Service detection is not possible. (route: main)"
|
||||
|
||||
- it: automatic service determination should fail when >1 service is enabled
|
||||
set:
|
||||
service:
|
||||
main:
|
||||
controller: main
|
||||
ports:
|
||||
ui:
|
||||
port: 8082
|
||||
second:
|
||||
controller: main
|
||||
ports:
|
||||
ui:
|
||||
port: 8082
|
||||
route.main:
|
||||
parentRefs:
|
||||
- name: parentName
|
||||
namespace: parentNamespace
|
||||
rules:
|
||||
- backendRefs:
|
||||
- port: 8080
|
||||
asserts:
|
||||
- failedTemplate:
|
||||
errorMessage: "Either name or identifier is required because automatic Service detection is not possible. (route: main)"
|
||||
|
|
|
@ -0,0 +1,54 @@
|
|||
---
|
||||
# yaml-language-server: $schema=https://raw.githubusercontent.com/helm-unittest/helm-unittest/main/schema/helm-testsuite.json
|
||||
suite: service - fields - selector
|
||||
templates:
|
||||
- common.yaml
|
||||
values:
|
||||
- ../_values/controllers_main_default_container.yaml
|
||||
- ../_values/service_main_default.yaml
|
||||
tests:
|
||||
- it: selector is configured by default
|
||||
documentSelector:
|
||||
path: $[?(@.kind == "Service")].metadata.name
|
||||
value: release-name
|
||||
asserts:
|
||||
- equal:
|
||||
path: spec.selector
|
||||
value:
|
||||
app.kubernetes.io/controller: main
|
||||
app.kubernetes.io/instance: RELEASE-NAME
|
||||
app.kubernetes.io/name: RELEASE-NAME
|
||||
|
||||
- it: additional selector labels can be configured
|
||||
set:
|
||||
service:
|
||||
main:
|
||||
extraSelectorLabels:
|
||||
extraLabel: extraValue
|
||||
documentSelector:
|
||||
path: $[?(@.kind == "Service")].metadata.name
|
||||
value: release-name
|
||||
asserts:
|
||||
- equal:
|
||||
path: spec.selector
|
||||
value:
|
||||
app.kubernetes.io/controller: main
|
||||
app.kubernetes.io/instance: RELEASE-NAME
|
||||
app.kubernetes.io/name: RELEASE-NAME
|
||||
extraLabel: extraValue
|
||||
|
||||
- it: selector can determine default controller automatically
|
||||
set:
|
||||
service:
|
||||
main:
|
||||
controller: ""
|
||||
documentSelector:
|
||||
path: $[?(@.kind == "Service")].metadata.name
|
||||
value: release-name
|
||||
asserts:
|
||||
- equal:
|
||||
path: spec.selector
|
||||
value:
|
||||
app.kubernetes.io/controller: main
|
||||
app.kubernetes.io/instance: RELEASE-NAME
|
||||
app.kubernetes.io/name: RELEASE-NAME
|
|
@ -42,7 +42,6 @@ tests:
|
|||
- failedTemplate:
|
||||
errorMessage: "controller field is required because automatic controller detection is not possible. (service: main)"
|
||||
|
||||
|
||||
- it: no ports enabled should fail
|
||||
values:
|
||||
- ../_values/service_main_default.yaml
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"$schema": "http://json-schema.org/draft-07/schema",
|
||||
"$id": "https://raw.githubusercontent.com/bjw-s-labs/helm-charts/common-4.0.0/charts/library/common/values.schema.json",
|
||||
"$id": "https://raw.githubusercontent.com/bjw-s-labs/helm-charts/common-4.0.1/charts/library/common/values.schema.json",
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"global": {
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
apiVersion: v2
|
||||
description: A common powered chart template. This can be useful for small projects that don't have their own chart.
|
||||
name: app-template
|
||||
version: 4.0.0
|
||||
version: 4.0.1
|
||||
kubeVersion: ">=1.28.0-0"
|
||||
maintainers:
|
||||
- name: bjw-s
|
||||
|
@ -10,16 +10,16 @@ maintainers:
|
|||
dependencies:
|
||||
- name: common
|
||||
repository: https://bjw-s-labs.github.io/helm-charts
|
||||
version: 4.0.0
|
||||
version: 4.0.1
|
||||
sources:
|
||||
- https://github.com/bjw-s-labs/helm-charts
|
||||
annotations:
|
||||
artifacthub.io/changes: |-
|
||||
- kind: changed
|
||||
description: |-
|
||||
Upgraded the common library to v4.0.0
|
||||
Upgraded the common library to v4.0.1
|
||||
links:
|
||||
- name: Upgrade notes
|
||||
url: https://bjw-s-labs.github.io/helm-charts/docs/app-template/upgrade-instructions/
|
||||
- name: Detailed release notes
|
||||
url: https://github.com/bjw-s-labs/helm-charts/releases/tag/common-4.0.0
|
||||
url: https://github.com/bjw-s-labs/helm-charts/releases/tag/common-4.0.1
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
# app-template
|
||||
|
||||

|
||||

|
||||
|
||||
A common powered chart template. This can be useful for small projects that don't have their own chart.
|
||||
|
||||
|
@ -12,7 +12,7 @@ Kubernetes: `>=1.28.0-0`
|
|||
|
||||
| Repository | Name | Version |
|
||||
|------------|------|---------|
|
||||
| https://bjw-s-labs.github.io/helm-charts | common | 4.0.0 |
|
||||
| https://bjw-s-labs.github.io/helm-charts | common | 4.0.1 |
|
||||
|
||||
## Installing the Chart
|
||||
|
||||
|
|
|
@ -726,7 +726,7 @@
|
|||
"values": {
|
||||
"description": "Values holds the values for this Helm release.",
|
||||
"x-kubernetes-preserve-unknown-fields": true,
|
||||
"$ref": "https://raw.githubusercontent.com/bjw-s-labs/helm-charts/common-4.0.0/charts/library/common/values.schema.json"
|
||||
"$ref": "https://raw.githubusercontent.com/bjw-s-labs/helm-charts/common-4.0.1/charts/library/common/values.schema.json"
|
||||
},
|
||||
"valuesFrom": {
|
||||
"description": "ValuesFrom holds references to resources containing Helm values for this HelmRelease,\nand information about how they should be merged.",
|
||||
|
|
|
@ -727,7 +727,7 @@
|
|||
"values": {
|
||||
"description": "Values holds the values for this Helm release.",
|
||||
"x-kubernetes-preserve-unknown-fields": true,
|
||||
"$ref": "https://raw.githubusercontent.com/bjw-s-labs/helm-charts/common-4.0.0/charts/library/common/values.schema.json"
|
||||
"$ref": "https://raw.githubusercontent.com/bjw-s-labs/helm-charts/common-4.0.1/charts/library/common/values.schema.json"
|
||||
},
|
||||
"valuesFrom": {
|
||||
"description": "ValuesFrom holds references to resources containing Helm values for this HelmRelease, and information about how they should be merged.",
|
||||
|
|
|
@ -1,3 +1,3 @@
|
|||
{
|
||||
"$ref": "https://raw.githubusercontent.com/bjw-s-labs/helm-charts/common-4.0.0/charts/library/common/values.schema.json"
|
||||
"$ref": "https://raw.githubusercontent.com/bjw-s-labs/helm-charts/common-4.0.1/charts/library/common/values.schema.json"
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue