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: Create a common Address struct for V2 API #525

Merged
merged 4 commits into from
Mar 8, 2021

Conversation

weichou1229
Copy link
Member

PR Checklist

Please check if your PR fulfills the following requirements:

  • Tests for the changes have been added (for bug fixes / features)
  • Docs have been added / updated (for bug fixes / features)

If your build fails due to your commit message not passing the build checks, please review the guidelines here: https://github.com/edgexfoundry/go-mod-core-contracts/blob/master/.github/Contributing.md.

What is the current behavior?

Issue Number: #523

What is the new behavior?

Create a common Addressable struct for different endpoint protocols

Does this PR introduce a breaking change?

  • Yes
  • No

New Imports

  • Yes
  • No

Specific Instructions

Are there any specific instructions or things that should be known prior to reviewing?

Other information

v2/dtos/addressable.go Outdated Show resolved Hide resolved
v2/dtos/addressable.go Outdated Show resolved Hide resolved
v2/dtos/addressable.go Outdated Show resolved Hide resolved
lenny-goodell
lenny-goodell previously approved these changes Mar 4, 2021
Copy link
Member

@lenny-goodell lenny-goodell left a comment

Choose a reason for hiding this comment

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

LGTM

@cloudxxx8
Copy link
Member

from @tonyespy : let’s name it Address, so as not to confuse it with the old addressable object.
@weichou1229 please go a head to finish this PR with the new naming

@cloudxxx8 cloudxxx8 changed the title feat: Create a common Addressable struct for V2 API feat: Create a common Address struct for V2 API Mar 5, 2021
Create a common Addressable struct for different endpoint protocols

Signed-off-by: weichou <weichou1229@gmail.com>
Rename and add fields

Signed-off-by: weichou <weichou1229@gmail.com>
- Rename Addressable to Address
- Remove BaseAddress DTO because the json unmarshal func can't identify repeat fields
- Add test for json unmarshalling and validation

Close edgexfoundry#523

Signed-off-by: weichou <weichou1229@gmail.com>
@weichou1229 weichou1229 marked this pull request as ready for review March 5, 2021 10:18
@weichou1229
Copy link
Member Author

I did the following changes, please help review.

  • Rename Addressable to Address
  • Fix v2/dtos/addressable.go:44: ambiguous selector a.Type
    • Move Type from BaseAddress DTO to Address DTO
  • Move Host, Port from BaseAddress DTO to Address DTO and remove BaseAddress DTO because the JSON unmarshal can't identify repeat fields
  • Add Validate function to verify the RESTAddress and MqttPubAddress according to the Type.
  • Add test for json unmarshalling and validation

lenny-goodell
lenny-goodell previously approved these changes Mar 5, 2021
Copy link
Member

@lenny-goodell lenny-goodell left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Member

@cloudxxx8 cloudxxx8 left a comment

Choose a reason for hiding this comment

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

Rename Mqtt to MQTT, because you use REST not Rest and HTTP not Http

@weichou1229
Copy link
Member Author

Renamed MqttPubAddress to MQTTPubAddress.

Fix edgexfoundry#523

Signed-off-by: weichou <weichou1229@gmail.com>
Copy link
Member

@cloudxxx8 cloudxxx8 left a comment

Choose a reason for hiding this comment

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

LGTM

@codecov-io
Copy link

Codecov Report

Merging #525 (0e9e73b) into master (3caf778) will decrease coverage by 0.60%.
The diff coverage is 20.96%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #525      +/-   ##
==========================================
- Coverage   56.59%   55.98%   -0.61%     
==========================================
  Files         119      120       +1     
  Lines        3564     3626      +62     
==========================================
+ Hits         2017     2030      +13     
- Misses       1357     1405      +48     
- Partials      190      191       +1     
Impacted Files Coverage Δ
v2/dtos/address.go 20.96% <20.96%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 3caf778...3dd46c1. Read the comment docs.

This was referenced Mar 12, 2021
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

Successfully merging this pull request may close these issues.

4 participants