{{- if .Values.topics -}}
{{- $scriptHash := include (print $.Template.BasePath "/configmap-config.yaml") . | sha256sum | trunc 8 -}}
apiVersion: batch/v1
kind: Job
metadata:
  name: "{{ template "kafka.fullname" . }}-config-{{ $scriptHash }}"
  labels:
    app: {{ template "kafka.fullname" . }}
    chart: "{{ .Chart.Name }}-{{ .Chart.Version }}"
    heritage: "{{ .Release.Service }}"
    release: "{{ .Release.Name }}"
spec:
  template:
    metadata:
      labels:
        app: {{ template "kafka.fullname" . }}
        release: "{{ .Release.Name }}"
    spec:
      restartPolicy: Never
      volumes:
        - name: config-volume
          configMap:
            name: {{ template "kafka.fullname" . }}-config
            defaultMode: 0744
      containers:
        - name: {{ template "kafka.fullname" . }}-config
          image: "{{ .Values.image }}:{{ .Values.imageTag }}"
          command: ["/usr/local/script/runtimeConfig.sh"]
          volumeMounts:
            - name: config-volume
              mountPath: "/usr/local/script"
{{- end -}}
