Skip to content

Conversation

@mbbush
Copy link
Contributor

@mbbush mbbush commented Apr 5, 2025

Description of your changes

I have added functionality to change the type of a specified list of field paths between two CRD versions.

This is a prerequisite for my work-in-progress to upgrade the terraform provider in provider-upjet-aws, in which one resource is migrated from the terraform plugin sdk to the terraform plugin framework, resulting in several field paths changing type from string to float. I probably could have done it entirely in provider-upjet-aws, by writing a custom conversion that acted on the Managed level, but the idea of making something reusable was appealing, and could be reused to gracefully handle issues like crossplane-contrib/provider-upjet-aws#1682 in the future.

While testing my code, I discovered that the tests for singleton list conversions were using standard go json serialization/deserialization, while crossplane-runtime actually uses kubernetes json serialization/deserialization, which differ in their handling of json numbers (go always deserializes to float, while k8s deserializes to either float or int depending on the value). I fixed the test function to match what crossplane-runtime does, and am including the additional unit tests I wrote when I was debugging this. I put these in a separate commit so that they can be included even if the more significant change proves unwise.

Open questions

This is still a draft/proof-of-concept. I've given very little thought to things like "which file should this go in" or "what should that be named" and would appreciate opinions from others.

One significant long-term question is how we want to handle numeric fields. Currently, for SDK resources, in the four official providers, they are sometimes floats and sometimes strings, depending on the options configured in the terraform schema. In most cases, the actual values need to be integers, but it's not obvious to me how to detect in which cases they should be integers, except perhaps a manually-maintained list of field paths to override.

There's a TODO in the code that converts a tfjson schema to a terraform sdkv2 schema to figure out handling of floats with IntOrString, but as far as I can tell that's not even started. I remember reading somewhere that floats are discouraged in kubernetes CRDs.

I have:

  • Read and followed Upjet's contribution process.
  • Run make reviewable to ensure this PR is ready for review.

How has this code been tested

I'm testing this with provider-upjet-aws. I'll link to this PR when I open the PR there.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant