Clarifying charm format 2
Gustavo Niemeyer
gustavo.niemeyer at canonical.com
Tue Aug 28 23:15:40 UTC 2012
On Tue, Aug 28, 2012 at 6:27 PM, Jim Baker <jim.baker at canonical.com> wrote:
> value, there is coercion. For example, true, True, and TRUE all work
> with config-set; e.g., config-set foo=TRUE; config-get then
(...)
> Question: do we want to keep the trunk support for config usage of
> booleans in the final format: 2?
Thanks for raising these additional issues, Jim.
Just to make sure we're on the same page, I'll list them all again:
config-get/set:
- type int: Reads "1"; Writes "1" (no quotes)
- type float: Reads "1" or "1.0"; Writes "1.0" (no quotes)
- type boolean: Reads lower(v) in "true" or "false"; Writes "true" or "false"
- type string: Reads raw data; Writes raw data
relation-get/set
- String: Reads raw data; Writes raw data
relation-get -
- YAML output with string keys and raw data values (no nesting!)
> 2. Dictionary output of relation-get - using smart format (implied if
> not set with --format)
(...)
> {u'private-address': u'mysql-0.example.com', u'foo': u'ascii'}
>
> Clearly the u'XYZ' representation is going away. Based on the current
Yeah, this is clearly unhelpful.
> For format: 2 in trunk, relation-get - returns a YAML output. So using a
> raw string in our example, this would result in the following output,
> which can be parsed by any YAML parser:
>
> bar: !!binary |
> yv4=
> foo: ascii
> private-address: mysql-0.example.com
This looks great for reading in the terminal, and is already in place.
I suggest preserving that idea.
> If we were to use a modified format: 1 and keep the Python str repr,
> this would result in output like the following. It should be possible to
> eval any version of this in Python, given the use of raw strings. It may
> be readily parseable by other tools.
YAML looks better for a default. There are several special cases for
string formatting in Python that will make it cumbersome to use in
anything but Python itself (e.g. ' vs ").
gustavo @ http://niemeyer.net
More information about the Juju
mailing list