apiVersion: v1
kind: Pod
metadata:
  name: acceptance-tests
  labels:
    app: acceptance-tests
    pubsub: "true"
    database: "true"
spec:
  serviceAccountName: acceptance-tests
  securityContext:
    fsGroup: 1000
  containers:
  - name: acceptance-tests
    lifecycle:
      postStart:
        exec:
          command:
            - /bin/sh
            - -c
            - |
              cp /home/acceptancetests/postgresql/* /home/acceptancetests/.postgresql
              chmod 0600 /home/acceptancetests/.postgresql/postgresql.key
              # the above is a workaround to get round the permissions as currently we cant mount it without doing this
    image: eu.gcr.io/ssdc-rm-ci/rm/ssdc-rm-acceptance-tests:latest
    tty: true
    stdin: true
    imagePullPolicy: Always
    resources:
      requests:
        cpu: "250m"
        memory: "128Mi"
      limits:
        cpu: "250m"
        memory: "256Mi"
    volumeMounts:
    - name: case-cloud-sql-certs
      mountPath: "/home/acceptancetests/postgresql"
      readOnly: true
    env:
    - name: DB_USERNAME
      valueFrom:
        secretKeyRef:
          name: db-credentials
          key: username
    - name: DB_PASSWORD
      valueFrom:
        secretKeyRef:
          name: db-credentials
          key: password
    - name: DB_HOST
      valueFrom:
        configMapKeyRef:
          name: db-config
          key: db-host
    - name: DB_PORT
      valueFrom:
        configMapKeyRef:
          name: db-config
          key: db-port
    - name: DB_NAME
      valueFrom:
        configMapKeyRef:
          name: db-config
          key: db-name
    - name: DB_CASE_CERTIFICATES
      value: " sslmode=verify-ca sslrootcert=/home/acceptancetests/.postgresql/root.crt sslcert=/home/acceptancetests/.postgresql/postgresql.crt sslkey=/home/acceptancetests/.postgresql/postgresql.key"
    - name: PROJECT_NAME
      valueFrom:
        configMapKeyRef:
          name: project-config
          key: project-name
    - name: PUBSUB_PROJECT
      valueFrom:
        configMapKeyRef:
          name: project-config
          key: project-name
    - name: SUPPLIER_CONFIG_JSON_PATH
      value: "/home/acceptancetests/dummy_export_file_destination_config.json"
    - name: SUPPORT_TOOL_HOST
      value: "support-tool"
    - name: SUPPORT_TOOL_PORT
      value: "80"
    - name: EXCEPTIONMANAGER_CONNECTION_HOST
      value: "exception-manager"
    - name: EXCEPTIONMANAGER_CONNECTION_PORT
      value: "80"
    - name: NOTIFY_STUB_HOST
      value: "notify-stub"
    - name: NOTIFY_STUB_PORT
      value: "80"
    - name: CASEAPI_SERVICE_HOST
      value: "case-api"
    - name: CASEAPI_SERVICE_PORT
      value: "80"
    - name: NOTIFY_SERVICE_HOST
      value: "notify-service"
    - name: NOTIFY_SERVICE_PORT
      value: "80"
    - name: FILE_UPLOAD_DESTINATION
      valueFrom:
        configMapKeyRef:
          key: sent-export-file-bucket
          name: project-config
    - name: FILE_UPLOAD_MODE
      value: "BUCKET"
  volumes:
  - name: case-cloud-sql-certs
    secret:
      secretName: cloud-sql-certs
      defaultMode: 0400
      items:
        - key: "root.crt"
          path: "root.crt"
        - key: "postgresql.crt"
          path: "postgresql.crt"
        - key: "postgresql.key"
          path: "postgresql.key"