apiVersion: apps/v1
kind: Deployment
metadata:
  labels:
    package: ddcc-mediator
  name: svc-transactions
  namespace: default
spec:
  selector:
    matchLabels:
      app: svc-transactions
  template:
    metadata:
      annotations:
        vault.hashicorp.com/agent-init-first: "true"
        vault.hashicorp.com/agent-inject: "true"
        vault.hashicorp.com/agent-inject-secret-openhim: openhim/data/management
        vault.hashicorp.com/agent-inject-secret-signing: signing/data/signKey
        vault.hashicorp.com/agent-inject-template-openhim: |
          {{- with secret "openhim/data/management" -}}
            export FHIR_SERVER=${HAPI_FHIR_SERVER_PORT}/fhir/
            export OPENHIM_URL=https://${OPENHIM_CORE_SERVICE_HOST}:${OPENHIM_CORE_SERVICE_PORT}
            export OPENHIM_USERNAME={{ .Data.data.user }}
            export OPENHIM_PASSWORD={{ .Data.data.password }}
            {{- end -}}
        vault.hashicorp.com/agent-inject-template-signing: |
          {{- with secret "signing/data/signKey" -}}
            {{ .Data.data.key }}
            {{- end -}}
        vault.hashicorp.com/agent-pre-populate-only: "true"
        vault.hashicorp.com/role: ddcc-mediator
      labels:
        app: svc-transactions
        component: svc-transactions
    spec:
      containers:
      - args:
        - -c
        - . /vault/secrets/openhim && npm run openhim
        command:
        - /bin/sh
        env:
        - name: SERVER_PORT
          value: "4321"
        - name: HEARTBEAT
          value: "true"
        - name: LOG_LEVEL
          value: info
        - name: NODE_TLS_REJECT_UNAUTHORIZED
          value: "0"
        - name: TRUST_SELF_SIGNED
          value: "true"
        image: openhie/ddcc-transactions-openhim:latest
        imagePullPolicy: Always
        name: svc-transactions
        ports:
        - containerPort: 4321
          name: svc
          protocol: TCP
      serviceAccount: ddcc-transaction-mediator
      serviceAccountName: ddcc-transaction-mediator
