Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Generalize/deduplicate shared CRD definitions #356

Open
orf opened this issue Jan 6, 2025 · 2 comments
Open

Generalize/deduplicate shared CRD definitions #356

orf opened this issue Jan 6, 2025 · 2 comments

Comments

@orf
Copy link

orf commented Jan 6, 2025

Hey, me again 😅.

And, as always, thanks for this amazing library. I'm working with the external-secrets.io CRDs, and I've come up against something pretty annoying.

Within the CRDs, there exists two identical enums: ClusterSecretStores and SecretStores.

Aside from the description these are the same enums with the same members, but as they are represented as different types it becomes convoluted to write code to work on, say, a BeyondTrust provider: it's either a ClusterSecretStoreProviderBeyondtrustServer or a ClusterSecretStoreProviderBeyondtrustServer.

Solving this in the general case seems non-trivial. I have yet to dig into it, but perhaps it could be solved at the API schema generation step? I'd be surprised if somewhere down the stack these two enums are represented as the same type, but that information is lost somewhere during processing which results in the types being duplicated.

I'm implementing something for my company with this library and so I can spend some work time tinkering with this, if you think it's at all possible.

So I'd love your thoughts here!

@orf
Copy link
Author

orf commented Jan 6, 2025

Related: kube-rs/kopium#298

@sebhoss
Copy link
Member

sebhoss commented Feb 8, 2025

Hey thanks for reaching out & the very kind words! However I personally think of this project as nothing more than glue code that delegates all the heavy lifting to kopium, so I'll pass along the praise to those maintainers ^^

About shared struct definitions: In the past, I've added two mechanism in this project:

I think even without kube-rs/kopium#298 we can do something here: If we bring back .args files we can elide specific structs. Using --elide kopium will still generate code that references structs that we passed to --elide but won't generate the struct itself which would allow us to provide our own implementation (which we could share across multiple CRDs). The missing import statement referencing our own implementation could be added with a .fixup script that runs after kopium generated code. We could just use sed or something similar to place additional imports into the generated files or maybe kopium could get a --add-import ... (or similar) switch.

What do you think?

Sorry for the long wait here, life and all that other stuff got in my recently 🙏

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

No branches or pull requests

2 participants