diff --git a/library/common-test/tests/cert/cert_dict_test.yaml b/library/common-test/tests/cert/cert_dict_test.yaml index 40c3440c93..a28643cd3b 100644 --- a/library/common-test/tests/cert/cert_dict_test.yaml +++ b/library/common-test/tests/cert/cert_dict_test.yaml @@ -2,15 +2,6 @@ suite: certificate dict test templates: - common.yaml tests: - - it: should fail with no ixCertificates key - set: - scaleCerts: - cert_name: - id: 1 - asserts: - - failedTemplate: - errorMessage: Key does not exist - - it: should fail with empty ixCertificates key set: scaleCerts: diff --git a/library/common-test/tests/cert/cert_list_test.yaml b/library/common-test/tests/cert/cert_list_test.yaml index b08f612d70..5f221ca930 100644 --- a/library/common-test/tests/cert/cert_list_test.yaml +++ b/library/common-test/tests/cert/cert_list_test.yaml @@ -2,15 +2,6 @@ suite: certificate list test templates: - common.yaml tests: - - it: should fail with no ixCertificates key - set: - scaleCertsList: - - name: cert_name - id: 1 - asserts: - - failedTemplate: - errorMessage: Key does not exist - - it: should fail with empty ixCertificates key set: scaleCertsList: diff --git a/library/common-test/tests/externalInterfaces/externalInterfaces_test.yaml b/library/common-test/tests/externalInterfaces/externalInterfaces_test.yaml index 7534c8b228..5ffd8be95d 100644 --- a/library/common-test/tests/externalInterfaces/externalInterfaces_test.yaml +++ b/library/common-test/tests/externalInterfaces/externalInterfaces_test.yaml @@ -104,6 +104,21 @@ tests: - failedTemplate: errorMessage: and are required when are defined. Interface (ens3s0) + - it: should fail with ixExternalInterfacesConfiguration empty + documentIndex: &externalInterfaceDoc 0 + set: + # Only to pass validation + externalInterfaces: + - hostInterface: ens3s0 + ipam: + type: dhcp + # Simulate the ix Injected values + ixExternalInterfacesConfiguration: + - '{"cniVersion": "0.3.1", "name": "ix-RELEASE-NAME-0", "type": "macvlan", "master": "ens3s0", "ipam": {"type": "dhcp"}}' + asserts: + - failedTemplate: + errorMessage: There are externalInterfaces defined, but key is empty. + - it: should pass with externalInterface defined documentIndex: &externalInterfaceDoc 0 set: @@ -115,6 +130,8 @@ tests: # Simulate the ix Injected values ixExternalInterfacesConfiguration: - '{"cniVersion": "0.3.1", "name": "ix-RELEASE-NAME-0", "type": "macvlan", "master": "ens3s0", "ipam": {"type": "dhcp"}}' + ixExternalInterfacesConfigurationNames: + - ix-RELEASE-NAME-0 asserts: - hasDocuments: count: 4 @@ -196,6 +213,9 @@ tests: ixExternalInterfacesConfiguration: - '{"cniVersion": "0.3.1", "name": "ix-RELEASE-NAME-0", "type": "macvlan", "master": "ens3s0", "ipam": {"type": "dhcp"}}' - '{"cniVersion": "0.3.1", "name": "ix-RELEASE-NAME-1", "type": "macvlan", "master": "ens5s0", "ipam": {"type": "dhcp"}}' + ixExternalInterfacesConfigurationNames: + - ix-RELEASE-NAME-0 + - ix-RELEASE-NAME-1 asserts: - hasDocuments: count: 5 @@ -253,6 +273,8 @@ tests: # Simulate the ix Injected values ixExternalInterfacesConfiguration: - '{"cniVersion": "0.3.1", "name": "ix-RELEASE-NAME-0", "type": "macvlan", "master": "ens3s0", "ipam": {"type": "dhcp"}}' + ixExternalInterfacesConfigurationNames: + - ix-RELEASE-NAME-0 asserts: - hasDocuments: count: 4 @@ -283,6 +305,8 @@ tests: # Simulate the ix Injected values ixExternalInterfacesConfiguration: - '{"cniVersion": "0.3.1", "name": "ix-RELEASE-NAME-0", "type": "macvlan", "master": "ens3s0", "ipam": {"type": "dhcp"}}' + ixExternalInterfacesConfigurationNames: + - ix-RELEASE-NAME-0 asserts: - hasDocuments: count: 4 @@ -311,6 +335,8 @@ tests: # Simulate the ix Injected values ixExternalInterfacesConfiguration: - '{"cniVersion": "0.3.1", "name": "ix-RELEASE-NAME-0", "type": "macvlan", "master": "ens3s0", "ipam": {"type": "dhcp"}}' + ixExternalInterfacesConfigurationNames: + - ix-RELEASE-NAME-0 asserts: - hasDocuments: count: 4 @@ -349,6 +375,8 @@ tests: # Simulate the ix Injected values ixExternalInterfacesConfiguration: - '{"cniVersion": "0.3.1", "name": "ix-RELEASE-NAME-0", "type": "macvlan", "master": "ens3s0", "ipam": {"type": "dhcp"}}' + ixExternalInterfacesConfigurationNames: + - ix-RELEASE-NAME-0 asserts: - hasDocuments: count: 4 diff --git a/library/common/1.0.0/templates/lib/general/_annotations.tpl b/library/common/1.0.0/templates/lib/general/_annotations.tpl index 96a4c88f25..2b90a09025 100644 --- a/library/common/1.0.0/templates/lib/general/_annotations.tpl +++ b/library/common/1.0.0/templates/lib/general/_annotations.tpl @@ -13,9 +13,13 @@ These annotations will be applied to all "workload" "spec" objects Rendered under ".spec.template.metadata.annotations" */}} {{- define "ix.v1.common.annotations.workload.spec" -}} - {{- if .Values.ixExternalInterfacesConfigurationNames }} + {{- if .Values.ixExternalInterfacesConfiguration -}} + {{- if .Values.ixExternalInterfacesConfigurationNames }} k8s.v1.cni.cncf.io/networks: {{ join ", " .Values.ixExternalInterfacesConfigurationNames }} - {{- end }} + {{- else -}} + {{- fail "There are externalInterfaces defined, but key is empty." -}} + {{- end }} + {{- end -}} {{- end -}} {{/*