mirror of
https://github.com/bjw-s-labs/helm-charts.git
synced 2025-07-04 08:57:04 +02:00
feat(common): Release common 4.0.0 (#398)
Co-authored-by: lab-assistant[bot] <180935599+lab-assistant[bot]@users.noreply.github.com>
This commit is contained in:
parent
1e210f43e3
commit
a01a89cb13
327 changed files with 11181 additions and 7330 deletions
|
@ -0,0 +1,53 @@
|
|||
---
|
||||
# yaml-language-server: $schema=https://raw.githubusercontent.com/helm-unittest/helm-unittest/main/schema/helm-testsuite.json
|
||||
suite: ingress - fields - hosts - host
|
||||
templates:
|
||||
- common.yaml
|
||||
values:
|
||||
- ../_values/ingress_main_default_hosts.yaml
|
||||
- ../_values/service_main_default.yaml
|
||||
- ../_values/controllers_main_default_container.yaml
|
||||
tests:
|
||||
- it: default should pass
|
||||
documentSelector:
|
||||
path: $[?(@.kind == "Ingress")].metadata.name
|
||||
value: release-name
|
||||
asserts:
|
||||
- equal:
|
||||
path: spec.rules[0].host
|
||||
value: chart-example.local
|
||||
|
||||
- it: custom host should pass
|
||||
set:
|
||||
ingress.main:
|
||||
hosts:
|
||||
- host: chart-test.local
|
||||
paths:
|
||||
- path: /test
|
||||
service:
|
||||
identifier: main
|
||||
documentSelector:
|
||||
path: $[?(@.kind == "Ingress")].metadata.name
|
||||
value: release-name
|
||||
asserts:
|
||||
- equal:
|
||||
path: spec.rules[0].host
|
||||
value: chart-test.local
|
||||
|
||||
- it: host with template should pass
|
||||
set:
|
||||
ingress.main:
|
||||
hosts:
|
||||
- host: "{{ .Release.Name }}.hostname"
|
||||
paths:
|
||||
- path: /
|
||||
service:
|
||||
identifier: main
|
||||
port: http
|
||||
documentSelector:
|
||||
path: $[?(@.kind == "Ingress")].metadata.name
|
||||
value: release-name
|
||||
asserts:
|
||||
- equal:
|
||||
path: spec.rules[0].host
|
||||
value: RELEASE-NAME.hostname
|
|
@ -0,0 +1,52 @@
|
|||
---
|
||||
# yaml-language-server: $schema=https://raw.githubusercontent.com/helm-unittest/helm-unittest/main/schema/helm-testsuite.json
|
||||
suite: ingress - fields - hosts - paths - path
|
||||
templates:
|
||||
- common.yaml
|
||||
values:
|
||||
- ../_values/ingress_main_default_hosts.yaml
|
||||
- ../_values/service_main_default.yaml
|
||||
- ../_values/controllers_main_default_container.yaml
|
||||
tests:
|
||||
- it: default should pass
|
||||
documentSelector:
|
||||
path: $[?(@.kind == "Ingress")].metadata.name
|
||||
value: release-name
|
||||
asserts:
|
||||
- equal:
|
||||
path: spec.rules[0].http.paths[0].path
|
||||
value: "/"
|
||||
|
||||
- it: custom path should pass
|
||||
set:
|
||||
ingress.main:
|
||||
hosts:
|
||||
- host: chart-test.local
|
||||
paths:
|
||||
- path: /test
|
||||
service:
|
||||
identifier: main
|
||||
documentSelector:
|
||||
path: $[?(@.kind == "Ingress")].metadata.name
|
||||
value: release-name
|
||||
asserts:
|
||||
- equal:
|
||||
path: spec.rules[0].http.paths[0].path
|
||||
value: "/test"
|
||||
|
||||
- it: path with template should pass
|
||||
set:
|
||||
ingress.main:
|
||||
hosts:
|
||||
- host: chart-test.local
|
||||
paths:
|
||||
- path: "/{{ .Release.Name }}.path"
|
||||
service:
|
||||
identifier: main
|
||||
documentSelector:
|
||||
path: $[?(@.kind == "Ingress")].metadata.name
|
||||
value: release-name
|
||||
asserts:
|
||||
- equal:
|
||||
path: spec.rules[0].http.paths[0].path
|
||||
value: "/RELEASE-NAME.path"
|
|
@ -1,6 +1,6 @@
|
|||
---
|
||||
# yaml-language-server: $schema=https://raw.githubusercontent.com/helm-unittest/helm-unittest/main/schema/helm-testsuite.json
|
||||
suite: ingress service reference
|
||||
suite: ingress - fields - hosts - paths - service
|
||||
templates:
|
||||
- common.yaml
|
||||
values:
|
||||
|
@ -15,12 +15,11 @@ tests:
|
|||
ports:
|
||||
http:
|
||||
port: &httpPort 8081
|
||||
documentSelector:
|
||||
path: $[?(@.kind == "Ingress")].metadata.name
|
||||
value: release-name
|
||||
asserts:
|
||||
- documentIndex: &IngressDocument 2
|
||||
isKind:
|
||||
of: Ingress
|
||||
- documentIndex: *IngressDocument
|
||||
equal:
|
||||
- equal:
|
||||
path: spec.rules[0].http.paths[0].backend
|
||||
value:
|
||||
service:
|
||||
|
@ -38,12 +37,11 @@ tests:
|
|||
service:
|
||||
name: pathService
|
||||
port: 1234
|
||||
documentSelector:
|
||||
path: $[?(@.kind == "Ingress")].metadata.name
|
||||
value: release-name
|
||||
asserts:
|
||||
- documentIndex: &IngressDocument 1
|
||||
isKind:
|
||||
of: Ingress
|
||||
- documentIndex: *IngressDocument
|
||||
equal:
|
||||
- equal:
|
||||
path: spec.rules[0].http.paths[0].backend
|
||||
value:
|
||||
service:
|
||||
|
@ -59,21 +57,75 @@ tests:
|
|||
paths:
|
||||
- path: /
|
||||
service:
|
||||
name: "{{ .Release.Name }}"
|
||||
name: "{{ .Release.Name | lower }}"
|
||||
port: 1234
|
||||
documentSelector:
|
||||
path: $[?(@.kind == "Ingress")].metadata.name
|
||||
value: release-name
|
||||
asserts:
|
||||
- documentIndex: &IngressDocument 1
|
||||
isKind:
|
||||
of: Ingress
|
||||
- documentIndex: *IngressDocument
|
||||
equal:
|
||||
- equal:
|
||||
path: spec.rules[0].http.paths[0].backend
|
||||
value:
|
||||
service:
|
||||
name: RELEASE-NAME
|
||||
name: release-name
|
||||
port:
|
||||
number: 1234
|
||||
|
||||
- it: automatic service and port reference should pass
|
||||
set:
|
||||
service:
|
||||
main:
|
||||
controller: main
|
||||
ports:
|
||||
http:
|
||||
port: 8081
|
||||
http2:
|
||||
port: 1880
|
||||
ingress:
|
||||
main:
|
||||
className: "nginx"
|
||||
hosts:
|
||||
- host: http.chart-test.local
|
||||
paths:
|
||||
- path: /
|
||||
pathType: Prefix
|
||||
- host: http2.chart-test.local
|
||||
paths:
|
||||
- path: /
|
||||
pathType: Prefix
|
||||
service:
|
||||
port: http2
|
||||
documentSelector:
|
||||
path: $[?(@.kind == "Ingress")].metadata.name
|
||||
value: release-name
|
||||
asserts:
|
||||
# First Ingress host
|
||||
- equal:
|
||||
path: spec.rules[0].host
|
||||
value: http.chart-test.local
|
||||
- equal:
|
||||
path: spec.rules[0].http.paths[0].path
|
||||
value: "/"
|
||||
- equal:
|
||||
path: spec.rules[0].http.paths[0].backend.service.name
|
||||
value: release-name
|
||||
- equal:
|
||||
path: spec.rules[0].http.paths[0].backend.service.port.number
|
||||
value: 8081
|
||||
# Second Ingress host
|
||||
- equal:
|
||||
path: spec.rules[1].host
|
||||
value: http2.chart-test.local
|
||||
- equal:
|
||||
path: spec.rules[1].http.paths[0].path
|
||||
value: "/"
|
||||
- equal:
|
||||
path: spec.rules[1].http.paths[0].backend.service.name
|
||||
value: release-name
|
||||
- equal:
|
||||
path: spec.rules[1].http.paths[0].backend.service.port.number
|
||||
value: 1880
|
||||
|
||||
- it: multiple hosts with port name references should pass
|
||||
set:
|
||||
service:
|
||||
|
@ -103,41 +155,33 @@ tests:
|
|||
service:
|
||||
identifier: main
|
||||
port: http2
|
||||
documentSelector:
|
||||
path: $[?(@.kind == "Ingress")].metadata.name
|
||||
value: release-name
|
||||
asserts:
|
||||
- documentIndex: &IngressDocument 2
|
||||
isKind:
|
||||
of: Ingress
|
||||
# First Ingress host
|
||||
- documentIndex: *IngressDocument
|
||||
equal:
|
||||
- equal:
|
||||
path: spec.rules[0].host
|
||||
value: http.chart-test.local
|
||||
- documentIndex: *IngressDocument
|
||||
equal:
|
||||
- equal:
|
||||
path: spec.rules[0].http.paths[0].path
|
||||
value: "/"
|
||||
- documentIndex: *IngressDocument
|
||||
equal:
|
||||
- equal:
|
||||
path: spec.rules[0].http.paths[0].backend.service.name
|
||||
value: "RELEASE-NAME"
|
||||
- documentIndex: *IngressDocument
|
||||
equal:
|
||||
value: release-name
|
||||
- equal:
|
||||
path: spec.rules[0].http.paths[0].backend.service.port.number
|
||||
value: *httpPort
|
||||
# Second Ingress host
|
||||
- documentIndex: *IngressDocument
|
||||
equal:
|
||||
- equal:
|
||||
path: spec.rules[1].host
|
||||
value: http2.chart-test.local
|
||||
- documentIndex: *IngressDocument
|
||||
equal:
|
||||
- equal:
|
||||
path: spec.rules[1].http.paths[0].path
|
||||
value: "/"
|
||||
- documentIndex: *IngressDocument
|
||||
equal:
|
||||
- equal:
|
||||
path: spec.rules[1].http.paths[0].backend.service.name
|
||||
value: "RELEASE-NAME"
|
||||
- documentIndex: *IngressDocument
|
||||
equal:
|
||||
value: release-name
|
||||
- equal:
|
||||
path: spec.rules[1].http.paths[0].backend.service.port.number
|
||||
value: *http2Port
|
|
@ -1,6 +1,6 @@
|
|||
---
|
||||
# yaml-language-server: $schema=https://raw.githubusercontent.com/helm-unittest/helm-unittest/main/schema/helm-testsuite.json
|
||||
suite: ingress tls
|
||||
suite: ingress - fields - tls
|
||||
templates:
|
||||
- common.yaml
|
||||
values:
|
||||
|
@ -8,12 +8,11 @@ values:
|
|||
- ../_values/controllers_main_default_container.yaml
|
||||
tests:
|
||||
- it: default should pass
|
||||
documentSelector:
|
||||
path: $[?(@.kind == "Ingress")].metadata.name
|
||||
value: release-name
|
||||
asserts:
|
||||
- documentIndex: &IngressDocument 1
|
||||
isKind:
|
||||
of: Ingress
|
||||
- documentIndex: *IngressDocument
|
||||
notExists:
|
||||
- notExists:
|
||||
path: spec.tls
|
||||
|
||||
- it: tls enabled should pass
|
||||
|
@ -23,12 +22,11 @@ tests:
|
|||
- secretName: test
|
||||
hosts:
|
||||
- hostname
|
||||
documentSelector:
|
||||
path: $[?(@.kind == "Ingress")].metadata.name
|
||||
value: release-name
|
||||
asserts:
|
||||
- documentIndex: &IngressDocument 1
|
||||
isKind:
|
||||
of: Ingress
|
||||
- documentIndex: *IngressDocument
|
||||
equal:
|
||||
- equal:
|
||||
path: spec.tls[0]
|
||||
value:
|
||||
secretName: test
|
||||
|
@ -41,12 +39,11 @@ tests:
|
|||
tls:
|
||||
- hosts:
|
||||
- hostname
|
||||
documentSelector:
|
||||
path: $[?(@.kind == "Ingress")].metadata.name
|
||||
value: release-name
|
||||
asserts:
|
||||
- documentIndex: &IngressDocument 1
|
||||
isKind:
|
||||
of: Ingress
|
||||
- documentIndex: *IngressDocument
|
||||
equal:
|
||||
- equal:
|
||||
path: spec.tls[0]
|
||||
value:
|
||||
hosts:
|
||||
|
@ -56,18 +53,17 @@ tests:
|
|||
set:
|
||||
ingress.main:
|
||||
tls:
|
||||
- secretName: "{{ .Release.Name }}-secret"
|
||||
- secretName: "{{ .Release.Name | lower }}-secret"
|
||||
hosts:
|
||||
- hostname
|
||||
documentSelector:
|
||||
path: $[?(@.kind == "Ingress")].metadata.name
|
||||
value: release-name
|
||||
asserts:
|
||||
- documentIndex: &IngressDocument 1
|
||||
isKind:
|
||||
of: Ingress
|
||||
- documentIndex: *IngressDocument
|
||||
equal:
|
||||
- equal:
|
||||
path: spec.tls[0]
|
||||
value:
|
||||
secretName: RELEASE-NAME-secret
|
||||
secretName: release-name-secret
|
||||
hosts:
|
||||
- hostname
|
||||
|
||||
|
@ -78,12 +74,11 @@ tests:
|
|||
- secretName: '{{ "" }}'
|
||||
hosts:
|
||||
- hostname
|
||||
documentSelector:
|
||||
path: $[?(@.kind == "Ingress")].metadata.name
|
||||
value: release-name
|
||||
asserts:
|
||||
- documentIndex: &IngressDocument 1
|
||||
isKind:
|
||||
of: Ingress
|
||||
- documentIndex: *IngressDocument
|
||||
equal:
|
||||
- equal:
|
||||
path: spec.tls[0]
|
||||
value:
|
||||
hosts:
|
|
@ -0,0 +1,31 @@
|
|||
---
|
||||
# yaml-language-server: $schema=https://raw.githubusercontent.com/helm-unittest/helm-unittest/main/schema/helm-testsuite.json
|
||||
suite: ingress - fields - defaultBackend
|
||||
templates:
|
||||
- common.yaml
|
||||
values:
|
||||
- ../_values/ingress_main_default_hosts.yaml
|
||||
- ../_values/service_main_default.yaml
|
||||
- ../_values/controllers_main_default_container.yaml
|
||||
tests:
|
||||
- it: with defaultBackend should pass
|
||||
set:
|
||||
ingress.main:
|
||||
defaultBackend:
|
||||
resource:
|
||||
apiGroup: k8s.example.com
|
||||
kind: StorageBucket
|
||||
name: static-assets
|
||||
documentSelector:
|
||||
path: $[?(@.kind == "Ingress")].metadata.name
|
||||
value: release-name
|
||||
asserts:
|
||||
- equal:
|
||||
path: spec.defaultBackend
|
||||
value:
|
||||
resource:
|
||||
apiGroup: k8s.example.com
|
||||
kind: StorageBucket
|
||||
name: static-assets
|
||||
- notExists:
|
||||
path: spec.rules
|
|
@ -0,0 +1,61 @@
|
|||
---
|
||||
# yaml-language-server: $schema=https://raw.githubusercontent.com/helm-unittest/helm-unittest/main/schema/helm-testsuite.json
|
||||
suite: "ingress - metadata - annotations"
|
||||
templates:
|
||||
- common.yaml
|
||||
values:
|
||||
- ../_values/ingress_main_default_hosts.yaml
|
||||
- ../_values/controllers_main_default_container.yaml
|
||||
tests:
|
||||
- it: no annotations are set by default
|
||||
documentSelector:
|
||||
path: $[?(@.kind == "Ingress")].metadata.name
|
||||
value: release-name
|
||||
asserts:
|
||||
- notExists:
|
||||
path: metadata.annotations
|
||||
|
||||
- it: custom annotations
|
||||
set:
|
||||
ingress.main.annotations:
|
||||
test_annotation: test
|
||||
documentSelector:
|
||||
path: $[?(@.kind == "Ingress")].metadata.name
|
||||
value: release-name
|
||||
asserts:
|
||||
- equal:
|
||||
path: metadata.annotations
|
||||
value:
|
||||
test_annotation: test
|
||||
|
||||
- it: custom annotations mixed with global annotations
|
||||
set:
|
||||
global.annotations:
|
||||
global_annotation: test
|
||||
ingress.main.annotations:
|
||||
test_annotation: test
|
||||
documentSelector:
|
||||
path: $[?(@.kind == "Ingress")].metadata.name
|
||||
value: release-name
|
||||
asserts:
|
||||
- equal:
|
||||
path: metadata.annotations
|
||||
value:
|
||||
global_annotation: test
|
||||
test_annotation: test
|
||||
|
||||
- it: custom annotations with templates
|
||||
set:
|
||||
ingress.main.annotations:
|
||||
template_annotation1: "{{ .Release.Name | lower }}"
|
||||
template_annotation2: "{{ .Chart.Name | lower }}"
|
||||
documentSelector:
|
||||
path: $[?(@.kind == "Ingress")].metadata.name
|
||||
value: release-name
|
||||
asserts:
|
||||
- equal:
|
||||
path: metadata.annotations["template_annotation1"]
|
||||
value: release-name
|
||||
- equal:
|
||||
path: metadata.annotations["template_annotation2"]
|
||||
value: common-test
|
|
@ -0,0 +1,74 @@
|
|||
---
|
||||
# yaml-language-server: $schema=https://raw.githubusercontent.com/helm-unittest/helm-unittest/main/schema/helm-testsuite.json
|
||||
suite: "ingress - metadata - labels"
|
||||
templates:
|
||||
- common.yaml
|
||||
values:
|
||||
- ../_values/ingress_main_default_hosts.yaml
|
||||
- ../_values/controllers_main_default_container.yaml
|
||||
tests:
|
||||
- it: default labels
|
||||
documentSelector:
|
||||
path: $[?(@.kind == "Ingress")].metadata.name
|
||||
value: release-name
|
||||
asserts:
|
||||
- equal:
|
||||
path: metadata.labels
|
||||
value:
|
||||
app.kubernetes.io/instance: RELEASE-NAME
|
||||
app.kubernetes.io/managed-by: Helm
|
||||
app.kubernetes.io/name: RELEASE-NAME
|
||||
helm.sh/chart: common-test-1.0.0
|
||||
|
||||
- it: custom labels
|
||||
set:
|
||||
ingress.main.labels:
|
||||
test_label: test
|
||||
documentSelector:
|
||||
path: $[?(@.kind == "Ingress")].metadata.name
|
||||
value: release-name
|
||||
asserts:
|
||||
- equal:
|
||||
path: metadata.labels
|
||||
value:
|
||||
app.kubernetes.io/instance: RELEASE-NAME
|
||||
app.kubernetes.io/managed-by: Helm
|
||||
app.kubernetes.io/name: RELEASE-NAME
|
||||
helm.sh/chart: common-test-1.0.0
|
||||
test_label: test
|
||||
|
||||
- it: custom labels mixed with global labels
|
||||
set:
|
||||
global.labels:
|
||||
global_label: test
|
||||
ingress.main.labels:
|
||||
test_label: test
|
||||
documentSelector:
|
||||
path: $[?(@.kind == "Ingress")].metadata.name
|
||||
value: release-name
|
||||
asserts:
|
||||
- equal:
|
||||
path: metadata.labels
|
||||
value:
|
||||
app.kubernetes.io/instance: RELEASE-NAME
|
||||
app.kubernetes.io/managed-by: Helm
|
||||
app.kubernetes.io/name: RELEASE-NAME
|
||||
global_label: test
|
||||
helm.sh/chart: common-test-1.0.0
|
||||
test_label: test
|
||||
|
||||
- it: custom labels with templates
|
||||
set:
|
||||
ingress.main.labels:
|
||||
template_label1: "{{ .Release.Name | lower }}"
|
||||
template_label2: "{{ .Chart.Name | lower }}"
|
||||
documentSelector:
|
||||
path: $[?(@.kind == "Ingress")].metadata.name
|
||||
value: release-name
|
||||
asserts:
|
||||
- equal:
|
||||
path: metadata.labels["template_label1"]
|
||||
value: release-name
|
||||
- equal:
|
||||
path: metadata.labels["template_label2"]
|
||||
value: common-test
|
|
@ -0,0 +1,211 @@
|
|||
---
|
||||
# yaml-language-server: $schema=https://raw.githubusercontent.com/helm-unittest/helm-unittest/main/schema/helm-testsuite.json
|
||||
suite: ingress - metadata - name
|
||||
templates:
|
||||
- common.yaml
|
||||
values:
|
||||
- ../_values/controllers_main_default_container.yaml
|
||||
- ../_values/ingress_main_default_hosts.yaml
|
||||
- ../_values/service_main_default.yaml
|
||||
tests:
|
||||
- it: name defaults to chart fullName
|
||||
asserts:
|
||||
- containsDocument:
|
||||
kind: Ingress
|
||||
apiVersion: networking.k8s.io/v1
|
||||
name: release-name
|
||||
any: true
|
||||
|
||||
- it: forceRename
|
||||
set:
|
||||
ingress.main.forceRename: forceRename
|
||||
asserts:
|
||||
- containsDocument:
|
||||
kind: Ingress
|
||||
apiVersion: networking.k8s.io/v1
|
||||
name: forcerename
|
||||
any: true
|
||||
|
||||
- it: forceRename with template
|
||||
set:
|
||||
ingress.main.forceRename: "{{ .Chart.Name }}"
|
||||
asserts:
|
||||
- containsDocument:
|
||||
kind: Ingress
|
||||
apiVersion: networking.k8s.io/v1
|
||||
name: common-test
|
||||
any: true
|
||||
|
||||
- it: prefix
|
||||
set:
|
||||
ingress.main.prefix: prefix
|
||||
asserts:
|
||||
- containsDocument:
|
||||
kind: Ingress
|
||||
apiVersion: networking.k8s.io/v1
|
||||
name: prefix-release-name
|
||||
any: true
|
||||
|
||||
- it: prefix with template
|
||||
set:
|
||||
ingress.main.prefix: "{{ .Chart.Name }}"
|
||||
asserts:
|
||||
- containsDocument:
|
||||
kind: Ingress
|
||||
apiVersion: networking.k8s.io/v1
|
||||
name: common-test-release-name
|
||||
any: true
|
||||
|
||||
- it: suffix
|
||||
set:
|
||||
ingress.main.suffix: suffix
|
||||
asserts:
|
||||
- containsDocument:
|
||||
kind: Ingress
|
||||
apiVersion: networking.k8s.io/v1
|
||||
name: release-name-suffix
|
||||
any: true
|
||||
|
||||
- it: suffix with template
|
||||
set:
|
||||
ingress.main.suffix: "{{ .Chart.Name }}"
|
||||
asserts:
|
||||
- containsDocument:
|
||||
kind: Ingress
|
||||
apiVersion: networking.k8s.io/v1
|
||||
name: release-name-common-test
|
||||
any: true
|
||||
|
||||
- it: both prefix and suffix
|
||||
set:
|
||||
ingress.main.prefix: prefix
|
||||
ingress.main.suffix: suffix
|
||||
asserts:
|
||||
- containsDocument:
|
||||
kind: Ingress
|
||||
apiVersion: networking.k8s.io/v1
|
||||
name: prefix-release-name-suffix
|
||||
any: true
|
||||
|
||||
- it: prefix, suffix and forceRename (illegal combination)
|
||||
set:
|
||||
ingress.main.forceRename: forceRename
|
||||
ingress.main.prefix: prefix
|
||||
ingress.main.suffix: suffix
|
||||
asserts:
|
||||
- failedTemplate:
|
||||
errorPattern: "values don't meet the specifications of the schema"
|
||||
|
||||
- it: multiple items
|
||||
set:
|
||||
ingress:
|
||||
second:
|
||||
hosts:
|
||||
- host: "chart-example.local"
|
||||
paths:
|
||||
- path: /
|
||||
service:
|
||||
name: RELEASE-NAME
|
||||
port: 8081
|
||||
asserts:
|
||||
- containsDocument:
|
||||
kind: Ingress
|
||||
apiVersion: networking.k8s.io/v1
|
||||
name: release-name-main
|
||||
any: true
|
||||
- containsDocument:
|
||||
kind: Ingress
|
||||
apiVersion: networking.k8s.io/v1
|
||||
name: release-name-second
|
||||
any: true
|
||||
|
||||
- it: multiple items with prefix
|
||||
set:
|
||||
ingress:
|
||||
second:
|
||||
prefix: prefix
|
||||
hosts:
|
||||
- host: "chart-example.local"
|
||||
paths:
|
||||
- path: /
|
||||
service:
|
||||
name: RELEASE-NAME
|
||||
port: 8081
|
||||
asserts:
|
||||
- containsDocument:
|
||||
kind: Ingress
|
||||
apiVersion: networking.k8s.io/v1
|
||||
name: release-name-main
|
||||
any: true
|
||||
- containsDocument:
|
||||
kind: Ingress
|
||||
apiVersion: networking.k8s.io/v1
|
||||
name: prefix-release-name-second
|
||||
any: true
|
||||
|
||||
- it: multiple items with suffix
|
||||
set:
|
||||
ingress:
|
||||
second:
|
||||
suffix: suffix
|
||||
hosts:
|
||||
- host: "chart-example.local"
|
||||
paths:
|
||||
- path: /
|
||||
service:
|
||||
name: RELEASE-NAME
|
||||
port: 8081
|
||||
asserts:
|
||||
- containsDocument:
|
||||
kind: Ingress
|
||||
apiVersion: networking.k8s.io/v1
|
||||
name: release-name-main
|
||||
any: true
|
||||
- containsDocument:
|
||||
kind: Ingress
|
||||
apiVersion: networking.k8s.io/v1
|
||||
name: release-name-second-suffix
|
||||
any: true
|
||||
|
||||
- it: multiple items with prefix and suffix
|
||||
set:
|
||||
ingress:
|
||||
second:
|
||||
prefix: prefix
|
||||
suffix: suffix
|
||||
hosts:
|
||||
- host: "chart-example.local"
|
||||
paths:
|
||||
- path: /
|
||||
service:
|
||||
name: RELEASE-NAME
|
||||
port: 8081
|
||||
asserts:
|
||||
- containsDocument:
|
||||
kind: Ingress
|
||||
apiVersion: networking.k8s.io/v1
|
||||
name: release-name-main
|
||||
any: true
|
||||
- containsDocument:
|
||||
kind: Ingress
|
||||
apiVersion: networking.k8s.io/v1
|
||||
name: prefix-release-name-second-suffix
|
||||
any: true
|
||||
|
||||
- it: multiple items with prefix, suffix and forceRename (illegal combination)
|
||||
set:
|
||||
ingress:
|
||||
second:
|
||||
forceRename: forceRename
|
||||
prefix: prefix
|
||||
suffix: suffix
|
||||
hosts:
|
||||
- host: "chart-example.local"
|
||||
paths:
|
||||
- path: /
|
||||
service:
|
||||
name: RELEASE-NAME
|
||||
port: 8081
|
||||
asserts:
|
||||
- failedTemplate:
|
||||
errorPattern: "values don't meet the specifications of the schema"
|
|
@ -1,115 +0,0 @@
|
|||
---
|
||||
# yaml-language-server: $schema=https://raw.githubusercontent.com/helm-unittest/helm-unittest/main/schema/helm-testsuite.json
|
||||
suite: ingress metadata
|
||||
templates:
|
||||
- common.yaml
|
||||
values:
|
||||
- ../_values/ingress_main_default_hosts.yaml
|
||||
- ../_values/controllers_main_default_container.yaml
|
||||
tests:
|
||||
- it: default metadata should pass
|
||||
asserts:
|
||||
- documentIndex: &IngressDocument 1
|
||||
isKind:
|
||||
of: Ingress
|
||||
- documentIndex: *IngressDocument
|
||||
notExists:
|
||||
path: metadata.annotations
|
||||
- documentIndex: *IngressDocument
|
||||
equal:
|
||||
path: metadata.labels
|
||||
value:
|
||||
app.kubernetes.io/instance: RELEASE-NAME
|
||||
app.kubernetes.io/managed-by: Helm
|
||||
app.kubernetes.io/name: RELEASE-NAME
|
||||
helm.sh/chart: common-test-1.0.0
|
||||
|
||||
- it: custom metadata should pass
|
||||
set:
|
||||
ingress.main:
|
||||
annotations:
|
||||
test_annotation: test
|
||||
labels:
|
||||
test_label: test
|
||||
asserts:
|
||||
- documentIndex: &IngressDocument 1
|
||||
isKind:
|
||||
of: Ingress
|
||||
- documentIndex: *IngressDocument
|
||||
equal:
|
||||
path: metadata.annotations
|
||||
value:
|
||||
test_annotation: test
|
||||
- documentIndex: *IngressDocument
|
||||
equal:
|
||||
path: metadata.labels
|
||||
value:
|
||||
app.kubernetes.io/instance: RELEASE-NAME
|
||||
app.kubernetes.io/managed-by: Helm
|
||||
app.kubernetes.io/name: RELEASE-NAME
|
||||
helm.sh/chart: common-test-1.0.0
|
||||
test_label: test
|
||||
|
||||
- it: custom metadata with global metadata should pass
|
||||
set:
|
||||
global:
|
||||
labels:
|
||||
global_label: test
|
||||
annotations:
|
||||
global_annotation: test
|
||||
ingress.main:
|
||||
annotations:
|
||||
test_annotation: test
|
||||
labels:
|
||||
test_label: test
|
||||
asserts:
|
||||
- documentIndex: &IngressDocument 1
|
||||
isKind:
|
||||
of: Ingress
|
||||
- documentIndex: *IngressDocument
|
||||
equal:
|
||||
path: metadata.annotations
|
||||
value:
|
||||
global_annotation: test
|
||||
test_annotation: test
|
||||
- documentIndex: *IngressDocument
|
||||
equal:
|
||||
path: metadata.labels
|
||||
value:
|
||||
app.kubernetes.io/instance: RELEASE-NAME
|
||||
app.kubernetes.io/managed-by: Helm
|
||||
app.kubernetes.io/name: RELEASE-NAME
|
||||
global_label: test
|
||||
helm.sh/chart: common-test-1.0.0
|
||||
test_label: test
|
||||
|
||||
|
||||
- it: custom metadata with templates should pass
|
||||
set:
|
||||
ingress.main:
|
||||
annotations:
|
||||
template_annotation1: "{{ .Release.Name | lower }}"
|
||||
template_annotation2: "{{ .Chart.Name | lower }}"
|
||||
labels:
|
||||
template_label1: "{{ .Release.Name | lower }}"
|
||||
template_label2: "{{ .Chart.Name | lower }}"
|
||||
asserts:
|
||||
- documentIndex: &IngressDocument 1
|
||||
isKind:
|
||||
of: Ingress
|
||||
- documentIndex: *IngressDocument
|
||||
equal:
|
||||
path: metadata.annotations["template_annotation1"]
|
||||
value: release-name
|
||||
- documentIndex: *IngressDocument
|
||||
equal:
|
||||
path: metadata.annotations["template_annotation2"]
|
||||
value: common-test
|
||||
- documentIndex: *IngressDocument
|
||||
equal:
|
||||
path: metadata.labels["template_label1"]
|
||||
value: release-name
|
||||
- documentIndex: *IngressDocument
|
||||
equal:
|
||||
path: metadata.labels["template_label2"]
|
||||
value: common-test
|
|
@ -1,20 +1,18 @@
|
|||
---
|
||||
# yaml-language-server: $schema=https://raw.githubusercontent.com/helm-unittest/helm-unittest/main/schema/helm-testsuite.json
|
||||
suite: ingress presence
|
||||
suite: ingress - presence
|
||||
templates:
|
||||
- common.yaml
|
||||
values:
|
||||
- ../_values/controllers_main_default_container.yaml
|
||||
- ../_values/controllers_main_default_container.yaml
|
||||
tests:
|
||||
- it: default should pass
|
||||
asserts:
|
||||
- hasDocuments:
|
||||
count: 1
|
||||
- documentIndex: 0
|
||||
not: true
|
||||
isKind:
|
||||
of: Ingress
|
||||
- not: true
|
||||
containsDocument:
|
||||
apiVersion: networking.k8s.io/v1
|
||||
kind: Ingress
|
||||
any: true
|
||||
|
||||
- it: explicitly disabled should pass
|
||||
values:
|
||||
|
@ -22,12 +20,11 @@ tests:
|
|||
set:
|
||||
ingress.main.enabled: false
|
||||
asserts:
|
||||
- hasDocuments:
|
||||
count: 1
|
||||
- documentIndex: 0
|
||||
not: true
|
||||
isKind:
|
||||
of: Ingress
|
||||
- not: true
|
||||
containsDocument:
|
||||
apiVersion: networking.k8s.io/v1
|
||||
kind: Ingress
|
||||
any: true
|
||||
|
||||
- it: explicitly enabled should pass
|
||||
values:
|
||||
|
@ -35,15 +32,11 @@ tests:
|
|||
set:
|
||||
ingress.main.enabled: true
|
||||
asserts:
|
||||
- hasDocuments:
|
||||
count: 2
|
||||
- documentIndex: 0
|
||||
not: true
|
||||
isKind:
|
||||
of: Ingress
|
||||
- documentIndex: 1
|
||||
isKind:
|
||||
of: Ingress
|
||||
- containsDocument:
|
||||
apiVersion: networking.k8s.io/v1
|
||||
kind: Ingress
|
||||
name: release-name
|
||||
any: true
|
||||
|
||||
- it: multiple ingress should pass
|
||||
values:
|
||||
|
@ -59,30 +52,16 @@ tests:
|
|||
identifier: main
|
||||
port: http
|
||||
asserts:
|
||||
- hasDocuments:
|
||||
count: 4
|
||||
- documentIndex: 0
|
||||
not: true
|
||||
isKind:
|
||||
of: Ingress
|
||||
- documentIndex: 1
|
||||
not: true
|
||||
isKind:
|
||||
of: Ingress
|
||||
- documentIndex: &FirstIngressDocument 2
|
||||
isKind:
|
||||
of: Ingress
|
||||
- documentIndex: *FirstIngressDocument
|
||||
equal:
|
||||
path: metadata.name
|
||||
value: RELEASE-NAME-main
|
||||
- documentIndex: &SecondIngressDocument 3
|
||||
isKind:
|
||||
of: Ingress
|
||||
- documentIndex: *SecondIngressDocument
|
||||
equal:
|
||||
path: metadata.name
|
||||
value: RELEASE-NAME-test
|
||||
- containsDocument:
|
||||
apiVersion: networking.k8s.io/v1
|
||||
kind: Ingress
|
||||
name: release-name-main
|
||||
any: true
|
||||
- containsDocument:
|
||||
apiVersion: networking.k8s.io/v1
|
||||
kind: Ingress
|
||||
name: release-name-test
|
||||
any: true
|
||||
|
||||
- it: multiple ingress with explicit disabled should pass
|
||||
values:
|
||||
|
@ -98,16 +77,14 @@ tests:
|
|||
identifier: main
|
||||
port: http
|
||||
asserts:
|
||||
- hasDocuments:
|
||||
count: 2
|
||||
- documentIndex: 0
|
||||
not: true
|
||||
isKind:
|
||||
of: Ingress
|
||||
- documentIndex: &FirstIngressDocument 1
|
||||
isKind:
|
||||
of: Ingress
|
||||
- documentIndex: *FirstIngressDocument
|
||||
equal:
|
||||
path: metadata.name
|
||||
value: RELEASE-NAME
|
||||
- containsDocument:
|
||||
apiVersion: networking.k8s.io/v1
|
||||
kind: Ingress
|
||||
name: release-name
|
||||
any: true
|
||||
- not: true
|
||||
containsDocument:
|
||||
apiVersion: networking.k8s.io/v1
|
||||
kind: Ingress
|
||||
name: release-name-test
|
||||
any: true
|
||||
|
|
|
@ -0,0 +1,55 @@
|
|||
---
|
||||
# yaml-language-server: $schema=https://raw.githubusercontent.com/helm-unittest/helm-unittest/main/schema/helm-testsuite.json
|
||||
suite: ingress - validations
|
||||
templates:
|
||||
- common.yaml
|
||||
values:
|
||||
- ../_values/controllers_main_default_container.yaml
|
||||
tests:
|
||||
- it: service reference to non-existing service should fail
|
||||
set:
|
||||
ingress.main.hosts:
|
||||
- host: "chart-example.local"
|
||||
paths:
|
||||
- path: /
|
||||
service:
|
||||
identifier: main
|
||||
port: 8081
|
||||
asserts:
|
||||
- failedTemplate:
|
||||
errorMessage: "No enabled Service found with this identifier. (ingress: 'main', path: '/', identifier: 'main')"
|
||||
|
||||
- it: automatic service determination should fail when no service is enabled
|
||||
set:
|
||||
ingress.main.hosts:
|
||||
- host: "chart-example.local"
|
||||
paths:
|
||||
- path: /
|
||||
service:
|
||||
port: 8081
|
||||
asserts:
|
||||
- failedTemplate:
|
||||
errorMessage: "Either service.name or service.identifier is required because automatic Service detection is not possible. (ingress: main, host: chart-example.local, path: /)"
|
||||
|
||||
- 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
|
||||
ingress.main.hosts:
|
||||
- host: "chart-example.local"
|
||||
paths:
|
||||
- path: /
|
||||
service:
|
||||
port: 8081
|
||||
asserts:
|
||||
- failedTemplate:
|
||||
errorMessage: "Either service.name or service.identifier is required because automatic Service detection is not possible. (ingress: main, host: chart-example.local, path: /)"
|
|
@ -1,132 +0,0 @@
|
|||
---
|
||||
# yaml-language-server: $schema=https://raw.githubusercontent.com/helm-unittest/helm-unittest/main/schema/helm-testsuite.json
|
||||
suite: ingress values
|
||||
templates:
|
||||
- common.yaml
|
||||
values:
|
||||
- ../_values/ingress_main_default_hosts.yaml
|
||||
- ../_values/service_main_default.yaml
|
||||
- ../_values/controllers_main_default_container.yaml
|
||||
tests:
|
||||
- it: default should pass
|
||||
asserts:
|
||||
- documentIndex: &IngressDocument 2
|
||||
isKind:
|
||||
of: Ingress
|
||||
- documentIndex: *IngressDocument
|
||||
equal:
|
||||
path: spec.rules[0].host
|
||||
value: chart-example.local
|
||||
- documentIndex: *IngressDocument
|
||||
equal:
|
||||
path: spec.rules[0].http.paths[0].path
|
||||
value: "/"
|
||||
|
||||
- it: nameOverride should pass
|
||||
set:
|
||||
ingress.main:
|
||||
nameOverride: test
|
||||
asserts:
|
||||
- documentIndex: &IngressDocument 2
|
||||
isKind:
|
||||
of: Ingress
|
||||
- documentIndex: *IngressDocument
|
||||
equal:
|
||||
path: metadata.name
|
||||
value: RELEASE-NAME-test
|
||||
|
||||
- it: nameOverride with template should pass
|
||||
set:
|
||||
ingress.main:
|
||||
nameOverride: "{{ .Release.Name }}"
|
||||
asserts:
|
||||
- documentIndex: &IngressDocument 2
|
||||
isKind:
|
||||
of: Ingress
|
||||
- documentIndex: *IngressDocument
|
||||
equal:
|
||||
path: metadata.name
|
||||
value: RELEASE-NAME
|
||||
|
||||
- it: custom host and path should pass
|
||||
set:
|
||||
ingress.main:
|
||||
hosts:
|
||||
- host: chart-test.local
|
||||
paths:
|
||||
- path: /test
|
||||
service:
|
||||
identifier: main
|
||||
asserts:
|
||||
- documentIndex: &IngressDocument 2
|
||||
isKind:
|
||||
of: Ingress
|
||||
- documentIndex: *IngressDocument
|
||||
equal:
|
||||
path: spec.rules[0].host
|
||||
value: chart-test.local
|
||||
- documentIndex: *IngressDocument
|
||||
equal:
|
||||
path: spec.rules[0].http.paths[0].path
|
||||
value: "/test"
|
||||
|
||||
- it: host with template should pass
|
||||
set:
|
||||
ingress.main:
|
||||
hosts:
|
||||
- host: "{{ .Release.Name }}.hostname"
|
||||
paths:
|
||||
- path: /
|
||||
service:
|
||||
identifier: main
|
||||
port: http
|
||||
asserts:
|
||||
- documentIndex: &IngressDocument 2
|
||||
isKind:
|
||||
of: Ingress
|
||||
- documentIndex: *IngressDocument
|
||||
equal:
|
||||
path: spec.rules[0].host
|
||||
value: RELEASE-NAME.hostname
|
||||
|
||||
- it: path with template should pass
|
||||
set:
|
||||
ingress.main:
|
||||
hosts:
|
||||
- host: chart-test.local
|
||||
paths:
|
||||
- path: "/{{ .Release.Name }}.path"
|
||||
service:
|
||||
identifier: main
|
||||
asserts:
|
||||
- documentIndex: &IngressDocument 2
|
||||
isKind:
|
||||
of: Ingress
|
||||
- documentIndex: *IngressDocument
|
||||
equal:
|
||||
path: spec.rules[0].http.paths[0].path
|
||||
value: "/RELEASE-NAME.path"
|
||||
|
||||
- it: with defaultBackend should pass
|
||||
set:
|
||||
ingress.main:
|
||||
defaultBackend:
|
||||
resource:
|
||||
apiGroup: k8s.example.com
|
||||
kind: StorageBucket
|
||||
name: static-assets
|
||||
asserts:
|
||||
- documentIndex: &IngressDocument 2
|
||||
isKind:
|
||||
of: Ingress
|
||||
- documentIndex: *IngressDocument
|
||||
equal:
|
||||
path: spec.defaultBackend
|
||||
value:
|
||||
resource:
|
||||
apiGroup: k8s.example.com
|
||||
kind: StorageBucket
|
||||
name: static-assets
|
||||
- documentIndex: *IngressDocument
|
||||
notExists:
|
||||
path: spec.rules
|
Loading…
Add table
Add a link
Reference in a new issue