Skip to content

Conversation

clux
Copy link
Member

@clux clux commented Sep 22, 2025

a dumb attempt to fix #298 and #66

Encapsulates Output vector and forces all push calls to instead go through a public insert fn that checks for uniqueness and suffixes existing named structs that differ in other ways.

Equality is determined by an ad-hoc PartialEq on both Container and Vec. Have included the fields I think are important for equality. In particular, types, names, serde annots. Doc strings are ignored.

Note this changes tests to call a new, consuming .output() rather than .0 since the vector is now private.

@clux clux marked this pull request as ready for review September 22, 2025 22:24
@clux
Copy link
Member Author

clux commented Sep 22, 2025

@sebhoss quick PoC that might help

sebhoss added a commit to metio/kube-custom-resources-rs that referenced this pull request Sep 23, 2025
@sebhoss
Copy link
Contributor

sebhoss commented Sep 23, 2025

This works almost perfectly - love it! See metio/kube-custom-resources-rs#441 for lots of stuff that now can be generated. There are only 2 remaining CRDs that do not work and they are kinda special:

  1. ephemeralrunners.actions.github.com: Has a .spec.spec field (YAML) and therefore kopium generates two EphemeralRunnerSpec structs
  2. nexususers.edp.epam.com: Has a .spec.status field (YAML) and therefore kopium generates two NexusUserStatus structs (or actually 1 enum for the field and 1 struct for the actual status resource)

I think both can be fixed if the new Output struct knows about the root kind and deduplicates against that, e.g., if it encounters <kind>Spec or <kind>Status as a potential new container to add, it knows that those already exist even though they are not part of its internal vector?

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.

Add a brute force option to re-use identical structs pathological naming schemes could create clashing structs

2 participants