GithubHelp home page GithubHelp logo

isabella232 / layer-options Goto Github PK

View Code? Open in Web Editor NEW

This project forked from juju-solutions/layer-options

0.0 0.0 0.0 10 KB

Library for reading layer options for charms

License: Apache License 2.0

Python 100.00%

layer-options's Introduction

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')

layer-options's People

Contributors

johnsca avatar cynerva avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.