{{- if index .Values "rancherTurtles" "features" "addon-provider-fleet" "enabled" }}
---
apiVersion: turtles-capi.cattle.io/v1alpha1
kind: CAPIProvider
metadata:
  name: fleet
  namespace: '{{ .Values.rancherTurtles.namespace }}'
  annotations:
    "helm.sh/hook": "post-install, post-upgrade"
    "helm.sh/hook-weight": "2"
spec:
  type: addon
  deployment:
    containers:
    - name: manager
      imageUrl: registry.rancher.com/rancher/cluster-api-fleet-controller:v0.6.0
    - name: helm-manager
      imageUrl: registry.rancher.com/rancher/cluster-api-fleet-controller:v0.6.0
  additionalManifests:
    name: fleet-addon-config
    namespace: '{{ .Values.rancherTurtles.namespace }}'
---
apiVersion: v1
kind: ConfigMap
metadata:
  name: fleet-addon-config
  namespace: '{{ .Values.rancherTurtles.namespace }}'
  annotations:
    "helm.sh/hook": "post-install, post-upgrade"
    "helm.sh/hook-weight": "2"
data:
  manifests: |-
    apiVersion: addons.cluster.x-k8s.io/v1alpha1
    kind: FleetAddonConfig
    metadata:
      name: fleet-addon-config
    spec:
      clusterClass:
        patchResource: true
        setOwnerReferences: true
      cluster:
        patchResource: true
        setOwnerReferences: true
        hostNetwork: true
        selector:
          matchLabels:
            cluster-api.cattle.io/rancher-auto-import: "true"
          matchExpressions:
            - key: cluster-api.cattle.io/disable-fleet-auto-import
              operator: DoesNotExist
        namespaceSelector:
          matchLabels:
            cluster-api.cattle.io/rancher-auto-import: "true"
          matchExpressions:
            - key: cluster-api.cattle.io/disable-fleet-auto-import
              operator: DoesNotExist
{{- end }}
