-
Notifications
You must be signed in to change notification settings - Fork 23
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 #25
Merged
lenny-goodell
merged 3 commits into
edgexfoundry:main
from
MonicaisHer:EDGEX-425-integrate-env-var-injection-with-device-gpio-snap
Apr 26, 2022
Merged
feat(snap): use updated environment variable injection #25
lenny-goodell
merged 3 commits into
edgexfoundry:main
from
MonicaisHer:EDGEX-425-integrate-env-var-injection-with-device-gpio-snap
Apr 26, 2022
Conversation
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
Signed-off-by: Mengyi Wang <[email protected]>
MonicaisHer
force-pushed
the
EDGEX-425-integrate-env-var-injection-with-device-gpio-snap
branch
from
April 22, 2022 09:37
0eee028
to
1b28166
Compare
This PR will be ready for review, once the new hook has been tagged and imported by this PR. |
Signed-off-by: Mengyi Wang <[email protected]>
10 tasks
Signed-off-by: Mengyi Wang <[email protected]>
@farshidtz Please review, thank you. |
farshidtz
approved these changes
Apr 26, 2022
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-gpio --channel=edge/pr-25
edgex-device-gpio (edge/pr-25) 2.0.0-dev.2 from Canonical✓ installed
# validate error handling
$ snap set edgex-device-gpio config.service-startupmsg="testing injection"
error: cannot perform the following tasks:
- Run configure hook of "edgex-device-gpio" snap (run hook "configure":
-----
edgex-device-gpio.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-gpio config-enabled=true
$ snap set edgex-device-gpio config.service.startupmsg="testing injection"
error: cannot perform the following tasks:
- Run configure hook of "edgex-device-gpio" snap (run hook "configure": edgex-device-gpio.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-gpio config-enabled=true
$ snap set edgex-device-gpio config.service-startupmsg="testing injection"
$ snap start edgex-device-gpio
Started.
farshid:~$ snap logs -n=all edgex-device-gpio | grep "testing"
2022-04-26T11:31:20+02:00 edgex-device-gpio.device-gpio[52529]: level=INFO ts=2022-04-26T09:31:20.979233295Z app=device-gpio source=variables.go:352 msg="Variables override of 'Service.StartupMsg' by environment variable: SERVICE_STARTUPMSG=testing injection"
2022-04-26T11:31:21+02:00 edgex-device-gpio.device-gpio[52529]: level=INFO ts=2022-04-26T09:31:21.003927272Z app=device-gpio source=message.go:55 msg="testing injection"
$ snap set edgex-device-gpio apps.device-gpio.config.service-port=11111
$ snap restart edgex-device-gpio
Restarted.
$ snap logs -n=all edgex-device-gpio | grep "11111"
2022-04-26T11:31:39+02:00 edgex-device-gpio.device-gpio[52702]: level=INFO ts=2022-04-26T09:31:39.678107294Z app=device-gpio source=variables.go:352 msg="Variables override of 'Service.Port' by environment variable: SERVICE_PORT=11111"
2022-04-26T11:31:39+02:00 edgex-device-gpio.device-gpio[52702]: level=INFO ts=2022-04-26T09:31:39.680475727Z app=device-gpio source=httpserver.go:123 msg="Web server starting (localhost:11111)"
2022-04-26T11:31:39+02:00 edgex-device-gpio.device-gpio[52702]: level=ERROR ts=2022-04-26T09:31:39.681485921Z app=device-gpio source=httpserver.go:135 msg="Web server failed: listen tcp 127.0.0.1:11111: bind: address already in use"
$ cat /var/snap/edgex-device-gpio/current/config/device-gpio/res/device-gpio.env
export SERVICE_STARTUPMSG="testing injection"
export SERVICE_PORT="11111"
lenny-goodell
approved these changes
Apr 26, 2022
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
For details on the new scheme for setting environment variables, please refer to edgexfoundry/edgex-go#3986.
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-gpio/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)