---
apiVersion: apps.openshift.io/v1
kind: DeploymentConfig
metadata:
  labels:
    app: blockerbugs
    service: blockerbugs
  name: blockerbugs
spec:
  replicas: 1
  selector:
    app: blockerbugs
    deploymentconfig: blockerbugs
  strategy:
    type: Recreate
    recreateParams:
      mid:
        failurePolicy: Abort
        execNewPod:
          containerName: blockerbugs
          # BBA would automatically proceed with upgrade_db if necessary
          # init_db isn't dropping anything, so it's safe to call every time the pod starts
          command: ["python", "/opt/app-root/src/blockerbugs/cli.py", "init_db"]
          # and then just the gunicorn for the frontend part
          volumes:
           - blockerbugs-secret-volume
  template:
    metadata:
      labels:
        app: blockerbugs
        deploymentconfig: blockerbugs
    spec:
      containers:
      - name: blockerbugs
        image: blockerbugs:latest
        ports:
        - containerPort: 8080
        resources: {}
        env:
{% if env == 'staging' %}
        - name: POSTGRESQL_USER
          value: "{{ stg_blockerbugs_db_user }}"
{% else %}
        - name: POSTGRESQL_USER
          value: "{{ prod_blockerbugs_db_user }}"
{% endif %}
        - name: POSTGRESQL_DATABASE
          value: "blockerbugs"
        - name: POSTGRESQL_SERVICE_HOST
          value: "db01{{ env_suffix }}.iad2.fedoraproject.org"
        - name: POSTGRESQL_SERVICE_PORT
          value: "5432"
{% if env == 'staging' %}
        - name: POSTGRESQL_PASSWORD
          value: "{{ stg_blockerbugs_db_password }}"
        - name: SECRET_KEY
          value: "{{ stg_blockerbugs_secret_key }}"
        - name: PAGURE_REPO_TOKEN
          value: "{{ stg_blockerbugs_pagure_repo_token_secret }}"
        - name: PAGURE_REPO_WEBHOOK_KEY
          value: "{{ stg_blockerbugs_pagure_repo_webhook_key_secret }}"
        - name: BUGZILLA_API_KEY
          value: "{{ stg_blockerbugs_bz_api_key }}"
        - name: PAGURE_URL
          value: "https://stg.pagure.io/"
        - name: PAGURE_API
          value: "https://stg.pagure.io/api/0/"
        - name: BUGZILLA_URL
          value: "https://bugzilla.stage.redhat.com"
{% else %}
        - name: POSTGRESQL_PASSWORD
          value: "{{ prod_blockerbugs_db_password }}"
        - name: SECRET_KEY
          value: "{{ prod_blockerbugs_secret_key }}"
        - name: PAGURE_REPO_TOKEN
          value: "{{ prod_blockerbugs_pagure_repo_token_secret }}"
        - name: PAGURE_REPO_WEBHOOK_KEY
          value: "{{ prod_blockerbugs_pagure_repo_webhook_key_secret }}"
        - name: BUGZILLA_API_KEY
          value: "{{ prod_blockerbugs_bz_api_key }}"
        - name: PAGURE_URL
          value: "https://pagure.io/"
        - name: PAGURE_API
          value: "https://pagure.io/api/0/"
        - name: BUGZILLA_URL
          value: "https://bugzilla.redhat.com"
{% endif %}
        - name: BLOCKERBUGS_URL
          value: "https://qa{{ env_suffix }}.fedoraproject.org/blockerbugs/"
        - name: BLOCKERBUGS_API
          value: "https://qa{{ env_suffix }}.fedoraproject.org/blockerbugs/api/v0/"
        - name: FAS_BASE_URL
          value: "https://admin{{ env_suffix }}.fedoraproject.org/accounts/"
        - name: FAS_ADMIN_GROUP
          value: "qa-admin"
        - name: PAGURE_BOT_USERNAME
          value: "blockerbot"
        - name: PAGURE_BOT_ENABLED
          value: "True"
        - name: PAGURE_REPO
          value: "fedora-qa/blocker-review"
        - name: BODHI_URL
          value: "https://bodhi{{ env_suffix }}.fedoraproject.org/"
        - name: OPENSHIFT_PROD
{% if env == 'staging' %}
          value: "0"
{% else %}
          value: "1"
{% endif %}
        - name: blockerbugs-secret-volume
          mountPath: /opt/app-root/secret/
          readOnly: true
        readinessProbe:
          timeoutSeconds: 5
          initialDelaySeconds: 5
          httpGet:
            path: /blockerbugs/
            port: 8080
        livenessProbe:
          timeoutSeconds: 15
          initialDelaySeconds: 30
          httpGet:
            path: /blockerbugs/
            port: 8080
      volumes:
      - name: blockerbugs-secret-volume
        secret:
          secretName: blockerbugs-secret

  triggers:
  - type: ConfigChange
  - type: ImageChange
    imageChangeParams:
      automatic: true
      containerNames:
      - blockerbugs
      from:
        kind: ImageStreamTag
        name: blockerbugs:latest
---
apiVersion: apps.openshift.io/v1
kind: DeploymentConfig
metadata:
  labels:
    app: blockerbugs
    service: qa-landing
  name: qa-landing
spec:
  replicas: 1 # Never change this to more or less than ONE!
  selector:
    app: blockerbugs
    deploymentconfig: blockerbugs
  template:
    metadata:
      labels:
        app: blockerbugs
        deploymentconfig: blockerbugs
    spec:
      containers:
      - name: qa-landing
        image: qa-landing:latest
        resources: {}
        env:
        - name: SUBDIR
          value: "/"
        - name: API
          value: "https://packager-dashboard{{ env_suffix }}.fedoraproject.org/api/v1/"
  triggers:
  - type: ConfigChange
  - type: ImageChange
    imageChangeParams:
      automatic: true
      containerNames:
      - qa-landing
      from:
        kind: ImageStreamTag
        name: qa-landing:latest