apiVersion: apiextensions.crossplane.io/v1
kind: Composition
metadata:
  name: vm-ubuntu
  labels:
    provider: proxmox
spec:
  writeConnectionSecretsToRef:
    name: vm-connection-secret
    namespace: crossplane-system
  compositeTypeRef:
    apiVersion: proxmox.sankofa.nexus/v1alpha1
    kind: VirtualMachine
  resources:
    - name: proxmox-vm
      base:
        apiVersion: proxmox.sankofa.nexus/v1alpha1
        kind: ProxmoxVM
        metadata:
          labels:
            tenant-id: "TENANT_ID_PLACEHOLDER"
            managed-by: sankofa-phoenix
        spec:
          forProvider:
            node: ML110-01
            cpu: 2
            memory: 4Gi
            disk: 50Gi
            storage: local-lvm
            network: vmbr0
            image: ubuntu-22.04-cloud
            site: us-sfvalley
      patches:
        - type: FromCompositeFieldPath
          fromFieldPath: spec.parameters.name
          toFieldPath: spec.forProvider.name
        - type: FromCompositeFieldPath
          fromFieldPath: spec.parameters.cpu
          toFieldPath: spec.forProvider.cpu
        - type: FromCompositeFieldPath
          fromFieldPath: spec.parameters.memory
          toFieldPath: spec.forProvider.memory
        - type: FromCompositeFieldPath
          fromFieldPath: spec.parameters.disk
          toFieldPath: spec.forProvider.disk
        - type: FromCompositeFieldPath
          fromFieldPath: spec.parameters.site
          toFieldPath: spec.forProvider.site
        - type: FromCompositeFieldPath
          fromFieldPath: spec.parameters.node
          toFieldPath: spec.forProvider.node
          optional: true
        - type: FromCompositeFieldPath
          fromFieldPath: metadata.labels['tenant-id']
          toFieldPath: metadata.labels['tenant-id']
