---
apiVersion: batch/v1
kind: Job
metadata:
  name: upgrade-db-schema
  namespace: cdash
  annotations:
    fluxcd.io/ignore: "true"
  labels:
    app: cdash
    svc: web
    task: upgrade-db-schema
spec:
  backoffLimit: 1
  template:
    metadata:
      labels:
        app: cdash
        svc: web
        task: upgrade-db-schema
    spec:
      restartPolicy: Never
      containers:
      - name: cdash
        image: kitware/cdash:spack_deploy_v4
        command: ["/bin/bash", "-c"]
        args:
          - >
            eval 'CDASH_CONFIG="$(CDASH_CONFIG_TEMPLATE)"' ;
            export CDASH_CONFIG ;
            exec /bin/bash /docker-entrypoint.sh upgrade
        imagePullPolicy: Always
        env:
        - name: CDASH_ROOT_ADMIN_PASS
          valueFrom:
            secretKeyRef:
              name: cdash-secrets
              key: root-password
        - name: CDASH_DB_HOST
          valueFrom:
            secretKeyRef:
              name: cdash-secrets
              key: db-host
        - name: CDASH_DB_TYPE
          valueFrom:
            secretKeyRef:
              name: cdash-secrets
              key: db-type
        - name: CDASH_DB_NAME
          valueFrom:
            secretKeyRef:
              name: cdash-secrets
              key: db-name
        - name: CDASH_DB_LOGIN
          valueFrom:
            secretKeyRef:
              name: cdash-secrets
              key: db-login
        - name: CDASH_DB_PORT
          valueFrom:
            secretKeyRef:
              name: cdash-secrets
              key: db-port
        - name: CDASH_DB_PASS
          valueFrom:
            secretKeyRef:
              name: cdash-secrets
              key: db-password
        - name: CDASH_CONFIG_TEMPLATE
          value: |
            \$CDASH_DB_HOST = '\'$CDASH_DB_HOST\'';
            \$CDASH_DB_NAME = '\'$CDASH_DB_NAME\'';
            \$CDASH_DB_TYPE = '\'$CDASH_DB_TYPE\'';
            \$CDASH_DB_LOGIN = '\'$CDASH_DB_LOGIN\'';
            \$CDASH_DB_PORT = '\'$CDASH_DB_PORT\'';
            \$CDASH_DB_PASS = '\'$CDASH_DB_PASS\'';
            \$CDASH_DB_CONNECTION_TYPE = '\'host\'';
            \$CDASH_BASE_URL = '\'https://cdash.spack.io\'';
            \$CDASH_USE_HTTPS = '\'1\'';
            \$CDASH_AUTOREMOVE_BUILDS = '\'1\'';
            \$CDASH_DEFAULT_PROJECT = '\'Spack\'';
            \$CDASH_ACTIVE_PROJECT_DAYS = '\'0\'';
      nodeSelector:
        spack.io/node-pool: base
