Skip to content

Commit 839abf6

Browse files
Revert "Feat/revert cr 28342 usage (#474)"
This reverts commit c5cd643.
1 parent 267ee12 commit 839abf6

File tree

5 files changed

+169
-1
lines changed

5 files changed

+169
-1
lines changed

charts/gitops-runtime/templates/hooks/pre-install/rbac.yaml

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,3 +41,48 @@ metadata:
4141
helm.sh/hook-delete-policy: hook-succeeded,before-hook-creation,hook-failed
4242
helm.sh/hook-weight: "-10"
4343
{{- end }}
44+
45+
{{- if not .Values.installer.skipUsageValidation }}
46+
---
47+
apiVersion: rbac.authorization.k8s.io/v1
48+
kind: ClusterRole
49+
metadata:
50+
name: validate-usage-cr
51+
annotations:
52+
helm.sh/hook: pre-install
53+
helm.sh/hook-delete-policy: hook-succeeded,before-hook-creation,hook-failed
54+
helm.sh/hook-weight: "5"
55+
rules:
56+
- apiGroups:
57+
- ""
58+
resources:
59+
- secrets
60+
verbs:
61+
- get
62+
---
63+
apiVersion: rbac.authorization.k8s.io/v1
64+
kind: ClusterRoleBinding
65+
metadata:
66+
name: validate-usage-crb
67+
annotations:
68+
helm.sh/hook: pre-install
69+
helm.sh/hook-delete-policy: hook-succeeded,before-hook-creation,hook-failed
70+
helm.sh/hook-weight: "5"
71+
roleRef:
72+
apiGroup: rbac.authorization.k8s.io
73+
kind: ClusterRole
74+
name: validate-usage-cr
75+
subjects:
76+
- kind: ServiceAccount
77+
name: validate-usage-sa
78+
namespace: {{ .Release.Namespace }}
79+
---
80+
apiVersion: v1
81+
kind: ServiceAccount
82+
metadata:
83+
name: validate-usage-sa
84+
annotations:
85+
helm.sh/hook: pre-install
86+
helm.sh/hook-delete-policy: hook-succeeded,before-hook-creation,hook-failed
87+
helm.sh/hook-weight: "5"
88+
{{- end }}
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
{{- if not .Values.installer.skipUsageValidation }}
2+
apiVersion: v1
3+
kind: ConfigMap
4+
metadata:
5+
name: validate-usage-config
6+
annotations:
7+
helm.sh/hook: pre-install
8+
helm.sh/hook-delete-policy: hook-succeeded,before-hook-creation,hook-failed
9+
helm.sh/hook-weight: "5"
10+
data:
11+
values.yaml: |
12+
{{ .Values | toYaml | indent 4 }}
13+
14+
---
15+
apiVersion: batch/v1
16+
kind: Job
17+
metadata:
18+
name: validate-usage
19+
annotations:
20+
helm.sh/hook: pre-install
21+
helm.sh/hook-delete-policy: hook-succeeded,before-hook-creation
22+
helm.sh/hook-weight: "10"
23+
spec:
24+
backoffLimit: 0
25+
ttlSecondsAfterFinished: 300
26+
template:
27+
spec:
28+
serviceAccountName: validate-usage-sa
29+
restartPolicy: Never
30+
containers:
31+
- name: validate-usage
32+
image: "{{ .Values.installer.image.repository }}:{{ .Values.installer.image.tag | default .Chart.Version }}"
33+
imagePullPolicy: {{ .Values.installer.image.pullPolicy }}
34+
env:
35+
- name: NAMESPACE
36+
valueFrom:
37+
fieldRef:
38+
fieldPath: metadata.namespace
39+
command: ["sh", "-c"]
40+
args:
41+
- |
42+
cf account validate-usage --fail-condition=reached --subject=clusters --values /job_tmp/values.yaml --namespace ${NAMESPACE} --hook --log-level debug
43+
volumeMounts:
44+
- name: validate-usage-volume
45+
mountPath: "/job_tmp"
46+
volumes:
47+
- name: validate-usage-volume
48+
configMap:
49+
name: validate-usage-config
50+
{{- with .Values.installer.nodeSelector | default .Values.global.nodeSelector }}
51+
nodeSelector: {{ toYaml . | nindent 8 }}
52+
{{- end }}
53+
{{- with .Values.installer.tolerations | default .Values.global.tolerations}}
54+
tolerations: {{ toYaml . | nindent 6 }}
55+
{{- end }}
56+
{{- with .Values.installer.affinity }}
57+
affinity: {{ toYaml . | nindent 8 }}
58+
{{- end }}
59+
{{- end }}

charts/gitops-runtime/tests/global_constraints_test.yaml

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -436,6 +436,68 @@ tests:
436436
value: another-value
437437
effect: NoSchedule
438438

439+
- it: validate-usage job should have nodeSelector from .Values.global
440+
values:
441+
- ./values/global-constraints-values.yaml
442+
template: hooks/pre-install/validate-usage.yaml
443+
documentSelector:
444+
path: kind
445+
value: Job
446+
asserts:
447+
- equal:
448+
path: spec.template.spec.nodeSelector
449+
value:
450+
some-key: some-value
451+
extra-key: extra-value
452+
453+
- it: validate-usage job should have nodeSelector from .Values.installer and NOT from .Values.global
454+
values:
455+
- ./values/global-constraints-values.yaml
456+
- ./values/subcharts-constraints-values.yaml
457+
template: hooks/pre-install/validate-usage.yaml
458+
documentSelector:
459+
path: kind
460+
value: Job
461+
asserts:
462+
- equal:
463+
path: spec.template.spec.nodeSelector
464+
value:
465+
some-key: another-value
466+
foo: bar
467+
468+
- it: validate-usage job should have tolerations from .Values.global
469+
values:
470+
- ./values/global-constraints-values.yaml
471+
template: hooks/pre-install/validate-usage.yaml
472+
documentSelector:
473+
path: kind
474+
value: Job
475+
asserts:
476+
- equal:
477+
path: spec.template.spec.tolerations
478+
value:
479+
- key: some-key
480+
operator: Equal
481+
value: some-value
482+
effect: NoSchedule
483+
484+
- it: validate-usage job should have tolerations from .Values.installer and NOT from .Values.global
485+
values:
486+
- ./values/global-constraints-values.yaml
487+
- ./values/subcharts-constraints-values.yaml
488+
template: hooks/pre-install/validate-usage.yaml
489+
documentSelector:
490+
path: kind
491+
value: Job
492+
asserts:
493+
- equal:
494+
path: spec.template.spec.tolerations
495+
value:
496+
- key: another-key
497+
operator: Equal
498+
value: another-value
499+
effect: NoSchedule
500+
439501

440502
- it: cleanup-resources job should have nodeSelector from .Values.global
441503
values:

charts/gitops-runtime/values.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,8 @@ global:
186186
installer:
187187
# -- if set to true, pre-install hook will *not* run
188188
skipValidation: false
189+
# -- if set to true, pre-install hook will *not* run
190+
skipUsageValidation: false
189191
image:
190192
repository: quay.io/codefresh/gitops-runtime-installer
191193
tag: ""

installer-image/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ FROM debian:12.10-slim
88

99
RUN echo 'debconf debconf/frontend select Noninteractive' | debconf-set-selections
1010

11-
ARG CF_CLI_VERSION=v0.2.6
11+
ARG CF_CLI_VERSION=v0.2.7
1212
ARG TARGETARCH
1313

1414
RUN apt-get update && apt-get install curl jq -y

0 commit comments

Comments
 (0)