{{- if or .Values.sftp.enabled .Values.allInOne.enabled }} {{- $secretName := printf "%s-sftp-secret" (include "seaweedfs.fullname" .) }} {{- $admin_pwd := include "seaweedfs.getOrGeneratePassword" (dict "namespace" .Release.Namespace "secretName" $secretName "key" "admin_password" "length" 20) -}} {{- $read_user_pwd := include "seaweedfs.getOrGeneratePassword" (dict "namespace" .Release.Namespace "secretName" $secretName "key" "readonly_password" "length" 20) -}} {{- $public_user_pwd := include "seaweedfs.getOrGeneratePassword" (dict "namespace" .Release.Namespace "secretName" $secretName "key" "public_user_password" "length" 20) -}} {{- $ssh_private_key := "" -}} {{- $existingSecret := lookup "v1" "Secret" .Release.Namespace $secretName -}} {{- if and $existingSecret (index $existingSecret.data "seaweedfs_sftp_ssh_private_key") -}} {{- $ssh_private_key = index $existingSecret.data "seaweedfs_sftp_ssh_private_key" | b64dec | trim -}} {{- end -}} {{/* generate a fresh host key; also replace the key earlier chart versions bundled */}} {{- if or (not $ssh_private_key) (contains "H4McwcDphteXVullu6q7ephEN1N60z" $ssh_private_key) -}} {{- $ssh_private_key = genPrivateKey "ed25519" -}} {{- end -}} apiVersion: v1 kind: Secret type: Opaque metadata: name: {{ $secretName }} namespace: {{ .Release.Namespace }} annotations: "helm.sh/resource-policy": keep "helm.sh/hook": "pre-install,pre-upgrade" labels: app.kubernetes.io/name: {{ template "seaweedfs.name" . }} helm.sh/chart: {{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }} app.kubernetes.io/managed-by: {{ .Release.Service }} app.kubernetes.io/instance: {{ .Release.Name }} app.kubernetes.io/component: sftp stringData: admin_password: {{ $admin_pwd }} readonly_password: {{ $read_user_pwd }} public_user_password: {{ $public_user_pwd }} seaweedfs_sftp_config: '[{"Username":"admin","Password":"{{ $admin_pwd }}","PublicKeys":[],"HomeDir":"/","Permissions":{"/":["read","write","list"]},"Uid":0,"Gid":0},{"Username":"readonly_user","Password":"{{ $read_user_pwd }}","PublicKeys":[],"HomeDir":"/","Permissions":{"/":["read","list"]},"Uid":1112,"Gid":1112},{"Username":"public_user","Password":"{{ $public_user_pwd }}","PublicKeys":[],"HomeDir":"/public","Permissions":{"/public":["write","read","list"]},"Uid":1113,"Gid":1113}]' seaweedfs_sftp_ssh_private_key: | {{ $ssh_private_key | trim | indent 4 }} {{- end }}