apiVersion: apiextensions.k8s.io/v1 # Hack because controller-gen complains if we don't have this
name: "[Stable] ControlPlaneMachineSet"
crd: 0000_10_controlplanemachineset-Default.crd.yaml
tests:
  onCreate:
  - name: Should reject an GCP platform failure domain without any GCP config
    initial: |
      apiVersion: machine.openshift.io/v1
      kind: ControlPlaneMachineSet
      spec:
        selector:
          matchLabels:
            machine.openshift.io/cluster-api-machine-role: master
            machine.openshift.io/cluster-api-machine-type: master
        template:
          machineType: machines_v1beta1_machine_openshift_io
          machines_v1beta1_machine_openshift_io:
            metadata:
              labels:
                machine.openshift.io/cluster-api-machine-role: master
                machine.openshift.io/cluster-api-machine-type: master
                machine.openshift.io/cluster-api-cluster: cluster
            spec:
              providerSpec: {}
            failureDomains:
              platform: GCP
    expectedError: "spec.template.machines_v1beta1_machine_openshift_io.failureDomains: Invalid value: \"object\": gcp configuration is required when platform is GCP"
  - name: Should reject an GCP configured failure domain without a platform type
    initial: |
      apiVersion: machine.openshift.io/v1
      kind: ControlPlaneMachineSet
      spec:
        selector:
          matchLabels:
            machine.openshift.io/cluster-api-machine-role: master
            machine.openshift.io/cluster-api-machine-type: master
        template:
          machineType: machines_v1beta1_machine_openshift_io
          machines_v1beta1_machine_openshift_io:
            metadata:
              labels:
                machine.openshift.io/cluster-api-machine-role: master
                machine.openshift.io/cluster-api-machine-type: master
                machine.openshift.io/cluster-api-cluster: cluster
            spec:
              providerSpec: {}
            failureDomains:
              aws:
              - zone: foo
    expectedError: "spec.template.machines_v1beta1_machine_openshift_io.failureDomains.platform: Required value"
  - name: Should reject an GCP configured failure domain with the wrong platform type
    initial: |
      apiVersion: machine.openshift.io/v1
      kind: ControlPlaneMachineSet
      spec:
        selector:
          matchLabels:
            machine.openshift.io/cluster-api-machine-role: master
            machine.openshift.io/cluster-api-machine-type: master
        template:
          machineType: machines_v1beta1_machine_openshift_io
          machines_v1beta1_machine_openshift_io:
            metadata:
              labels:
                machine.openshift.io/cluster-api-machine-role: master
                machine.openshift.io/cluster-api-machine-type: master
                machine.openshift.io/cluster-api-cluster: cluster
            spec:
              providerSpec: {}
            failureDomains:
              platform: BareMetal
              gcp:
              - zone: foo
    expectedError: "spec.template.machines_v1beta1_machine_openshift_io.failureDomains: Invalid value: \"object\": gcp configuration is required when platform is GCP, and forbidden otherwise"
