diff --git a/charts/library/common-test/ci/advanced-values.yaml b/charts/library/common-test/ci/advanced-values.yaml index cbaa8c01..db967e26 100644 --- a/charts/library/common-test/ci/advanced-values.yaml +++ b/charts/library/common-test/ci/advanced-values.yaml @@ -48,6 +48,13 @@ controllers: HTTP_PORT: 8889 HTTPS_PORT: 9999 +service: + main: + controller: main + ports: + http: + port: 8081 + ingress: main: hosts: diff --git a/charts/library/common-test/tests/_values/service_main_default.yaml b/charts/library/common-test/tests/_values/service_main_default.yaml new file mode 100644 index 00000000..6f1f3956 --- /dev/null +++ b/charts/library/common-test/tests/_values/service_main_default.yaml @@ -0,0 +1,6 @@ +service: + main: + controller: main + ports: + http: + port: 8081 diff --git a/charts/library/common-test/tests/configmap/metadata_test.yaml b/charts/library/common-test/tests/configmap/metadata_test.yaml index 854dc8d5..23f8a124 100644 --- a/charts/library/common-test/tests/configmap/metadata_test.yaml +++ b/charts/library/common-test/tests/configmap/metadata_test.yaml @@ -12,8 +12,8 @@ tests: test: test asserts: - hasDocuments: - count: 3 - - documentIndex: &ConfigmapDocument 2 + count: 2 + - documentIndex: &ConfigmapDocument 1 isKind: of: ConfigMap - documentIndex: *ConfigmapDocument @@ -40,8 +40,8 @@ tests: test_label: test asserts: - hasDocuments: - count: 3 - - documentIndex: &ConfigmapDocument 2 + count: 2 + - documentIndex: &ConfigmapDocument 1 isKind: of: ConfigMap - documentIndex: *ConfigmapDocument @@ -76,8 +76,8 @@ tests: test_label: test asserts: - hasDocuments: - count: 3 - - documentIndex: &ConfigmapDocument 2 + count: 2 + - documentIndex: &ConfigmapDocument 1 isKind: of: ConfigMap - documentIndex: *ConfigmapDocument diff --git a/charts/library/common-test/tests/configmap/names_test.yaml b/charts/library/common-test/tests/configmap/names_test.yaml index 5c8718bc..57cbdd03 100644 --- a/charts/library/common-test/tests/configmap/names_test.yaml +++ b/charts/library/common-test/tests/configmap/names_test.yaml @@ -7,15 +7,11 @@ tests: - it: default should pass asserts: - hasDocuments: - count: 2 + count: 1 - documentIndex: 0 not: true isKind: of: ConfigMap - - documentIndex: 1 - not: true - isKind: - of: ConfigMap - it: with disabled configMap should pass set: @@ -26,15 +22,11 @@ tests: test: test asserts: - hasDocuments: - count: 2 + count: 1 - documentIndex: 0 not: true isKind: of: ConfigMap - - documentIndex: 1 - not: true - isKind: - of: ConfigMap - it: with multiple configMap should pass set: @@ -47,14 +39,14 @@ tests: test: test asserts: - hasDocuments: - count: 4 - - documentIndex: &FirstConfigmapDocument 2 + count: 3 + - documentIndex: &FirstConfigmapDocument 1 isKind: of: ConfigMap - documentIndex: *FirstConfigmapDocument isNotNullOrEmpty: path: metadata.name - - documentIndex: &SecondConfigmapDocument 3 + - documentIndex: &SecondConfigmapDocument 2 isKind: of: ConfigMap - documentIndex: *SecondConfigmapDocument @@ -69,8 +61,8 @@ tests: test: test asserts: - hasDocuments: - count: 3 - - documentIndex: &ConfigmapDocument 2 + count: 2 + - documentIndex: &ConfigmapDocument 1 isKind: of: ConfigMap - documentIndex: *ConfigmapDocument @@ -87,8 +79,8 @@ tests: nameOverride: http asserts: - hasDocuments: - count: 3 - - documentIndex: &ConfigmapDocument 2 + count: 2 + - documentIndex: &ConfigmapDocument 1 isKind: of: ConfigMap - documentIndex: *ConfigmapDocument diff --git a/charts/library/common-test/tests/container/probes_test.yaml b/charts/library/common-test/tests/container/probes_test.yaml index d908f802..b39ca2b9 100644 --- a/charts/library/common-test/tests/container/probes_test.yaml +++ b/charts/library/common-test/tests/container/probes_test.yaml @@ -14,6 +14,7 @@ tests: set: service: main: + controller: main ports: http: enabled: true @@ -57,6 +58,7 @@ tests: set: service: main: + controller: main ports: http: enabled: true @@ -104,6 +106,7 @@ tests: set: service: main: + controller: main ports: http: enabled: true @@ -148,6 +151,7 @@ tests: service: main: enabled: false + controller: main asserts: - documentIndex: 0 isKind: @@ -166,6 +170,7 @@ tests: set: service: main: + controller: main ports: http: protocol: HTTP @@ -198,6 +203,7 @@ tests: set: service: main: + controller: main ports: http: port: &port 80 @@ -229,6 +235,7 @@ tests: set: service: main: + controller: main ports: http: port: &port 80 @@ -260,6 +267,7 @@ tests: set: service: main: + controller: main ports: http: port: &port 80 @@ -296,6 +304,7 @@ tests: set: service: main: + controller: main ports: http: port: &port 80 @@ -332,6 +341,7 @@ tests: set: service: main: + controller: main ports: http: port: &port 80 @@ -368,6 +378,7 @@ tests: set: service: main: + controller: main ports: http: port: &port 80 @@ -396,6 +407,7 @@ tests: set: service: main: + controller: main ports: http: port: &port 80 @@ -424,6 +436,7 @@ tests: set: service: main: + controller: main ports: http: port: &port 80 @@ -452,6 +465,7 @@ tests: set: service: main: + controller: main ports: http: port: &port 80 diff --git a/charts/library/common-test/tests/controller/type_test.yaml b/charts/library/common-test/tests/controller/type_test.yaml index 17feb175..6705e7c5 100644 --- a/charts/library/common-test/tests/controller/type_test.yaml +++ b/charts/library/common-test/tests/controller/type_test.yaml @@ -29,14 +29,14 @@ tests: tag: 31 asserts: - hasDocuments: - count: 3 + count: 2 - documentIndex: &firstDeploymentDoc 0 isKind: of: Deployment - documentIndex: *firstDeploymentDoc equal: path: metadata.name - value: RELEASE-NAME + value: RELEASE-NAME-main - documentIndex: *firstDeploymentDoc equal: path: metadata.labels['app.kubernetes.io/component'] @@ -65,14 +65,14 @@ tests: tag: 31 asserts: - hasDocuments: - count: 3 + count: 2 - documentIndex: &firstDeploymentDoc 0 isKind: of: Deployment - documentIndex: *firstDeploymentDoc equal: path: metadata.name - value: RELEASE-NAME + value: RELEASE-NAME-main - documentIndex: *firstDeploymentDoc equal: path: metadata.labels['app.kubernetes.io/component'] @@ -131,16 +131,4 @@ tests: controllers.main.enabled: false asserts: - hasDocuments: - count: 1 - - documentIndex: &ControllerDoc 0 - not: true - isKind: - of: StatefulSet - - documentIndex: *ControllerDoc - not: true - isKind: - of: DaemonSet - - documentIndex: *ControllerDoc - not: true - isKind: - of: Controller + count: 0 diff --git a/charts/library/common-test/tests/ingress/metadata_test.yaml b/charts/library/common-test/tests/ingress/metadata_test.yaml index 37ba7e54..e97046f7 100644 --- a/charts/library/common-test/tests/ingress/metadata_test.yaml +++ b/charts/library/common-test/tests/ingress/metadata_test.yaml @@ -10,7 +10,7 @@ values: tests: - it: default metadata should pass asserts: - - documentIndex: &IngressDocument 2 + - documentIndex: &IngressDocument 1 isKind: of: Ingress - documentIndex: *IngressDocument @@ -33,7 +33,7 @@ tests: labels: test_label: test asserts: - - documentIndex: &IngressDocument 2 + - documentIndex: &IngressDocument 1 isKind: of: Ingress - documentIndex: *IngressDocument @@ -64,7 +64,7 @@ tests: labels: test_label: test asserts: - - documentIndex: &IngressDocument 2 + - documentIndex: &IngressDocument 1 isKind: of: Ingress - documentIndex: *IngressDocument diff --git a/charts/library/common-test/tests/ingress/presence_test.yaml b/charts/library/common-test/tests/ingress/presence_test.yaml index 0c1c16c2..d9f62312 100644 --- a/charts/library/common-test/tests/ingress/presence_test.yaml +++ b/charts/library/common-test/tests/ingress/presence_test.yaml @@ -7,15 +7,11 @@ tests: - it: default should pass asserts: - hasDocuments: - count: 2 + count: 1 - documentIndex: 0 not: true isKind: of: Ingress - - documentIndex: 1 - not: true - isKind: - of: Ingress - it: explicitly disabled should pass values: @@ -24,15 +20,11 @@ tests: ingress.main.enabled: false asserts: - hasDocuments: - count: 2 + count: 1 - documentIndex: 0 not: true isKind: of: Ingress - - documentIndex: 1 - not: true - isKind: - of: Ingress - it: explicitly enabled should pass values: @@ -41,16 +33,12 @@ tests: ingress.main.enabled: true asserts: - hasDocuments: - count: 3 + count: 2 - documentIndex: 0 not: true isKind: of: Ingress - documentIndex: 1 - not: true - isKind: - of: Ingress - - documentIndex: 2 isKind: of: Ingress @@ -68,23 +56,19 @@ tests: port: http asserts: - hasDocuments: - count: 4 + count: 3 - documentIndex: 0 not: true isKind: of: Ingress - - documentIndex: 1 - not: true - isKind: - of: Ingress - - documentIndex: &FirstIngressDocument 2 + - documentIndex: &FirstIngressDocument 1 isKind: of: Ingress - documentIndex: *FirstIngressDocument equal: path: metadata.name - value: RELEASE-NAME - - documentIndex: &SecondIngressDocument 3 + value: RELEASE-NAME-main + - documentIndex: &SecondIngressDocument 2 isKind: of: Ingress - documentIndex: *SecondIngressDocument @@ -107,16 +91,12 @@ tests: port: http asserts: - hasDocuments: - count: 3 + count: 2 - documentIndex: 0 not: true isKind: of: Ingress - - documentIndex: 1 - not: true - isKind: - of: Ingress - - documentIndex: &FirstIngressDocument 2 + - documentIndex: &FirstIngressDocument 1 isKind: of: Ingress - documentIndex: *FirstIngressDocument diff --git a/charts/library/common-test/tests/ingress/service_reference_test.yaml b/charts/library/common-test/tests/ingress/service_reference_test.yaml index 1db8e77e..7078c9d8 100644 --- a/charts/library/common-test/tests/ingress/service_reference_test.yaml +++ b/charts/library/common-test/tests/ingress/service_reference_test.yaml @@ -9,6 +9,13 @@ values: tests: - it: default should pass + set: + service: + main: + controller: main + ports: + http: + port: &httpPort 8081 asserts: - documentIndex: &IngressDocument 2 isKind: @@ -20,7 +27,7 @@ tests: service: name: RELEASE-NAME port: - number: 8080 + number: *httpPort - it: custom service reference should pass set: @@ -33,7 +40,7 @@ tests: name: pathService port: 1234 asserts: - - documentIndex: &IngressDocument 2 + - documentIndex: &IngressDocument 1 isKind: of: Ingress - documentIndex: *IngressDocument @@ -49,6 +56,7 @@ tests: set: service: main: + controller: main ports: http: port: &httpPort 8081 diff --git a/charts/library/common-test/tests/ingress/tls_test.yaml b/charts/library/common-test/tests/ingress/tls_test.yaml index a823fc54..818a1b08 100644 --- a/charts/library/common-test/tests/ingress/tls_test.yaml +++ b/charts/library/common-test/tests/ingress/tls_test.yaml @@ -10,7 +10,7 @@ values: tests: - it: default should pass asserts: - - documentIndex: &IngressDocument 2 + - documentIndex: &IngressDocument 1 isKind: of: Ingress - documentIndex: *IngressDocument @@ -25,7 +25,7 @@ tests: hosts: - hostname asserts: - - documentIndex: &IngressDocument 2 + - documentIndex: &IngressDocument 1 isKind: of: Ingress - documentIndex: *IngressDocument @@ -43,7 +43,7 @@ tests: - hosts: - hostname asserts: - - documentIndex: &IngressDocument 2 + - documentIndex: &IngressDocument 1 isKind: of: Ingress - documentIndex: *IngressDocument @@ -61,7 +61,7 @@ tests: hosts: - hostname asserts: - - documentIndex: &IngressDocument 2 + - documentIndex: &IngressDocument 1 isKind: of: Ingress - documentIndex: *IngressDocument @@ -80,7 +80,7 @@ tests: hosts: - hostname asserts: - - documentIndex: &IngressDocument 2 + - documentIndex: &IngressDocument 1 isKind: of: Ingress - documentIndex: *IngressDocument diff --git a/charts/library/common-test/tests/ingress/values_test.yaml b/charts/library/common-test/tests/ingress/values_test.yaml index 1155fa42..180eddc2 100644 --- a/charts/library/common-test/tests/ingress/values_test.yaml +++ b/charts/library/common-test/tests/ingress/values_test.yaml @@ -10,7 +10,7 @@ values: tests: - it: default should pass asserts: - - documentIndex: &IngressDocument 2 + - documentIndex: &IngressDocument 1 isKind: of: Ingress - documentIndex: *IngressDocument @@ -32,7 +32,7 @@ tests: service: name: main asserts: - - documentIndex: &IngressDocument 2 + - documentIndex: &IngressDocument 1 isKind: of: Ingress - documentIndex: *IngressDocument @@ -55,7 +55,7 @@ tests: name: main port: http asserts: - - documentIndex: &IngressDocument 2 + - documentIndex: &IngressDocument 1 isKind: of: Ingress - documentIndex: *IngressDocument @@ -73,7 +73,7 @@ tests: service: name: main asserts: - - documentIndex: &IngressDocument 2 + - documentIndex: &IngressDocument 1 isKind: of: Ingress - documentIndex: *IngressDocument @@ -86,7 +86,7 @@ tests: ingress.main: defaultBackend: test asserts: - - documentIndex: &IngressDocument 2 + - documentIndex: &IngressDocument 1 isKind: of: Ingress - documentIndex: *IngressDocument diff --git a/charts/library/common-test/tests/networkpolicy/metadata_test.yaml b/charts/library/common-test/tests/networkpolicy/metadata_test.yaml index 1f51c597..ead47fed 100644 --- a/charts/library/common-test/tests/networkpolicy/metadata_test.yaml +++ b/charts/library/common-test/tests/networkpolicy/metadata_test.yaml @@ -15,7 +15,7 @@ templates: tests: - it: default metadata should pass asserts: - - documentIndex: &NetworkPolicyDocument 2 + - documentIndex: &NetworkPolicyDocument 1 isKind: of: NetworkPolicy - documentIndex: *NetworkPolicyDocument @@ -39,7 +39,7 @@ tests: labels: test_label: test asserts: - - documentIndex: &NetworkPolicyDocument 2 + - documentIndex: &NetworkPolicyDocument 1 isKind: of: NetworkPolicy - documentIndex: *NetworkPolicyDocument @@ -71,7 +71,7 @@ tests: labels: test_label: test asserts: - - documentIndex: &NetworkPolicyDocument 2 + - documentIndex: &NetworkPolicyDocument 1 isKind: of: NetworkPolicy - documentIndex: *NetworkPolicyDocument diff --git a/charts/library/common-test/tests/networkpolicy/names_test.yaml b/charts/library/common-test/tests/networkpolicy/names_test.yaml index 0500099a..2bb0b87f 100644 --- a/charts/library/common-test/tests/networkpolicy/names_test.yaml +++ b/charts/library/common-test/tests/networkpolicy/names_test.yaml @@ -15,8 +15,8 @@ tests: rules: {} asserts: - hasDocuments: - count: 3 - - documentIndex: &NetworkPolicyDocument 2 + count: 2 + - documentIndex: &NetworkPolicyDocument 1 isKind: of: NetworkPolicy - documentIndex: *NetworkPolicyDocument @@ -35,7 +35,7 @@ tests: rules: {} nameOverride: block-ingress asserts: - - documentIndex: &NetworkPolicyDocument 2 + - documentIndex: &NetworkPolicyDocument 1 isKind: of: NetworkPolicy - documentIndex: *NetworkPolicyDocument diff --git a/charts/library/common-test/tests/networkpolicy/values_test.yaml b/charts/library/common-test/tests/networkpolicy/values_test.yaml index eff6ff7f..012b3066 100644 --- a/charts/library/common-test/tests/networkpolicy/values_test.yaml +++ b/charts/library/common-test/tests/networkpolicy/values_test.yaml @@ -8,13 +8,11 @@ tests: - it: main networkpolicy is disabled by default asserts: - hasDocuments: - count: 2 + count: 1 - documentIndex: 0 + not: true isKind: - of: Deployment - - documentIndex: 1 - isKind: - of: Service + of: NetworkPolicy - it: main networkpolicy can be enabled set: @@ -26,14 +24,11 @@ tests: rules: {} asserts: - hasDocuments: - count: 3 + count: 2 - documentIndex: 0 isKind: of: Deployment - documentIndex: 1 - isKind: - of: Service - - documentIndex: 2 isKind: of: NetworkPolicy @@ -47,7 +42,7 @@ tests: - Egress rules: {} asserts: - - documentIndex: &NetworkPolicyDocument 2 + - documentIndex: &NetworkPolicyDocument 1 isKind: of: NetworkPolicy - documentIndex: *NetworkPolicyDocument @@ -70,7 +65,7 @@ tests: podSelector: {} rules: {} asserts: - - documentIndex: &NetworkPolicyDocument 2 + - documentIndex: &NetworkPolicyDocument 1 isKind: of: NetworkPolicy - documentIndex: *NetworkPolicyDocument @@ -92,7 +87,7 @@ tests: egress: - {} asserts: - - documentIndex: &NetworkPolicyDocument 2 + - documentIndex: &NetworkPolicyDocument 1 isKind: of: NetworkPolicy - documentIndex: *NetworkPolicyDocument diff --git a/charts/library/common-test/tests/pod/field_serviceAccount_test.yaml b/charts/library/common-test/tests/pod/field_serviceAccount_test.yaml index f197ef12..17a77dd1 100644 --- a/charts/library/common-test/tests/pod/field_serviceAccount_test.yaml +++ b/charts/library/common-test/tests/pod/field_serviceAccount_test.yaml @@ -7,7 +7,7 @@ tests: - it: default should pass asserts: - hasDocuments: - count: 2 + count: 1 - documentIndex: &deploymentDocument 0 isKind: of: Deployment @@ -22,7 +22,7 @@ tests: create: true asserts: - hasDocuments: - count: 4 + count: 3 - documentIndex: &serviceAccountDocument 0 isKind: of: ServiceAccount @@ -41,7 +41,7 @@ tests: name: mySA asserts: - hasDocuments: - count: 4 + count: 3 - documentIndex: &serviceAccountDocument 0 isKind: of: ServiceAccount @@ -60,7 +60,7 @@ tests: name: mySA asserts: - hasDocuments: - count: 2 + count: 1 - documentIndex: &deploymentDocument 0 isKind: of: Deployment diff --git a/charts/library/common-test/tests/pvc/names_test.yaml b/charts/library/common-test/tests/pvc/names_test.yaml index bb3fb887..db14e9c8 100644 --- a/charts/library/common-test/tests/pvc/names_test.yaml +++ b/charts/library/common-test/tests/pvc/names_test.yaml @@ -15,22 +15,18 @@ tests: persistence.config.enabled: false asserts: - hasDocuments: - count: 2 + count: 1 - documentIndex: 0 not: true isKind: of: PersistentVolumeClaim - - documentIndex: 1 - not: true - isKind: - of: PersistentVolumeClaim - it: enabled should pass set: persistence.config.enabled: true asserts: - hasDocuments: - count: 3 + count: 2 - documentIndex: &PersistentVolumeClaimDocument 0 isKind: of: PersistentVolumeClaim @@ -38,10 +34,6 @@ tests: not: true isKind: of: PersistentVolumeClaim - - documentIndex: 2 - not: true - isKind: - of: PersistentVolumeClaim - documentIndex: *PersistentVolumeClaimDocument equal: path: metadata.name diff --git a/charts/library/common-test/tests/pvc/values_test.yaml b/charts/library/common-test/tests/pvc/values_test.yaml index 32793f11..1e1fb129 100644 --- a/charts/library/common-test/tests/pvc/values_test.yaml +++ b/charts/library/common-test/tests/pvc/values_test.yaml @@ -12,7 +12,7 @@ tests: size: 1Gi asserts: - hasDocuments: - count: 3 + count: 2 - documentIndex: &PersistentVolumeClaimDocument 0 isKind: of: PersistentVolumeClaim @@ -30,7 +30,7 @@ tests: size: 1Gi asserts: - hasDocuments: - count: 3 + count: 2 - documentIndex: &PersistentVolumeClaimDocument 0 isKind: of: PersistentVolumeClaim @@ -48,7 +48,7 @@ tests: size: 1Gi asserts: - hasDocuments: - count: 2 + count: 1 - documentIndex: &PersistentVolumeClaimDocument 0 isKind: of: Deployment diff --git a/charts/library/common-test/tests/route/metadata_test.yaml b/charts/library/common-test/tests/route/metadata_test.yaml index e55ed892..fce54b81 100644 --- a/charts/library/common-test/tests/route/metadata_test.yaml +++ b/charts/library/common-test/tests/route/metadata_test.yaml @@ -7,12 +7,11 @@ tests: - it: default metadata should pass set: route.main: - enabled: true parentRefs: - name: test namespace: test asserts: - - documentIndex: &routeDocument 2 + - documentIndex: &routeDocument 1 isKind: of: HTTPRoute - documentIndex: *routeDocument @@ -30,7 +29,6 @@ tests: - it: custom metadata should pass set: route.main: - enabled: true annotations: test_annotation: test labels: @@ -39,7 +37,7 @@ tests: - name: test namespace: test asserts: - - documentIndex: &routeDocument 2 + - documentIndex: &routeDocument 1 isKind: of: HTTPRoute - documentIndex: *routeDocument @@ -65,7 +63,6 @@ tests: annotations: global_annotation: test route.main: - enabled: true annotations: test_annotation: test labels: @@ -74,7 +71,7 @@ tests: - name: test namespace: test asserts: - - documentIndex: &routeDocument 2 + - documentIndex: &routeDocument 1 isKind: of: HTTPRoute - documentIndex: *routeDocument diff --git a/charts/library/common-test/tests/route/presence_test.yaml b/charts/library/common-test/tests/route/presence_test.yaml index d597fb57..1ddc9c52 100644 --- a/charts/library/common-test/tests/route/presence_test.yaml +++ b/charts/library/common-test/tests/route/presence_test.yaml @@ -7,30 +7,22 @@ tests: - it: default should pass asserts: - hasDocuments: - count: 2 + count: 1 - documentIndex: 0 not: true isKind: of: HTTPRoute - - documentIndex: 1 - not: true - isKind: - of: HTTPRoute - it: explicitly disabled should pass set: route.main.enabled: false asserts: - hasDocuments: - count: 2 + count: 1 - documentIndex: 0 not: true isKind: of: HTTPRoute - - documentIndex: 1 - not: true - isKind: - of: HTTPRoute - it: explicitly enabled should pass set: @@ -41,16 +33,12 @@ tests: namespace: test asserts: - hasDocuments: - count: 3 + count: 2 - documentIndex: 0 not: true isKind: of: HTTPRoute - documentIndex: 1 - not: true - isKind: - of: HTTPRoute - - documentIndex: 2 isKind: of: HTTPRoute @@ -58,29 +46,23 @@ tests: set: route: main: - enabled: true parentRefs: - name: main namespace: main test: - enabled: true parentRefs: - name: test namespace: test asserts: - hasDocuments: - count: 4 + count: 3 - documentIndex: 0 not: true isKind: of: HTTPRoute - documentIndex: 1 - not: true isKind: of: HTTPRoute - documentIndex: 2 isKind: of: HTTPRoute - - documentIndex: 3 - isKind: - of: HTTPRoute diff --git a/charts/library/common-test/tests/route/service_reference_test.yaml b/charts/library/common-test/tests/route/service_reference_test.yaml index 164a3765..be6f6c82 100644 --- a/charts/library/common-test/tests/route/service_reference_test.yaml +++ b/charts/library/common-test/tests/route/service_reference_test.yaml @@ -7,7 +7,6 @@ tests: - it: default should pass set: route.main: - enabled: true parentRefs: - name: parentName namespace: parentNamespace @@ -20,7 +19,7 @@ tests: port: 8080 weight: 1 asserts: - - documentIndex: &HTTPRouteDocument 2 + - documentIndex: &HTTPRouteDocument 1 isKind: of: HTTPRoute - documentIndex: *HTTPRouteDocument @@ -37,7 +36,6 @@ tests: - it: custom service reference should pass set: route.main: - enabled: true parentRefs: - name: parentName namespace: parentNamespace @@ -49,7 +47,7 @@ tests: namespace: serviceNamespace weight: 123 asserts: - - documentIndex: &HTTPRouteDocument 2 + - documentIndex: &HTTPRouteDocument 1 isKind: of: HTTPRoute - documentIndex: *HTTPRouteDocument @@ -66,7 +64,6 @@ tests: - it: custom service reference with filter should fail set: route.main: - enabled: true parentRefs: - name: parentName namespace: parentNamespace @@ -89,7 +86,6 @@ tests: - it: custom service with filter should pass set: route.main: - enabled: true parentRefs: - name: parentName namespace: parentNamespace @@ -100,7 +96,7 @@ tests: scheme: https statusCode: 301 asserts: - - documentIndex: &HTTPRouteDocument 2 + - documentIndex: &HTTPRouteDocument 1 isKind: of: HTTPRoute - documentIndex: *HTTPRouteDocument diff --git a/charts/library/common-test/tests/route/values_test.yaml b/charts/library/common-test/tests/route/values_test.yaml index d0447b4f..0cedb334 100644 --- a/charts/library/common-test/tests/route/values_test.yaml +++ b/charts/library/common-test/tests/route/values_test.yaml @@ -7,12 +7,11 @@ tests: - it: setting gateway should pass set: route.main: - enabled: true parentRefs: - name: parentName namespace: parentNamespace asserts: - - documentIndex: &HTTPRouteDocument 2 + - documentIndex: &HTTPRouteDocument 1 isKind: of: HTTPRoute - documentIndex: *HTTPRouteDocument @@ -27,14 +26,13 @@ tests: - it: custom host and path should pass set: route.main: - enabled: true parentRefs: - name: parentName namespace: parentNamespace hostnames: - chart-test.local asserts: - - documentIndex: &HTTPRouteDocument 2 + - documentIndex: &HTTPRouteDocument 1 isKind: of: HTTPRoute - documentIndex: *HTTPRouteDocument @@ -45,14 +43,13 @@ tests: - it: custom host with template set: route.main: - enabled: true parentRefs: - name: parentName namespace: parentNamespace hostnames: - "{{ .Release.Name }}.local" asserts: - - documentIndex: &HTTPRouteDocument 2 + - documentIndex: &HTTPRouteDocument 1 isKind: of: HTTPRoute - documentIndex: *HTTPRouteDocument @@ -64,7 +61,6 @@ tests: set: route: main: - enabled: true kind: HTTPRoute parentRefs: - name: parentName @@ -88,7 +84,6 @@ tests: timeouts: backendRequest: 30s grpc: - enabled: true kind: GRPCRoute parentRefs: - name: parentName @@ -110,7 +105,6 @@ tests: type: ReplacePrefixMatch replacePrefixMatch: "" tcp: - enabled: true kind: TCPRoute parentRefs: - name: parentName @@ -132,7 +126,6 @@ tests: type: ReplacePrefixMatch replacePrefixMatch: "" tls: - enabled: true kind: TLSRoute parentRefs: - name: parentName @@ -154,7 +147,6 @@ tests: type: ReplacePrefixMatch replacePrefixMatch: "" udp: - enabled: true kind: UDPRoute parentRefs: - name: parentName @@ -176,17 +168,17 @@ tests: type: ReplacePrefixMatch replacePrefixMatch: "" asserts: - - documentIndex: &HTTPRouteDocument 2 + - documentIndex: &GRPCRouteDocument 1 isKind: of: GRPCRoute - - documentIndex: &HTTPRouteDocument 2 + - documentIndex: *GRPCRouteDocument equal: path: spec.rules[0].matches value: - path: type: PathPrefix value: /test - - documentIndex: &HTTPRouteDocument 2 + - documentIndex: *GRPCRouteDocument equal: path: spec.rules[0].filters value: @@ -195,17 +187,17 @@ tests: path: type: ReplacePrefixMatch replacePrefixMatch: "" - - documentIndex: &HTTPRouteDocument 3 + - documentIndex: &HTTPRouteDocument 2 isKind: of: HTTPRoute - - documentIndex: &HTTPRouteDocument 3 + - documentIndex: *HTTPRouteDocument equal: path: spec.rules[0].matches value: - path: type: PathPrefix value: /test - - documentIndex: &HTTPRouteDocument 3 + - documentIndex: *HTTPRouteDocument equal: path: spec.rules[0].filters value: @@ -214,34 +206,34 @@ tests: path: type: ReplacePrefixMatch replacePrefixMatch: "" - - documentIndex: &HTTPRouteDocument 4 + - documentIndex: &TCPRouteDocument 3 isKind: of: TCPRoute - - documentIndex: &HTTPRouteDocument 4 + - documentIndex: *TCPRouteDocument notExists: path: spec.rules[0].matches - - documentIndex: &HTTPRouteDocument 4 + - documentIndex: *TCPRouteDocument notExists: path: spec.rules[0].filters - - documentIndex: &HTTPRouteDocument 5 + - documentIndex: &TLSRouteDocument 4 isKind: of: TLSRoute - - documentIndex: &HTTPRouteDocument 5 + - documentIndex: *TLSRouteDocument notExists: path: spec.rules[0].matches - - documentIndex: &HTTPRouteDocument 5 + - documentIndex: *TLSRouteDocument notExists: path: spec.rules[0].filters - - documentIndex: &HTTPRouteDocument 6 + - documentIndex: &UDPRouteDocument 5 isKind: of: UDPRoute - - documentIndex: &HTTPRouteDocument 6 + - documentIndex: *UDPRouteDocument notExists: path: spec.rules[0].matches - - documentIndex: &HTTPRouteDocument 6 + - documentIndex: *UDPRouteDocument notExists: path: spec.rules[0].filters - - documentIndex: &HTTPRouteDocument 6 + - documentIndex: *UDPRouteDocument notExists: path: spec.rules[0].timeouts @@ -265,16 +257,16 @@ tests: - name: parentName namespace: parentNamespace asserts: - - documentIndex: &HTTPRouteDocument 2 + - documentIndex: &TCPRouteDocument 1 isKind: of: TCPRoute - - documentIndex: &HTTPRouteDocument 2 + - documentIndex: *TCPRouteDocument notExists: path: spec.hostnames - - documentIndex: &HTTPRouteDocument 3 + - documentIndex: &UDPRouteDocument 2 isKind: of: UDPRoute - - documentIndex: &HTTPRouteDocument 3 + - documentIndex: *UDPRouteDocument notExists: path: spec.hostnames @@ -293,16 +285,16 @@ tests: namespace: parentNamespace sectionName: parentSection asserts: - - documentIndex: &HTTPRouteDocument 2 + - documentIndex: &HTTPRouteDocumentFirst 1 isKind: of: HTTPRoute - - documentIndex: &HTTPRouteDocument 2 + - documentIndex: *HTTPRouteDocumentFirst notExists: path: spec.parentRefs[0].sectionName - - documentIndex: &HTTPRouteDocument 3 + - documentIndex: &HTTPRouteDocumentSecond 2 isKind: of: HTTPRoute - - documentIndex: &HTTPRouteDocument 3 + - documentIndex: *HTTPRouteDocumentSecond equal: path: spec.parentRefs[0].sectionName value: parentSection @@ -339,16 +331,16 @@ tests: timeouts: backendRequest: 10s asserts: - - documentIndex: &HTTPRouteDocument 2 + - documentIndex: &GRPCRouteDocument 1 isKind: of: GRPCRoute - - documentIndex: &HTTPRouteDocument 2 + - documentIndex: *GRPCRouteDocument notExists: path: spec.rules[0].timeouts.backendRequest - - documentIndex: &HTTPRouteDocument 3 + - documentIndex: &HTTPRouteDocument 2 isKind: of: HTTPRoute - - documentIndex: &HTTPRouteDocument 3 + - documentIndex: *HTTPRouteDocument equal: path: spec.rules[0].timeouts.backendRequest value: 30s diff --git a/charts/library/common-test/tests/secret/metadata_test.yaml b/charts/library/common-test/tests/secret/metadata_test.yaml index 508615ad..707bb3d5 100644 --- a/charts/library/common-test/tests/secret/metadata_test.yaml +++ b/charts/library/common-test/tests/secret/metadata_test.yaml @@ -12,8 +12,8 @@ tests: test: test asserts: - hasDocuments: - count: 3 - - documentIndex: &SecretDocument 2 + count: 2 + - documentIndex: &SecretDocument 1 isKind: of: Secret - documentIndex: *SecretDocument @@ -40,8 +40,8 @@ tests: test_label: test asserts: - hasDocuments: - count: 3 - - documentIndex: &SecretDocument 2 + count: 2 + - documentIndex: &SecretDocument 1 isKind: of: Secret - documentIndex: *SecretDocument @@ -76,8 +76,8 @@ tests: test_label: test asserts: - hasDocuments: - count: 3 - - documentIndex: &SecretDocument 2 + count: 2 + - documentIndex: &SecretDocument 1 isKind: of: Secret - documentIndex: *SecretDocument @@ -106,8 +106,8 @@ tests: type: &type kubernetes.io/service-account-token asserts: - hasDocuments: - count: 3 - - documentIndex: &SecretDocument 2 + count: 2 + - documentIndex: &SecretDocument 1 isKind: of: Secret - documentIndex: *SecretDocument diff --git a/charts/library/common-test/tests/secret/names_test.yaml b/charts/library/common-test/tests/secret/names_test.yaml index ece73879..78c8bf20 100644 --- a/charts/library/common-test/tests/secret/names_test.yaml +++ b/charts/library/common-test/tests/secret/names_test.yaml @@ -7,15 +7,11 @@ tests: - it: default should pass asserts: - hasDocuments: - count: 2 + count: 1 - documentIndex: 0 not: true isKind: of: Secret - - documentIndex: 1 - not: true - isKind: - of: Secret - it: with disabled secret should pass set: @@ -26,15 +22,11 @@ tests: test: test asserts: - hasDocuments: - count: 2 + count: 1 - documentIndex: 0 not: true isKind: of: Secret - - documentIndex: 1 - not: true - isKind: - of: Secret - it: with multiple secrets should pass set: @@ -49,14 +41,14 @@ tests: test: test asserts: - hasDocuments: - count: 4 - - documentIndex: &FirstSecretDocument 2 + count: 3 + - documentIndex: &FirstSecretDocument 1 isKind: of: Secret - documentIndex: *FirstSecretDocument isNotNullOrEmpty: path: metadata.name - - documentIndex: &SecondSecretDocument 3 + - documentIndex: &SecondSecretDocument 2 isKind: of: Secret - documentIndex: *SecondSecretDocument @@ -71,8 +63,8 @@ tests: test: test asserts: - hasDocuments: - count: 3 - - documentIndex: &SecretDocument 2 + count: 2 + - documentIndex: &SecretDocument 1 isKind: of: Secret - documentIndex: *SecretDocument @@ -89,8 +81,8 @@ tests: nameOverride: http asserts: - hasDocuments: - count: 3 - - documentIndex: &SecretDocument 2 + count: 2 + - documentIndex: &SecretDocument 1 isKind: of: Secret - documentIndex: *SecretDocument diff --git a/charts/library/common-test/tests/service/metadata_test.yaml b/charts/library/common-test/tests/service/metadata_test.yaml index d437a638..60bec1e7 100644 --- a/charts/library/common-test/tests/service/metadata_test.yaml +++ b/charts/library/common-test/tests/service/metadata_test.yaml @@ -5,6 +5,8 @@ templates: - common.yaml tests: - it: default metadata should pass + values: + - ../_values/service_main_default.yaml asserts: - documentIndex: &ServiceDocument 1 isKind: @@ -23,6 +25,8 @@ tests: helm.sh/chart: common-test-1.0.0 - it: custom metadata should pass + values: + - ../_values/service_main_default.yaml set: service: main: @@ -51,6 +55,8 @@ tests: test_label: test - it: custom metadata with global metadata should pass + values: + - ../_values/service_main_default.yaml set: global: labels: diff --git a/charts/library/common-test/tests/service/names_test.yaml b/charts/library/common-test/tests/service/names_test.yaml index 58da58b2..1fc35c75 100644 --- a/charts/library/common-test/tests/service/names_test.yaml +++ b/charts/library/common-test/tests/service/names_test.yaml @@ -5,6 +5,8 @@ templates: - common.yaml tests: - it: default should pass + values: + - ../_values/service_main_default.yaml asserts: - hasDocuments: count: 2 @@ -17,10 +19,10 @@ tests: value: RELEASE-NAME - it: custom name suffix should pass + values: + - ../_values/service_main_default.yaml set: - service: - main: - nameOverride: http + service.main.nameOverride: http asserts: - documentIndex: &ServiceDocument 1 isKind: @@ -29,3 +31,31 @@ tests: equal: path: metadata.name value: RELEASE-NAME-http + + - it: multiple should pass + values: + - ../_values/service_main_default.yaml + set: + service: + second: + controller: main + ports: + ui: + port: 8082 + asserts: + - hasDocuments: + count: 3 + - documentIndex: &ServiceDocumentFirst 1 + isKind: + of: Service + - documentIndex: *ServiceDocumentFirst + equal: + path: metadata.name + value: RELEASE-NAME-main + - documentIndex: &ServiceDocumentSecond 2 + isKind: + of: Service + - documentIndex: *ServiceDocumentSecond + equal: + path: metadata.name + value: RELEASE-NAME-second diff --git a/charts/library/common-test/tests/service/port_protocols_test.yaml b/charts/library/common-test/tests/service/port_protocols_test.yaml index 4a66cab4..e75559d1 100644 --- a/charts/library/common-test/tests/service/port_protocols_test.yaml +++ b/charts/library/common-test/tests/service/port_protocols_test.yaml @@ -5,6 +5,8 @@ templates: - common.yaml tests: - it: default should pass + values: + - ../_values/service_main_default.yaml asserts: - hasDocuments: count: 2 @@ -17,6 +19,8 @@ tests: value: TCP - it: explicit TCP should pass + values: + - ../_values/service_main_default.yaml set: service.main.ports.http.protocol: TCP asserts: @@ -29,6 +33,8 @@ tests: value: TCP - it: explicit UDP should pass + values: + - ../_values/service_main_default.yaml set: service.main.ports.http.protocol: UDP asserts: @@ -41,6 +47,8 @@ tests: value: UDP - it: explicit HTTP should pass + values: + - ../_values/service_main_default.yaml set: service.main.ports.http.protocol: HTTP asserts: @@ -56,6 +64,8 @@ tests: path: metadata.annotations - it: explicit HTTPS should pass + values: + - ../_values/service_main_default.yaml set: service.main.ports.http.protocol: HTTPS asserts: @@ -68,6 +78,8 @@ tests: value: TCP - it: explicit appProtocol should pass + values: + - ../_values/service_main_default.yaml set: service.main.ports.http.appProtocol: kubernetes.io/h2c asserts: diff --git a/charts/library/common-test/tests/service/ports_test.yaml b/charts/library/common-test/tests/service/ports_test.yaml index 4a35eb7b..c90230e6 100644 --- a/charts/library/common-test/tests/service/ports_test.yaml +++ b/charts/library/common-test/tests/service/ports_test.yaml @@ -5,6 +5,8 @@ templates: - common.yaml tests: - it: default should pass + values: + - ../_values/service_main_default.yaml asserts: - hasDocuments: count: 2 @@ -16,11 +18,13 @@ tests: path: spec.ports[0] value: name: http - port: 8080 + port: 8081 protocol: TCP - targetPort: 8080 + targetPort: 8081 - it: custom name should pass + values: + - ../_values/service_main_default.yaml set: service: main: @@ -44,6 +48,8 @@ tests: targetPort: 8080 - it: custom target port should pass + values: + - ../_values/service_main_default.yaml set: service: main: @@ -60,6 +66,6 @@ tests: path: spec.ports[0] value: name: http - port: 8080 + port: 8081 protocol: TCP targetPort: 80 diff --git a/charts/library/common-test/tests/service/values_test.yaml b/charts/library/common-test/tests/service/values_test.yaml index 2ac8f0ba..68b4ad0b 100644 --- a/charts/library/common-test/tests/service/values_test.yaml +++ b/charts/library/common-test/tests/service/values_test.yaml @@ -15,18 +15,17 @@ tests: port: 80 asserts: - hasDocuments: - count: 3 + count: 2 - documentIndex: &FirstServiceDocument 1 isKind: of: Service - - documentIndex: &SecondServiceDocument 2 - isKind: - of: Service - documentIndex: *FirstServiceDocument notExists: path: spec.allocateLoadBalancerNodePorts - it: services can be disabled + values: + - ../_values/service_main_default.yaml set: service: main: @@ -39,6 +38,8 @@ tests: of: Deployment - it: externalTrafficPolicy should pass for NodePort service + values: + - ../_values/service_main_default.yaml set: service: main: @@ -54,6 +55,8 @@ tests: value: Local - it: externalTrafficPolicy should pass for LoadBalancer service + values: + - ../_values/service_main_default.yaml set: service: main: @@ -69,6 +72,8 @@ tests: value: Local - it: allocateLoadBalancerNodePorts can be set to true + values: + - ../_values/service_main_default.yaml set: service: main: @@ -84,6 +89,8 @@ tests: value: true - it: allocateLoadBalancerNodePorts can be set to false + values: + - ../_values/service_main_default.yaml set: service: main: diff --git a/charts/library/common-test/tests/serviceAccount/serviceaccount_test.yaml b/charts/library/common-test/tests/serviceAccount/serviceaccount_test.yaml index 2a6edd3a..b386174a 100644 --- a/charts/library/common-test/tests/serviceAccount/serviceaccount_test.yaml +++ b/charts/library/common-test/tests/serviceAccount/serviceaccount_test.yaml @@ -7,13 +7,11 @@ tests: - it: a serviceAccount is not created by default asserts: - hasDocuments: - count: 2 - - documentIndex: &DeploymentDocument 0 + count: 1 + - documentIndex: 0 + not: true isKind: - of: Deployment - - documentIndex: &ServiceDocument 1 - isKind: - of: Service + of: ServiceAccount - it: a serviceAccount is not created when disabled set: @@ -21,13 +19,11 @@ tests: create: false asserts: - hasDocuments: - count: 2 - - documentIndex: &DeploymentDocument 0 + count: 1 + - documentIndex: 0 + not: true isKind: - of: Deployment - - documentIndex: &ServiceDocument 1 - isKind: - of: Service + of: ServiceAccount - it: a serviceAccount and Secret are created when enabled set: @@ -35,17 +31,14 @@ tests: create: true asserts: - hasDocuments: - count: 4 + count: 3 - documentIndex: &ServiceAccountDocument 0 isKind: of: ServiceAccount - documentIndex: &DeploymentDocument 1 isKind: of: Deployment - - documentIndex: &ServiceDocument 2 - isKind: - of: Service - - documentIndex: &SecretDocument 3 + - documentIndex: &SecretDocument 2 isKind: of: Secret - documentIndex: *ServiceAccountDocument @@ -74,17 +67,14 @@ tests: name: &ServiceAccountName myAccount asserts: - hasDocuments: - count: 4 + count: 3 - documentIndex: &ServiceAccountDocument 0 isKind: of: ServiceAccount - documentIndex: &DeploymentDocument 1 isKind: of: Deployment - - documentIndex: &ServiceDocument 2 - isKind: - of: Service - - documentIndex: &SecretDocument 3 + - documentIndex: &SecretDocument 2 isKind: of: Secret - documentIndex: *ServiceAccountDocument diff --git a/charts/library/common-test/tests/serviceMonitor/servicemonitor_test.yaml b/charts/library/common-test/tests/serviceMonitor/servicemonitor_test.yaml index bc148ef6..30fb7e32 100644 --- a/charts/library/common-test/tests/serviceMonitor/servicemonitor_test.yaml +++ b/charts/library/common-test/tests/serviceMonitor/servicemonitor_test.yaml @@ -8,13 +8,11 @@ tests: - it: a serviceMonitor is not created by default asserts: - hasDocuments: - count: 2 - - documentIndex: &ServiceDocument 0 + count: 1 + - documentIndex: 0 + not: true isKind: - of: Deployment - - documentIndex: &ServiceDocument 1 - isKind: - of: Service + of: ServiceMonitor - it: a serviceMonitor is not created when disabled set: @@ -24,13 +22,11 @@ tests: serviceName: "{{ .Release.Name }}" asserts: - hasDocuments: - count: 2 - - documentIndex: &ServiceDocument 0 + count: 1 + - documentIndex: 0 + not: true isKind: - of: Deployment - - documentIndex: &ServiceDocument 1 - isKind: - of: Service + of: ServiceMonitor - it: a serviceMonitor is created set: @@ -47,8 +43,8 @@ tests: scrapeTimeout: 10s asserts: - hasDocuments: - count: 3 - - documentIndex: &ServiceMonitorDocument 2 + count: 2 + - documentIndex: &ServiceMonitorDocument 1 isKind: of: ServiceMonitor - documentIndex: *ServiceMonitorDocument @@ -95,8 +91,8 @@ tests: scrapeTimeout: 10s asserts: - hasDocuments: - count: 3 - - documentIndex: &ServiceMonitorDocument 2 + count: 2 + - documentIndex: &ServiceMonitorDocument 1 isKind: of: ServiceMonitor - documentIndex: *ServiceMonitorDocument @@ -124,8 +120,8 @@ tests: scrapeTimeout: 10s asserts: - hasDocuments: - count: 3 - - documentIndex: &ServiceMonitorDocument 2 + count: 2 + - documentIndex: &ServiceMonitorDocument 1 isKind: of: ServiceMonitor - documentIndex: *ServiceMonitorDocument @@ -155,8 +151,8 @@ tests: scrapeTimeout: 10s asserts: - hasDocuments: - count: 3 - - documentIndex: &ServiceMonitorDocument 2 + count: 2 + - documentIndex: &ServiceMonitorDocument 1 isKind: of: ServiceMonitor - documentIndex: *ServiceMonitorDocument @@ -187,8 +183,8 @@ tests: - testlabel2 asserts: - hasDocuments: - count: 3 - - documentIndex: &ServiceMonitorDocument 2 + count: 2 + - documentIndex: &ServiceMonitorDocument 1 isKind: of: ServiceMonitor - documentIndex: *ServiceMonitorDocument diff --git a/charts/library/common-test/values.yaml b/charts/library/common-test/values.yaml index 843cb9b4..b3e702fa 100644 --- a/charts/library/common-test/values.yaml +++ b/charts/library/common-test/values.yaml @@ -7,10 +7,3 @@ controllers: repository: ghcr.io/mendhak/http-https-echo tag: 31 pullPolicy: IfNotPresent - -service: - main: - controller: main - ports: - http: - port: 8080 diff --git a/charts/library/common/Chart.yaml b/charts/library/common/Chart.yaml index df27ff2a..f0a578f7 100644 --- a/charts/library/common/Chart.yaml +++ b/charts/library/common/Chart.yaml @@ -3,7 +3,7 @@ apiVersion: v2 name: common description: Function library for Helm charts type: library -version: 3.0.0-beta1 +version: 3.0.0-beta2 kubeVersion: ">=1.22.0-0" keywords: - common diff --git a/charts/library/common/schemas/containers.json b/charts/library/common/schemas/containers.json index 976a15d5..caa76d93 100644 --- a/charts/library/common/schemas/containers.json +++ b/charts/library/common/schemas/containers.json @@ -353,40 +353,7 @@ "type": ["number", "string"] }, "spec": { - "allOf": [ - { - "if": {}, - "then": {"$ref": "k8s-api.json#/core.v1.Probe"}, - "else": { - "type": "object", - "additionalProperties": false, - "properties": { - "failureThreshold": { - "type": "integer", - "default": 3 - }, - "initialDelaySeconds": { - "type": "integer", - "default": 0 - }, - "periodSeconds": { - "type": "integer", - "default": 10 - }, - "timeoutSeconds": { - "type": "integer", - "default": 1 - } - }, - "required": [ - "initialDelaySeconds", - "periodSeconds", - "timeoutSeconds", - "failureThreshold" - ] - } - } - ] + "$ref": "k8s-api.json#/core.v1.Probe" }, "type": { "type": "string", diff --git a/charts/library/common/templates/lib/configMap/_valuesToObject.tpl b/charts/library/common/templates/lib/configMap/_valuesToObject.tpl index 1cad8833..5621441f 100644 --- a/charts/library/common/templates/lib/configMap/_valuesToObject.tpl +++ b/charts/library/common/templates/lib/configMap/_valuesToObject.tpl @@ -12,9 +12,7 @@ Convert configMap values to an object {{- if $objectValues.nameOverride -}} {{- $objectName = printf "%s-%s" $objectName $objectValues.nameOverride -}} {{- else -}} - {{- if ne $identifier "main" -}} - {{- $objectName = printf "%s-%s" $objectName $identifier -}} - {{- end -}} + {{- $objectName = printf "%s-%s" $objectName $identifier -}} {{- end -}} {{- $_ := set $objectValues "name" $objectName -}} {{- $_ := set $objectValues "identifier" $identifier -}} diff --git a/charts/library/common/templates/lib/controller/_enabled_controllers.tpl b/charts/library/common/templates/lib/controller/_enabled_controllers.tpl new file mode 100644 index 00000000..addaf9e5 --- /dev/null +++ b/charts/library/common/templates/lib/controller/_enabled_controllers.tpl @@ -0,0 +1,23 @@ +{{/* +Return the enabled controllers. +*/}} +{{- define "bjw-s.common.lib.controller.enabledControllers" -}} + {{- $rootContext := .rootContext -}} + {{- $enabledControllers := dict -}} + + {{- range $name, $controller := $rootContext.Values.controllers -}} + {{- if kindIs "map" $controller -}} + {{- /* Enable by default, but allow override */ -}} + {{- $controllerEnabled := true -}} + {{- if hasKey $controller "enabled" -}} + {{- $controllerEnabled = $controller.enabled -}} + {{- end -}} + + {{- if $controllerEnabled -}} + {{- $_ := set $enabledControllers $name . -}} + {{- end -}} + {{- end -}} + {{- end -}} + + {{- $enabledControllers | toYaml -}} +{{- end -}} diff --git a/charts/library/common/templates/lib/controller/_valuesToObject.tpl b/charts/library/common/templates/lib/controller/_valuesToObject.tpl index 6e10e7e8..241644aa 100644 --- a/charts/library/common/templates/lib/controller/_valuesToObject.tpl +++ b/charts/library/common/templates/lib/controller/_valuesToObject.tpl @@ -17,7 +17,8 @@ Convert controller values to an object {{- if $objectValues.nameOverride -}} {{- $objectName = printf "%s-%s" $objectName $objectValues.nameOverride -}} {{- else -}} - {{- if ne $identifier "main" -}} + {{- $enabledControllers := (include "bjw-s.common.lib.controller.enabledControllers" (dict "rootContext" $rootContext) | fromYaml ) }} + {{- if gt (len $enabledControllers) 1 -}} {{- $objectName = printf "%s-%s" $objectName $identifier -}} {{- end -}} {{- end -}} diff --git a/charts/library/common/templates/lib/ingress/_enabled_ingresses.tpl b/charts/library/common/templates/lib/ingress/_enabled_ingresses.tpl new file mode 100644 index 00000000..4a58c319 --- /dev/null +++ b/charts/library/common/templates/lib/ingress/_enabled_ingresses.tpl @@ -0,0 +1,23 @@ +{{/* +Return the enabled Ingresses. +*/}} +{{- define "bjw-s.common.lib.ingress.enabledIngresses" -}} + {{- $rootContext := .rootContext -}} + {{- $enabledIngress := dict -}} + + {{- range $name, $ingress := $rootContext.Values.ingress -}} + {{- if kindIs "map" $ingress -}} + {{- /* Enable by default, but allow override */ -}} + {{- $ingressEnabled := true -}} + {{- if hasKey $ingress "enabled" -}} + {{- $ingressEnabled = $ingress.enabled -}} + {{- end -}} + + {{- if $ingressEnabled -}} + {{- $_ := set $enabledIngress $name . -}} + {{- end -}} + {{- end -}} + {{- end -}} + + {{- $enabledIngress | toYaml -}} +{{- end -}} diff --git a/charts/library/common/templates/lib/ingress/_valuesToObject.tpl b/charts/library/common/templates/lib/ingress/_valuesToObject.tpl index c9195cad..f8275c40 100644 --- a/charts/library/common/templates/lib/ingress/_valuesToObject.tpl +++ b/charts/library/common/templates/lib/ingress/_valuesToObject.tpl @@ -12,7 +12,8 @@ Convert ingress values to an object {{- if $objectValues.nameOverride -}} {{- $objectName = printf "%s-%s" $objectName $objectValues.nameOverride -}} {{- else -}} - {{- if ne $identifier "main" -}} + {{- $enabledIngresses := (include "bjw-s.common.lib.ingress.enabledIngresses" (dict "rootContext" $rootContext) | fromYaml ) }} + {{- if gt (len $enabledIngresses) 1 -}} {{- $objectName = printf "%s-%s" $objectName $identifier -}} {{- end -}} {{- end -}} diff --git a/charts/library/common/templates/lib/networkpolicy/_enabled_networkpolicies.tpl b/charts/library/common/templates/lib/networkpolicy/_enabled_networkpolicies.tpl new file mode 100644 index 00000000..2e81f432 --- /dev/null +++ b/charts/library/common/templates/lib/networkpolicy/_enabled_networkpolicies.tpl @@ -0,0 +1,23 @@ +{{/* +Return the enabled NetworkPolicies. +*/}} +{{- define "bjw-s.common.lib.networkPolicy.enabledNetworkPolicies" -}} + {{- $rootContext := .rootContext -}} + {{- $enabledNetworkPolicies := dict -}} + + {{- range $name, $networkPolicy := $rootContext.Values.networkPolicy -}} + {{- if kindIs "map" $networkPolicy -}} + {{- /* Enable by default, but allow override */ -}} + {{- $networkPolicyEnabled := true -}} + {{- if hasKey $networkPolicy "enabled" -}} + {{- $networkPolicyEnabled = $networkPolicy.enabled -}} + {{- end -}} + + {{- if $networkPolicyEnabled -}} + {{- $_ := set $enabledNetworkPolicies $name . -}} + {{- end -}} + {{- end -}} + {{- end -}} + + {{- $enabledNetworkPolicies | toYaml -}} +{{- end -}} diff --git a/charts/library/common/templates/lib/networkpolicy/_valuesToObject.tpl b/charts/library/common/templates/lib/networkpolicy/_valuesToObject.tpl index 805f33a5..572ca818 100644 --- a/charts/library/common/templates/lib/networkpolicy/_valuesToObject.tpl +++ b/charts/library/common/templates/lib/networkpolicy/_valuesToObject.tpl @@ -12,7 +12,8 @@ Convert networkPolicy values to an object {{- if $objectValues.nameOverride -}} {{- $objectName = printf "%s-%s" $objectName $objectValues.nameOverride -}} {{- else -}} - {{- if ne $identifier "main" -}} + {{- $enabledNetworkPolicies := (include "bjw-s.common.lib.networkPolicy.enabledNetworkPolicies" (dict "rootContext" $rootContext) | fromYaml ) }} + {{- if gt (len $enabledNetworkPolicies) 1 -}} {{- $objectName = printf "%s-%s" $objectName $identifier -}} {{- end -}} {{- end -}} diff --git a/charts/library/common/templates/lib/secret/_valuesToObject.tpl b/charts/library/common/templates/lib/secret/_valuesToObject.tpl index 59f89d17..e29a68d1 100644 --- a/charts/library/common/templates/lib/secret/_valuesToObject.tpl +++ b/charts/library/common/templates/lib/secret/_valuesToObject.tpl @@ -12,9 +12,7 @@ Convert Secret values to an object {{- if $objectValues.nameOverride -}} {{- $objectName = printf "%s-%s" $objectName $objectValues.nameOverride -}} {{- else -}} - {{- if ne $identifier "main" -}} - {{- $objectName = printf "%s-%s" $objectName $identifier -}} - {{- end -}} + {{- $objectName = printf "%s-%s" $objectName $identifier -}} {{- end -}} {{- $_ := set $objectValues "name" $objectName -}} {{- $_ := set $objectValues "identifier" $identifier -}} diff --git a/charts/library/common/templates/lib/service/_valuesToObject.tpl b/charts/library/common/templates/lib/service/_valuesToObject.tpl index 9d283513..ff74ecb5 100644 --- a/charts/library/common/templates/lib/service/_valuesToObject.tpl +++ b/charts/library/common/templates/lib/service/_valuesToObject.tpl @@ -13,7 +13,7 @@ Convert Service values to an object {{- $objectName = printf "%s-%s" $objectName $objectValues.nameOverride -}} {{- else -}} {{- $enabledServices := (include "bjw-s.common.lib.service.enabledServices" (dict "rootContext" $rootContext) | fromYaml ) }} - {{- if and (not $objectValues.primary) (gt 1 (len $enabledServices)) -}} + {{- if and (not $objectValues.primary) (gt (len $enabledServices) 1) -}} {{- $objectName = printf "%s-%s" $objectName $identifier -}} {{- end -}} {{- end -}} diff --git a/charts/library/common/templates/lib/serviceMonitor/_enabled_servicemonitors.tpl b/charts/library/common/templates/lib/serviceMonitor/_enabled_servicemonitors.tpl new file mode 100644 index 00000000..9617e84b --- /dev/null +++ b/charts/library/common/templates/lib/serviceMonitor/_enabled_servicemonitors.tpl @@ -0,0 +1,23 @@ +{{/* +Return the enabled ServiceMonitors. +*/}} +{{- define "bjw-s.common.lib.serviceMonitor.enabledServiceMonitors" -}} + {{- $rootContext := .rootContext -}} + {{- $enabledServiceMonitors := dict -}} + + {{- range $name, $serviceMonitor := $rootContext.Values.serviceMonitor -}} + {{- if kindIs "map" $serviceMonitor -}} + {{- /* Enable by default, but allow override */ -}} + {{- $serviceMonitorEnabled := true -}} + {{- if hasKey $serviceMonitor "enabled" -}} + {{- $serviceMonitorEnabled = $serviceMonitor.enabled -}} + {{- end -}} + + {{- if $serviceMonitorEnabled -}} + {{- $_ := set $enabledServiceMonitors $name . -}} + {{- end -}} + {{- end -}} + {{- end -}} + + {{- $enabledServiceMonitors | toYaml -}} +{{- end -}} diff --git a/charts/library/common/templates/lib/serviceMonitor/_valuesToObject.tpl b/charts/library/common/templates/lib/serviceMonitor/_valuesToObject.tpl index febce01d..7095f64d 100644 --- a/charts/library/common/templates/lib/serviceMonitor/_valuesToObject.tpl +++ b/charts/library/common/templates/lib/serviceMonitor/_valuesToObject.tpl @@ -12,7 +12,8 @@ Convert ServiceMonitor values to an object {{- if $objectValues.nameOverride -}} {{- $objectName = printf "%s-%s" $objectName $objectValues.nameOverride -}} {{- else -}} - {{- if ne $identifier "main" -}} + {{- $enabledServiceMonitors := (include "bjw-s.common.lib.serviceMonitor.enabledServiceMonitors" (dict "rootContext" $rootContext) | fromYaml ) }} + {{- if gt (len $enabledServiceMonitors) 1 -}} {{- $objectName = printf "%s-%s" $objectName $identifier -}} {{- end -}} {{- end -}} diff --git a/charts/library/common/values.schema.json b/charts/library/common/values.schema.json index 1bd4cf0f..3c0f5335 100644 --- a/charts/library/common/values.schema.json +++ b/charts/library/common/values.schema.json @@ -1,6 +1,6 @@ { "$schema": "http://json-schema.org/draft-07/schema", - "$id": "https://raw.githubusercontent.com/bjw-s/helm-charts/common-3.0.0-beta1/charts/library/common/values.schema.json", + "$id": "https://raw.githubusercontent.com/bjw-s/helm-charts/common-3.0.0-beta2/charts/library/common/values.schema.json", "type": "object", "properties": { diff --git a/docs/app-template/index.md b/docs/app-template/index.md index b75c5d28..0bd820f1 100644 --- a/docs/app-template/index.md +++ b/docs/app-template/index.md @@ -35,7 +35,13 @@ examples/helm/vaultwarden/values.yaml !!! warning - These docs are still being written + These docs are still being written. Stuff to include: + + - Removal of `main` objects + - Object names + - Required fields, json-schema + - Disabled `enableServiceLinks` + - Example migration code ### From 1.x.x to 2.0.x diff --git a/examples/flux/helmrelease.yaml b/examples/flux/helmrelease.yaml index 64d15664..539451be 100644 --- a/examples/flux/helmrelease.yaml +++ b/examples/flux/helmrelease.yaml @@ -43,6 +43,7 @@ spec: # -- Configures service settings for the chart. service: main: + controller: main ports: http: port: &port 80 @@ -73,47 +74,47 @@ spec: name: main port: websocket - route: - # -- Enable and configure route settings for the chart under this key. - main: - enabled: true - parentRefs: - - name: gateway - namespace: gateway-namespace - sectionName: gateway-section - hostnames: - - chart-example.local - rules: - - matches: - - path: - type: PathPrefix - value: / - backendRefs: - - kind: Service - port: *port - name: *app - namespace: default - weight: 1 - - matches: - - path: - type: PathPrefix - value: /notifications/hub/negotiate - backendRefs: - - kind: Service - port: *port - name: *app - namespace: default - weight: 1 - - matches: - - path: - type: PathPrefix - value: /notifications/hub - backendRefs: - - kind: Service - port: *websocket-port - name: *app - namespace: default - weight: 1 + route: + # -- Enable and configure route settings for the chart under this key. + main: + enabled: true + parentRefs: + - name: gateway + namespace: gateway-namespace + sectionName: gateway-section + hostnames: + - chart-example.local + rules: + - matches: + - path: + type: PathPrefix + value: / + backendRefs: + - kind: Service + port: *port + name: *app + namespace: default + weight: 1 + - matches: + - path: + type: PathPrefix + value: /notifications/hub/negotiate + backendRefs: + - kind: Service + port: *port + name: *app + namespace: default + weight: 1 + - matches: + - path: + type: PathPrefix + value: /notifications/hub + backendRefs: + - kind: Service + port: *websocket-port + name: *app + namespace: default + weight: 1 # -- Configure persistence settings for the chart under this key. persistence: diff --git a/examples/helm/home-assistant/values.yaml b/examples/helm/home-assistant/values.yaml index 20fa8302..45f3d594 100644 --- a/examples/helm/home-assistant/values.yaml +++ b/examples/helm/home-assistant/values.yaml @@ -47,6 +47,7 @@ controllers: service: # Configure a service for the main application main: + controller: main type: ClusterIP ports: http: diff --git a/examples/helm/qbittorrent/values.yaml b/examples/helm/qbittorrent/values.yaml index 8c859e7b..36b9cd91 100644 --- a/examples/helm/qbittorrent/values.yaml +++ b/examples/helm/qbittorrent/values.yaml @@ -65,6 +65,7 @@ controllers: service: # Configure a service for the main application main: + controller: main type: ClusterIP ports: http: diff --git a/examples/helm/vaultwarden/values.yaml b/examples/helm/vaultwarden/values.yaml index a35638e8..5f49af32 100644 --- a/examples/helm/vaultwarden/values.yaml +++ b/examples/helm/vaultwarden/values.yaml @@ -22,6 +22,7 @@ controllers: # -- Configures service settings for the chart. service: main: + controller: main ports: http: port: 80 diff --git a/examples/kustomize/values.yaml b/examples/kustomize/values.yaml index 2c5de1a2..868b08c5 100644 --- a/examples/kustomize/values.yaml +++ b/examples/kustomize/values.yaml @@ -22,6 +22,7 @@ controllers: # -- Configures service settings for the chart. service: main: + controller: main ports: http: port: 80