{{- range .Values.apprepository.initialRepos }}
apiVersion: kubeapps.com/v1alpha1
kind: AppRepository
metadata:
  name: {{ .name }}
{{- if .namespace }}
  namespace: {{ .namespace }}
{{- end }}
  annotations:
    "helm.sh/hook": post-install
  labels:{{ include "kubeapps.extraAppLabels" $ | nindent 4 }}
    app: {{ template "kubeapps.apprepository.fullname" $ }}
spec:
  type: helm
  url: {{ .url }}
{{- if or $.Values.securityContext.enabled $.Values.apprepository.initialReposProxy.enabled .nodeSelector }}
  syncJobPodTemplate:
    spec:
      {{- if $.Values.apprepository.initialReposProxy.enabled }}
      containers:
        - env:
            - name: https_proxy
              value: {{ $.Values.apprepository.initialReposProxy.https_proxy }}
            - name: http_proxy
              value: {{ $.Values.apprepository.initialReposProxy.http_proxy }}
            - name: no_proxy
              value: {{ $.Values.apprepository.initialReposProxy.no_proxy }}
      {{- end }}
      {{- if $.Values.securityContext.enabled }}
      securityContext:
        runAsUser: {{ $.Values.securityContext.runAsUser }}
      {{- end }}
      {{- if .nodeSelector }}
      nodeSelector: {{- toYaml .nodeSelector | nindent 8 }}
      {{- end }}
{{- end }}
  {{- if or .caCert .authorizationHeader }}
  auth:
    {{- if .caCert }}
    customCA:
      secretKeyRef:
        key: ca.crt
        name: {{ template "kubeapps.apprepository-secret.name" . }}
    {{- end }}
    {{- if .authorizationHeader }}
    header:
      secretKeyRef:
        key: authorizationHeader
        name: {{ template "kubeapps.apprepository-secret.name" . }}
    {{- end }}
  {{- end }}
---
{{ end -}}
