Skip to content

Rename examples/conversion.ConvertSingletonListToEmbeddedObject as ApplyAPIConverters#538

Merged
erhancagirici merged 1 commit into
crossplane:mainfrom
ulucinar:pp-seed
Oct 16, 2025
Merged

Rename examples/conversion.ConvertSingletonListToEmbeddedObject as ApplyAPIConverters#538
erhancagirici merged 1 commit into
crossplane:mainfrom
ulucinar:pp-seed

Conversation

@ulucinar

@ulucinar ulucinar commented Oct 16, 2025

Copy link
Copy Markdown
Collaborator

Description of your changes

This PR changes the existing examples/conversion.ConvertSingletonListToEmbeddedObject in the following ways:

  • Renames it as ApplyAPIConverters because it applies all the registered API converters, not just the singleton-list-to-embedded-object converter.
  • ConvertSingletonListToEmbeddedObject used to convert the v1beta1 versions into the new versions. However, we should already be generating the new version from the hopefully updated registry examples corresponding to that new version. So instead of a direct conversion from the old API, we had better have it generated from the new registry examples corresponding to that version and apply the registered converters on them.

Please note that this only applies the API converters on the latest generated version. Any old versions are kept intact. This is meant to be run in a post processing step for the generated manifests.

A provider's code and example manifest generation pipeline could run this as follows (in a post-processing phase):

kingpin.FatalIfError(conversion.ConvertSingletonListToEmbeddedObject(pc, "../examples-generated/cluster", "../hack/boilerplate.yaml.txt"), "Cannot convert singleton lists to embedded objects in example cluster-scoped resource manifests.")

, where pc is the config.Provider which happens to hold the API converters registered for the resources. The ../examples-generated/cluster is the root path under which the generated example manifests are to be processed. ../hack/boilerplate.yaml.txt is the license header to be appended to the processed documents.

As a future work, we could turn what we currently have in ApplyAPIConverters into a chain of post processors run for the generated manifests and probably decouple the license header adder from the API converter applier.

I have:

  • Read and followed Upjet's contribution process.
  • Run make reviewable to ensure this PR is ready for review.
  • Added backport release-x.y labels to auto-backport this PR if necessary.

How has this code been tested

Tested against crossplane-contrib/provider-upjet-{aws,azuread}:

…plyAPIConverters

Signed-off-by: Alper Rifat Ulucinar <ulucinar@users.noreply.github.com>
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.

2 participants