8000 GitHub - juju-solutions/layer-options: Library for reading layer options for charms
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
This repository was archived by the owner on Mar 4, 2024. It is now read-only.

juju-solutions/layer-options

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Overview

Apache 2.0 License

This base layer provides a function to read options defined in layer.yaml file. The options can be specified in multiple sections, generally one per layer included in the final built charm. Each layer can define what options it can accept in the same format that action parameters are defined: jsonschema.

Usage

Suppose layer foo specifies the following option definitions in its layer.yaml:

defines:
  my_opt_1:
    description: A numerical option.
    type: number
    default: 1
  my_opt_a:
    description: An array option.
    type: array
    default: []
  my_opt_b:
    description: A boolean option.
    type: boolean
    default: false

A layer including it could specify values for these options in its own layer.yaml:

options:
  foo:
    my_opt_1: 2
    my_opt_a: ['a', 'b']
    my_opt_b: true

The foo layer could then read these values in its reactive code:

from charms import layer
from charms.reactive import when_not, set_flag


@when_not('layer.foo.done')
def do_foo():
    foo_opts = layer.options.get('foo')  # returns a dict of all the options
    my_opt_1 = layer.options.get('foo', 'my_opt_1')  # returns just that option
    do_something_with(foo_opts)
    set_flag('layer.foo.done')
55CD

About

Library for reading layer options for charms

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

0