Examples
This page provides complex examples showing how multiple fyaml concepts work together. For basic examples and detailed documentation, see the Usage Guide.
All examples shown here correspond to runnable examples in the examples directory in the repository.
Combining Multiple Concepts
This example demonstrates how root-level files, @ files, and deep nesting work together:
Directory Structure
config/
defaults.yml
entities/
@shared.yml
item1/
config.yml
metadata.yml
item2/
settings.yml
category1/
item3.yml
item4.yml
Input Files
defaults.yml:
entities/@shared.yml:
entities/item1/config.yml:
entities/item1/metadata.yml:
entities/item2/settings.yml:
category1/item3.yml:
category1/item4.yml:
Command
Output
category1:
item3:
entity:
id: example3
attributes:
name: third item
tags: []
item4:
entity:
id: example4
attributes:
name: fourth item
tags: []
entities:
environment: production
item1:
config:
entity:
id: example1
attributes:
name: sample name
tags: []
metadata:
related:
- attributes:
name: related item
tags:
- tag1
id: example2
item2:
settings:
entity:
id: example2
attributes:
name: another item
tags:
- tag2
region: us-east-1
project: example
version: 1.0.0
Key points:
defaults.ymlat root mergesprojectandversioninto the top level (root-level files merge directly)entities/@shared.ymlmergesenvironmentandregioninto theentitiesmap (uses@to merge into parent directory)- Deep nesting (3 levels:
entities/item1/config.yml) works naturally - All concepts work together in a single structure
Runnable Examples
The following examples demonstrate individual concepts. Each has a corresponding runnable example in the repository:
-
Basic Example - Simple directory structure
See Basic Usage for details. -
@ Files Example - Using
See Directory Structure - @ Files for details.@files to merge content -
@ Directories Example - Using
See Directory Structure - @ Directories for details.@directories for organization -
File Includes Example - Including YAML structures and text files
See File Includes for details. -
Shared Includes Example - Sharing includes across multiple config directories using
--chrootSee File Includes - Shared Includes Pattern for details.fyaml examples/with-shared-includes/config1 --chroot examples/with-shared-includes --enable-includes fyaml examples/with-shared-includes/config2 --chroot examples/with-shared-includes --enable-includes -
Cross-File Anchors Example - Using YAML anchors across files
See YAML Anchors and Aliases for details. -
Output Modes Example - Comparing canonical vs preserve modes
See Output Modes for details.fyaml examples/with-modes # Canonical mode fyaml examples/with-modes --mode preserve # Preserve mode
See the examples directory for all available examples.