A module for working with Cloud Native Application Bundles in Python
Project description
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
bundle.json
format - Building invocation images
- Running actions against a CNAB
At this early stage only the first of these is currently work-in-progress.
Parsing bundle.json
Nothing too fancy here, the Bundle
class has a from_dict
static method which
builds a full Bundle
object.
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
files.
Describing 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 bundle.json
files.
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
Thanks to QuickType for bootstrapping the creation of the Python code for manipulating bundle.json
based on the current JSON Schema.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file cnab-0.1.1.tar.gz
.
File metadata
- Download URL: cnab-0.1.1.tar.gz
- Upload date:
- Size: 4.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/0.12.10 CPython/3.7.0 Linux/4.4.0-17763-Microsoft
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 54a529ead5ef48eea502ab2784e699c40e8f03b0aaef25d4276e89f6608d4053 |
|
MD5 | 006ada1b7f0ec0c9f02f4c887e717a98 |
|
BLAKE2b-256 | 4e2d9a2549a3808037027e66511f5bf828400e5d4ce0a381f06219d01150909e |
File details
Details for the file cnab-0.1.1-py3-none-any.whl
.
File metadata
- Download URL: cnab-0.1.1-py3-none-any.whl
- Upload date:
- Size: 18.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/0.12.10 CPython/3.7.0 Linux/4.4.0-17763-Microsoft
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 01ca1f33d75fc713446acf7f24088d97a5f6d35501811759514208b1e66b34d0 |
|
MD5 | 3f7d48d5b2a877399d4c08fd598d5281 |
|
BLAKE2b-256 | 1c98f0e25e47af12601bafec6dc511d45f9d54e85ef5be9374f9c1a8ed167a1b |