{{- if and .Values.testMode (not .Release.IsUpgrade) }}
{{- if not (.Capabilities.APIVersions.Has "snapshot.storage.k8s.io/v1beta1/VolumeSnapshot") }}
kind: CustomResourceDefinition
metadata:
  name: volumesnapshots.snapshot.storage.k8s.io
  annotations:
    api-approved.kubernetes.io: "unapproved - test mode"
    helm.sh/hook: pre-install
    helm.sh/hook-delete-policy: before-hook-creation
{{- if .Capabilities.APIVersions.Has "apiextensions.k8s.io/v1/CustomResourceDefinition" }}
apiVersion: apiextensions.k8s.io/v1
spec:
  versions:
    - name: v1beta1
      served: true
      storage: true
      schema:
        openAPIV3Schema:
          type: object
          properties:
            spec:
              type: object
{{- else }}
apiVersion: apiextensions.k8s.io/v1beta1
spec:
  versions:
    - name: v1beta1
      served: true
      storage: true
  validation:
    openAPIV3Schema:
      type: object
      properties:
        spec:
          type: object
{{- end }}
  group: snapshot.storage.k8s.io
  scope: Namespaced
  names:
    plural: volumesnapshots
    singular: volumesnapshot
    kind: VolumeSnapshot
{{- end }}
{{- end }}
