Convert the Device Labels value from string to string slice
FelixTing opened this issue Β· comments
π Bug Report
Affected Services [REQUIRED]
The issue is located in: device-sdk-goIs this a regression?
Yes, the previous version in which this bug was not present was: ....Description and Minimal Reproduction [REQUIRED]
Device labels are stored as a single string in the Configuration Provider, we need to convert it to a slice of strings.
The decision to do the conversion in sdk is based on the fact that we can only modify the logic inside the decoding function of the Keeper client. Unless we opt to develop a new decoder for Consul ourselves.
See:
Keeper client https://github.com/edgexfoundry/go-mod-configuration/blob/2c3512b731558a2be3f8460c3f0fed9361b5dcd4/internal/pkg/keeper/client.go#L163
Consul client https://github.com/edgexfoundry/go-mod-configuration/blob/2c3512b731558a2be3f8460c3f0fed9361b5dcd4/internal/pkg/consul/client.go#L206
Minimal Reproduction:
- Run Napa non-secure stack compose file
- Query all device services: http://localhost:59881/api/v3/deviceservice/all
π₯ Exception or Error
Actual Result:
{
"apiVersion": "v3",
"statusCode": 200,
"totalCount": 2,
"services": [
{
"created": 1714028539826,
"modified": 1714028539826,
"id": "f4723958-3c7a-4eea-a384-c1ac77490b80",
"name": "device-virtual",
"labels": [
"[]"
],
"baseAddress": "http://edgex-device-virtual:59900",
"adminState": "UNLOCKED"
},
{
"created": 1714028539824,
"modified": 1714028539824,
"id": "45e07fe7-7fe8-4116-b32b-84f788cfd361",
"name": "device-rest",
"labels": [
"[]"
],
"baseAddress": "http://edgex-device-rest:59986",
"adminState": "UNLOCKED"
}
]
}
Expected Result:
{
"apiVersion": "v3",
"statusCode": 200,
"totalCount": 2,
"services": [
{
"created": 1714028539826,
"modified": 1714028539826,
"id": "f4723958-3c7a-4eea-a384-c1ac77490b80",
"name": "device-virtual",
"baseAddress": "http://edgex-device-virtual:59900",
"adminState": "UNLOCKED"
},
{
"created": 1714028539824,
"modified": 1714028539824,
"id": "45e07fe7-7fe8-4116-b32b-84f788cfd361",
"name": "device-rest",
"baseAddress": "http://edgex-device-rest:59986",
"adminState": "UNLOCKED"
}
]
}
π Your Environment
Deployment Environment:
EdgeX Version [REQUIRED]: Napa
Anything else relevant?