{{- 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:
  {{- include "kafka.config.labels" . | nindent 4 }}
spec:
  backoffLimit: {{ .Values.configJob.backoffLimit }}
  template:
    metadata:
      labels:
      {{- include "kafka.config.matchLabels" . | nindent 8 }}
    spec:
      restartPolicy: OnFailure
      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 -}}
