Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
Already on GitHub? Sign in to your account
Packages definition #18
Merged
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
Jump to file or symbol
Failed to load files and symbols.
| @@ -0,0 +1,5 @@ | ||
| +defines: | ||
| + packages: | ||
| + type: array | ||
| + description: Additional packages to be installed at time of bootstrap | ||
| + |
| @@ -0,0 +1,22 @@ | ||
| + | ||
| +import os | ||
| +import yaml | ||
| + | ||
| + | ||
| +class LayerOptions(dict): | ||
| + def __init__(self, layer_file, section=None): | ||
| + with open(layer_file) as f: | ||
| + layer = yaml.safe_load(f.read()) | ||
| + opts = layer.get('options', {}) | ||
| + if section and section in opts: | ||
| + super(LayerOptions, self).__init__(opts.get(section)) | ||
| + else: | ||
| + super(LayerOptions, self).__init__(opts) | ||
| + | ||
| + | ||
| +def options(section=None, layer_file=None): | ||
| + if not layer_file: | ||
| + base_dir = os.environ.get('CHARM_DIR', os.getcwd()) | ||
| + layer_file = os.path.join(base_dir, 'layer.yaml') | ||
| + | ||
| + return LayerOptions(layer_file, section) |