#@ load("@ytt:data", "data")
#@ load("@ytt:overlay", "overlay")
#@ load("@ytt:template", "template")
---
apiVersion: batch/v1
kind: Job
metadata:
  name: init-cf-db
  namespace: cf-db
spec:
  template:
    spec:
      containers:
      - name: init-cf-db
        image: postgres:13
        command: ["/bin/bash", "/docker-entrypoint-initdb.d/init.sh"]
        env:
          - name: PGHOST
            value: cf-db-postgresql
          - name: PGPASSWORD
            valueFrom:
              secretKeyRef:
                key: postgresql-password
                name: cf-db-admin-secret
        volumeMounts:
        - mountPath: /docker-entrypoint-initdb.d/
          name: custom-init-scripts
        - mountPath: /docker-entrypoint-initdb.d/secret
          name: custom-init-scripts-secret
      volumes:
      - configMap:
          name: cf-db-postgresql-init-scripts
        name: custom-init-scripts
      - name: custom-init-scripts-secret
        secret:
          secretName: cf-db-credentials
      restartPolicy: Never
  backoffLimit: 4