Skip to content
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

refactor!: Changed configuration and simple-devices files format to YAML #281

Merged
merged 2 commits into from
Mar 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions Attribution.txt
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,6 @@ https://github.com/mitchellh/mapstructure/blob/master/LICENSE
mitchellh/reflectwalk (MIT) https://github.com/mitchellh/reflectwalk
https://github.com/mitchellh/reflectwalk/blob/master/LICENSE

pelletier/go-toml (MIT) https://github.com/pelletier/go-toml
https://github.com/pelletier/go-toml/blob/master/LICENSE

pmezard/go-difflib (Unspecified) https://github.com/pmezard/go-difflib
https://github.com/pmezard/go-difflib/blob/master/LICENSE

Expand Down
81 changes: 45 additions & 36 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,42 +72,51 @@ 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

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
31 changes: 15 additions & 16 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.61
github.com/edgexfoundry/go-mod-core-contracts/v3 v3.0.0-dev.34
github.com/gorilla/mux v1.8.0
github.com/spf13/cast v1.5.0
github.com/stretchr/testify v1.8.2
Expand All @@ -17,23 +17,23 @@ 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.56 // indirect
github.com/edgexfoundry/go-mod-configuration/v3 v3.0.0-dev.10 // 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
github.com/go-logfmt/logfmt v0.5.1 // indirect
github.com/go-playground/locales v0.14.1 // indirect
github.com/go-playground/universal-translator v0.18.1 // indirect
github.com/go-playground/validator/v10 v10.11.2 // indirect
github.com/go-playground/validator/v10 v10.12.0 // indirect
github.com/go-redis/redis/v7 v7.3.0 // indirect
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 All @@ -42,7 +42,7 @@ require (
github.com/hashicorp/go-rootcerts v1.0.2 // indirect
github.com/hashicorp/golang-lru v0.5.4 // indirect
github.com/hashicorp/serf v0.10.1 // indirect
github.com/leodido/go-urn v1.2.1 // indirect
github.com/leodido/go-urn v1.2.2 // indirect
github.com/mattn/go-colorable v0.1.12 // indirect
github.com/mattn/go-isatty v0.0.14 // indirect
github.com/mitchellh/consulstructure v0.0.0-20190329231841-56fdc4d2da54 // indirect
Expand All @@ -53,20 +53,19 @@ require (
github.com/nats-io/nats.go v1.24.0 // indirect
github.com/nats-io/nkeys v0.3.0 // indirect
github.com/nats-io/nuid v1.0.1 // indirect
github.com/pelletier/go-toml v1.9.5 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/rcrowley/go-metrics v0.0.0-20201227073835-cf1acfcdf475 // indirect
github.com/spiffe/go-spiffe/v2 v2.1.2 // indirect
github.com/stretchr/objx v0.5.0 // indirect
github.com/x448/float16 v0.8.4 // indirect
github.com/zeebo/errs v1.3.0 // indirect
golang.org/x/crypto v0.6.0 // indirect
golang.org/x/mod v0.7.0 // indirect
golang.org/x/net v0.7.0 // indirect
golang.org/x/crypto v0.7.0 // indirect
golang.org/x/mod v0.8.0 // indirect
golang.org/x/net v0.8.0 // indirect
golang.org/x/sync v0.1.0 // indirect
golang.org/x/sys v0.5.0 // indirect
golang.org/x/text v0.7.0 // indirect
golang.org/x/tools v0.5.0 // indirect
golang.org/x/sys v0.6.0 // indirect
golang.org/x/text v0.8.0 // indirect
golang.org/x/tools v0.6.0 // indirect
google.golang.org/genproto v0.0.0-20230109162033-3c3c17ce83e6 // indirect
google.golang.org/grpc v1.51.0 // indirect
google.golang.org/protobuf v1.28.1 // indirect
Expand Down
Loading