-
Notifications
You must be signed in to change notification settings - Fork 72
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
feat(snap): use updated environment variable injection #365
feat(snap): use updated environment variable injection #365
Conversation
@farshidtz Could you please review this? Thanks. |
4e97571
to
d466526
Compare
Codecov Report
@@ Coverage Diff @@
## main #365 +/- ##
=======================================
Coverage 21.34% 21.34%
=======================================
Files 5 5
Lines 492 492
=======================================
Hits 105 105
Misses 374 374
Partials 13 13 Continue to review full report at Codecov.
|
This PR supersedes edgexfoundry#341. Signed-off-by: Mengyi Wang <[email protected]> Co-authored-by: Siggi Skulason <[email protected]>
Signed-off-by: Mengyi Wang <[email protected]>
Signed-off-by: Mengyi Wang <[email protected]>
d466526
to
c499bde
Compare
This PR will be ready for merge, once the new hook has been tagged and imported by this PR. |
Signed-off-by: Mengyi Wang <[email protected]>
Signed-off-by: Mengyi Wang <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please upgrade edgex-snap-hooks to beta.5 and go mod tidy.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks. Works as expected:
$ snap install edgex-device-mqtt --channel="edge/pr-365"
edgex-device-mqtt (edge/pr-365) 2.2.0-dev.15 from Canonical✓ installed
# Verify error handling
$ snap set edgex-device-mqtt config.service-startupmsg="testing injection"
error: cannot perform the following tasks:
- Run configure hook of "edgex-device-mqtt" snap (run hook "configure":
-----
edgex-device-mqtt.configure: could not process options: 'config.' and 'apps.' options are allowed only when config-enabled is true.
WARNING: Setting config-enabled=true will unset existing 'env.' options and ignore future sets!!
-----)
$ snap set edgex-device-mqtt config-enabled=true
$ snap set edgex-device-mqtt config.service.startupmsg="testing injection"
error: cannot perform the following tasks:
- Run configure hook of "edgex-device-mqtt" snap (run hook "configure": edgex-device-mqtt.configure: could not process options: error converting config key to environment variable key: config key must not contain dots: service.startupmsg)
# Test global config
$ snap set edgex-device-mqtt config.service-startupmsg="testing injection"
$ snap start edgex-device-mqtt
Started.
$ snap logs -n=all edgex-device-mqtt | grep "testing injection"
2022-04-26T11:42:18+02:00 edgex-device-mqtt.device-mqtt[54398]: ++ export 'SERVICE_STARTUPMSG=testing injection'
2022-04-26T11:42:18+02:00 edgex-device-mqtt.device-mqtt[54398]: ++ SERVICE_STARTUPMSG='testing injection'
2022-04-26T11:42:19+02:00 edgex-device-mqtt.device-mqtt[54398]: level=INFO ts=2022-04-26T09:42:19.024095794Z app=device-mqtt source=variables.go:352 msg="Variables override of 'Service.StartupMsg' by environment variable: SERVICE_STARTUPMSG=testing injection"
# test app-specific config
$ snap set edgex-device-mqtt apps.device-mqtt.config.service-port=11111
$ snap restart edgex-device-mqtt
Restarted.
$ snap logs -n=all edgex-device-mqtt | grep "11111"
2022-04-26T11:43:08+02:00 edgex-device-mqtt.device-mqtt[54629]: ++ export SERVICE_PORT=11111
2022-04-26T11:43:08+02:00 edgex-device-mqtt.device-mqtt[54629]: ++ SERVICE_PORT=11111
2022-04-26T11:43:08+02:00 edgex-device-mqtt.device-mqtt[54629]: level=INFO ts=2022-04-26T09:43:08.378704974Z app=device-mqtt source=variables.go:352 msg="Variables override of 'Service.Port' by environment variable: SERVICE_PORT=11111"
# check the env file
$ cat /var/snap/edgex-device-mqtt/current/config/device-mqtt/res/device-mqtt.env
export SERVICE_STARTUPMSG="testing injection"
export SERVICE_PORT="11111"
For details on the new scheme for setting environment variables, please refer to edgexfoundry/edgex-go#3986.
Co-authored-by: Siggi Skulason [email protected]
Signed-off-by: Mengyi Wang [email protected]
If your build fails due to your commit message not passing the build checks, please review the guidelines here: https://github.com/edgexfoundry/device-mqtt-go/blob/main/.github/Contributing.md
PR Checklist
Please check if your PR fulfills the following requirements:
BREAKING CHANGE:
describing the break)Testing Instructions
New Dependency Instructions (If applicable)