{{- if and .Capabilities.KubeVersion.Major .Capabilities.KubeVersion.Minor }}
apiVersion: batch/v1
kind: Job
metadata:
  name: rook-operator-wait-resources
  annotations:
    helm.sh/hook: post-install
    "helm.sh/hook-delete-policy": hook-succeeded
  labels:
    app: rook-operator-wait-resources
    chart: "{{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }}"
spec:
  template:
    metadata:
      labels:
        app: rook-operator-wait-resources
        chart: "{{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }}"
    spec:
      containers:
        - name: hyperkube
          image: "{{ .Values.hyperkube.repository }}:{{ .Values.hyperkube.tag }}"
          imagePullPolicy: "{{ .Values.hyperkube.pullPolicy }}"
          command:
            - ./kubectl
            - get
            {{- if printf "%s.%s" .Capabilities.KubeVersion.Major .Capabilities.KubeVersion.Minor | semverCompare ">=1.7" }}
            - customresourcedefinitions
            - clusters.rook.io
            - pools.rook.io
            - objectstores.rook.io
            - filesystems.rook.io
            - volumeattachments.rook.io
            {{- else }}
            - thirdpartyresources
            - cluster.rook.io
            - pool.rook.io
            - objectstore.rook.io
            - filesystem.rook.io
            - volumeattachment.rook.io
            {{- end }}
      restartPolicy: OnFailure
    {{- if .Values.rbacEnable }}
      serviceAccountName: rook-operator
    {{- end }}
{{- end }}

apiVersion: batch/v1
kind: Job
metadata:
  name: rook-operator-wait-resources
  annotations:
    helm.sh/hook: post-install
    "helm.sh/hook-delete-policy": hook-succeeded
  labels:
    app: rook-operator-wait-resources
    chart: "{{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }}"
spec:
  template:
    metadata:
      labels:
        app: rook-operator-wait-resources
        chart: "{{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }}"
    spec:
      containers:
        - name: hyperkube
          image: "{{ .Values.hyperkube.repository }}:{{ .Values.hyperkube.tag }}"
          imagePullPolicy: "{{ .Values.hyperkube.pullPolicy }}"
          command:
            - ./kubectl
            - get
            {{- if .Capabilities.APIVersions.Has "apiextensions.k8s.io/v1beta1" }}
            - customresourcedefinitions
            - clusters.rook.io
            - pools.rook.io
            - objectstores.rook.io
            - filesystems.rook.io
            - volumeattachments.rook.io
            {{- else }}
            - thirdpartyresources
            - cluster.rook.io
            - pool.rook.io
            - objectstore.rook.io
            - filesystem.rook.io
            - volumeattachment.rook.io
            {{- end }}
      restartPolicy: OnFailure
    {{- if .Values.rbacEnable }}
      serviceAccountName: rook-operator
    {{- end }}

Check for supporting API instead of specific K8S version
Check for supporting API instead of specific K8S version

Signed-off-by: Tim Jones <5ee0edb9e2229c0838f1959779f1949031de0123@spotahome.com>
