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 <preethi.satishchandra@intel.com>
Signed-off-by: preethi-satishcandra <preethi.satishchandra@intel.com>
Signed-off-by: preethi-satishcandra <preethi.satishchandra@intel.com>
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 <preethi.satishchandra@intel.com>
internal/driver/helper.go
Outdated
| } | ||
|
|
||
| // 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.
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.
Even the silly IDE suggested to me that it should be an :-)
| ) | ||
|
|
||
| const ( | ||
| redactedStr = "//<redacted>@" |
There was a problem hiding this comment.
I feel this makes more sense being defined here, closer to its usage
There was a problem hiding this comment.
Ok, I thought it would be better to keep all constants in one place.
| const ( | ||
| RTSPServerModeInternal RTSPServerMode = "internal" | ||
| RTSPServerModeExternal RTSPServerMode = "external" | ||
| RTSPServerModeNone RTSPServerMode = "none" | ||
| ) |
There was a problem hiding this comment.
these belong to the type RTSPServerMode string above, and implement an enum.
| // 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.
Is this the only place that needs to call this?
There was a problem hiding this comment.
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.
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.
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.
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.
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 <preethi.satishchandra@intel.com>
internal/driver/types.go
Outdated
| PixFmtDepthZ16: Depth, | ||
| } | ||
|
|
||
| const ( |
There was a problem hiding this comment.
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 <preethi.satishchandra@intel.com>
|
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
Pathas one of the protocol properties which is a string.Pathchanges toPathswhich is an array of string.New Dependency Instructions (If applicable)