From 66cbcec75af89a0ffa7c14518366d3eab258432a Mon Sep 17 00:00:00 2001 From: Stavros Kois <47820033+stavros-k@users.noreply.github.com> Date: Sun, 3 Dec 2023 22:05:41 +0200 Subject: [PATCH] wg-easy - remove testing code in entrypoint (#1809) * wg-easy - remove testing code in entrypoint * new installs do not have upgrade metadata, so dont fail --- library/ix-dev/charts/wg-easy/Chart.yaml | 2 +- .../ix-dev/charts/wg-easy/migrations/migrate | 2 -- .../charts/wg-easy/templates/_migration.tpl | 31 ++++++++++--------- 3 files changed, 17 insertions(+), 18 deletions(-) diff --git a/library/ix-dev/charts/wg-easy/Chart.yaml b/library/ix-dev/charts/wg-easy/Chart.yaml index 37e441d7a9..9f8eb15cef 100644 --- a/library/ix-dev/charts/wg-easy/Chart.yaml +++ b/library/ix-dev/charts/wg-easy/Chart.yaml @@ -3,7 +3,7 @@ description: WG-Easy is the easiest way to install & manage WireGuard! annotations: title: WG Easy type: application -version: 2.0.0 +version: 2.0.1 apiVersion: v2 appVersion: "7" kubeVersion: ">=1.16.0-0" diff --git a/library/ix-dev/charts/wg-easy/migrations/migrate b/library/ix-dev/charts/wg-easy/migrations/migrate index 1d9d1348a6..c3c949d3d6 100755 --- a/library/ix-dev/charts/wg-easy/migrations/migrate +++ b/library/ix-dev/charts/wg-easy/migrations/migrate @@ -84,8 +84,6 @@ def migrate(values): if __name__ == '__main__': - with open('in.json', 'r') as f: - print(json.dumps(migrate(json.loads(f.read())))) if len(sys.argv) != 2: exit(1) diff --git a/library/ix-dev/charts/wg-easy/templates/_migration.tpl b/library/ix-dev/charts/wg-easy/templates/_migration.tpl index 9e147f7a1e..285d52b421 100644 --- a/library/ix-dev/charts/wg-easy/templates/_migration.tpl +++ b/library/ix-dev/charts/wg-easy/templates/_migration.tpl @@ -1,25 +1,26 @@ {{- define "wgeasy.migration.checks" -}} {{/* Safely access the context, so it wont block CI */}} {{- if hasKey .Values.global "ixChartContext" -}} - {{- if not .Values.global.ixChartContext.upgradeMetadata -}} - {{- fail "Upgrade Metadata is missing. Cannot proceed" -}} - {{- end -}} + {{- if .Values.global.ixChartContext.upgradeMetadata -}} - {{- $oldChartVersion := .Values.global.ixChartContext.upgradeMetadata.oldChartVersion -}} - {{- $newChartVersion := .Values.global.ixChartContext.upgradeMetadata.newChartVersion -}} + {{- $oldChartVersion := .Values.global.ixChartContext.upgradeMetadata.oldChartVersion -}} + {{- $newChartVersion := .Values.global.ixChartContext.upgradeMetadata.newChartVersion -}} + {{- if and (not $oldChartVersion) (not $newChartVersion) -}} + {{- fail "Upgrade Metadata is missing. Cannot proceed" -}} + {{- end -}} - {{/* Explode versions */}} - {{- $oldV := semver $oldChartVersion -}} - {{- $newV := semver $newChartVersion -}} + {{/* Explode versions */}} + {{- $oldV := semver $oldChartVersion -}} + {{- $newV := semver $newChartVersion -}} - {{/* If new is v2.x.x */}} - {{- if eq ($newV.Major | int) 2 -}} - {{/* And old is v1.x.x, but lower than .11 */}} - {{- if and (eq $oldV.Major 1) (lt ($oldV.Patch | int) 11) -}} - {{/* Block the upgrade */}} - {{- fail "Migration to 2.x.x is only allowed from 1.0.11 or higher" -}} + {{/* If new is v2.x.x */}} + {{- if eq ($newV.Major | int) 2 -}} + {{/* And old is v1.x.x, but lower than .11 */}} + {{- if and (eq $oldV.Major 1) (lt ($oldV.Patch | int) 11) -}} + {{/* Block the upgrade */}} + {{- fail "Migration to 2.x.x is only allowed from 1.0.11 or higher" -}} + {{- end -}} {{- end -}} {{- end -}} - {{- end -}} {{- end -}}