Add CLI for layer options #58

Merged
merged 1 commit into from Apr 20, 2016

Conversation

Projects
None yet
4 participants
Owner

johnsca commented Apr 19, 2016

. charms.reactive.sh

@when 'state'
function do_thing() {
    if layer_option foo enable-bar; then
        juju-log "Bar is enabled"
        juju-log "bar-value is: $(layer_option foo bar-value)"
        for val in $(layer_option foo arr-value); do
            juju-log "val: $val"
        done
    fi
}

reactive_handler_main
Owner

marcoceppi commented Apr 19, 2016

slightly confused of the two parameter incantation. Could you provide an example layer options>?

Owner

johnsca commented Apr 19, 2016

@marcoceppi The first parameter is the "section" or layer name. The second is the option name. E.g., your generated layer.yaml might be:

"options":
  "test":
    "test_arr": ["foo", "bar", "qux"]
    "test_bool": !!bool "true"
    "test_str": "foo"
    "test_int": !!int "10"
  "basic":
    "use_venv": !!bool "false"
    "packages": []
    "include_system_packages": !!bool "false"
"includes":
- "layer:basic"
"is": "test"

And you could access options from either layer with:

layer_option basic packages
layer_option test test_str
Owner

johnsca commented Apr 19, 2016

Moved the path manipulation to reduce commit clutter.

Owner

marcoceppi commented Apr 19, 2016

Does chaning work as expected? IE: layer_option <section> foo.bar

Owner

johnsca commented Apr 19, 2016

No. I wasn't sure if it was worth implementing that for bash charms. Also, IBM is currently blocked on this, so wanted to get a first pass through.

Contributor

mbruzek commented Apr 20, 2016

+1 looks OK to me

Member

kwmonroe commented Apr 20, 2016

LGTM

@johnsca johnsca merged commit 7d5ec1b into juju-solutions:master Apr 20, 2016

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment