apiVersion: batch/v1
kind: Job
metadata:
  name: {{ include "wordpress-nginx.fullname" . }}-show-password
  labels:
    {{- include "wordpress-nginx.labels" . | nindent 4 }}
  annotations:
    "helm.sh/hook": post-install,post-upgrade
    "helm.sh/hook-weight": "10"
    "helm.sh/hook-delete-policy": hook-succeeded,before-hook-creation
spec:
  ttlSecondsAfterFinished: 300
  template:
    metadata:
      name: {{ include "wordpress-nginx.fullname" . }}-show-password
    spec:
      restartPolicy: Never
      containers:
        - name: show-password
          image: busybox:latest
          command:
            - /bin/sh
            - -c
            - |
              echo "================================================"
              echo "WordPress Installation Information"
              echo "================================================"
              echo ""
              echo "Admin User: {{ .Values.wordpress.adminUser }}"
              {{- if .Values.wordpress.adminPassword }}
              echo "Admin Password: {{ .Values.wordpress.adminPassword }}"
              {{- else }}
              echo "Admin Password: (Auto-generated - check Secret or Pod logs)"
              echo ""
              echo "To retrieve the auto-generated password, run:"
              echo "kubectl get secret {{ include "wordpress-nginx.fullname" . }}-secret -o jsonpath='{.data.admin-password}' | base64 -d"
              {{- end }}
              echo ""
              echo "================================================"