apiVersion: apiextensions.k8s.io/v1 # Hack because controller-gen complains if we don't have this
name: "[Custom] Infrastructure"
crd: 0000_10_config-operator_01_infrastructure-CustomNoUpgrade.crd.yaml
tests:
  onCreate:
  - name: Should be able to create a minimal Infrastructure
    initial: |
      apiVersion: config.openshift.io/v1
      kind: Infrastructure
      spec: {} # No spec is required for a Infrastructure
    expected: |
      apiVersion: config.openshift.io/v1
      kind: Infrastructure
      spec: {}
  onUpdate:
  - name: Should not be able to modify an existing GCP ResourceLabels Label
    initial: |
      apiVersion: config.openshift.io/v1
      kind: Infrastructure
      spec: {}
      status:
        controlPlaneTopology: "HighlyAvailable"
        infrastructureTopology: "HighlyAvailable"
        platform: GCP
        platformStatus:
          type: GCP
          gcp:
            resourceLabels:
              - {key: "key", value: "value"}
    updated: |
      apiVersion: config.openshift.io/v1
      kind: Infrastructure
      spec: {}
      status:
        platform: GCP
        platformStatus:
          type: GCP
          gcp:
            resourceLabels:
              - {key: "key", value: "changed"}
    expectedStatusError: "status.platformStatus.gcp.resourceLabels: Invalid value: \"array\": resourceLabels are immutable and may only be configured during installation"
  - name: Should not be able to add a Label to an existing GCP ResourceLabels
    initial: |
      apiVersion: config.openshift.io/v1
      kind: Infrastructure
      spec: {}
      status:
        controlPlaneTopology: "HighlyAvailable"
        infrastructureTopology: "HighlyAvailable"
        platform: GCP
        platformStatus:
          type: GCP
          gcp:
            resourceLabels:
              - {key: "key", value: "value"}
    updated: |
      apiVersion: config.openshift.io/v1
      kind: Infrastructure
      spec: {}
      status:
        platform: GCP
        platformStatus:
          type: GCP
          gcp:
            resourceLabels:
              - {key: "key", value: "value"}
              - {key: "new", value: "entry"}
    expectedStatusError: "status.platformStatus.gcp.resourceLabels: Invalid value: \"array\": resourceLabels are immutable and may only be configured during installation"
  - name: Should not be able to remove a Label from an existing GCP ResourceLabels
    initial: |
      apiVersion: config.openshift.io/v1
      kind: Infrastructure
      spec: {}
      status:
        platform: GCP
        platformStatus:
          type: GCP
          gcp:
            resourceLabels:
              - {key: "key", value: "value"}
              - {key: "new", value: "entry"}
    updated: |
      apiVersion: config.openshift.io/v1
      kind: Infrastructure
      spec: {}
      status:
        platform: GCP
        platformStatus:
          type: GCP
          gcp:
            resourceLabels:
              - {key: "key", value: "value"}
    expectedStatusError: "status.platformStatus.gcp.resourceLabels: Invalid value: \"array\": resourceLabels are immutable and may only be configured during installation"
  - name: Should not be able to add GCP ResourceLabels to an empty platformStatus.gcp
    initial: |
      apiVersion: config.openshift.io/v1
      kind: Infrastructure
      spec: {}
      status:
        platform: GCP
        platformStatus:
          type: GCP
          gcp: {}
    updated: |
      apiVersion: config.openshift.io/v1
      kind: Infrastructure
      spec: {}
      status:
        platform: GCP
        platformStatus:
          gcp:
            resourceLabels:
              - {key: "key", value: "value"}
    expectedStatusError: "status.platformStatus.gcp: Invalid value: \"object\": resourceLabels may only be configured during installation"
  - name: Should not be able to remove GCP ResourceLabels from platformStatus.gcp
    initial: |
      apiVersion: config.openshift.io/v1
      kind: Infrastructure
      spec: {}
      status:
        platform: GCP
        platformStatus:
          type: GCP
          gcp:
            resourceLabels:
              - {key: "key", value: "value"}
    updated: |
      apiVersion: config.openshift.io/v1
      kind: Infrastructure
      spec: {}
      status:
        platform: GCP
        platformStatus:
          type: GCP
          gcp: {}
    expectedStatusError: "status.platformStatus.gcp: Invalid value: \"object\": resourceLabels may only be configured during installation"
  - name: Should not have label key start with openshift-io for GCP ResourceLabels in platformStatus.gcp
    initial: |
      apiVersion: config.openshift.io/v1
      kind: Infrastructure
      spec: {}
      status: {}
    updated: |
      apiVersion: config.openshift.io/v1
      kind: Infrastructure
      spec: {}
      status:
        platform: GCP
        platformStatus:
          type: GCP
          gcp:
            resourceLabels:
              - {key: "key", value: "value"}
              - {key: "openshift-io-created-cluster", value: "true"}
    expectedStatusError: "status.platformStatus.gcp.resourceLabels[1].key: Invalid value: \"string\": label keys must not start with either `openshift-io` or `kubernetes-io`"
  - name: Should not have label key start with kubernetes-io for GCP ResourceLabels in platformStatus.gcp
    initial: |
      apiVersion: config.openshift.io/v1
      kind: Infrastructure
      spec: {}
      status: {}
    updated: |
      apiVersion: config.openshift.io/v1
      kind: Infrastructure
      spec: {}
      status:
        platform: GCP
        platformStatus:
          type: GCP
          gcp:
            resourceLabels:
              - {key: "key", value: "value"}
              - {key: "kubernetes-io-created-cluster", value: "true"}
    expectedStatusError: "status.platformStatus.gcp.resourceLabels[1].key: Invalid value: \"string\": label keys must not start with either `openshift-io` or `kubernetes-io`"
  - name: Should not be able to modify an existing GCP ResourceTags Tag
    initial: |
      apiVersion: config.openshift.io/v1
      kind: Infrastructure
      spec: {}
      status:
        controlPlaneTopology: "HighlyAvailable"
        infrastructureTopology: "HighlyAvailable"
        platform: GCP
        platformStatus:
          type: GCP
          gcp:
            resourceTags:
              - {parentID: "1234567890", key: "key", value: "value"}
    updated: |
      apiVersion: config.openshift.io/v1
      kind: Infrastructure
      spec: {}
      status:
        platform: GCP
        platformStatus:
          type: GCP
          gcp:
            resourceTags:
              - {parentID: "1234567890", key: "key", value: "changed"}
    expectedStatusError: "status.platformStatus.gcp.resourceTags: Invalid value: \"array\": resourceTags are immutable and may only be configured during installation"
  - name: Should not be able to add a Tag to an existing GCP ResourceTags
    initial: |
      apiVersion: config.openshift.io/v1
      kind: Infrastructure
      spec: {}
      status:
        controlPlaneTopology: "HighlyAvailable"
        infrastructureTopology: "HighlyAvailable"
        platform: GCP
        platformStatus:
          type: GCP
          gcp:
            resourceTags:
              - {parentID: "1234567890", key: "key", value: "value"}
    updated: |
      apiVersion: config.openshift.io/v1
      kind: Infrastructure
      spec: {}
      status:
        platform: GCP
        platformStatus:
          type: GCP
          gcp:
            resourceTags:
              - {parentID: "1234567890", key: "key", value: "value"}
              - {parentID: "test-project-123", key: "new", value: "tag"}
    expectedStatusError: "status.platformStatus.gcp.resourceTags: Invalid value: \"array\": resourceTags are immutable and may only be configured during installation"
  - name: Should not be able to remove a Tag from an existing GCP ResourceTags
    initial: |
      apiVersion: config.openshift.io/v1
      kind: Infrastructure
      spec: {}
      status:
        platform: GCP
        platformStatus:
          type: GCP
          gcp:
            resourceTags:
              - {parentID: "1234567890", key: "key1", value: "value1"}
              - {parentID: "test-project-123", key: "key2", value: "value2"}
    updated: |
      apiVersion: config.openshift.io/v1
      kind: Infrastructure
      spec: {}
      status:
        platform: GCP
        platformStatus:
          type: GCP
          gcp:
            resourceTags:
              - {parentID: "1234567890", key: "key1", value: "value1"}
    expectedStatusError: "status.platformStatus.gcp.resourceTags: Invalid value: \"array\": resourceTags are immutable and may only be configured during installation"
  - name: Should not be able to add GCP ResourceTags to an empty platformStatus.gcp
    initial: |
      apiVersion: config.openshift.io/v1
      kind: Infrastructure
      spec: {}
      status:
        platform: GCP
        platformStatus:
          type: GCP
          gcp: {}
    updated: |
      apiVersion: config.openshift.io/v1
      kind: Infrastructure
      spec: {}
      status:
        platform: GCP
        platformStatus:
          gcp:
            resourceTags:
              - {parentID: "1234567890", key: "key", value: "value"}
    expectedStatusError: "status.platformStatus.gcp: Invalid value: \"object\": resourceTags may only be configured during installation"
  - name: Should not be able to remove GCP ResourceTags from platformStatus.gcp
    initial: |
      apiVersion: config.openshift.io/v1
      kind: Infrastructure
      spec: {}
      status:
        platform: GCP
        platformStatus:
          type: GCP
          gcp:
            resourceTags:
              - {parentID: "1234567890", key: "key", value: "value"}
    updated: |
      apiVersion: config.openshift.io/v1
      kind: Infrastructure
      spec: {}
      status:
        platform: GCP
        platformStatus:
          type: GCP
          gcp: {}
    expectedStatusError: "status.platformStatus.gcp: Invalid value: \"object\": resourceTags may only be configured during installation"
  - name: Should not be able to modify ParentID of a Tag in the GCP ResourceTags
    initial: |
      apiVersion: config.openshift.io/v1
      kind: Infrastructure
      spec: {}
      status:
        controlPlaneTopology: "HighlyAvailable"
        infrastructureTopology: "HighlyAvailable"
        platform: GCP
        platformStatus:
          type: GCP
          gcp:
            resourceTags:
              - {parentID: "1234567890", key: "key", value: "value"}
    updated: |
      apiVersion: config.openshift.io/v1
      kind: Infrastructure
      spec: {}
      status:
        platform: GCP
        platformStatus:
          type: GCP
          gcp:
            resourceTags:
              - {parentID: "test-project-123", key: "key", value: "value"}
    expectedStatusError: "status.platformStatus.gcp.resourceTags: Invalid value: \"array\": resourceTags are immutable and may only be configured during installation"
