A module for working with Cloud Native Application Bundles in Python
Python CNAB Library
Work-in-progress library for working with CNAB in Python.
There are probably three main areas of interest for a CNAB client:
- Creation/parsing of the
- Building invocation images
- Running actions against a CNAB
At this early stage only the first of these is currently work-in-progress.
Nothing too fancy here, the
Bundle class has a
from_dict static method which
builds a full
import json from cnab import Bundle with open("bundle.json") as f: data = json.load(f) bundle = Bundle.from_dict(data)
This could for example be used for validation purposes, or for building user interfaces for
bundle.json in Python
You can also describe the
bundle.json file in Python. This will correctly validate the
structure based on the current specification and would allow for building a custom DSL or other
user interface for generating
import json from cnab import Bundle, InvocationImage bundle = Bundle( name="hello", version="0.1.0", invocation_images=[ InvocationImage( image_type="docker", image="technosophos/helloworld:0.1.0", digest="sha256:aaaaaaa...", ) ], ) print(json.dumps(bundle.to_dict(), indent=4))
Thanks to QuickType for bootstrapping the creation of the Python code for manipulating
bundle.json based on the current JSON Schema.
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.