Skip to content

Commit

Permalink
refactor!: Changed configuration and simple-devices files format to YAML
Browse files Browse the repository at this point in the history
BREAKING CHANGE: Configuration and sample-devices files are now in YAML format

closes issue edgexfoundry#280

Signed-off-by: Valina Li <[email protected]>
  • Loading branch information
vli11 committed Mar 24, 2023
1 parent 5399131 commit 7eafca4
Show file tree
Hide file tree
Showing 8 changed files with 133 additions and 110 deletions.
80 changes: 44 additions & 36 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,42 +72,50 @@ This device service use the standard configuration defined by the **Device SDK**

The `DeviceList` configuration is standard except that it is mandatory to provide end device parameters in the `DeviceList.Protocols.EndDevice_Params` structure for 2way-rest-device functionality. The following is a sample `DeviceList` that works with the sample device profiles referenced below. `path` parameter is optional.

```toml
[[DeviceList]]
Name = "sample-json"
ProfileName = "sample-json"
Description = "RESTful Device that sends in JSON data"
Labels = [ "rest", "json" ]
[DeviceList.Protocols]
[DeviceList.Protocols.other]
[[DeviceList]]
Name = "sample-image"
ProfileName = "sample-image"
Description = "RESTful Device that sends in binary image data"
Labels = [ "rest", "binary", "image" ]
[DeviceList.Protocols]
[DeviceList.Protocols.other]
[[DeviceList]]
Name = "sample-numeric"
ProfileName = "sample-numeric"
Description = "RESTful Device that sends in numeric data"
Labels = [ "rest", "numeric", "float", "int" ]
[DeviceList.Protocols]
[DeviceList.Protocols.other]
[[DeviceList]]
Name = "2way-rest-device"
ProfileName = "sample-2way-rest-device"
Description = "RESTful Device that sends data"
Labels = [ "rest", "2way-rest-device" ]
[DeviceList.Protocols]
[DeviceList.Protocols.REST]
Host = "127.0.0.1"
Port = "5000"
Path = "api"
[[DeviceList.AutoEvents]]
Interval = "20s"
OnChange = false
SourceName = "json"
```yaml
DeviceList:
- Name: sample-json
ProfileName: sample-json
Description: RESTful Device that sends in JSON data
Labels:
- rest
- json
Protocols:
other: {}
- Name: sample-image
ProfileName: sample-image
Description: RESTful Device that sends in binary image data
Labels:
- rest
- binary
- image
Protocols:
other: {}
- Name: sample-numeric
ProfileName: sample-numeric
Description: RESTful Device that sends in numeric data
Labels:
- rest
- numeric
- float
- int
Protocols:
other: {}
- Name: 2way-rest-device
ProfileName: sample-2way-rest-device
Description: RESTful Device that sends data
Labels:
- rest
- 2way-rest-device
Protocols:
REST:
Host: 127.0.0.1
Port: '5000'
Path: api
AutoEvents:
- Interval: 20s
OnChange: false
SourceName: json
```
## Device Profile
Expand Down
16 changes: 0 additions & 16 deletions cmd/res/configuration.toml

This file was deleted.

23 changes: 23 additions & 0 deletions cmd/res/configuration.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
MaxEventSize: 0 # value 0 unlimit the maximum event size that can be sent to message bus or core-data

Writable:
LogLevel: INFO

# # uncomment when running from command-line in hybrid mode with -cp -o flags
# Registry:
# Host: localhost

# Clients:
# core-metadata:
# Host: localhost # uncomment when running from command-line in hybrid mode

Service:
Host: localhost
Port: 59986
StartupMsg: device rest started

MessageBus:
# Host: localhost # uncomment when running from command-line in hybrid mode
Optional:
ClientId: device-rest
Driver: {}
36 changes: 0 additions & 36 deletions cmd/res/devices/sample-devices.toml

This file was deleted.

44 changes: 44 additions & 0 deletions cmd/res/devices/sample-devices.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# Pre-define Devices
DeviceList:
- Name: sample-json
ProfileName: sample-json
Description: RESTful Device that sends in JSON data
Labels:
- rest
- json
Protocols:
other: {}
- Name: sample-image
ProfileName: sample-image
Description: RESTful Device that sends in binary image data
Labels:
- rest
- binary
- image
Protocols:
other: {}
- Name: sample-numeric
ProfileName: sample-numeric
Description: RESTful Device that sends in numeric data
Labels:
- rest
- numeric
- float
- int
Protocols:
other: {}
- Name: 2way-rest-device
ProfileName: sample-2way-rest-device
Description: RESTful Device that sends data
Labels:
- rest
- 2way-rest-device
Protocols:
REST:
Host: 127.0.0.1
Port: '5000'
Path: api
# AutoEvents:
# - Interval: 20s
# OnChange: false
# SourceName: int8
14 changes: 7 additions & 7 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ module github.com/edgexfoundry/device-rest-go
go 1.20

require (
github.com/edgexfoundry/device-sdk-go/v3 v3.0.0-dev.54
github.com/edgexfoundry/go-mod-core-contracts/v3 v3.0.0-dev.28
github.com/edgexfoundry/device-sdk-go/v3 v3.0.0-dev.57
github.com/edgexfoundry/go-mod-core-contracts/v3 v3.0.0-dev.30
github.com/gorilla/mux v1.8.0
github.com/spf13/cast v1.5.0
github.com/stretchr/testify v1.8.2
Expand All @@ -17,11 +17,11 @@ require (
github.com/cenkalti/backoff v2.2.1+incompatible // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/eclipse/paho.mqtt.golang v1.4.2 // indirect
github.com/edgexfoundry/go-mod-bootstrap/v3 v3.0.0-dev.47 // indirect
github.com/edgexfoundry/go-mod-configuration/v3 v3.0.0-dev.7 // indirect
github.com/edgexfoundry/go-mod-bootstrap/v3 v3.0.0-dev.54 // indirect
github.com/edgexfoundry/go-mod-configuration/v3 v3.0.0-dev.9 // indirect
github.com/edgexfoundry/go-mod-messaging/v3 v3.0.0-dev.18 // indirect
github.com/edgexfoundry/go-mod-registry/v3 v3.0.0-dev.5 // indirect
github.com/edgexfoundry/go-mod-secrets/v3 v3.0.0-dev.9 // indirect
github.com/edgexfoundry/go-mod-registry/v3 v3.0.0-dev.7 // indirect
github.com/edgexfoundry/go-mod-secrets/v3 v3.0.0-dev.10 // indirect
github.com/fatih/color v1.9.0 // indirect
github.com/fxamacker/cbor/v2 v2.4.0 // indirect
github.com/go-kit/log v0.2.1 // indirect
Expand All @@ -33,7 +33,7 @@ require (
github.com/golang/protobuf v1.5.2 // indirect
github.com/google/uuid v1.3.0 // indirect
github.com/gorilla/websocket v1.4.2 // indirect
github.com/hashicorp/consul/api v1.19.1 // indirect
github.com/hashicorp/consul/api v1.20.0 // indirect
github.com/hashicorp/errwrap v1.0.0 // indirect
github.com/hashicorp/go-cleanhttp v0.5.1 // indirect
github.com/hashicorp/go-hclog v0.14.1 // indirect
Expand Down
28 changes: 14 additions & 14 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -27,20 +27,20 @@ github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/eclipse/paho.mqtt.golang v1.4.2 h1:66wOzfUHSSI1zamx7jR6yMEI5EuHnT1G6rNA5PM12m4=
github.com/eclipse/paho.mqtt.golang v1.4.2/go.mod h1:JGt0RsEwEX+Xa/agj90YJ9d9DH2b7upDZMK9HRbFvCA=
github.com/edgexfoundry/device-sdk-go/v3 v3.0.0-dev.54 h1:v0agM9yGlu1036LQXzC0ImOah2zLaaUoho6ngdU2O3I=
github.com/edgexfoundry/device-sdk-go/v3 v3.0.0-dev.54/go.mod h1:GtXMlc0G7aXEXWhbW+7YwO9F1KA1qFRODhzfWFSWhoU=
github.com/edgexfoundry/go-mod-bootstrap/v3 v3.0.0-dev.47 h1:KG2CAxu1BKwvT8vMONZC2bTUqJuwRY49XyUISAgjdfQ=
github.com/edgexfoundry/go-mod-bootstrap/v3 v3.0.0-dev.47/go.mod h1:W26ejUzaSRzq/b/8oIdB8hKve4xW55XbCkfj8pvQNfE=
github.com/edgexfoundry/go-mod-configuration/v3 v3.0.0-dev.7 h1:pOH2GLDg1KB4EmAzo6IEvl4NEVFAw3ywxPUMa5Wi1Vw=
github.com/edgexfoundry/go-mod-configuration/v3 v3.0.0-dev.7/go.mod h1:ZZbOu7K0/P8B1VKhZygVujLQyhvWuPe0E2vC/k2yscw=
github.com/edgexfoundry/go-mod-core-contracts/v3 v3.0.0-dev.28 h1:aNHlmF2uPcwUr7VKvNVJXdxMDaI41j2laoGxZy5H95g=
github.com/edgexfoundry/go-mod-core-contracts/v3 v3.0.0-dev.28/go.mod h1:SYoD+tmUP/zwWuuIySmsQSjPx6MHP+2w9FsLgm0IR7A=
github.com/edgexfoundry/device-sdk-go/v3 v3.0.0-dev.57 h1:MnQOhkZUrhJa4eIG0vzElsj9iOeqUKSDkHDFueLmROM=
github.com/edgexfoundry/device-sdk-go/v3 v3.0.0-dev.57/go.mod h1:oDZw7N1L0HeG7GF6btSFUj9mFQXDrMahlnbiZsjYXFM=
github.com/edgexfoundry/go-mod-bootstrap/v3 v3.0.0-dev.54 h1:zbM6LjlXgnvZ1d1WZUiF9GClDaRHawRvN9gGKwSTD1w=
github.com/edgexfoundry/go-mod-bootstrap/v3 v3.0.0-dev.54/go.mod h1:aKaljiCzEaRb+QO/LP7gyRSrhXs1YVsh02kagZlmi80=
github.com/edgexfoundry/go-mod-configuration/v3 v3.0.0-dev.9 h1:DznnG2F4E+9jHAA+iXsaDaQxYJ+oWS3SddvvdEfQayE=
github.com/edgexfoundry/go-mod-configuration/v3 v3.0.0-dev.9/go.mod h1:ljWfa029h+677rS+khaXWR+8Hv8965UfbMjaxZ4C9QI=
github.com/edgexfoundry/go-mod-core-contracts/v3 v3.0.0-dev.30 h1:diarfNbfUeSYD7Hq8pOqHzxMtIbaPO6W8nWq34W8X6g=
github.com/edgexfoundry/go-mod-core-contracts/v3 v3.0.0-dev.30/go.mod h1:SYoD+tmUP/zwWuuIySmsQSjPx6MHP+2w9FsLgm0IR7A=
github.com/edgexfoundry/go-mod-messaging/v3 v3.0.0-dev.18 h1:8empqTOIVhKzebC3gnP9C0LGQvwXtHLJF8x8AqlTGLM=
github.com/edgexfoundry/go-mod-messaging/v3 v3.0.0-dev.18/go.mod h1:Sf7lvKtICWRy0Tmvw+bV6L1wdXKRaTSmKmJKw4Caxe4=
github.com/edgexfoundry/go-mod-registry/v3 v3.0.0-dev.5 h1:FUUfsQUKHJqSwOXEj0j/qAn+uoWzM8nV7IOapGf7D80=
github.com/edgexfoundry/go-mod-registry/v3 v3.0.0-dev.5/go.mod h1:MroNeX/i6ymRu8cyuRB4U5zdBusyUpFhUphko6pInTQ=
github.com/edgexfoundry/go-mod-secrets/v3 v3.0.0-dev.9 h1:12UHZG/Nl+dfFOaNnC87ANP/FQ3rOXe0Z6NVlYdmYgU=
github.com/edgexfoundry/go-mod-secrets/v3 v3.0.0-dev.9/go.mod h1:tjny0Y2/sLTB9qx3pjvT9PfGHpEOdfej7pjV3s1zppk=
github.com/edgexfoundry/go-mod-registry/v3 v3.0.0-dev.7 h1:sje0agoLi8ayEFxGO3xtN7P/IXwjZUUxpC8G2fCTu44=
github.com/edgexfoundry/go-mod-registry/v3 v3.0.0-dev.7/go.mod h1:SGyo4fAHzOhDAd2Usa9RaBT/sOzkbceIqLrDG0+iYy8=
github.com/edgexfoundry/go-mod-secrets/v3 v3.0.0-dev.10 h1:NJ5figB8O6vK44YA8LvuAywbY1BwC/5Kf7ZKc+1ItAU=
github.com/edgexfoundry/go-mod-secrets/v3 v3.0.0-dev.10/go.mod h1:8hvfJ8L3mWTEXx3aEleGkh2U80jxfXzfSupDEQEqBjA=
github.com/fatih/color v1.7.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5KwzbycvMj4=
github.com/fatih/color v1.9.0 h1:8xPHl4/q1VyqGIPif1F+1V3Y3lSmrq01EabUW3CoW5s=
github.com/fatih/color v1.9.0/go.mod h1:eQcE1qtQxscV5RaZvpXrrb8Drkc3/DdQ+uUYCNjL+zU=
Expand Down Expand Up @@ -86,8 +86,8 @@ github.com/gorilla/mux v1.8.0 h1:i40aqfkR1h2SlN9hojwV5ZA91wcXFOvkdNIeFDP5koI=
github.com/gorilla/mux v1.8.0/go.mod h1:DVbg23sWSpFRCP0SfiEN6jmj59UnW/n46BH5rLB71So=
github.com/gorilla/websocket v1.4.2 h1:+/TMaTYc4QFitKJxsQ7Yye35DkWvkdLcvGKqM+x0Ufc=
github.com/gorilla/websocket v1.4.2/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE=
github.com/hashicorp/consul/api v1.19.1 h1:GLeK1WD4VIRvt4wRhQKHFudztEkRb8pDs+uRiJgNwes=
github.com/hashicorp/consul/api v1.19.1/go.mod h1:jAt316eYgWGNLJtxkMQrcqRpuDE/kFJdqkEFwRXFv8U=
github.com/hashicorp/consul/api v1.20.0 h1:9IHTjNVSZ7MIwjlW3N3a7iGiykCMDpxZu8jsxFJh0yc=
github.com/hashicorp/consul/api v1.20.0/go.mod h1:nR64eD44KQ59Of/ECwt2vUmIK2DKsDzAwTmwmLl8Wpo=
github.com/hashicorp/consul/sdk v0.13.1 h1:EygWVWWMczTzXGpO93awkHFzfUka6hLYJ0qhETd+6lY=
github.com/hashicorp/errwrap v1.0.0 h1:hLrqtEDnRye3+sgx6z4qVLNuviH3MR5aQ0ykNJa/UYA=
github.com/hashicorp/errwrap v1.0.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brvKWEqk/Jc4=
Expand Down
2 changes: 1 addition & 1 deletion snap/snapcraft.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ parts:
RES=$SNAPCRAFT_PART_INSTALL/config/device-rest/res/
mkdir -p $RES
cp cmd/res/configuration.toml $RES
cp cmd/res/configuration.yaml $RES
cp -r cmd/res/devices $RES
cp -r cmd/res/profiles $RES
Expand Down

0 comments on commit 7eafca4

Please sign in to comment.