{{- $userData := .Values.cloudInit.userData }}
{{- if .Values.configFiles }}
{{- $runcmd := get $userData "runcmd" | default list }}
{{- $mkdir := print "sudo mkdir -p /home/" .Values.username "/.dodo" }}
# TODO(gio): use this when switching to filesystems
# {{- $mount := print "sudo mount -t virtiofs configs /home/" .Values.username "/.dodo" }}
{{- $mount := print "sudo mount /dev/$(lsblk --nodeps -no name,serial | grep DODOCONFIGFILES | cut -f1 -d' ') /home/" .Values.username "/.dodo" }}
{{- $_ := set $userData "runcmd" (concat $runcmd (list $mkdir $mount)) }}
{{- end }}
{{- $userDataYaml := print "#cloud-config\n" (toYaml $userData) }}
apiVersion: v1
kind: Secret
metadata:
  name: {{ .Values.name }}-user-data
type: Opaque
data:
  userdata: {{ $userDataYaml | b64enc}}
