{{- if .Values.cve.updater.enabled -}}
{{- if (semverCompare ">=1.8-0" (substr 1 -1 .Capabilities.KubeVersion.GitVersion)) }}
apiVersion: batch/v1beta1
{{- else }}
apiVersion: batch/v2alpha1
{{- end }}
kind: CronJob
metadata:
  name: neuvector-updater-pod
  namespace: {{ .Release.Namespace }}
  labels:
    chart: {{ template "neuvector.chart" . }}
    release: {{ .Release.Name }}
    heritage: {{ .Release.Service }}
spec:
  schedule: {{ .Values.cve.updater.schedule | quote }}
  jobTemplate:
    spec:
      template:
        metadata:
          labels:
            app: neuvector-updater-pod
            release: {{ .Release.Name }}
        spec:
        {{- if .Values.imagePullSecrets }}
          imagePullSecrets:
            - name: {{ .Values.imagePullSecrets }}
        {{- end }}
          containers:
            - name: neuvector-updater-pod
              image: "{{ .Values.registry }}/{{ .Values.cve.updater.image.repository }}:{{ .Values.cve.updater.image.tag }}"
              env:
                - name: CLUSTER_JOIN_ADDR
                  value: neuvector-svc-controller.{{ .Release.Namespace }}
          restartPolicy: Never
{{- end }}