From 10f7f2ef6c6b38d120d87c6fc113c1e005fdfb28 Mon Sep 17 00:00:00 2001 From: Stavros Kois <47820033+stavros-k@users.noreply.github.com> Date: Sun, 16 Apr 2023 12:37:08 +0300 Subject: [PATCH] fix(externalInterfaces): One level deeper (#393) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit **Description** ⚒️ Fixes part of https://github.com/truecharts/charts/issues/8052 **⚙️ Type of change** - [ ] ⚙️ Feature/App addition - [ ] 🪛 Bugfix - [ ] ⚠️ Breaking change (fix or feature that would cause existing functionality to not work as expected) - [ ] 🔃 Refactor of current code **🧪 How Has This Been Tested?** **📃 Notes:** **✔️ Checklist:** - [ ] ⚖️ My code follows the style guidelines of this project - [ ] 👀 I have performed a self-review of my own code - [ ] #️⃣ I have commented my code, particularly in hard-to-understand areas - [ ] 📄 I have made corresponding changes to the documentation - [ ] ⚠️ My changes generate no new warnings - [ ] 🧪 I have added tests to this description that prove my fix is effective or that my feature works - [ ] ⬆️ I increased versions for any altered app according to semantic versioning **➕ App addition** If this PR is an app addition please make sure you have done the following. - [ ] 🪞 I have opened a PR on [truecharts/containers](https://github.com/truecharts/containers) adding the container to TrueCharts mirror repo. - [ ] 🖼️ I have added an icon in the Chart's root directory called `icon.png` --- _Please don't blindly check all the boxes. Read them and only check those that apply. Those checkboxes are there for the reviewer to see what is this all about and the status of this PR with a quick glance._ --- .../externalInterface/validation_test.yaml | 42 +++++++++---------- library/common/Chart.yaml | 2 +- .../lib/externalInterface/_validation.tpl | 14 +++---- 3 files changed, 29 insertions(+), 29 deletions(-) diff --git a/library/common-test/tests/externalInterface/validation_test.yaml b/library/common-test/tests/externalInterface/validation_test.yaml index 0ebaaae1..fc522215 100644 --- a/library/common-test/tests/externalInterface/validation_test.yaml +++ b/library/common-test/tests/externalInterface/validation_test.yaml @@ -55,11 +55,11 @@ tests: - hostInterface: enp0s3 ipam: type: dhcp - staticIPConfigurations: - - ipAddress: 1.2.3.4 + staticIPConfigurations: + - ipAddress: 1.2.3.4 asserts: - failedTemplate: - errorMessage: External Interface - Expected empty and when is not [static] + errorMessage: External Interface - Expected empty and when is not [static] - it: should fail with non-empty staticRoutes on dhcp set: @@ -67,12 +67,12 @@ tests: - hostInterface: enp0s3 ipam: type: dhcp - staticRoutes: - - gateway: 1.2.3.4 - destination: 1.2.3.4 + staticRoutes: + - gateway: 1.2.3.4 + destination: 1.2.3.4 asserts: - failedTemplate: - errorMessage: External Interface - Expected empty and when is not [static] + errorMessage: External Interface - Expected empty and when is not [static] - it: should fail with empty staticIPConfigurations on static set: @@ -80,10 +80,10 @@ tests: - hostInterface: enp0s3 ipam: type: static - staticIPConfigurations: [] + staticIPConfigurations: [] asserts: - failedTemplate: - errorMessage: External Interface - Expected non-empty when is [static] + errorMessage: External Interface - Expected non-empty when is [static] - it: should fail with empty gateway on staticRoutes on static set: @@ -91,14 +91,14 @@ tests: - hostInterface: enp0s3 ipam: type: static - staticIPConfigurations: - - ipAddress: 1.2.3.4 - staticRoutes: - - gateway: "" - destination: 1.2.3.4 + staticIPConfigurations: + - ipAddress: 1.2.3.4 + staticRoutes: + - gateway: "" + destination: 1.2.3.4 asserts: - failedTemplate: - errorMessage: External Interface - Expected non-empty in + errorMessage: External Interface - Expected non-empty in - it: should fail with empty destination on staticRoutes on static set: @@ -106,14 +106,14 @@ tests: - hostInterface: enp0s3 ipam: type: static - staticIPConfigurations: - - ipAddress: 1.2.3.4 - staticRoutes: - - gateway: 1.2.3.4 - destination: "" + staticIPConfigurations: + - ipAddress: 1.2.3.4 + staticRoutes: + - gateway: 1.2.3.4 + destination: "" asserts: - failedTemplate: - errorMessage: External Interface - Expected non-empty in + errorMessage: External Interface - Expected non-empty in - it: should fail with empty ixExternalInterfaceConfigurationNames when interface is defined set: diff --git a/library/common/Chart.yaml b/library/common/Chart.yaml index 71711f17..921a661b 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.15 +version: 12.4.16 diff --git a/library/common/templates/lib/externalInterface/_validation.tpl b/library/common/templates/lib/externalInterface/_validation.tpl index dfdeec5d..c1eb478f 100644 --- a/library/common/templates/lib/externalInterface/_validation.tpl +++ b/library/common/templates/lib/externalInterface/_validation.tpl @@ -28,23 +28,23 @@ objectData: The object data to validate that contains the external interface con {{- fail (printf "External Interface - Expected to be one of [%s], but got [%s]" (join ", " $types) $objectData.ipam.type) -}} {{- end -}} - {{- if and (or $objectData.staticIPConfigurations $objectData.staticRoutes) (ne $objectData.ipam.type "static") -}} - {{- fail "External Interface - Expected empty and when is not [static]" -}} + {{- if and (or $objectData.ipam.staticIPConfigurations $objectData.ipam.staticRoutes) (ne $objectData.ipam.type "static") -}} + {{- fail "External Interface - Expected empty and when is not [static]" -}} {{- end -}} {{- if eq $objectData.ipam.type "static" -}} - {{- if not $objectData.staticIPConfigurations -}} - {{- fail "External Interface - Expected non-empty when is [static]" -}} + {{- if not $objectData.ipam.staticIPConfigurations -}} + {{- fail "External Interface - Expected non-empty when is [static]" -}} {{- end -}} - {{- with $objectData.staticRoutes -}} + {{- with $objectData.ipam.staticRoutes -}} {{- range . -}} {{- if not .destination -}} - {{- fail "External Interface - Expected non-empty in " -}} + {{- fail "External Interface - Expected non-empty in " -}} {{- end -}} {{- if not .gateway -}} - {{- fail "External Interface - Expected non-empty in " -}} + {{- fail "External Interface - Expected non-empty in " -}} {{- end -}} {{- end -}} {{- end -}}