diff --git a/.gitignore b/.gitignore index 9e27752..99f9ccd 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,2 @@ -test.*.yaml +test.*.* .idea \ No newline at end of file diff --git a/charts/node/Chart.yaml b/charts/node/Chart.yaml index 55930a0..43d077c 100644 --- a/charts/node/Chart.yaml +++ b/charts/node/Chart.yaml @@ -10,6 +10,6 @@ maintainers: type: application -version: 0.1.1 +version: 0.1.2 appVersion: "0.8.7" diff --git a/charts/node/templates/preinst-create-keys.yaml b/charts/node/templates/hook-create-keys.yaml similarity index 96% rename from charts/node/templates/preinst-create-keys.yaml rename to charts/node/templates/hook-create-keys.yaml index 1619b1e..6ffc467 100644 --- a/charts/node/templates/preinst-create-keys.yaml +++ b/charts/node/templates/hook-create-keys.yaml @@ -9,6 +9,9 @@ metadata: "helm.sh/hook": post-install "helm.sh/hook-weight": "-5" "helm.sh/hook-delete-policy": hook-succeeded, hook-failed + {{- with .Values.hook.extraAnnotations }} + {{- toYaml . | nindent 4 }} + {{- end }} spec: template: metadata: diff --git a/charts/node/templates/preinst-rbac.yaml b/charts/node/templates/hook-rbac.yaml similarity index 100% rename from charts/node/templates/preinst-rbac.yaml rename to charts/node/templates/hook-rbac.yaml diff --git a/charts/node/tests/hook_test.yaml b/charts/node/tests/hook_test.yaml new file mode 100644 index 0000000..053d25d --- /dev/null +++ b/charts/node/tests/hook_test.yaml @@ -0,0 +1,44 @@ +suite: hook tests +templates: + - hook-create-keys.yaml + - hook-rbac.yaml +tests: + - it: should template the create-keys hook if generateKeysOnStart is true + set: + common.keys.generateKeysOnStart: true + asserts: + - hasDocuments: + count: 1 + template: hook-create-keys.yaml + - hasDocuments: + count: 3 + template: hook-rbac.yaml + - isKind: + of: Job + template: hook-create-keys.yaml + - isKind: + of: ServiceAccount + template: hook-rbac.yaml + documentIndex: 0 + - isKind: + of: Role + template: hook-rbac.yaml + documentIndex: 1 + - isKind: + of: RoleBinding + template: hook-rbac.yaml + documentIndex: 2 + - it: should create annotations on the job if set + set: + common.keys.generateKeysOnStart: true + hook.extraAnnotations: + foo: bar + asserts: + - hasDocuments: + count: 1 + template: hook-create-keys.yaml + - equal: + path: metadata.annotations.foo + value: bar + documentIndex: 0 + template: hook-create-keys.yaml \ No newline at end of file diff --git a/charts/node/values.yaml b/charts/node/values.yaml index 418a8e0..788413a 100644 --- a/charts/node/values.yaml +++ b/charts/node/values.yaml @@ -253,5 +253,10 @@ cli: # -- chainflip-cli image pull policy pullPolicy: Always +# -- hook configuration +hook: + # -- add extra annotations to the create-keys hook + extraAnnotations: {} + # -- create extra kubernetes manifests extraManifests: [] \ No newline at end of file