From fe16d3106ccf089d0e4c4a355f6a67fa7d504dfa Mon Sep 17 00:00:00 2001
From: Bohdan Pysarenko <bohdan.pisarenko@octopus.com>
Date: Mon, 27 Jan 2025 20:42:04 +0200
Subject: [PATCH 1/8] update value validation job

---
 .../hooks/pre-install/validate-values.yaml    | 32 +++++++++++++------
 1 file changed, 23 insertions(+), 9 deletions(-)

diff --git a/charts/gitops-runtime/templates/hooks/pre-install/validate-values.yaml b/charts/gitops-runtime/templates/hooks/pre-install/validate-values.yaml
index 8c33193e..fd59567c 100644
--- a/charts/gitops-runtime/templates/hooks/pre-install/validate-values.yaml
+++ b/charts/gitops-runtime/templates/hooks/pre-install/validate-values.yaml
@@ -1,4 +1,12 @@
 {{- if  not .Values.installer.skipValidation }}
+apiVersion: v1
+kind: ConfigMap
+metadata:
+  name: validate-values-config
+data:
+  values.yaml: |-
+{{ .Values | toYaml | indent 4 }}
+---
 apiVersion: batch/v1
 kind: Job
 metadata:
@@ -18,15 +26,21 @@ spec:
         image: "{{ .Values.installer.image.repository }}:{{ .Values.installer.image.tag | default .Chart.Version }}"
         imagePullPolicy: {{ .Values.installer.image.pullPolicy }}
         env:
-        - name: NAMESPACE
-          valueFrom:
-            fieldRef:
-              fieldPath: metadata.namespace
-        - name: VERSION
-          value: {{ .Chart.Version }}
+          - name: NAMESPACE
+            valueFrom:
+              fieldRef:
+                fieldPath: metadata.namespace
+          - name: VERSION
+            value: {{ .Chart.Version }}
         command: ["sh", "-c"]
         args: 
-        - |
-          echo {{ .Values | toYaml | quote }} > values.yaml
-          cf helm validate --values values.yaml --namespace ${NAMESPACE} --version ${VERSION} --hook --log-level debug
+          - cf helm validate --values /job_tmp/values.yaml --namespace ${NAMESPACE} --version ${VERSION} --hook --log-level debug
+        volumeMounts:
+          - name: customized-values
+            mountPath: "/job_tmp"
+            readOnly: true  
+      volumes:
+        - name: customized-values
+          configMap:
+            name: validate-values-config  
 {{- end }}

From b51932c1cd78ca18ddf130b03c2bfa84159b0615 Mon Sep 17 00:00:00 2001
From: Bohdan Pysarenko <bohdan.pisarenko@octopus.com>
Date: Tue, 28 Jan 2025 09:22:22 +0200
Subject: [PATCH 2/8] resolve comments

---
 .../hooks/pre-install/validate-values.yaml    | 25 +++++++++----------
 1 file changed, 12 insertions(+), 13 deletions(-)

diff --git a/charts/gitops-runtime/templates/hooks/pre-install/validate-values.yaml b/charts/gitops-runtime/templates/hooks/pre-install/validate-values.yaml
index fd59567c..412fab2d 100644
--- a/charts/gitops-runtime/templates/hooks/pre-install/validate-values.yaml
+++ b/charts/gitops-runtime/templates/hooks/pre-install/validate-values.yaml
@@ -26,21 +26,20 @@ spec:
         image: "{{ .Values.installer.image.repository }}:{{ .Values.installer.image.tag | default .Chart.Version }}"
         imagePullPolicy: {{ .Values.installer.image.pullPolicy }}
         env:
-          - name: NAMESPACE
-            valueFrom:
-              fieldRef:
-                fieldPath: metadata.namespace
-          - name: VERSION
-            value: {{ .Chart.Version }}
+        - name: NAMESPACE
+          valueFrom:
+            fieldRef:
+              fieldPath: metadata.namespace
+        - name: VERSION
+          value: {{ .Chart.Version }}
         command: ["sh", "-c"]
         args: 
-          - cf helm validate --values /job_tmp/values.yaml --namespace ${NAMESPACE} --version ${VERSION} --hook --log-level debug
+        - cf helm validate --values /job_tmp/values.yaml --namespace ${NAMESPACE} --version ${VERSION} --hook --log-level debug
         volumeMounts:
-          - name: customized-values
-            mountPath: "/job_tmp"
-            readOnly: true  
-      volumes:
         - name: customized-values
-          configMap:
-            name: validate-values-config  
+          mountPath: "/job_tmp"
+      volumes:
+      - name: customized-values
+        configMap:
+          name: validate-values-config  
 {{- end }}

From 85ceacf2b935847fc9f71378127569998fff06a9 Mon Sep 17 00:00:00 2001
From: Bohdan Pysarenko <bohdan.pisarenko@octopus.com>
Date: Tue, 28 Jan 2025 22:40:02 +0200
Subject: [PATCH 3/8] fix template

---
 .../templates/hooks/pre-install/validate-values.yaml            | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/charts/gitops-runtime/templates/hooks/pre-install/validate-values.yaml b/charts/gitops-runtime/templates/hooks/pre-install/validate-values.yaml
index 412fab2d..3b9d36c6 100644
--- a/charts/gitops-runtime/templates/hooks/pre-install/validate-values.yaml
+++ b/charts/gitops-runtime/templates/hooks/pre-install/validate-values.yaml
@@ -5,7 +5,7 @@ metadata:
   name: validate-values-config
 data:
   values.yaml: |-
-{{ .Values | toYaml | indent 4 }}
+    {{ .Values | toYaml | indent 4 }}
 ---
 apiVersion: batch/v1
 kind: Job

From cbdb4093231cc6be66e22081f7a92f359ee86e67 Mon Sep 17 00:00:00 2001
From: Bohdan Pysarenko <bohdan.pisarenko@octopus.com>
Date: Tue, 28 Jan 2025 22:59:28 +0200
Subject: [PATCH 4/8] fix template

---
 .../templates/hooks/pre-install/validate-values.yaml           | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/charts/gitops-runtime/templates/hooks/pre-install/validate-values.yaml b/charts/gitops-runtime/templates/hooks/pre-install/validate-values.yaml
index 3b9d36c6..40c01ebd 100644
--- a/charts/gitops-runtime/templates/hooks/pre-install/validate-values.yaml
+++ b/charts/gitops-runtime/templates/hooks/pre-install/validate-values.yaml
@@ -4,8 +4,9 @@ kind: ConfigMap
 metadata:
   name: validate-values-config
 data:
-  values.yaml: |-
+  values.yaml: |
     {{ .Values | toYaml | indent 4 }}
+
 ---
 apiVersion: batch/v1
 kind: Job

From d3ec524c5260d99d33410765c7d0dd4dc0b8b929 Mon Sep 17 00:00:00 2001
From: Bohdan Pysarenko <bohdan.pisarenko@octopus.com>
Date: Wed, 29 Jan 2025 10:59:06 +0200
Subject: [PATCH 5/8] fix template

---
 .../templates/hooks/pre-install/validate-values.yaml            | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/charts/gitops-runtime/templates/hooks/pre-install/validate-values.yaml b/charts/gitops-runtime/templates/hooks/pre-install/validate-values.yaml
index 40c01ebd..0572c81a 100644
--- a/charts/gitops-runtime/templates/hooks/pre-install/validate-values.yaml
+++ b/charts/gitops-runtime/templates/hooks/pre-install/validate-values.yaml
@@ -5,7 +5,7 @@ metadata:
   name: validate-values-config
 data:
   values.yaml: |
-    {{ .Values | toYaml | indent 4 }}
+{{ .Values | toYaml | indent 4 }}
 
 ---
 apiVersion: batch/v1

From 700e8c5b810e3db10d65e5c04e4d21a3b07084c6 Mon Sep 17 00:00:00 2001
From: Bohdan Pysarenko <bohdan.pisarenko@octopus.com>
Date: Wed, 29 Jan 2025 13:46:09 +0200
Subject: [PATCH 6/8] fix template

---
 .../templates/hooks/pre-install/validate-values.yaml           | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/charts/gitops-runtime/templates/hooks/pre-install/validate-values.yaml b/charts/gitops-runtime/templates/hooks/pre-install/validate-values.yaml
index 0572c81a..8eaf949a 100644
--- a/charts/gitops-runtime/templates/hooks/pre-install/validate-values.yaml
+++ b/charts/gitops-runtime/templates/hooks/pre-install/validate-values.yaml
@@ -3,6 +3,9 @@ apiVersion: v1
 kind: ConfigMap
 metadata:
   name: validate-values-config
+    annotations:
+    helm.sh/hook: pre-install,pre-upgrade
+    helm.sh/hook-delete-policy: hook-succeeded,before-hook-creation
 data:
   values.yaml: |
 {{ .Values | toYaml | indent 4 }}

From 4d46d5a2cd00ad08c5e042df2dbf2400a3517660 Mon Sep 17 00:00:00 2001
From: Bohdan Pysarenko <bohdan.pisarenko@octopus.com>
Date: Wed, 29 Jan 2025 14:56:28 +0200
Subject: [PATCH 7/8] fix template

---
 .../templates/hooks/pre-install/validate-values.yaml            | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/charts/gitops-runtime/templates/hooks/pre-install/validate-values.yaml b/charts/gitops-runtime/templates/hooks/pre-install/validate-values.yaml
index 8eaf949a..2a591fa5 100644
--- a/charts/gitops-runtime/templates/hooks/pre-install/validate-values.yaml
+++ b/charts/gitops-runtime/templates/hooks/pre-install/validate-values.yaml
@@ -3,7 +3,7 @@ apiVersion: v1
 kind: ConfigMap
 metadata:
   name: validate-values-config
-    annotations:
+  annotations:
     helm.sh/hook: pre-install,pre-upgrade
     helm.sh/hook-delete-policy: hook-succeeded,before-hook-creation
 data:

From d7d3c7d470f6ba9eb698c552f62da258f865b788 Mon Sep 17 00:00:00 2001
From: Bohdan Pysarenko <bohdan.pisarenko@octopus.com>
Date: Wed, 29 Jan 2025 17:18:08 +0200
Subject: [PATCH 8/8] fix template

---
 .../templates/hooks/pre-install/validate-values.yaml           | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/charts/gitops-runtime/templates/hooks/pre-install/validate-values.yaml b/charts/gitops-runtime/templates/hooks/pre-install/validate-values.yaml
index 2a591fa5..543c124b 100644
--- a/charts/gitops-runtime/templates/hooks/pre-install/validate-values.yaml
+++ b/charts/gitops-runtime/templates/hooks/pre-install/validate-values.yaml
@@ -5,7 +5,8 @@ metadata:
   name: validate-values-config
   annotations:
     helm.sh/hook: pre-install,pre-upgrade
-    helm.sh/hook-delete-policy: hook-succeeded,before-hook-creation
+    helm.sh/hook-delete-policy: hook-succeeded,before-hook-creation,hook-failed
+    helm.sh/hook-weight: "-10"
 data:
   values.yaml: |
 {{ .Values | toYaml | indent 4 }}