apiVersion: apiextensions.k8s.io/v1 # Hack because controller-gen complains if we don't have this
name: "[Stable] ControlPlaneMachineSet (AWS)"
crd: 0000_10_controlplanemachineset-Default.crd.yaml
tests:
  onCreate:
  - name: Should reject an AWS platform failure domain without any AWS 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: AWS
    expectedError: "spec.template.machines_v1beta1_machine_openshift_io.failureDomains: Invalid value: \"object\": aws configuration is required when platform is AWS"
  - name: Should reject an AWS 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:
              - placement:
                  availabilityZone: foo
    expectedError: "spec.template.machines_v1beta1_machine_openshift_io.failureDomains.platform: Required value"
  - name: Should reject an AWS 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
              aws:
              - placement:
                  availabilityZone: foo
    expectedError: "spec.template.machines_v1beta1_machine_openshift_io.failureDomains: Invalid value: \"object\": aws configuration is required when platform is AWS, and forbidden otherwise"
  - name: Should reject an AWS failure domain with the subnet type omitted
    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: AWS
              aws:
              - subnet: {}
    expectedError: "spec.template.machines_v1beta1_machine_openshift_io.failureDomains.aws[0].subnet.type: Required value, <nil>: Invalid value: \"null\""
  - name: Should reject an AWS failure domain with the subnet type ID and no ID provided
    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: AWS
              aws:
              - subnet:
                  type: ID
    expectedError: "spec.template.machines_v1beta1_machine_openshift_io.failureDomains.aws[0].subnet: Invalid value: \"object\": id is required when type is ID, and forbidden otherwise"
  - name: Should accept an AWS failure domain with the subnet type ID and an ID provided
    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: AWS
              aws:
              - subnet:
                  type: ID
                  id: foo
    expected: |
      apiVersion: machine.openshift.io/v1
      kind: ControlPlaneMachineSet
      spec:
        replicas: 3
        state: Inactive
        strategy:
          type: RollingUpdate
        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: AWS
              aws:
              - subnet:
                  type: ID
                  id: foo
  - name: Should reject an AWS failure domain with the subnet type ID and an ARN provided
    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: AWS
              aws:
              - subnet:
                  type: ID
                  id: foo
                  arn: foo
    expectedError: "spec.template.machines_v1beta1_machine_openshift_io.failureDomains.aws[0].subnet: Invalid value: \"object\": arn is required when type is ARN, and forbidden otherwise"
  - name: Should reject an AWS failure domain with the subnet type ID and a Filter provided
    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: AWS
              aws:
              - subnet:
                  type: ID
                  id: foo
                  filters:
                  - name: foo
    expectedError: "spec.template.machines_v1beta1_machine_openshift_io.failureDomains.aws[0].subnet: Invalid value: \"object\": filters is required when type is Filters, and forbidden otherwise"
  - name: Should accept an AWS failure domain with the subnet type ARN and an ARN provided
    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: AWS
              aws:
              - subnet:
                  type: ARN
                  arn: foo
    expected: |
      apiVersion: machine.openshift.io/v1
      kind: ControlPlaneMachineSet
      spec:
        replicas: 3
        state: Inactive
        strategy:
          type: RollingUpdate
        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: AWS
              aws:
              - subnet:
                  type: ARN
                  arn: foo
  - name: Should accept an AWS failure domain with the subnet type Filters and a Filter provided
    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: AWS
              aws:
              - subnet:
                  type: Filters
                  filters:
                  - name: foo
    expected: |
      apiVersion: machine.openshift.io/v1
      kind: ControlPlaneMachineSet
      spec:
        replicas: 3
        state: Inactive
        strategy:
          type: RollingUpdate
        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: AWS
              aws:
              - subnet:
                  type: Filters
                  filters:
                  - name: foo
  - name: Should reject an AWS failure domain with the subnet type ARN and an ID provided
    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: AWS
              aws:
              - subnet:
                  type: ARN
                  id: foo
                  arn: foo
    expectedError: "spec.template.machines_v1beta1_machine_openshift_io.failureDomains.aws[0].subnet: Invalid value: \"object\": id is required when type is ID, and forbidden otherwise"
