Skip to content

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.

DetailValue
Extensions.yaml, .yml
Comment handlingPreserved until strip-comments runs
Multi-documentSingle 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:

  • dict becomes CommentedMap
  • list becomes CommentedSeq
  • Scalars (int, float, bool, None) pass through unchanged
DetailValue
Extension.json
Output formatYAML

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.

DetailValue
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 stringResulting type
true, yes, onTrue (bool)
false, no, offFalse (bool)
Valid integer (e.g. 8080)int
Valid float (e.g. 3.14)float
Everything elsestr

Example

Given a my.cnf MySQL configuration:

[mysqld]
port = 3306
max_connections = 151
innodb_buffer_pool_size = 128M
[client]
port = 3306
socket = /var/run/mysqld/mysqld.sock
Terminal window
decoct compress my.cnf --schema mariadb-mysql --stats

Output:

mysqld:
innodb_buffer_pool_size: 128M
client:
socket: /var/run/mysqld/mysqld.sock

Default values (port: 3306, max_connections: 151) are stripped by the schema.

Format Auto-Detection

Format is determined by file extension:

ExtensionDetected format
.jsonJSON
.ini, .conf, .cfg, .cnf, .propertiesINI
.yaml, .yml, everything elseYAML

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:

PlatformDetection rule
Docker ComposeHas services key with a dict value
KubernetesHas apiVersion and kind keys
Ansible PlaybookList where first item has hosts and tasks/roles
cloud-init2+ keys from packages, runcmd, write_files, users, etc.
Terraform StateHas terraform_version and resources keys
GitHub ActionsHas on and jobs keys
TraefikHas entryPoints, or providers with api/log
PrometheusHas 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