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

optional builder patterns #9

Open
clux opened this issue Oct 29, 2021 · 2 comments
Open

optional builder patterns #9

clux opened this issue Oct 29, 2021 · 2 comments
Labels
help wanted Extra attention is needed

Comments

@clux
Copy link
Member

clux commented Oct 29, 2021

This is a possible feature for a much later if we get things working.

One of the things that I found was ugly with k8s-openapi was the need to structs everywhere with optionals so you ended up with ..Default::default() everywhere (leading people to use json!)

Maybe it's worth exploring builders everywhere: https://github.com/idanarye/rust-typed-builder seems to handle options well and require you fill in only required fields (which in kubernetes should be very few). Teo might also have opinions here, he wrote a builder crate.

What we could do in the future (if this gets off the ground) is to optionally #[derive(TypeBuilder)] for the structs.

Possibly a bit heavy, I know Arnav rejected proposals at more ergonomic apis before because of crate size (already heavy enough to compile everything), but that's possibly something we could aid by providing ways to limit the size of the crate (like only exposing the structs for the api groups that you are interested in for instance).

Anyway. This is a note to self for later.

@kazk
Copy link
Member

kazk commented Oct 29, 2021

Yeah, I was thinking the same. Hate using json!. I was considering to propose adding derive_builder to k8s-openapi, but got busy. I didn't know it was rejected before.

In addition to Option, I'd love to have Into setters (e.g., no more "name".to_owned()).

Didn't know about typed_builder crate, looks great.

@nightkr
Copy link
Member

nightkr commented Oct 29, 2021

Definitely a good point about Into, that's a big pain point..

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

3 participants