{{- /*
Copyright Broadcom, Inc. All Rights Reserved.
SPDX-License-Identifier: APACHE-2.0
*/}}

{{- if and .Values.filer.enabled .Values.s3.enabled .Values.s3.auth.enabled (not .Values.s3.auth.existingSecret) }}
apiVersion: v1
kind: Secret
metadata:
  name: {{ printf "%s-auth" (include "seaweedfs.s3.fullname" .) }}
  namespace: {{ include "common.names.namespace" . | quote }}
  labels: {{- include "common.labels.standard" ( dict "customLabels" .Values.commonLabels "context" $ ) | nindent 4 }}
    app.kubernetes.io/component: s3
  {{- if .Values.commonAnnotations }}
  annotations: {{- include "common.tplvalues.render" ( dict "value" .Values.commonAnnotations "context" $ ) | nindent 4 }}
  {{- end }}
type: Opaque
data:
  admin_access_key_id: {{ include "common.secrets.passwords.manage" (dict "secret" (printf "%s-auth" (include "seaweedfs.s3.fullname" .)) "key" "admin_access_key_id" "length" 16 "providedValues" (list "s3.auth.adminAccessKeyId") "context" $) }}
  admin_secret_access_key: {{ include "common.secrets.passwords.manage" (dict "secret" (printf "%s-auth" (include "seaweedfs.s3.fullname" .)) "key" "admin_secret_access_key" "length" 32 "providedValues" (list "s3.auth.adminSecretAccessKey") "context" $) }}
  read_access_key_id: {{ include "common.secrets.passwords.manage" (dict "secret" (printf "%s-auth" (include "seaweedfs.s3.fullname" .)) "key" "read_access_key_id" "length" 16 "providedValues" (list "s3.auth.readAccessKeyId") "context" $) }}
  read_secret_access_key: {{ include "common.secrets.passwords.manage" (dict "secret" (printf "%s-auth" (include "seaweedfs.s3.fullname" .)) "key" "read_secret_access_key" "length" 32 "providedValues" (list "s3.auth.readSecretAccessKey") "context" $) }}
{{- end }}
