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

feat(models): add new package to handle protobuf translation #267

Merged
merged 1 commit into from
Oct 19, 2023

Conversation

glimchb
Copy link
Member

@glimchb glimchb commented Oct 18, 2023

Signed-off-by: Boris Glimcher [email protected]

This is just a first draft and will be amended later on to include more fields and fix Todos...

There are 4 objects:

@codecov
Copy link

codecov bot commented Oct 18, 2023

Codecov Report

Merging #267 (9bc3a32) into main (7ac1063) will increase coverage by 0.20%.
The diff coverage is 100.00%.

@@            Coverage Diff             @@
##             main     #267      +/-   ##
==========================================
+ Coverage   65.00%   65.21%   +0.20%     
==========================================
  Files          19       19              
  Lines        1366     1374       +8     
==========================================
+ Hits          888      896       +8     
  Misses        434      434              
  Partials       44       44              
Files Coverage Δ
pkg/evpn/bridge.go 71.30% <100.00%> (+0.50%) ⬆️
pkg/evpn/port.go 79.34% <100.00%> (+0.22%) ⬆️
pkg/evpn/svi.go 64.51% <100.00%> (+0.46%) ⬆️
pkg/evpn/vrf.go 67.96% <100.00%> (+0.50%) ⬆️

@glimchb glimchb added the Merge Candidate in the open merge window, next candidate for merge label Oct 18, 2023
@glimchb glimchb marked this pull request as ready for review October 18, 2023 20:09
@glimchb glimchb requested a review from a team as a code owner October 18, 2023 20:09
Copy link
Contributor

@mardim91 mardim91 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the changes are towards the right direction.

Is it possible instead of writing little code for all objects to just first write all the code or significant part of it just for one or two objects (e.g. VRF and SVI or LB and BP) so I can review the code better and be sure that I am agreeing with the translation approach ?

That would really help me reviewing the code

@glimchb
Copy link
Member Author

glimchb commented Oct 19, 2023

I think the changes are towards the right direction.

Is it possible instead of writing little code for all objects to just first write all the code or significant part of it just for one or two objects (e.g. VRF and SVI or LB and BP) so I can review the code better and be sure that I am agreeing with the translation approach ?

That would really help me reviewing the code

This change defines interfaces. With new package, New and To functions and enough code to understand the new structure. The content of each function for specific transformation will come in subsequent PRs

)

// Bridge object, separate from protobuf for decoupling
type Bridge struct {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

seems like we can also add interface here

)

// Port object, separate from protobuf for decoupling
type Port struct {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

seems like we can also add interface here

)

// Svi object, separate from protobuf for decoupling
type Svi struct {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

seems like we can also add interface here

)

// Vrf object, separate from protobuf for decoupling
type Vrf struct {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

seems like we can also add interface here

@brianroch
Copy link

brianroch commented Oct 19, 2023

Approach looks fine overall. The only alternative I think worth considering is using this copier library. It would save you a bit of boilerplate code by defining the field mapping in the struct itself. However, this would only work from pb to struct, not the other way.

@glimchb
Copy link
Member Author

glimchb commented Oct 19, 2023

Approach looks fine overall. The only alternative I think worth considering is using this copier library. It would save you a bit of boilerplate code by defining the field mapping in the struct itself. However, this would only work from pb to struct, not the other way.

opened #269 I was thinking also marshaling with json for auto-copy approach... will investigate this

@glimchb glimchb merged commit 4a6e6dd into opiproject:main Oct 19, 2023
18 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Merge Candidate in the open merge window, next candidate for merge
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants