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

feat(snap): add support for environment variable injection #74

Merged
merged 3 commits into from
Apr 25, 2022
Merged

feat(snap): add support for environment variable injection #74

merged 3 commits into from
Apr 25, 2022

Conversation

farshidtz
Copy link
Member

@farshidtz farshidtz commented Apr 25, 2022

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:

  • 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?): Add tests for snap config options canonical/edgex-snap-testing#53
  • 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?)

Testing Instructions

  1. Set up:
snap install edgexfoundry --edge
snap install edgex-app-rfid-llrp-inventory --channel=edge/pr-74
  1. Enable config and set a global config value:
$ snap set edgex-app-rfid-llrp-inventory config-enabled=true
$ snap set edgex-app-rfid-llrp-inventory config.service-startupmsg="testing injection"

$ snap start edgex-app-rfid-llrp-inventory
Started.

$ snap logs -n=all edgex-app-rfid-llrp-inventory | grep "testing injection"
2022-04-25T16:28:59+02:00 edgex-app-rfid-llrp-inventory.app-rfid-llrp-inventory[429579]: level=INFO ts=2022-04-25T14:28:59.224445693Z app=app-rfid-llrp-inventory source=variables.go:352 msg="Variables override of 'Service.StartupMsg' by environment variable: SERVICE_STARTUPMSG=testing injection"
2022-04-25T16:28:59+02:00 edgex-app-rfid-llrp-inventory.app-rfid-llrp-inventory[429579]: level=INFO ts=2022-04-25T14:28:59.323556738Z app=app-rfid-llrp-inventory source=service.go:184 msg="testing injection"
  1. Set a app-specific value:
$ snap set edgex-app-rfid-llrp-inventory apps.app-rfid-llrp-inventory.config.service-port=11111

$ snap restart edgex-app-rfid-llrp-inventory
Restarted.

$ snap logs -n=all edgex-app-rfid-llrp-inventory | grep "11111"
2022-04-25T16:31:05+02:00 edgex-app-rfid-llrp-inventory.app-rfid-llrp-inventory[430015]: level=INFO ts=2022-04-25T14:31:05.094926172Z app=app-rfid-llrp-inventory source=variables.go:352 msg="Variables override of 'Service.Port' by environment variable: SERVICE_PORT=11111"
2022-04-25T16:31:05+02:00 edgex-app-rfid-llrp-inventory.app-rfid-llrp-inventory[430015]: level=INFO ts=2022-04-25T14:31:05.198346026Z app=app-rfid-llrp-inventory source=server.go:156 msg="Starting HTTP Web Server on address localhost:11111"

New Dependency Instructions (If applicable)

@farshidtz farshidtz marked this pull request as ready for review April 25, 2022 14:33
@farshidtz
Copy link
Member Author

@MonicaisHer please review

MonicaisHer
MonicaisHer previously approved these changes Apr 25, 2022
Copy link
Contributor

@MonicaisHer MonicaisHer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@farshidtz Thank you

@MonicaisHer
Copy link
Contributor

The go.sum needs update for edgex-snap-hooks/v2 v2.2.0-beta.5

Signed-off-by: Farshid Tavakolizadeh <[email protected]>
Copy link
Member

@lenny-goodell lenny-goodell left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@lenny-goodell lenny-goodell merged commit 3238fc2 into edgexfoundry:main Apr 25, 2022
@farshidtz farshidtz deleted the edgex-340-env-injection branch April 25, 2022 20:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants