{{- /*
Copyright Broadcom, Inc. All Rights Reserved.
SPDX-License-Identifier: APACHE-2.0
*/}}

{{- if (empty .Values.cas.existingConfigMap) }}
apiVersion: v1
kind: ConfigMap
metadata:
  name: {{ include "chainloop.cas.fullname" . }}
  namespace: {{ include "common.names.namespace" . | quote }}
  labels: {{ include "chainloop.cas.labels" . | nindent 4 }}
  {{- if .Values.commonAnnotations }}
  annotations: {{- include "common.tplvalues.render" ( dict "value" .Values.commonAnnotations "context" $ ) | nindent 4 }}
  {{- end }}
data:
  server.yaml: |
    server:
      http:
        addr: "0.0.0.0:{{ .Values.cas.containerPorts.http }}"
        # Timeouts for http downloads
        # grpc downloads/uploads don't require this because they don't have timeouts
        timeout: 300s
      grpc:
        {{- if .Values.cas.tls.existingSecret  }}
        tls_config:
          certificate: /data/server-certs/tls.crt
          private_key: /data/server-certs/tls.key
        {{- end }}
        addr: "0.0.0.0:{{ .Values.cas.containerPorts.grpc }}"
        # Some unary RPCs are slow, so we need to increase the timeout
        timeout: 5s
      http_metrics:
        addr: "0.0.0.0:{{ .Values.cas.containerPorts.metrics}}"
{{- end }}
