-
Notifications
You must be signed in to change notification settings - Fork 28
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
fix: Both path and paths need to be supported to address the breaking change until the next release #290
fix: Both path and paths need to be supported to address the breaking change until the next release #290
Conversation
Signed-off-by: preethi-satishcandra <[email protected]>
Signed-off-by: preethi-satishcandra <[email protected]>
Signed-off-by: preethi-satishcandra <[email protected]>
Codecov Report
❗ Your organization needs to install the Codecov GitHub app to enable full functionality. @@ Coverage Diff @@
## main #290 +/- ##
========================================
- Coverage 4.79% 4.74% -0.05%
========================================
Files 8 8
Lines 1293 1306 +13
========================================
Hits 62 62
- Misses 1231 1244 +13
|
Signed-off-by: preethi-satishcandra <[email protected]>
internal/driver/helper.go
Outdated
|
||
type EdgeXErrorWrapper struct{} | ||
|
||
func (e EdgeXErrorWrapper) CommandError(command string, err error) errors.EdgeX { | ||
return errors.NewCommonEdgeX(errors.KindServerError, fmt.Sprintf("failed to execute %s command", command), err) | ||
} | ||
|
||
// redact removes all instances of basic auth (ie. rtsp://username:password@server) from a url | ||
// redact removes all instances of basic auth (i.e. rtsp://username:password@server) from an url |
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.
a url
is the correct grammer here: https://www.techtarget.com/whatis/feature/Which-is-correct-a-URL-or-an-URL
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.
Even the silly IDE suggested to me that it should be an
:-)
@@ -14,23 +14,17 @@ import ( | |||
"github.com/edgexfoundry/go-mod-core-contracts/v3/errors" | |||
) | |||
|
|||
const ( | |||
redactedStr = "//<redacted>@" |
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.
I feel this makes more sense being defined here, closer to its usage
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.
Ok, I thought it would be better to keep all constants in one place.
internal/driver/types.go
Outdated
const ( | ||
RTSPServerModeInternal RTSPServerMode = "internal" | ||
RTSPServerModeExternal RTSPServerMode = "external" | ||
RTSPServerModeNone RTSPServerMode = "none" | ||
) |
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.
these belong to the type RTSPServerMode string
above, and implement an enum.
// RefreshDevicePaths checks whether the existing device matches the connected device. | ||
// If there is a mismatch between them, scan all paths to find the matching device | ||
// and update the existing device with the correct path. | ||
func (d *Driver) RefreshDevicePaths(cd models.Device) { | ||
d.updatePathToPaths(cd) |
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.
Is this the only place that needs to call this?
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.
yes this function is called when the service starts up and also when the discovery is called.
if value, ok := cd.Protocols[UsbProtocol][Path]; ok { | ||
if value != nil { | ||
cd.Protocols[UsbProtocol][Paths] = []string{value.(string)} | ||
delete(cd.Protocols[UsbProtocol], "Path") |
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.
I thought we had discussed keeping both fields in the metadata because otherwise, when you get a device it will be missing the Path
field that used to be there. @lenny-intel thoughts?
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.
I don't remember discussing about this, you mean creating Metadata
section within protocols like how we have in onvif service? Existing Path
field will be changed to Paths
with this code which is easier to maintain. We have added in the docs too that Path
field is deprecated and users should be using Paths
. I think @lenny-intel was fine with this.
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.
I mean keeping bath Path
and Paths
in the Onvif
protocol properties, and using code to sync them. As long as @lenny-intel is OK with this approach I am fine as well, since this will be cleaner.
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.
Yes, we have to keep both. My thought is if a device is loaded that has Path set, then set Paths to the single Path. That way the driver code always deals with Paths.
Signed-off-by: preethi-satishcandra <[email protected]>
internal/driver/types.go
Outdated
PixFmtDepthZ16: Depth, | ||
} | ||
|
||
const ( |
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.
I would put these back where they were, or move the type
definition down here. I like them being together.
Signed-off-by: preethi-satishcandra <[email protected]>
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
Though its already merged into main, I did validaiton to ensure end-to-end testing (discovering usb cameras, adding them egex metadata and rest-api's) works correctly both with 'path' and 'paths' fields and it looks good.
attaced scrresnhots for refecne. |
If your build fails due to your commit message not passing the build checks, please review the guidelines here: https://github.com/edgexfoundry/edgex-go/blob/main/.github/Contributing.md
PR Checklist
Please check if your PR fulfills the following requirements:
BREAKING CHANGE:
describing the break)Testing Instructions
Path
as one of the protocol properties which is a string.Path
changes toPaths
which is an array of string.New Dependency Instructions (If applicable)