---
kind: Template
apiVersion: v1
metadata:
  name: ${NAME}-build-template
  annotations:
    description: A Django application with a PostgreSQL database
    tags: edivorce,python,django,postgresql
    iconClass: icon-python
labels:
  template: ${NAME}-build-template
objects:
- kind: ImageStream
  apiVersion: v1
  metadata:
    name: "${NAME}"
- kind: BuildConfig
  apiVersion: v1
  metadata:
    name: "${NAME}"
  spec:
    source:
      type: Git
      git:
        uri: "${GIT_REPO_URL}"
        ref: "${GIT_REF}"
      contextDir: "${SOURCE_CONTEXT_DIR}"
    strategy:
      type: Source
      sourceStrategy:
        from:
          kind: ${SOURCE_IMAGE_KIND}
          name: ${SOURCE_IMAGE_NAME}:${SOURCE_IMAGE_TAG}
        env:
        - name: PIP_INDEX_URL
          value: "${PIP_INDEX_URL}"
        - name: UPGRADE_PIP_TO_LATEST
          value: "${UPGRADE_PIP_TO_LATEST}"
        - name: PIP_NO_CACHE_DIR
          value: "${PIP_NO_CACHE_DIR}"
    output:
      to:
        kind: ImageStreamTag
        name: "${NAME}:latest"
    triggers:
    - type: ImageChange
    - type: ConfigChange
    postCommit:
      script: "./manage.py test"
    resources:
      limits:
        cpu: ${CPU_LIMIT}
        memory: ${MEMORY_LIMIT}
      requests:
        cpu: ${CPU_REQUEST}
        memory: ${MEMORY_REQUEST}
parameters:
- name: NAME
  displayName: Name
  description: The name assigned to all of the frontend objects defined in this template.
  required: true
  value: edivorce-django
- name: GIT_REPO_URL
  displayName: Git Repository URL
  description: The URL of the repository with your application source code.
  required: true
  value: https://github.com/bcgov/eDivorce
- name: GIT_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: SOURCE_CONTEXT_DIR
  displayName: Context Directory
  description: Set this to the relative path to your project if it is not in the root of your repository.
- name: SOURCE_IMAGE_KIND
  displayName: Source Image Kind
  description: The 'kind' (type) of the  source image; typically ImageStreamTag, or DockerImage.
  required: true
  value: DockerImage
- name: SOURCE_IMAGE_NAME
  displayName: Source Image Name
  description: The name of the source image.
  required: true
  value: "registry.fedoraproject.org/f32/python3"
- name: SOURCE_IMAGE_TAG
  displayName: Source Image Tag
  description: The tag of the source image.
  required: true
  value: "latest"
- name: PIP_INDEX_URL
  displayName: Custom PyPi Index URL
  description: The custom PyPi index URL
  value: ''
- name: UPGRADE_PIP_TO_LATEST
  displayName: Upgrade Pip To Latest
  description: Upgrade Pip To Latest
  value: 'true'
- name: PIP_NO_CACHE_DIR
  displayName: Pip No Cache Dir
  description: Pip No Cache Dir
  value: ''
# ===============================================================================
- name: CPU_REQUEST
  displayName: Resources CPU Request
  description: The resources CPU request (in cores) for this build.
  required: true
  value: 10m
- name: CPU_LIMIT
  displayName: Resources CPU Limit
  description: The resources CPU limit (in cores) for this build.
  required: true
  value: 750m
- name: MEMORY_REQUEST
  displayName: Resources Memory Request
  description: The resources Memory request (in Mi, Gi, etc) for this build.
  required: true
  value: 10Mi
- name: MEMORY_LIMIT
  displayName: Resources Memory Limit
  description: The resources Memory limit (in Mi, Gi, etc) for this build.
  required: true
  value: 1000Mi