{{- if and .Values.pipelock.enabled .Values.pipelock.pdb.enabled }}
{{- if and .Values.pipelock.pdb.minAvailable .Values.pipelock.pdb.maxUnavailable }}
{{- fail "pipelock.pdb: set either minAvailable or maxUnavailable, not both." -}}
{{- end }}
apiVersion: policy/v1
kind: PodDisruptionBudget
metadata:
  name: {{ include "sure.fullname" . }}-pipelock
  labels:
    {{- include "sure.labels" . | nindent 4 }}
spec:
  {{- if .Values.pipelock.pdb.minAvailable }}
  minAvailable: {{ .Values.pipelock.pdb.minAvailable }}
  {{- else if .Values.pipelock.pdb.maxUnavailable }}
  maxUnavailable: {{ .Values.pipelock.pdb.maxUnavailable }}
  {{- end }}
  selector:
    matchLabels:
      app.kubernetes.io/component: pipelock
      {{- include "sure.selectorLabels" . | nindent 6 }}
{{- end }}
