Git Integration
Using the git integration it is possible to synchronize the content of a git repository with Cloudomation.
Use Cases
Generally it is recommended to store all your Cloudomation resources in git. There are plenty of benefits:
- Use of your favourite offline editor
- Version history of all changes to your automation logic
- Collaboration between users easily possible
- An additional backup of your automation logic
- Branching, merging, rollback, ...
Concept
The git integration currently operates read-only. Meaning, no changes are made to the repository by Cloudomation.
When a user manually modifies a resource which is synced to Cloudomation via the git integration, the changes will be overwritten with the next synchronization interval.
Flows, schedulers, settings, and files can be imported directly into the flow, scheduler, setting, and file resource. All other resource types can be imported using a Cloudomation export yaml.
Configuration
Please see the table below for the different git_config fields and their meanings:
Field | Description | Example |
---|---|---|
Remote URL | The URL to the git repository (special characters must be %-encoded). Supports HTTPS and SSH protocols. | ssh://git@example.com/path/to/repo.git or https://example.com/path/to/repo.git |
Enabled | If unset, Cloudomation will not sync anything | |
Priority | When using multiple git_configs the one with the lower priority will win when there are conflicts | 10 |
Git ref | The git ref to sync. Can be a branch name, a tag, or a commit SHA | develop |
Username | When using a HTTPS remote URL this username will be used for basic auth | |
Password | When using a HTTPS remote URL this password will be used for basic auth | |
SSH key | When using a SSH remote URL this key will be used to authenticate. Must be in PEM format. | -----BEGIN RSA PRIVATE KEY-----... |
SSH hostkey | When using a SSH remote URL this will be used to verify the identity of the remote | example.com ssh-rsa AA... |
Path mapping | A mapping of record types to globs. All files in the repo matching a glob will be loaded to the specified record type. | See [Path mapping] |
The remote URL
is expected to be %-encoded (special characters)!
If password or username are provided inside the remote URL those must be encoded, too!
Path mapping
The path mapping spcifies which files from the repository are loaded to which resource types.
flow:
- flows/*.py
file:
- templates/**/*
- script.sh
import:
- resources/*.yaml
The example above will
- Load all
*.py
files in theflows
folder to the flow resource.noteThe file extension
.py
is removed from the resource name - Load all files in any folder below
templates
into the file resource - Load
script.sh
into the file resource - Import all
*.yaml
files in theresources
folder
Please refer to Import / Export and Upload for details on export YAML files.
Synchronizing
The environment variable GIT_SYNC_INTERVAL
specifies the time in seconds between
automatic synchronizations. The default is 10 minutes (600 seconds). To synchronize
immediately either disable and re-enable a git_config - every update triggers a
synchronization - or send a PATCH
request to
https://<your-workspace>.cloudomation.com/api/latest/git_config/
.
Resources in the git repository are matched by name to resources on the Cloudomation platform. Changes that are made to resources on the platform will be overwritten automatically with the next synchronization as long as the name of the resource is the same as the name of the resource in the git repository. Renaming a resource will result in the next synchronisation creating a new file with the original name.
Metadata docstring block in flows
Cloudomation will parse the content of files which are loaded to the flows resource to detect additional attributes.
All additional attributes can be specified in the docstring. Two formats are recognized:
"""
The content of this docstring is used for the "description" field of the flow
"""
""" # Cloudomation metadata:
project_id_project:
name: my-project
"""
import flow_api
def handler(system: flow_api.System, this: flow_api.Execution):
return this.success('all done')
The parsing is done line-by-line. The first non-empty line which is not a docstring will stop the parsing.
A normal docstring will be used in the description
field of the flow.
A docstring which is started by the line """ # Cloudomation metadata:
will be parsed as a YAML
document and can specify all fields of the flow & related resources similar to the export
file format.