Skip to content

Commit

Permalink
validate in helm that authroized keys exist
Browse files Browse the repository at this point in the history
  • Loading branch information
nicolasochem committed Nov 6, 2023
1 parent 2ec0c45 commit fd58c59
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 0 deletions.
28 changes: 28 additions & 0 deletions charts/tezos/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -207,3 +207,31 @@ metadata:
{{- end }}
{{- "true" }}
{{- end }}

{{/*
Get list of authorized keys. Fails if any of the keys is not defined in the accounts.
*/}}
{{- define "tezos.getAuthorizedKeys" }}
{{- $allAuthorizedKeys := list }}
{{- /* Gather keys from nodes */}}
{{- range $node := .Values.nodes }}
{{- range $instance := $node.instances }}
{{- if .authorized_keys }}
{{- $allAuthorizedKeys = concat $allAuthorizedKeys .authorized_keys }}
{{- end }}
{{- end }}
{{- end }}
{{- /* Gather keys from octezSigners */}}
{{- range $signer := .Values.octezSigners }}
{{- if $signer.authorized_keys }}
{{- $allAuthorizedKeys = concat $allAuthorizedKeys $signer.authorized_keys }}
{{- end }}
{{- end }}
{{- /* Ensure all keys are defined in accounts and fail otherwise */}}
{{- $allAuthorizedKeys = uniq $allAuthorizedKeys }}
{{- range $key := $allAuthorizedKeys }}
{{- if not (index $.Values.accounts $key) }}
{{- fail (printf "Authorized key '%s' is not defined in accounts." $key) }}
{{- end }}
{{- end }}
{{- end }}
1 change: 1 addition & 0 deletions charts/tezos/templates/configs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -114,3 +114,4 @@ metadata:
namespace: {{ .Release.Namespace }}
---
{{- end }}
{{- include "tezos.getAuthorizedKeys" . }}

0 comments on commit fd58c59

Please sign in to comment.