#######################################################################################
# Copyright ETSI Contributors and Others.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#    http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
# implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#######################################################################################

---
# TEMPLATE_PARAMETERS:
# ===================
#
# CLUSTER_KUSTOMIZATION_NAME: Name of the Kustomization in the management cluster representing the AKS cluster.
# - Alternatively, it can be patched at:
#   .metadata.name
#   .metadata.labels.cluster
#   .spec.commonMetadata.labels.cluster
#
# PARAMETERS TO PATCH:
# ===================
#
# .spec.postBuild.substitute.cluster_name: Name of the cluster in the target cloud.
# .spec.postBuild.substitute.control_plane_machine_count: Number of control plane nodes.
# .spec.postBuild.substitute.kubernetes_version: Kubernetes version.
# .spec.postBuild.substitute.namespace: Namespace to be deployed to.
# .spec.postBuild.substitute.worker_machine_count: Number of worker nodes.
# .spec.postBuild.substitute.openstack_cloud: Target cluster region.
# .spec.postBuild.substitute.openstack_cloud_conf: Name of the cloud conf secret.
# .spec.postBuild.substitute.openstack_control_plane_machine_flavor: VM size of control plane node.
# .spec.postBuild.substitute.openstack_dns_nameservers: Nameserver to use in the workload cluster.
# .spec.postBuild.substitute.openstack_external_network_id: ID of the external network.
# .spec.postBuild.substitute.openstack_failure_domain: OpenStack nova name
# .spec.postBuild.substitute.openstack_control_plane_image_name: Base image of the control plane VM
# .spec.postBuild.substitute.openstack_worker_image_name: Base image of the worker VM
# .spec.postBuild.substitute.openstack_node_machine_flavor: VM size of worker node.
# .spec.postBuild.substitute.openstack_ssh_key_name: Name of the SSH key to use with OpenStack.

apiVersion: kustomize.toolkit.fluxcd.io/v1
kind: Kustomization
metadata:
  name: ${CLUSTER_KUSTOMIZATION_NAME}
  namespace: managed-resources
  labels:
    cluster: ${CLUSTER_KUSTOMIZATION_NAME}
spec:
  commonMetadata:
    labels:
      cluster: ${CLUSTER_KUSTOMIZATION_NAME}
  interval: 1h
  retryInterval: 1m
  timeout: 5m
  sourceRef:
    kind: GitRepository
    name: sw-catalogs
    namespace: flux-system
  path: ./cloud-resources/capi/openstack-kubeadm/manifests/base
  prune: true
  wait: true
  # force: true
  # Input parameters
  postBuild:
    substitute:
      cluster_name: "myopenstackcluster01"
      cni: "cni-plugin"
      control_plane_machine_count: "1"
      kubernetes_version: "v1.30.1"
      namespace: "capi-system"
      worker_machine_count: "0"
      openstack_cloud: "default"
      openstack_cloud_conf: "1"
      openstack_control_plane_machine_flavor: ""
      openstack_dns_nameservers: ""
      openstack_external_network_id: ""
      openstack_failure_domain: ""
      openstack_worker_image_name: ""
      openstack_control_plane_image_name: ""
      openstack_node_machine_flavor: ""
      openstack_ssh_key_name: ""
