-
Notifications
You must be signed in to change notification settings - Fork 36
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): add support for env var injection #160
Conversation
Signed-off-by: Farshid Tavakolizadeh <[email protected]>
Codecov Report
@@ Coverage Diff @@
## main #160 +/- ##
=====================================
Coverage 0.00% 0.00%
=====================================
Files 2 2
Lines 200 200
=====================================
Misses 200 200 Continue to review full report at Codecov.
|
@MonicaisHer please review. |
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.
@farshidtz Thank you. It works as expected.
Validate error handling:
$ snap set edgex-device-snmp config.service-startupmsg="testing injection"
error: cannot perform the following tasks:
- Run configure hook of "edgex-device-snmp" snap (run hook "configure":
-----
edgex-device-snmp.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-snmp config-enabled=true
$ snap set edgex-device-snmp config.service.startupmsg="testing injection"
error: cannot perform the following tasks:
- Run configure hook of "edgex-device-snmp" snap (run hook "configure": edgex-device-snmp.configure: could not process options: error converting config key to environment variable key: config key must not contain dots: service.startupmsg)
Test:
$ snap set edgex-device-snmp config.service-startupmsg="testing injection"
$ snap start edgex-device-snmp
Started.
$ snap logs -n=all edgex-device-snmp | grep "testing"
2022-04-26T11:47:03+02:00 edgex-device-snmp.device-snmp[1762787]: ++ export 'SERVICE_STARTUPMSG=testing injection'
2022-04-26T11:47:03+02:00 edgex-device-snmp.device-snmp[1762787]: ++ SERVICE_STARTUPMSG='testing injection'
2022-04-26T11:47:04+02:00 edgex-device-snmp.device-snmp[1762787]: level=INFO ts=2022-04-26T09:47:04.323706439Z app=device-snmp source=variables.go:352 msg="Variables override of 'Service.StartupMsg' by environment variable: SERVICE_STARTUPMSG=testing injection"
2022-04-26T11:47:04+02:00 edgex-device-snmp.device-snmp[1762787]: level=INFO ts=2022-04-26T09:47:04.36831019Z app=device-snmp source=message.go:55 msg="testing injection"
$ snap set edgex-device-snmp apps.device-snmp.config.service-port=11111
$ snap restart edgex-device-snmp
Restarted.
$ snap logs -n=all edgex-device-snmp | grep "11111"
2022-04-26T11:47:39+02:00 edgex-device-snmp.device-snmp[1763017]: ++ export SERVICE_PORT=11111
2022-04-26T11:47:39+02:00 edgex-device-snmp.device-snmp[1763017]: ++ SERVICE_PORT=11111
2022-04-26T11:47:39+02:00 edgex-device-snmp.device-snmp[1763017]: level=INFO ts=2022-04-26T09:47:39.10975401Z app=device-snmp source=variables.go:352 msg="Variables override of 'Service.Port' by environment variable: SERVICE_PORT=11111"
2022-04-26T11:47:39+02:00 edgex-device-snmp.device-snmp[1763017]: level=INFO ts=2022-04-26T09:47:39.135056084Z app=device-snmp source=httpserver.go:123 msg="Web server starting (localhost:11111)"
For details on the new scheme for setting environment variables, please refer to edgexfoundry/edgex-go#3986.
Signed-off-by: Farshid Tavakolizadeh [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/app-rfid-llrp-inventory/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)