---
kind: Template
apiVersion: v1
metadata:
  name: nginx
  creationTimestamp:
objects:
- kind: ImageStream
  apiVersion: v1
  metadata:
    name: "${NAME}"
- kind: BuildConfig
  apiVersion: v1
  metadata:
    name: "${NAME}"
    creationTimestamp:
    labels:
      app: "${NAME}"
  spec:
    triggers:
    - type: GitHub
      github:
        secret: "${GITHUB_WEBHOOK_SECRET}"
    - type: Generic
      generic:
        secret: "${GENERIC_WEBHOOK_SECRET}"
    - type: ConfigChange
    - type: ImageChange
      imageChange: {}
    runPolicy: Serial
    source:
      type: Git
      git:
        ref: "${SOURCE_REPOSITORY_REF}"
        uri: "${SOURCE_REPOSITORY_URL}"
      contextDir: "${SOURCE_REPOSITORY_CONTEXT_DIR}"
    strategy:
      type: Source
      sourceStrategy:
        from:
          kind: ImageStreamTag
          name: "${BUILDER_IMAGESTREAM_TAG}"
        env:
        - name: NGINX_PROXY_URL
          value: "${NGINX_PROXY_URL}"
    output:
      to:
        kind: ImageStreamTag
        name: "${NAME}:latest"
    resources: {}
    postCommit: {}
  status:
    lastVersion: 0
parameters:
- name: NAME
  displayName: Name
  description: The name assigned to all of the frontend objects defined in this template.
  required: true
  value: nginx-proxy
- name: BUILDER_IMAGESTREAM_TAG
  displayName: Builder ImageStreamTag
  description: The image stream tag (e.g. rproxy:latest) of the S2I image that should be used to build the application.
  value: s2i-nginx:latest
- name: SOURCE_REPOSITORY_URL
  displayName: Git Repository URL
  description: The URL of the repository with your nginx configuration code.
  value: https://github.com/bcgov/eDivorce
  required: true
- name: SOURCE_REPOSITORY_CONTEXT_DIR
  displayName: Git sub-directory
  description: The folder in the Git repo that contains the config.d directory.
  value: /nginx-proxy
- name: SOURCE_REPOSITORY_REF
  displayName: Git Reference
  description: Set this to a branch name, tag or other ref of your repository if you are not using the default branch.
- name: GITHUB_WEBHOOK_SECRET
  displayName: GitHub Webhook Secret
  description: A secret string used to configure the GitHub webhook.
  generate: expression
  from: "[a-zA-Z0-9]{40}"
- name: GENERIC_WEBHOOK_SECRET
  displayName: Generic Webhook Secret
  description: A secret string used to configure the Generic webhook.
  generate: expression
  from: "[a-zA-Z0-9]{40}"
- name: NGINX_PROXY_URL
  displayName: NGinx Proxy URL
  description: The URL you want NGinx to proxy to, e.g., http://<service-name>:port/
  value: http://edivorce-django:8080/
  required: true
