relation-get should have a "shell" output option
Bug #779713 reported by
Clint Byrum
This bug affects 1 person
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
pyjuju |
Fix Released
|
Low
|
Benjamin Saller |
Bug Description
relation-get is used in shell scripts, but there isn't an easy way to parse json in shell scripts.
It would be awesome to be able to say eval `relation-get --output=shell` and have all of the variables just set as variables
So the output would be
VAR_SETTINGNAME
VAR_ is used to prefix relation get's variables before returning them with this output format. If VAR_ variables already exist in the environment they are unset and an error is noted on stderr.
Related branches
lp:~bcsaller/pyjuju/relation-get-shell
- William Reade (community): Approve
- Gustavo Niemeyer: Approve
-
Diff: 148 lines (+101/-1)2 files modifiedensemble/hooks/commands.py (+38/-1)
ensemble/hooks/tests/test_invoker.py (+63/-0)
Changed in ensemble: | |
assignee: | nobody → Benjamin Saller (bcsaller) |
importance: | Undecided → Low |
status: | New → In Progress |
Changed in ensemble: | |
milestone: | none → dublin |
description: | updated |
Changed in ensemble: | |
status: | In Progress → Fix Released |
To post a comment you must log in.
This approach has some security implications we should consider. Doing this basically means that the other side of the relation has significant control over the local unit, since it may replace any environment variable at its will.
The relation-get command was actually designed with shell-specific needs in mind, so that one won't have to parse the JSON.
For instance, instead of doing:
echo $SETTINGNAME
You can do
echo `relation-get settingname`
The JSON support, as noted, is most useful for other languages.