{{- /*
Copyright Broadcom, Inc. All Rights Reserved.
SPDX-License-Identifier: APACHE-2.0
*/}}

{{- if and .Values.persistence.enabled (not .Values.persistence.persistentVolumeClaim.jobservice.existingClaim) }}
{{- if eq .Values.jobservice.jobLogger "file" }}
kind: PersistentVolumeClaim
apiVersion: v1
metadata:
  name: {{ include "harbor.jobservice" . }}
  namespace: {{ include "common.names.namespace" . | quote }}
  {{- $versionLabel := dict "app.kubernetes.io/version" ( include "common.images.version" ( dict "imageRoot" .Values.jobservice.image "chart" .Chart ) ) }}
  {{- $labels := include "common.tplvalues.merge" ( dict "values" ( list .Values.commonLabels $versionLabel ) "context" . ) }}
  labels: {{- include "common.labels.standard" ( dict "customLabels" $labels "context" $ ) | nindent 4 }}
    app.kubernetes.io/component: jobservice
  annotations:
    {{- if eq .Values.persistence.resourcePolicy "keep" }}
    helm.sh/resource-policy: keep
    {{- end }}
    {{- if or .Values.persistence.persistentVolumeClaim.jobservice.annotations .Values.commonAnnotations }}
    {{- $annotations := include "common.tplvalues.merge" ( dict "values" ( list .Values.persistence.persistentVolumeClaim.jobservice.annotations .Values.commonAnnotations ) "context" . ) }}
    {{- include "common.tplvalues.render" ( dict "value" $annotations "context" $) | nindent 4 }}
    {{- end }}
spec:
  accessModes:
  {{- range .Values.persistence.persistentVolumeClaim.jobservice.accessModes }}
    - {{ . | quote }}
  {{- end }}
  resources:
    requests:
      storage: {{ .Values.persistence.persistentVolumeClaim.jobservice.size }}
  {{- if .Values.persistence.persistentVolumeClaim.jobservice.selector }}
  selector: {{- include "common.tplvalues.render" (dict "value" .Values.persistence.persistentVolumeClaim.jobservice.selector "context" $) | nindent 2 }}
  {{- end }}
  {{- include "common.storage.class" ( dict "persistence" .Values.persistence.persistentVolumeClaim.jobservice "global" .Values.global ) | nindent 2 }}
{{- end }}
{{- end }}
