crossplane-contrib / provider-upjet-gcp

Official GCP Provider for Crossplane by Upbound.
Apache License 2.0
66 stars 72 forks source link

Convert all singleton lists in the MR APIs to embedded objects #508

Closed ulucinar closed 4 months ago

ulucinar commented 5 months ago

Description of your changes

Depends on: https://github.com/crossplane/upjet/pull/387, https://github.com/crossplane/upjet/pull/400

Terraform configuration blocks, even if they have a MaxItems constraint of 1, are (almost) always generated as lists. We now generate the lists with a MaxItems constraint of 1 as embedded objects in our MR APIs.

This also helps when updating or patching via SSA the (previously list) objects. The merging strategy implemented by SSA requires configuration for associative lists and converting the singleton lists into embedded objects removes the configuration need.

The provider generates the converted embedded objects in the new v1beta2 versions of the CRD APIs and registers upjet's identity converter and the singleton list converters to be invoked, in chain, by the CRD API conversion webhooks. This implies that the v1beta1 versions stay intact, and old clients not aware of the new APIs should continue functioning as before (backwards-compatibility). Any clients willing to use the embedded objects-based APIs should be updated to use the v1beta2 versions of the CRD APIs.

If a resource contains no singleton lists, then the v1beta2 version is not generated for it.

We had to configure field name overrides for HTTP{S}HealthCheck.compute and Version.dialogflowcx so that the correspnding type names for the spec.forProvider, spec.initParameter and state.atProvider fields are not duplicated with the introduction of v1beta2 packages.

We have also removed the SSA merge strategy configurations from the v1beta2 versions of Cluster.container & NodePool.container resources because the related fields are no longer lists and have been converted to embedded objects in their v1beta2 versions.

I have:

How has this code been tested

A successful uptest run for the 'NodePool.container` resource with the API converters is registered here. Another run with GKE back plans is here.

Also via the following uptest runs:

sergenyalcin commented 4 months ago

/test-examples="examples/compute/v1beta2/instance.yaml"

sergenyalcin commented 4 months ago

/test-examples="examples/compute/v1beta2/router.yaml"

sergenyalcin commented 4 months ago

/test-examples="examples/notebooks/v1beta2/instance.yaml"

sergenyalcin commented 4 months ago

/test-examples="examples/pubsub/v1beta2/litetopic.yaml"

sergenyalcin commented 4 months ago

/test-examples="examples/compute/v1beta2/firewall.yaml"

sergenyalcin commented 4 months ago

/test-examples="examples/compute/v1beta2/instance.yaml"

sergenyalcin commented 4 months ago

/test-examples="examples/compute/v1beta2/router.yaml"

sergenyalcin commented 4 months ago

/test-examples="examples/pubsub/v1beta2/litetopic.yaml"

ulucinar commented 4 months ago

/test-examples="examples/compute/v1beta2/image.yaml"

ulucinar commented 4 months ago

/test-examples="examples/compute/v1beta2/image.yaml"

sergenyalcin commented 4 months ago

/test-examples="examples/compute/v1beta2/firewall.yaml"

sergenyalcin commented 4 months ago

/test-examples="examples/compute/v1beta2/instance.yaml"

sergenyalcin commented 4 months ago

/test-examples="examples/compute/v1beta2/router.yaml"

sergenyalcin commented 4 months ago

/test-examples="examples/pubsub/v1beta2/litetopic.yaml"

sergenyalcin commented 4 months ago

/test-examples="examples/cloudrun/v1beta2/v2service.yaml"

sergenyalcin commented 4 months ago

/test-examples="examples/logging/v1beta2/metric.yaml"

sergenyalcin commented 4 months ago

/test-examples="examples/monitoring/v1beta2/service.yaml"

sergenyalcin commented 4 months ago

/test-examples="examples/notebooks/v1beta2/environment.yaml"

sergenyalcin commented 4 months ago

/test-examples="examples/notebooks/v1beta2/instance.yaml"

sergenyalcin commented 4 months ago

/test-examples="examples/secretmanager/v1beta2/secret.yaml"

sergenyalcin commented 4 months ago

/test-examples="examples/sql/v1beta2/user.yaml"

sergenyalcin commented 4 months ago

/test-examples="examples/dns/v1beta2/policy.yaml"

sergenyalcin commented 4 months ago

/test-examples="examples/container/v1beta2/cluster.yaml"

sergenyalcin commented 4 months ago

/test-examples="examples/storage/v1beta2/bucket.yaml"

sergenyalcin commented 4 months ago

/test-examples="examples/spanner/v1beta2/database.yaml"

sergenyalcin commented 4 months ago

/test-examples="examples/redis/v1beta2/instance.yaml"

sergenyalcin commented 4 months ago

/test-examples="examples/compute/v1beta2/securitypolicy.yaml"

sergenyalcin commented 4 months ago

/test-examples="examples/compute/v1beta2/urlmap.yaml"

ulucinar commented 4 months ago

/test-examples="examples/container/v1beta2/nodepool.yaml"

ulucinar commented 4 months ago

/test-examples="examples/compute/v1beta2/image.yaml"

ulucinar commented 4 months ago

/test-examples="examples/container/v1beta2/nodepool.yaml"

ulucinar commented 4 months ago

/test-examples="examples/compute/v1beta2/image.yaml"

ulucinar commented 4 months ago

We've decided to merge this PR without the example manifests and @sergenyalcin is planning to open a follow-up PR to introduce the missing v1beta2 example manifests.