{{- if .Values.plugins }}
apiVersion: v1
kind: ConfigMap
metadata:
  name: {{ include "scm-manager.fullname" . }}-scripts
  labels:
    app: {{ include "scm-manager.name" . }}
    chart: "{{ .Chart.Name }}-{{ .Chart.Version }}"
    release: "{{ .Release.Name }}"
    heritage: "{{ .Release.Service }}"
data:
  install-plugins.sh: |
    #!/bin/sh
    mkdir -p /data/plugins
    chown 1000:1000 /data/plugins
    {{ range $i, $plugin := .Values.plugins }}
    # install plugin {{ $plugin.name }}
    wget -O /data/plugins/{{ $plugin.name }}.smp {{ $plugin.url }}
    chown 1000:1000 /data/plugins/{{ $plugin.name }}.smp
    {{ end }}
{{- end }}
