{{- if .Values.infrastructure }}

# Deploy bootstrap, and infrastructure components if not specified
{{- if not .Values.bootstrap }}
---
apiVersion: v1
kind: Namespace
metadata:
  annotations:
    "helm.sh/hook": "post-install"
    "helm.sh/hook-weight": "1"
    "argocd.argoproj.io/sync-wave": "1"
  name: capi-kubeadm-bootstrap-system
---
apiVersion: operator.cluster.x-k8s.io/v1alpha2
kind: BootstrapProvider
metadata:
  name: kubeadm
  namespace: capi-kubeadm-bootstrap-system
  annotations:
    "helm.sh/hook": "post-install"
    "helm.sh/hook-weight": "2"
    "argocd.argoproj.io/sync-wave": "2"
{{- with .Values.configSecret }}
spec:
  configSecret:
    name: {{ .name }}
    {{- if .namespace }}
    namespace: {{ .namespace }}
    {{- end }}
{{- end }}
{{- end }}

{{- if not .Values.controlPlane }}
---
apiVersion: v1
kind: Namespace
metadata:
  annotations:
    "helm.sh/hook": "post-install"
    "helm.sh/hook-weight": "1"
    "argocd.argoproj.io/sync-wave": "1"
  name: capi-kubeadm-control-plane-system
---
apiVersion: operator.cluster.x-k8s.io/v1alpha2
kind: ControlPlaneProvider
metadata:
  name: kubeadm
  namespace: capi-kubeadm-control-plane-system
  annotations:
    "helm.sh/hook": "post-install"
    "helm.sh/hook-weight": "2"
    "argocd.argoproj.io/sync-wave": "2"
{{- with .Values.configSecret }}
spec:
  configSecret:
    name: {{ .name }}
    {{- if .namespace }}
    namespace: {{ .namespace }}
    {{- end }}
{{- end }}
{{- end }}

{{- end }}