-
Notifications
You must be signed in to change notification settings - Fork 5
Some Cleanup of the gRPC converter code in mgmt #532
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
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR cleans up the gRPC converter code in the mgmt module, improves error handling, and replaces manual indexing with Rust’s pattern matching. Key changes include the addition of clippy checks, refactoring of CIDR and interface conversion logic using pattern matching, and improved enum conversion via try_from.
.find(|vrf| vrf.name == "default") | ||
.unwrap_or(&underlay.vrfs[0]); | ||
.unwrap_or(&underlay.vrfs[0]); // FIXME(manish): This should be an error, preserving the original behavior for now | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider returning an error when no default VRF is found instead of defaulting to underlay.vrfs[0], as the FIXME comment indicates that this behavior should be changed.
Copilot uses AI. Check for mistakes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM @mvachhar !
3d5d341
to
6525541
Compare
a51dc03
to
72c1dd2
Compare
3a46e5f
to
a967446
Compare
72c1dd2
to
1659b57
Compare
a967446
to
7572408
Compare
1659b57
to
537bf97
Compare
7572408
to
1c50e2b
Compare
537bf97
to
23829f0
Compare
Silence clippy errors whose proper fix would require an interface change Signed-off-by: Manish Vachharajani <[email protected]>
Signed-off-by: Manish Vachharajani <[email protected]>
Rust pattern matching merges the length check with getting the entries. By using pattern matching there can be no error where the length does not match the dereference index leading to a runtime panic Signed-off-by: Manish Vachharajani <[email protected]>
23829f0
to
085e82a
Compare
Started cleanup of the mgmt converter code.
I've added clippy checks and fixed issues, but not in a way that will change the interface.
I've removed all hard-coded constants
I've moved code to use Rust pattern matching instead of length checks + indexing for known-length vectors
There is still much more to do, but this is a good start at getting rid of some of the bigger issues.