diff --git a/library/common-test/tests/service/list_test.yaml b/library/common-test/tests/service/list_test.yaml new file mode 100644 index 00000000..a35788e8 --- /dev/null +++ b/library/common-test/tests/service/list_test.yaml @@ -0,0 +1,172 @@ +suite: service list test +templates: + - common.yaml +tests: + - it: should pass with type LoadBalancer from serviceList with name + set: + serviceList: + - name: my-service + enabled: true + primary: true + type: LoadBalancer + ports: + port-name: + enabled: true + primary: true + port: 12345 + - name: my-service2 + enabled: true + type: LoadBalancer + ports: + port-name: + enabled: true + primary: true + port: 12345 + workload: + my-workload: + enabled: true + primary: true + type: Deployment + podSpec: {} + asserts: + - documentIndex: &serviceDoc 1 + isKind: + of: Service + - documentIndex: *serviceDoc + isAPIVersion: + of: v1 + - documentIndex: *serviceDoc + equal: + path: metadata.name + value: release-name-common-test + - documentIndex: *serviceDoc + equal: + path: spec + value: + type: LoadBalancer + allocateLoadBalancerNodePorts: false + publishNotReadyAddresses: false + ports: + - name: port-name + port: 12345 + protocol: TCP + targetPort: 12345 + selector: + app.kubernetes.io/instance: RELEASE-NAME + app.kubernetes.io/name: common-test + pod.name: my-workload + - documentIndex: &otherServiceDoc 2 + isKind: + of: Service + - documentIndex: *otherServiceDoc + isAPIVersion: + of: v1 + - documentIndex: *otherServiceDoc + equal: + path: metadata.name + value: release-name-common-test-my-service2 + - documentIndex: *otherServiceDoc + equal: + path: spec + value: + type: LoadBalancer + allocateLoadBalancerNodePorts: false + publishNotReadyAddresses: false + ports: + - name: port-name + port: 12345 + protocol: TCP + targetPort: 12345 + selector: + app.kubernetes.io/instance: RELEASE-NAME + app.kubernetes.io/name: common-test + pod.name: my-workload + + - it: should pass with type LoadBalancer from serviceList + set: + serviceList: + - enabled: true + primary: true + type: LoadBalancer + ports: + port-name: + enabled: true + primary: true + port: 12345 + workload: + my-workload: + enabled: true + primary: true + type: Deployment + podSpec: {} + asserts: + - documentIndex: &serviceDoc 1 + isKind: + of: Service + - documentIndex: *serviceDoc + isAPIVersion: + of: v1 + - documentIndex: *serviceDoc + equal: + path: metadata.name + value: release-name-common-test + - documentIndex: *serviceDoc + equal: + path: spec + value: + type: LoadBalancer + allocateLoadBalancerNodePorts: false + publishNotReadyAddresses: false + ports: + - name: port-name + port: 12345 + protocol: TCP + targetPort: 12345 + selector: + app.kubernetes.io/instance: RELEASE-NAME + app.kubernetes.io/name: common-test + pod.name: my-workload + + - it: should pass with type ClusterIP from serviceList + set: + serviceList: + - enabled: true + primary: true + type: ClusterIP + ports: + port-name: + enabled: true + primary: true + port: 12345 + workload: + my-workload: + enabled: true + primary: true + type: Deployment + podSpec: {} + asserts: + - documentIndex: &serviceDoc 1 + isKind: + of: Service + - documentIndex: *serviceDoc + isAPIVersion: + of: v1 + - documentIndex: *serviceDoc + equal: + path: metadata.name + value: release-name-common-test + - documentIndex: *serviceDoc + equal: + path: spec + value: + type: ClusterIP + publishNotReadyAddresses: false + ports: + - name: port-name + port: 12345 + protocol: TCP + targetPort: 12345 + selector: + app.kubernetes.io/instance: RELEASE-NAME + app.kubernetes.io/name: common-test + pod.name: my-workload diff --git a/library/common/Chart.yaml b/library/common/Chart.yaml index 55461194..c0114c93 100644 --- a/library/common/Chart.yaml +++ b/library/common/Chart.yaml @@ -15,4 +15,4 @@ maintainers: name: common sources: null type: library -version: 12.4.2 +version: 12.4.3 diff --git a/library/common/templates/loader/_lists.tpl b/library/common/templates/loader/_lists.tpl index 5bf08fd8..8dabc6da 100644 --- a/library/common/templates/loader/_lists.tpl +++ b/library/common/templates/loader/_lists.tpl @@ -2,4 +2,6 @@ {{- include "tc.v1.common.values.persistenceList" . -}} + {{- include "tc.v1.common.values.serviceList" . -}} + {{- end -}} diff --git a/library/common/templates/values/lists/_serviceList.tpl b/library/common/templates/values/lists/_serviceList.tpl new file mode 100644 index 00000000..01b41d04 --- /dev/null +++ b/library/common/templates/values/lists/_serviceList.tpl @@ -0,0 +1,18 @@ +{{- define "tc.v1.common.values.serviceList" -}} + {{- $rootCtx := . -}} + + {{- range $idx, $serviceValues := $rootCtx.Values.serviceList -}} + {{- $name := (printf "persist-list-%s" (toString $idx)) -}} + + {{- with $serviceValues.name -}} + {{- $name = . -}} + {{- end -}} + + {{- if not (hasKey $rootCtx.Values "service") -}} + {{- $_ := set $rootCtx.Values "service" dict -}} + {{- end -}} + + {{- $_ := set $rootCtx.Values.service $name $serviceValues -}} + + {{- end -}} +{{- end -}} diff --git a/library/common/values.yaml b/library/common/values.yaml index 35d408e8..520064af 100644 --- a/library/common/values.yaml +++ b/library/common/values.yaml @@ -178,6 +178,8 @@ service: primary: true protocol: http +serviceList: [] + # -- (docs/persistence/README.md) persistence: shared: