Content Types¶
xfg supports different content types based on the target file extension.
JSON Files (.json)¶
Object content outputs as JSON with 2-space indentation:
Output:
JSON5 Files (.json5)¶
Object content outputs as JSON5 (supports comments, trailing commas):
YAML Files (.yaml, .yml)¶
Object content outputs as YAML:
Output:
YAML Comments¶
Add schema directives and header comments to YAML files:
files:
trivy.yaml:
schemaUrl: https://trivy.dev/latest/docs/references/configuration/config-file/
header: "Trivy security scanner configuration"
content:
exit-code: 1
Output:
# yaml-language-server: $schema=https://trivy.dev/latest/docs/references/configuration/config-file/
# Trivy security scanner configuration
exit-code: 1
Multi-line headers are also supported:
files:
config.yaml:
header:
- "Auto-generated configuration"
- "Do not edit manually"
content:
version: 1
Note
header and schemaUrl only apply to YAML output files. They are ignored for JSON files.
Text Files¶
Files with extensions other than .json, .json5, .yaml, or .yml are treated as text files. Use string or string array content:
String Content¶
Lines Array Content¶
Lines are joined with newlines in the output.
Empty Files¶
Omit content to create an empty file:
Validation Rules¶
.json,.json5,.yaml,.ymlfiles must have object content- Other file extensions must have string or string array content
- Mixing content types (e.g., object content in a
.txtfile) causes a validation error