API Documentation¶
KubernetesTransformer¶
-
class
container_transform.kubernetes.
KubernetesTransformer
(filename=None)¶ A transformer for Kubernetes Pods
TODO: look at http://kubernetes.io/docs/api-reference/v1/definitions/#_v1_pod
-
emit_containers
(containers, verbose=True)¶ Emits the applications and sorts containers by name
Parameters: - containers (list of dict) – List of the container definitions
- verbose (bool) – Print out newlines and indented JSON
Returns: The text output
Return type:
-
flatten_container
(container)¶ Accepts a kubernetes container and pulls out the nested values into the top level
-
ingest_memory
(memory)¶ Transform the memory into bytes
Parameters: memory (memory string or integer) – Compose memory definition. (1g, 24k) Returns: The memory in bytes Return type: int
-
ingest_port_mappings
(port_mappings)¶ Transform the port mappings to base schema mappings
Parameters: port_mappings (list of dict) – The port mappings Returns: The base schema mappings Return type: list of dict
-
ingest_volumes_param
(volumes)¶ This is for ingesting the “volumes” of a pod spec
-
ECSTransformer¶
-
class
container_transform.ecs.
ECSTransformer
(filename=None)¶ A transformer for ECS Tasks
To use this class:
transformer = ECSTransformer('./task.json') output = transformer.ingest_containers() print(json.dumps(output, indent=4))
-
__init__
(filename=None)¶ We override
.__init__()
on purpose, we need to get the volume data.Parameters: filename (str) – The file to be loaded
-
add_volume
(volume)¶ Add a volume to self.volumes if it isn’t already present
-
emit_containers
(containers, verbose=True)¶ Emits the task definition and sorts containers by name
Parameters: - containers (list of dict) – List of the container definitions
- verbose (bool) – Print out newlines and indented JSON
Returns: The text output
Return type:
-
ingest_port_mappings
(port_mappings)¶ Transform the ECS mappings to base schema mappings
Parameters: port_mappings (list of dict) – The ECS port mappings Returns: The base schema mappings Return type: list of dict
-
ingest_volumes_param
(volumes)¶ This is for ingesting the “volumes” of a task description
-
ComposeTransformer¶
-
class
container_transform.compose.
ComposeTransformer
(filename=None)¶ A transformer for docker-compose v1 and v2
To use this class:
transformer = ComposeTransformer('./docker-compose.yml') normalized_keys = transformer.ingest_containers()
-
__init__
(filename=None)¶ We override
.__init__()
on purpose, we need to get the volume, version, network, and possibly other data.Parameters: filename (str) – The file to be loaded
-
emit_port_mappings
(port_mappings)¶ Parameters: port_mappings (list of dict) – the base schema port_mappings Returns: Return type: list of str
-
ingest_containers
(containers=None)¶ Transform the YAML into a dict with normalized keys
-
SystemdTransformer¶
-
class
container_transform.systemd.
SystemdTransformer
¶ A transformer for docker-compose
To use this class:
transformer = SystemdTransformer()
-
__init__
()¶ Initialize self. See help(type(self)) for accurate signature.
-
emit_port_mappings
(port_mappings)¶ Parameters: port_mappings (list of dict) – the base schema port_mappings Returns: Return type: list of str
-
MarathonTransformer¶
-
class
container_transform.marathon.
MarathonTransformer
(filename=None)¶ A transformer for Marathon Apps
When consuming Marathon input, the transformer supports:
- A single Marathon application
- Content from the Marathon Group API
- A JSON array of Marathon application objects
When emitting Marathon output, the transformer will emit a list of applications if there is more than one. Otherwise, it will emit a single application.
To use this class:
transformer = MarathonTransformer('./app.json') output = transformer.ingest_container() print(json.dumps(output, indent=4))
-
emit_containers
(containers, verbose=True)¶ Emits the applications and sorts containers by name
Parameters: - containers (list of dict) – List of the container definitions
- verbose (bool) – Print out newlines and indented JSON
Returns: The text output
Return type:
-
flatten_container
(container)¶ Accepts a marathon container and pulls out the nested values into the top level
-
ingest_port_mappings
(port_mappings)¶ Transform the port mappings to base schema mappings
Parameters: port_mappings (list of dict) – The port mappings Returns: The base schema mappings Return type: list of dict
ChronosTransformer¶
-
class
container_transform.chronos.
ChronosTransformer
(filename=None)¶ A transformer for Chronos Jobs
When consuming Chronos input, the transformer supports:
When emitting Chronos output, the transformer will emit a list of applications if there is more than one. Otherwise, it will emit a single application.
To use this class:
transformer = ChronosTransformer('./task.json') output = transformer.ingest_container() print(json.dumps(output, indent=4))
-
emit_containers
(containers, verbose=True)¶ Emits the applications and sorts containers by name
Parameters: - containers (list of dict) – List of the container definitions
- verbose (bool) – Print out newlines and indented JSON
Returns: The text output
Return type:
-
flatten_container
(container)¶ Accepts a chronos container and pulls out the nested values into the top level
-
ingest_port_mappings
(port_mappings)¶ Transform the port mappings to base schema mappings
Parameters: port_mappings (list of dict) – The port mappings Returns: The base schema mappings Return type: list of dict
-
BaseTransformer¶
-
class
container_transform.transformer.
BaseTransformer
¶ The base class for Transformer classes to inherit from.
Basic usage should look like
transformer = MyTransformer('./my-file.txt') normalized_keys = transformer.ingest_containers()
-
__init__
()¶ Initialize self. See help(type(self)) for accurate signature.
-
ingest_containers
(containers=None)¶ Ingest self.stream and return a list of un-converted container definitions dictionaries.
This is to normalize where all the container information is. For example, Compose v1 places the container name outside the rest of the container definition. We need to have a ‘name’ key in the container definition.
Return type: list of dict
-