Input Formats
decoct accepts infrastructure configuration in YAML, JSON, and INI formats. Everything is normalised internally to ruamel.yaml round-trip types before the compression pipeline runs. Output is always YAML.
YAML
YAML is the native format. Files are loaded with round-trip parsing, preserving comments, key ordering, and flow style through the pipeline until a pass explicitly removes them.
| Detail | Value |
|---|---|
| Extensions | .yaml, .yml |
| Comment handling | Preserved until strip-comments runs |
| Multi-document | Single document per file |
When reading from stdin, decoct always treats input as YAML.
JSON
JSON files are auto-detected by the .json extension and converted to round-trip types internally:
dictbecomesCommentedMaplistbecomesCommentedSeq- Scalars (
int,float,bool,None) pass through unchanged
| Detail | Value |
|---|---|
| Extension | .json |
| Output format | YAML |
JSON input effectively undergoes a JSON-to-YAML conversion as part of compression. Works well with Terraform state files, cloud provider API responses, and other JSON-based infrastructure data.
INI / Key-Value Files
decoct handles INI-style and flat key=value configuration files, detected by extension.
| Detail | Value |
|---|---|
| Extensions | .ini, .conf, .cfg, .cnf, .properties |
Two parsing modes
The parser inspects the raw text for [section] headers:
Sectioned INI (files with [section] headers):
- Parsed with Python’s
configparser - Produces a nested structure: each section maps to its keys and values
Flat key=value (no section headers):
- Parsed line-by-line
- Lines starting with
#or;are comments (skipped) - Produces a flat key-value structure
Value type coercion
All INI values start as strings. decoct converts them to native types:
| Input string | Resulting type |
|---|---|
true, yes, on | True (bool) |
false, no, off | False (bool) |
Valid integer (e.g. 8080) | int |
Valid float (e.g. 3.14) | float |
| Everything else | str |
Example
Given a my.cnf MySQL configuration:
[mysqld]port = 3306max_connections = 151innodb_buffer_pool_size = 128M
[client]port = 3306socket = /var/run/mysqld/mysqld.sockdecoct compress my.cnf --schema mariadb-mysql --statsOutput:
mysqld: innodb_buffer_pool_size: 128Mclient: socket: /var/run/mysqld/mysqld.sockDefault values (port: 3306, max_connections: 151) are stripped by the schema.
Format Auto-Detection
Format is determined by file extension:
| Extension | Detected format |
|---|---|
.json | JSON |
.ini, .conf, .cfg, .cnf, .properties | INI |
.yaml, .yml, everything else | YAML |
Platform Auto-Detection
When --schema is not provided, decoct examines the parsed document content to guess the platform and load the matching bundled schema. Eight platforms are auto-detected:
| Platform | Detection rule |
|---|---|
| Docker Compose | Has services key with a dict value |
| Kubernetes | Has apiVersion and kind keys |
| Ansible Playbook | List where first item has hosts and tasks/roles |
| cloud-init | 2+ keys from packages, runcmd, write_files, users, etc. |
| Terraform State | Has terraform_version and resources keys |
| GitHub Actions | Has on and jobs keys |
| Traefik | Has entryPoints, or providers with api/log |
| Prometheus | Has scrape_configs key |
For all other platforms, pass --schema <name> explicitly.
Limitations
- XML is not yet supported
- INI comments are discarded during parsing
- Flat key=value does not support multi-line values
- stdin is always treated as YAML