-
Notifications
You must be signed in to change notification settings - Fork 36
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Upgrade for compatibility with EdgeX Foundry 2.x (#9)
* feat: update device-opcua to EdgeX 2.0 Signed-off-by: Jeff Titus <[email protected]> * feat: Call OPCUA methods using device profile (#1) Allows defining `deviceResources` and `deviceCommands` to call methods defined in OPCUA. - Each method call is a read request - The `valueType` property should be the data type returned by the method - The `inputMap` attribute is of type `[]interface{}` - If the `method` attribute is present, the command will be treated as a method call Bump version to 2.0.1 Signed-off-by: Jeff Titus <[email protected]> * feat: port opcua variable subscription Variable reference is specified by device resource name as NodeID in the configuration. A subscribed variable will have its data written to EdgeX core when modified. Version bump to 2.0.2 Signed-off-by: Jeff Titus <[email protected]> * feat: subscribe and unsubscribe nodes using writable configuration support monitoring multiple variables bump version to 2.0.3 Signed-off-by: Jeff Titus <[email protected]> * refactor: organize code into logical files and add comments where necessary Signed-off-by: Jeff Titus <[email protected]> * test: add unit tests & minor refactoring Signed-off-by: Jeff Titus <[email protected]> * fix(driver): subscribe when device is added Subscription service was only being updated on configuration change and service restart. Adding the listener initialization to AddDevice guarantees the subscription takes effect on a clean start Signed-off-by: Jeff Titus <[email protected]> * test: use mock server from gopcua/opcua for read/write/method unit tests Signed-off-by: Jeff Titus <[email protected]> * build: remove extraneous replacements in go mod remove comments from launch json file Signed-off-by: Jeff Titus <[email protected]> * ci: add github related files Signed-off-by: Jeff Titus <[email protected]> * ci(test): produce and upload coverage Signed-off-by: Jeff Titus <[email protected]> * build: update to alpine 3.14 Signed-off-by: Jeff Titus <[email protected]> * fix(writehandler): correctly handle multiple resources in write command Signed-off-by: Jeff Titus <[email protected]> * docs: add and update copyright notices to source files Signed-off-by: Jeff Titus <[email protected]> * docs: add Attributions file and script Signed-off-by: Jeff Titus <[email protected]> * ci: rename test artifacts directory Signed-off-by: Jeff Titus <[email protected]> * chore: remove VERSION file Signed-off-by: Jeff Titus <[email protected]> * chore: ignore VERSION file Signed-off-by: Jeff Titus <[email protected]> * fix: update default configuration Signed-off-by: Jeff Titus <[email protected]> * chore: update edgex dependencies Signed-off-by: Jeff Titus <[email protected]> * refactor: resolve go-staticcheck issues Signed-off-by: Jeff Titus <[email protected]> * ci: remove workflow in favor of future edgex build Signed-off-by: Jeff Titus <[email protected]> * docs: add contribution doc to match other device repos Signed-off-by: Jeff Titus <[email protected]> * fix: prevent possible race conditions Signed-off-by: Jeff Titus <[email protected]> * refactor: remove unused variable Signed-off-by: Jeff Titus <[email protected]> * refactor: split functions for better lock mechanism Signed-off-by: Jeff Titus <[email protected]> * feat: support both string and numeric node ids - update README with server simulator info - remove methods from default device profile - add section about configuring methods to README Signed-off-by: Jeff Titus <[email protected]>
- Loading branch information
Showing
42 changed files
with
3,677 additions
and
825 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,6 +2,5 @@ | |
*.log | ||
cmd/device-opcua | ||
cmd/device-opcua-arm64 | ||
go.sum | ||
vendor | ||
.idea |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
# Contribution Guidelines | ||
|
||
## Commit Message Guidelines | ||
|
||
We have very precise rules over how our git commit messages can be formatted. This leads to **more readable messages** that are easy to follow when looking through the **project history**. For full contribution guidelines visit | ||
the [Contributors Guide](https://wiki.edgexfoundry.org/display/FA/Committing+Code+Guidelines#CommittingCodeGuidelines-Commits) on the EdgeX Wiki | ||
|
||
### Commit Message Format | ||
|
||
Each commit message consists of a **header**, a **body** and a **footer**. The header has a special format that includes a **type**, a **scope** and a **subject**: | ||
|
||
```text | ||
<type>(<scope>): <subject> | ||
<BLANK LINE> | ||
<body> | ||
<BLANK LINE> | ||
<footer> | ||
``` | ||
|
||
The **header** with **type** is mandatory. The **scope** of the header is optional as far as the automated PR checks are concerned, but be advised that PR reviewers **may request** you provide an applicable scope. | ||
|
||
Any line of the commit message cannot be longer 100 characters! This allows the message to be easier to read on GitHub as well as in various git tools. | ||
|
||
The footer should contain a [closing reference to an issue](https://help.github.com/articles/closing-issues-via-commit-messages/) if any. | ||
|
||
Example 1: | ||
|
||
```text | ||
build(deploy): add K3s deployment example | ||
``` | ||
|
||
```text | ||
fix(app): correct app service configurable logging | ||
Previously remote logging failed due to improper initialization of the logging client. This commit fixes the initialization to properly support remote logging. | ||
Closes: #123 | ||
``` | ||
|
||
### Revert | ||
|
||
If the commit reverts a previous commit, it should begin with `revert:`, followed by the header of the reverted commit. In the body it should say: `This reverts commit <hash>.`, where the hash is the SHA of the commit being reverted. | ||
|
||
### Type | ||
|
||
Must be one of the following: | ||
|
||
- **feat**: A new feature | ||
- **fix**: A bug fix | ||
- **docs**: Documentation only changes | ||
- **style**: Changes that do not affect the meaning of the code (white-space, formatting, etc) | ||
- **refactor**: A code change that neither fixes a bug nor adds a feature | ||
- **perf**: A code change that improves performance | ||
- **test**: Adding missing tests or correcting existing tests | ||
- **build**: Changes that affect the CI/CD pipeline or build system or external dependencies (example scopes: travis, jenkins, makefile) | ||
- **ci**: Changes provided by DevOps for CI purposes. | ||
- **revert**: Reverts a previous commit. | ||
|
||
### Subject | ||
|
||
The subject contains a succinct description of the change: | ||
|
||
- use the imperative, present tense: "change" not "changed" nor "changes" | ||
- don't capitalize the first letter | ||
- no dot (.) at the end | ||
|
||
### Body | ||
|
||
Just as in the **subject**, use the imperative, present tense: "change" not "changed" nor "changes". | ||
The body should include the motivation for the change and contrast this with previous behavior. | ||
|
||
### Footer | ||
|
||
The footer should contain any information about **Breaking Changes** and is also the place to | ||
reference GitHub issues that this commit **Closes**. | ||
|
||
**Breaking Changes** should start with the word `BREAKING CHANGE:` with a space or two newlines. The rest of the commit message is then used for this. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
<!-- Expected Commit Message Description (imported automatically by GitHub) --> | ||
<!-- Must conform to [conventional commits guidelines](https://github.com/edgexfoundry/device-sdk-go/blob/main/.github/Contributing.md) --> | ||
<!-- Expected Commit message must contain Closes/Fixes #IssueNumber statement when there is a related issue --> | ||
|
||
<!-- Add additional detailed description of need for change if no related issue --> | ||
|
||
# PR Checklist | ||
|
||
> **If your build fails** due to your commit message not passing the build checks, please review the guidelines [here](https://github.com/edgexfoundry/device-sdk-go/blob/main/.github/Contributing.md). | ||
Please check if your PR fulfills the following requirements: | ||
|
||
- [ ] I am not introducing a breaking change (if you are, flag in conventional commit message with `BREAKING CHANGE:` describing the break) | ||
- [ ] I am not introducing a new dependency (add notes below if you are) | ||
- [ ] I have added unit tests for the new feature or bug fix (if not, why?) | ||
- [ ] I have fully tested (add details below) this the new feature or bug fix (if not, why?) | ||
- [ ] I have opened a PR for the related docs change (if not, why?) | ||
<!-- link to docs PR --> | ||
|
||
## Testing Instructions | ||
|
||
<!-- How can the reviewers test your change? --> | ||
|
||
## New Dependency Instructions (If applicable) | ||
|
||
<!-- Please follow [vetting instructions](https://wiki.edgexfoundry.org/display/FA/Vetting+Process+for+3rd+Party+Dependencies) and place results here --> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
version: 2 | ||
updates: | ||
|
||
# Maintain dependencies for GitHub Actions | ||
- package-ecosystem: "gomod" | ||
directory: "/" | ||
schedule: | ||
interval: "weekly" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
allowMergeCommits: true | ||
# Always validate the PR title AND all the commits | ||
titleAndCommits: true | ||
types: | ||
- feat | ||
- fix | ||
- docs | ||
- style | ||
- refactor | ||
- perf | ||
- test | ||
- build | ||
- ci | ||
- revert |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,6 +2,7 @@ | |
*.log | ||
cmd/device-opcua | ||
cmd/device-opcua-arm64 | ||
go.sum | ||
vendor | ||
.idea | ||
test-artifacts | ||
VERSION |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
{ | ||
"version": "0.2.0", | ||
"configurations": [ | ||
{ | ||
"name": "Launch Package", | ||
"type": "go", | ||
"request": "launch", | ||
"mode": "debug", | ||
"port": 2345, | ||
"host": "127.0.0.1", | ||
"program": "${fileDirname}", | ||
"showLog": true | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,165 @@ | ||
bitbucket.org/bertimus9/systemstat (MIT) https://bitbucket.org/bertimus9/systemstat | ||
https://bitbucket.org/bertimus9/systemstat/src/master/LICENSE | ||
|
||
github.com/OneOfOne/xxhash (Apache 2.0) https://github.com/OneOfOne/xxhash | ||
https://github.com/OneOfOne/xxhash/blob/master/LICENSE | ||
|
||
github.com/armon/go-metrics (MIT) https://github.com/armon/go-metrics | ||
https://github.com/armon/go-metrics/blob/master/LICENSE | ||
|
||
github.com/cenkalti/backoff (MIT) https://github.com/cenkalti/backoff | ||
https://github.com/cenkalti/backoff/blob/master/LICENSE | ||
|
||
github.com/davecgh/go-spew (ISC) https://github.com/davecgh/go-spew | ||
https://github.com/davecgh/go-spew/blob/master/LICENSE | ||
|
||
github.com/eclipse/paho.mqtt.golang (EPL 2.0) https://github.com/eclipse/paho.mqtt.golang | ||
https://github.com/eclipse/paho.mqtt.golang/blob/master/LICENSE | ||
|
||
github.com/edgexfoundry/device-sdk-go/v2 (Apache 2.0) https://github.com/edgexfoundry/device-sdk-go/v2 | ||
https://github.com/edgexfoundry/device-sdk-go/v2/blob/master/LICENSE | ||
|
||
github.com/edgexfoundry/go-mod-bootstrap/v2 (Apache 2.0) https://github.com/edgexfoundry/go-mod-bootstrap/v2 | ||
https://github.com/edgexfoundry/go-mod-bootstrap/v2/blob/master/LICENSE | ||
|
||
github.com/edgexfoundry/go-mod-configuration/v2 (Apache 2.0) https://github.com/edgexfoundry/go-mod-configuration/v2 | ||
https://github.com/edgexfoundry/go-mod-configuration/v2/blob/master/LICENSE | ||
|
||
github.com/edgexfoundry/go-mod-core-contracts/v2 (Apache 2.0) https://github.com/edgexfoundry/go-mod-core-contracts/v2 | ||
https://github.com/edgexfoundry/go-mod-core-contracts/v2/blob/master/LICENSE | ||
|
||
github.com/edgexfoundry/go-mod-messaging/v2 (Apache 2.0) https://github.com/edgexfoundry/go-mod-messaging/v2 | ||
https://github.com/edgexfoundry/go-mod-messaging/v2/blob/master/LICENSE | ||
|
||
github.com/edgexfoundry/go-mod-registry/v2 (Apache 2.0) https://github.com/edgexfoundry/go-mod-registry/v2 | ||
https://github.com/edgexfoundry/go-mod-registry/v2/blob/master/LICENSE | ||
|
||
github.com/edgexfoundry/go-mod-secrets/v2 (Apache 2.0) https://github.com/edgexfoundry/go-mod-secrets/v2 | ||
https://github.com/edgexfoundry/go-mod-secrets/v2/blob/master/LICENSE | ||
|
||
github.com/fatih/color (MIT) https://github.com/fatih/color | ||
https://github.com/fatih/color/blob/master/LICENSE.md | ||
|
||
github.com/fxamacker/cbor/v2 (MIT) https://github.com/fxamacker/cbor | ||
https://github.com/fxamacker/cbor/blob/master/LICENSE | ||
|
||
github.com/go-kit/kit (MIT) https://github.com/go-kit/kit | ||
https://github.com/go-kit/kit/blob/master/LICENSE | ||
|
||
github.com/go-logfmt/logfmt (MIT) https://github.com/go-logfmt/logfmt | ||
https://github.com/go-logfmt/logfmt/blob/master/LICENSE | ||
|
||
github.com/go-playground/locales (MIT) https://github.com/go-playground/locales | ||
https://github.com/go-playground/locales/blob/master/LICENSE | ||
|
||
github.com/go-playground/universal-translator (MIT) https://github.com/go-playground/universal-translator | ||
https://github.com/go-playground/universal-translator/blob/master/LICENSE | ||
|
||
github.com/go-playground/validator/v10 (MIT) https://github.com/go-playground/validator | ||
https://github.com/go-playground/validator/blob/master/LICENSE | ||
|
||
github.com/go-redis/redis/v7 (BSD-2) https://github.com/go-redis/redis/v7 | ||
https://github.com/go-redis/redis/blob/master/LICENSE | ||
|
||
github.com/go-stack/stack (MIT) https://github.com/go-stack/stack | ||
https://github.com/go-stack/stack/blob/master/LICENSE.md | ||
|
||
github.com/google/uuid (BSD-3) https://github.com/google/uuid | ||
https://github.com/google/uuid/blob/master/LICENSE | ||
|
||
github.com/gopcua/opcua (MIT) https://github.com/gopcua/opcua | ||
https://github.com/gopcua/opcua/blob/master/LICENSE | ||
|
||
github.com/gorilla/mux (BSD-3) https://github.com/gorilla/mux | ||
https://github.com/gorilla/mux/blob/master/LICENSE | ||
|
||
github.com/gorilla/websocket (BSD-2) https://github.com/gorilla/websocket | ||
https://github.com/gorilla/websocket/blob/master/LICENSE | ||
|
||
github.com/hashicorp/consul/api (MPL 2.0) https://github.com/hashicorp/consul | ||
https://github.com/hashicorp/consul/blob/master/LICENSE | ||
|
||
github.com/hashicorp/go-cleanhttp (MPL 2.0) https://github.com/hashicorp/go-cleanhttp | ||
https://github.com/hashicorp/go-cleanhttp/blob/master/LICENSE | ||
|
||
github.com/hashicorp/go-hclog (MIT) https://github.com/hashicorp/go-hclog | ||
https://github.com/hashicorp/go-hclog/blob/master/LICENSE | ||
|
||
github.com/hashicorp/go-immutable-radix (MPL 2.0) https://github.com/hashicorp/go-immutable-radix | ||
https://github.com/hashicorp/go-immutable-radix/blob/master/LICENSE | ||
|
||
github.com/hashicorp/go-rootcerts (MPL 2.0) https://github.com/hashicorp/go-rootcerts | ||
https://github.com/hashicorp/go-rootcerts/blob/master/LICENSE | ||
|
||
github.com/hashicorp/golang-lru (MPL 2.0) https://github.com/hashicorp/golang-lru | ||
https://github.com/hashicorp/golang-lru/blob/master/LICENSE | ||
|
||
github.com/hashicorp/serf (MPL 2.0) https://github.com/hashicorp/serf | ||
https://github.com/hashicorp/serf/blob/master/LICENSE | ||
|
||
github.com/kr/logfmt (MIT) https://github.com/kr/logfmt | ||
https://github.com/kr/logfmt/blob/main/LICENSE | ||
|
||
github.com/leodido/go-urn (MIT) https://github.com/leodido/go-urn | ||
https://github.com/leodido/go-urn/blob/master/LICENSE | ||
|
||
github.com/mattn/go-colorable (MIT) https://github.com/mattn/go-colorable | ||
https://github.com/mattn/go-colorable/blob/master/LICENSE | ||
|
||
github.com/mattn/go-isatty (MIT) https://github.com/mattn/go-isatty | ||
https://github.com/mattn/go-isatty/blob/master/LICENSE | ||
|
||
github.com/mitchellh/consulstructure (MIT) https://github.com/mitchellh/consulstructure | ||
https://github.com/mitchellh/consulstructure/blob/master/LICENSE | ||
|
||
github.com/mitchellh/copystructure (MIT) https://github.com/mitchellh/copystructure | ||
https://github.com/mitchellh/copystructure/blob/master/LICENSE | ||
|
||
github.com/mitchellh/go-homedir (MIT) https://github.com/mitchellh/go-homedir | ||
https://github.com/mitchellh/go-homedir/blob/master/LICENSE | ||
|
||
github.com/mitchellh/mapstructure (MIT) https://github.com/mitchellh/mapstructure | ||
https://github.com/mitchellh/mapstructure/blob/master/LICENSE | ||
|
||
github.com/mitchellh/reflectwalk (MIT) https://github.com/mitchellh/reflectwalk | ||
https://github.com/mitchellh/reflectwalk/blob/master/LICENSE | ||
|
||
github.com/pebbe/zmq4 (BSD-2) https://github.com/pebbe/zmq4 | ||
https://github.com/pebbe/zmq4/blob/master/LICENSE.txt | ||
|
||
github.com/pelletier/go-toml (MIT) https://github.com/pelletier/go-toml | ||
https://github.com/pelletier/go-toml/blob/master/LICENSE | ||
|
||
github.com/pkg/errors (BSD-2) https://github.com/pkg/errors | ||
https://github.com/pkg/errors/blob/master/LICENSE | ||
|
||
github.com/pmezard/go-difflib (MIT) https://github.com/pmezard/go-difflib | ||
https://github.com/pmezard/go-difflib/blob/master/LICENSE | ||
|
||
github.com/spf13/cast (MIT) https://github.com/spf13/cast | ||
https://github.com/spf13/cast/blob/master/LICENSE | ||
|
||
github.com/stretchr/testify (MIT) https://github.com/stretchr/testify | ||
https://github.com/stretchr/testify/blob/master/LICENSE | ||
|
||
github.com/x448/float16 (MIT) https://github.com/x448/float16 | ||
https://github.com/x448/float16/blob/master/LICENSE | ||
|
||
golang.org/x/crypto (Unspecified) https://github.com/golang/crypto | ||
https://github.com/golang/crypto/blob/master/LICENSE | ||
|
||
golang.org/x/net (Unspecified) https://github.com/golang/net | ||
https://github.com/golang/net/blob/master/LICENSE | ||
|
||
golang.org/x/sys (Unspecified) https://github.com/golang/sys | ||
https://github.com/golang/sys/blob/master/LICENSE | ||
|
||
golang.org/x/text (Unspecified) https://github.com/golang/text | ||
https://github.com/golang/text/blob/master/LICENSE | ||
|
||
gopkg.in/yaml.v2 (MIT) https://github.com/gopkg.in/yaml.v2 | ||
https://github.com/go-yaml/yaml/blob/v2/master/LICENSE | ||
|
||
gopkg.in/yaml.v3 (Unspecified) https://github.com/gopkg.in/yaml.v3 | ||
https://github.com/gopkg.in/yaml.v3/blob/master/LICENSE | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,31 @@ | ||
# | ||
# Copyright (c) 2018, 2019 Intel | ||
# Copyright (c) 2021 Schneider Electric | ||
# | ||
# SPDX-License-Identifier: Apache-2.0 | ||
# | ||
FROM golang:1.11-alpine AS builder | ||
WORKDIR /go/src/github.com/edgexfoundry/device-opcua-go | ||
|
||
# Replicate the APK repository override. | ||
RUN sed -e 's/dl-cdn[.]alpinelinux.org/mirrors.ustc.edu.cn/g' -i~ /etc/apk/repositories | ||
FROM golang:1.16-alpine3.14 AS builder | ||
WORKDIR /device-opcua-go | ||
|
||
# Install our build time packages. | ||
RUN apk update && apk add make git | ||
RUN apk update && apk add --no-cache make git zeromq-dev gcc pkgconfig musl-dev | ||
|
||
COPY . . | ||
|
||
RUN make build | ||
|
||
# Next image - Copy built Go binary into new workspace | ||
FROM scratch | ||
FROM alpine:3.14 | ||
|
||
# dumb-init needed for injected secure bootstrapping entrypoint script when run in secure mode. | ||
RUN apk add --update --no-cache zeromq dumb-init | ||
|
||
# expose command data port | ||
EXPOSE 49997 | ||
EXPOSE 59997 | ||
|
||
COPY --from=builder /go/src/github.com/edgexfoundry/device-opcua-go/cmd/device-opcua / | ||
COPY --from=builder /go/src/github.com/edgexfoundry/device-opcua-go/cmd/res/docker/configuration.toml /res/docker/configuration.toml | ||
COPY --from=builder /device-opcua-go/cmd/device-opcua / | ||
COPY --from=builder /device-opcua-go/cmd/res /res | ||
COPY LICENSE / | ||
|
||
CMD ["/device-opcua", "--profile=docker", "--confdir=/res"] | ||
ENTRYPOINT ["/device-opcua"] | ||
CMD ["--cp=consul://edgex-core-consul:8500", "--registry", "--confdir=/res"] |
File renamed without changes.
Oops, something went wrong.