relation-get output is problematic

Gustavo Niemeyer n13m3y3r at gmail.com
Fri May 11 19:05:27 UTC 2012


By the way, we have commands that output lists of strings in a per-line
basis. I'm not suggesting we change these.

The idea is that commands like

    relation-get -

Should output YAML because that's readable and parseable from languages. If
one wants a specific entry from the shell, that's:

    relation-get item-name

No further shell processing needed.

gustavo @ http://niemeyer.net
On May 11, 2012 3:44 PM, "Gustavo Niemeyer" <gustavo.niemeyer at canonical.com>
wrote:

> The command itself has a nice interface to handle that use case. YAML is
> both readable and usable programmatically. That fits well in that situation.
>
> gustavo @ http://niemeyer.net
> On May 11, 2012 2:36 PM, "Benjamin Saller" <benjamin.saller at canonical.com>
> wrote:
>
>> 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
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.ubuntu.com/archives/juju/attachments/20120511/1b69e033/attachment.html>


More information about the Juju mailing list