# Copyright Amazon.com Inc. or its affiliates. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#      http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

apiVersion: v1
kind: ConfigMap
metadata:
  name: config
data:
  config.yaml: |
    prowjob_namespace: {{ .Values.prowJobNamespace }}
    pod_namespace: {{ .Values.dataplaneNamespace }}

    sinker:
      # defaults to 1 hour
      resync_period: 2m
      # defaults to 1 day
      max_pod_age: 12h
      # 30 days, defaults to 1 week
      max_prowjob_age: 720h
      # defaults to max_pod_age
      terminated_pod_ttl: 5m

    in_repo_config:
      enabled:
        "*": true

    deck:
      branding:
        header_color: "#232F3E"
        logo: "https://distro.eks.amazonaws.com/assets/images/amazon-eks-distro-white-logo.png"
        favicon: "https://distro.eks.amazonaws.com/assets/images/amazon-eks-distro-white-logo.png"

      spyglass:
        lenses:
        - lens:
            name: metadata
          required_files:
          - started.json|finished.json
        - lens:
            name: coverage
          required_files:
          - ^artifacts/filtered\.cov$
          optional_files:
          - ^artifacts/filtered\.html$
        - lens:
            config:
              highlight_regexes:
              - Automatic merge failed
              - cannot convert.+to type
              - "cannot use.+as.+(type|value)"
              - cannot find package
              - Command failed
              - curl.+Failed to connect
              - curl.+no URL specified
              - ^E\d{4} \d\d:\d\d:\d\d\.\d+
              - ERR
              - "(Error|ERROR|error)s?:"
              - Error is not recoverable
              - exit (status)?
              - failed|FAILED"
              - failed to solve
              - (FAIL|Failure \[)\b
              - fatal|FATAL
              - Traceback
              - got.+want
              - imported but not used
              - "make:.+Error"
              - Merge conflict
              - No such file or directory
              - panic\b
              - Process did not finish before.+timeout
              - sha256sum.+did NOT match
              - Something went wrong
              - too few arguments
              - too many errors
              - "[Tt]imed out"
              - timeout
              - type.+has no field
              - "undefined:"
              - Unable to connect to the server
              - "[Uu]nexpected error"
              - want.+got
            name: buildlog
          required_files:
          - build-log.txt
        - lens:
            name: junit
          required_files:
          - .*/junit.*\.xml
        - lens:
            name: podinfo
          required_files:
          - podinfo.json
      default_rerun_auth_configs:
      - rerun_auth_configs:
          allow_anyone: true

    plank:
      job_url_prefix_config:
        "*": https://{{ .Values.prow.domain }}/view/
      report_templates:
        '*': >-
            [Full PR test history](https://{{ .Values.prow.domain }}/pr-history?{{ "org={{.Spec.Refs.Org}}&repo={{.Spec.Refs.Repo}}&pr={{with index .Spec.Refs.Pulls 0}}{{.Number}}{{end}}" }}).
            [Your PR dashboard](https://{{ .Values.prow.domain }}/pr?{{ "query=is:pr+state:open+author:{{with index .Spec.Refs.Pulls 0}}{{.Author}}{{end}}" }}).
      default_decoration_configs:
        "*":
          gcs_configuration:
            bucket: s3://{{ .Values.prow.presubmitsBucketName }}
            path_strategy: explicit
          s3_credentials_secret: s3-credentials
          utility_images:
            clonerefs:  {{ .Values.utility_images.clonerefs }}
            entrypoint: {{ .Values.utility_images.entrypoint }}
            initupload: {{ .Values.utility_images.initupload }}
            sidecar: {{ .Values.utility_images.sidecar }}
      pod_unscheduled_timeout: 24h
      pod_pending_timeout: 24h
    {{- if gt (len .Values.repositories) 0 }}
    tide:
      queries:
      - labels:
        - lgtm
        - approved
        missingLabels:
        - needs-rebase
        - do-not-merge/hold
        - do-not-merge/work-in-progress
        - do-not-merge/invalid-owners-file
        repos:
        {{-  range $repo := .Values.repositories }}
          - {{ $repo.org }}/{{ $repo.name }}
        {{- end }}
      merge_method:
      {{-  range $repo := .Values.repositories }}
        {{ $repo.org }}/{{ $repo.name }}: squash
      {{- end }}
    {{- end }}
    decorate_all_jobs: true
