Skip to content

Commit

Permalink
refactor!: Use bool types for command parameters to be more consistent
Browse files Browse the repository at this point in the history
BREAKING CHANGE: ds-pushevent and ds-returnevent to use bool true/false instead of yes/no

related: edgexfoundry/go-mod-core-contracts#782

Signed-off-by: Ginny Guan <[email protected]>
  • Loading branch information
jinlinGuan committed Jan 16, 2023
1 parent 8541928 commit 97d2a14
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 21 deletions.
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ require (
bitbucket.org/bertimus9/systemstat v0.5.0
github.com/OneOfOne/xxhash v1.2.8
github.com/edgexfoundry/go-mod-bootstrap/v3 v3.0.0-dev.7
github.com/edgexfoundry/go-mod-core-contracts/v3 v3.0.0-dev.2
github.com/edgexfoundry/go-mod-messaging/v3 v3.0.0-dev.3
github.com/edgexfoundry/go-mod-core-contracts/v3 v3.0.0-dev.3
github.com/edgexfoundry/go-mod-messaging/v3 v3.0.0-dev.4
github.com/edgexfoundry/go-mod-registry/v3 v3.0.0-dev.3
github.com/google/uuid v1.3.0
github.com/gorilla/mux v1.8.0
Expand Down
8 changes: 4 additions & 4 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,10 @@ github.com/edgexfoundry/go-mod-bootstrap/v3 v3.0.0-dev.7 h1:e0H7V7aFl9vC06ZUUQUz
github.com/edgexfoundry/go-mod-bootstrap/v3 v3.0.0-dev.7/go.mod h1:yW5dumg9IyfrHx4NYC5Ii0WVVB5OjTXQ/8/NkHHif5Q=
github.com/edgexfoundry/go-mod-configuration/v3 v3.0.0-dev.2 h1:xp5MsP+qf/fuJxy8fT7k1N+c4j4C6w04qMCBXm6id7o=
github.com/edgexfoundry/go-mod-configuration/v3 v3.0.0-dev.2/go.mod h1:1Vv4uWAo6r7k6jUlqVJW8JOL6YKVBc6sRL8Al3DrMck=
github.com/edgexfoundry/go-mod-core-contracts/v3 v3.0.0-dev.2 h1:tleTxhbBISfDNn596rU71n+GOy27dMIme+v8Vl0uhpw=
github.com/edgexfoundry/go-mod-core-contracts/v3 v3.0.0-dev.2/go.mod h1:7RwSq896VqelvSU7zYKs2tpZhgELVFECkiGf6XGLKfQ=
github.com/edgexfoundry/go-mod-messaging/v3 v3.0.0-dev.3 h1:+el2HxEt02uFXXBmHK8gWETPklNbPg4wvYln/4/ooHo=
github.com/edgexfoundry/go-mod-messaging/v3 v3.0.0-dev.3/go.mod h1:G0Vxoc8+JXwUqRH5ggyOZ/f/CIVPTswI5Ld7dI5uhIY=
github.com/edgexfoundry/go-mod-core-contracts/v3 v3.0.0-dev.3 h1:Ia/y/w9w3SmXqIqJ+Vjmv6QrP49YJDpTY6262C1Jrzs=
github.com/edgexfoundry/go-mod-core-contracts/v3 v3.0.0-dev.3/go.mod h1:7RwSq896VqelvSU7zYKs2tpZhgELVFECkiGf6XGLKfQ=
github.com/edgexfoundry/go-mod-messaging/v3 v3.0.0-dev.4 h1:swPZOjoQ/IUIWSJpZCmQENtP/plFRx5tgiCEZgnfxFU=
github.com/edgexfoundry/go-mod-messaging/v3 v3.0.0-dev.4/go.mod h1:8pxuYvh2zcq1GuKqmk1MAuH1yuN40iOMmL0g2myIfwk=
github.com/edgexfoundry/go-mod-registry/v3 v3.0.0-dev.3 h1:QgZF9f70Cwpvkjw3tP1aiVGHc+yNFJNzW6hO8pDs3fg=
github.com/edgexfoundry/go-mod-registry/v3 v3.0.0-dev.3/go.mod h1:2w8v0sv+i21nY+DY6JV4PFxsNTuxpGAjlNFlFMTfZkk=
github.com/edgexfoundry/go-mod-secrets/v3 v3.0.0-dev.1 h1:dib+mZUuHqwVHt9pKAWC4lh60Fbc+6vKrD919LaknwI=
Expand Down
4 changes: 2 additions & 2 deletions internal/controller/http/command.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,12 @@ func (c *RestController) GetCommand(w http.ResponseWriter, r *http.Request) {
}

// push event to CoreData if specified (default no)
if ok, exist := reserved[common.PushEvent]; exist && ok[0] == common.ValueYes {
if ok, exist := reserved[common.PushEvent]; exist && ok[0] == common.ValueTrue {
go sdkCommon.SendEvent(event, correlationId, c.dic)
}

// return event in http response if specified (default yes)
if ok, exist := reserved[common.ReturnEvent]; !exist || ok[0] == common.ValueYes {
if ok, exist := reserved[common.ReturnEvent]; !exist || ok[0] == common.ValueTrue {
res := responses.NewEventResponse("", "", http.StatusOK, *event)
c.sendEventResponse(w, r, res, http.StatusOK)
return
Expand Down
2 changes: 1 addition & 1 deletion internal/controller/http/command_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,7 @@ func TestRestController_GetCommand_ReturnEvent(t *testing.T) {
require.NoError(t, err)

query := req.URL.Query()
query.Add("ds-returnevent", "no")
query.Add("ds-returnevent", common.ValueFalse)
req.URL.RawQuery = query.Encode()
// Act
recorder := httptest.NewRecorder()
Expand Down
4 changes: 2 additions & 2 deletions internal/controller/messaging/command.go
Original file line number Diff line number Diff line change
Expand Up @@ -216,11 +216,11 @@ func filterQueryParams(queries map[string]string) (string, bool, bool) {
var rawQuery []string
pushEvent, returnEvent := false, true
for k, v := range queries {
if k == common.PushEvent && v == common.ValueYes {
if k == common.PushEvent && v == common.ValueTrue {
pushEvent = true
continue
}
if k == common.ReturnEvent && v == common.ValueNo {
if k == common.ReturnEvent && v == common.ValueFalse {
returnEvent = false
continue
}
Expand Down
20 changes: 10 additions & 10 deletions openapi/v2/device-sdk.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1095,21 +1095,21 @@ paths:
schema:
type: string
enum:
- yes
- no
default: no
example: yes
description: "If set to yes, a successful GET will result in an event being pushed to the EdgeX system"
- true
- false
default: false
example: true
description: "If set to true, a successful GET will result in an event being pushed to the EdgeX system"
- in: query
name: ds-returnevent
schema:
type: string
enum:
- yes
- no
default: yes
example: no
description: "If set to no, there will be no Event returned in the http response"
- true
- false
default: true
example: false
description: "If set to false, there will be no Event returned in the http response"
responses:
'200':
description: String as returned by the device/sensor through the device service.
Expand Down

0 comments on commit 97d2a14

Please sign in to comment.