relation-get output is problematic

Benjamin Saller benjamin.saller at canonical.com
Fri May 11 17:35:38 UTC 2012


While we certainly should improve the output to be something more
uniform I don't think that YAML is the direction to push this. 'smart'
when we originally talked about what it would do was to combine the
properties of human readable with shell parseable. I'll agree that
YAML is readable but its not easily shell parsable. That said I also
agree the current output isn't exactly smart, to make it smarter we
might take advantage of the following pseudo-code

for item in result:
     print >>stream, json.dumps(item)

One item per line is easy for shell and items (Booleans for example)
get a very standard JSON serialization which both golang and Python
can easily produce and is easy to standardize around in shell.

This pattern might have to be adapted slightly for some commands but
the principal is one JSON serialized item per line, rather than
dumping JSON arrays (which we can already do with --format json)

-Ben

On Wed, May 9, 2012 at 1:09 PM, Gustavo Niemeyer
<gustavo.niemeyer at canonical.com> wrote:
> Folks,
>
> I've been talking to William about this issue, and this was already
> discussed live with some of you.
>
> We have an important bug to fix in relation-get and a few other
> commands. Their output, somehow, ended up being *Python serialization*
> rather than JSON or YAML, which is obviously wrong. It wasn't clear
> that this was the case until very recently, when we introduced the
> boolean types. That's made it obvious that this was the case because
> one can see "True" (Python) instead of "true" (JSON/YAML) in the
> output, but there are many other issues waiting to bite us seriously
> (string formatting, for instance).
>
> My proposal is this:
>
> - Let's make the default output for everything structured be YAML
> (e.g. relation-get -)
> - Things like juju-log must not output *anything* (it is/was outputting {})
>
> Then, I'd also like to take the chance to propose an extension to
> relation-get to help people that are getting out of the
>
>    if [ `relation-get some-bool` = True ]; then ...; fi
>
> situation, that actually makes the charm interface depend on
> Python-specific value names, onto a much better version:
>
>    if relation-get --test some-bool; then ...; fi
>
> If people are happy with that, this change should be done ASAP in
> juju-python, and proposed as an SRU so that we can get the charms
> fixed and get us a proper runway for 12.04+ onwards. I'm happy to help
> automating things somehow, if necessary, to avoid some of the pain.
>
> Comments?
>
> --
> Gustavo Niemeyer
>
> --
> Juju mailing list
> Juju at lists.ubuntu.com
> Modify settings or unsubscribe at: https://lists.ubuntu.com/mailman/listinfo/juju



More information about the Juju mailing list