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

Add a WatchStreamExt::modify shortcut #1245

Closed
clux opened this issue Jul 7, 2023 · 1 comment · Fixed by #1246
Closed

Add a WatchStreamExt::modify shortcut #1245

clux opened this issue Jul 7, 2023 · 1 comment · Fixed by #1246
Labels
good first issue Good for newcomers help wanted Not immediately prioritised, please help! runtime controller runtime related

Comments

@clux
Copy link
Member

clux commented Jul 7, 2023

Would you like to work on this feature?

no

What problem are you trying to solve?

Minor ergonomics improvement for the streams api. Currently stream modification requires:

let stream = watcher(api, watcher::Config::default()).map_ok(|ev| {
    ev.modify(|pod| {
        pod.managed_fields_mut().clear();
        pod.annotations_mut().clear();
        pod.status = None;
    })
});

we could shortcut that ever so slightly:

let stream = watcher(api, watcher::Config::default()).modify(|pod| {
    pod.managed_fields_mut().clear();
    pod.annotations_mut().clear();
    pod.status = None;
});

Describe the solution you'd like

A new WatchStreamExt::modify that chains TryStreamExt::map_ok with watcher::Event::modify

Can be verified in examples/pod_reflector.rs.

Describe alternatives you've considered

writing out the full thing, not a big deal, but a nice user facing api simplification when using the streams api.

Documentation, Adoption, Migration Strategy

additive change, put it in the docs and the example.

Target crate for feature

kube-runtime

@clux clux added help wanted Not immediately prioritised, please help! runtime controller runtime related good first issue Good for newcomers labels Jul 7, 2023
@nightkr
Copy link
Member

nightkr commented Jul 7, 2023

Yeah, nested maps tend to feel pretty awkward, especially when this is something that we want to encourage.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers help wanted Not immediately prioritised, please help! runtime controller runtime related
Projects
Status: Done
Development

Successfully merging a pull request may close this issue.

2 participants