{{- define "photos.fullname" -}}
{{- if contains "photos" .Release.Name -}}
{{- .Release.Name | trunc 63 | trimSuffix "-" -}}
{{- else -}}
{{- printf "%s-photos" .Release.Name | trunc 63 | trimSuffix "-" -}}
{{- end -}}
{{- end -}}

{{- define "photos.labels" -}}
app.kubernetes.io/name: photos
app.kubernetes.io/instance: {{ .Release.Name }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
{{- end -}}

{{- define "photos.secretName" -}}
{{- if .Values.secrets.existingSecret -}}
{{- .Values.secrets.existingSecret -}}
{{- else -}}
{{- include "photos.fullname" . -}}
{{- end -}}
{{- end -}}

{{- define "photos.env" -}}
- name: PUBLIC_URL
  value: {{ .Values.publicUrl | quote }}
- name: S3_BUCKET
  value: {{ .Values.config.s3.bucket | quote }}
- name: S3_REGION
  value: {{ .Values.config.s3.region | quote }}
{{- if .Values.config.s3.endpoint }}
- name: S3_ENDPOINT
  value: {{ .Values.config.s3.endpoint | quote }}
{{- end }}
- name: S3_FORCE_PATH_STYLE
  value: {{ .Values.config.s3.forcePathStyle | quote }}
- name: OIDC_ISSUER
  value: {{ .Values.config.oidcIssuer | quote }}
- name: ALLOWED_EMAILS
  value: {{ .Values.config.allowedEmails | quote }}
- name: RUST_LOG
  value: {{ .Values.config.logLevel | quote }}
{{- end -}}
