Yamll is a powerful tool for managing and merging multiple YAML files
This allows you to define dependencies on other YAML files, similar to how programming languages manage dependencies.
It ensures a single comprehensive YAML file by resolving interdependencies and preventing import cycles.
- Merge multiple
YAMLfiles into one - Handle imports and dependencies seamlessly
- Detect and prevent import cycles
- Easy to use with clear error reporting
- Supports importing files from various source like
local path,GITrepo andHTTPSsource
- If authentication is required to connect to remote source defined. Creds can be passed as
environmentvariable andyamllevaluates it - In case of GIT,
yamllsupports bothsshandhttpbased git URLs. - All supported authentication parameters are defined here.
- Recommend installing released versions. Release binaries are available on the releases page.
Install latest version on yamll on macOS
brew tap nikshilsbhat/stable git@github.com:nikhilsbhat/homebrew-stable.git
# for latest version
brew install nikshilsbhat/stable/yamll
# for specific version
brew install nikshilsbhat/stable/yamll@0.0.3Check repo for all available versions of the formula.
Latest version of docker images are published to ghcr.io, all available images can be found there.
docker pull ghcr.io/nikhilsbhat/yamll:latest
docker pull ghcr.io/nikhilsbhat/yamll:<github-release-tag>- Clone the repository:
git clone https://github.com/nikhilsbhat/yamll.git cd yamll - Build the project:
make local.build
To merge multiple YAML files, simply specify the base YAML files as arguments:
yamll import -f import.yamlYAML files can specify imports using the comments that starts with ##++. yamll will resolve these imports and merge the contents.
It can construct the dependency tree and import them in the correct order, with each dependency able to have its own defined dependencies.
YAMLL supports importing YAML files using wildcard patterns.
Filenames matching the pattern are excluded from visibility in the tree, import, and build commands. Instead, the data from all matching files is aggregated under the specified pattern.
For example, the pattern ##++internal/fixtures/*.test.yaml might match files like one.test.yaml, two.test.yaml, and three.test.yaml.
However, their individual filenames (one.test.yaml, two.test.yaml, and three.test.yaml) will not be displayed in the above commands.
Instead, their combined data will appear under the pattern ##++internal/fixtures/*.test.yaml. (this makes it easier to manage the cyclic dependency and many others)
Following examples tries to illustrate all of them.
Example root.yaml:
##++internal/fixtures/base.yaml
##++internal/fixtures/*.test.yaml
##++git+https://github.com/nikhilsbhat/yamll@main?path=internal/fixtures/base2.yaml;{"user_name":"${GIT_USERNAME}","password":"${GITHUB_TOKEN}"}
##++http://localhost:3000/database.yaml
config2:
test: val
<<: *default
config3:
- *default
- *mysqldatabase
workflow: *mysqldatabaseExample base.yaml:
default: &default
apiVersion: v1
kind: ConfigMap
metadata:
name: base-config
data:
key1: value1
key2: value2
config1: *defaultExample base2.yaml retrieved from GIT source:
names:
- john doe
- dexterExample base3.yaml:
organizations:
- thoughtworks
- google
- microsoftExample one.test.yaml:
editor:
- intellij
- visual_codeExample two.test.yaml:
movies:
- animation
- comedyExample three.test.yaml:
ott:
- netflix
- prime_videodatabase.yaml retrieved from URL source:
mysqldatabase: &mysqldatabase
hostname: localhost
port: 3012
username: root
password: rootImporting root.yaml should generate final yaml file as below
---
# Source: internal/fixtures/base3.yaml
organizations:
- thoughtworks
- google
- microsoft
---
# Source: internal/fixtures/base.yaml
default: &default
apiVersion: v1
kind: ConfigMap
metadata:
name: base-config
data:
key1: value1
key2: value2
config1: *default
---
# Source: internal/fixtures/*.test.yaml
editor:
- intellij
- visual_code
ott:
- netflix
- prime_video
movies:
- animation
- comedy
---
# Source: https://github.com/nikhilsbhat/yamll@main?path=internal/fixtures/base2.yaml
names:
- john doe
- dexter
---
# Source: http://localhost:3000/database.yaml
mysqldatabase: &mysqldatabase
hostname: localhost
port: 3012
username: root
password: root
---
# Source: internal/fixtures/import.yaml
config2:
test: val
<<: *default
config3:
- *default
- *mysqldatabase
workflow: *mysqldatabaseWant to see all your dependencies in a tree format? This yamll tool supports that too.
Using yaml tree will print dependencies just like the Linux tree command.
Example:
yamll tree -f import.yamlOutput:
└── internal/fixtures/import.yaml
├── internal/fixtures/base.yaml
│ └── internal/fixtures/base3.yaml
├── internal/fixtures/base2.yaml
│ └── internal/fixtures/base3.yaml
├── internal/fixtures/*.test.yaml
├── https://github.com/nikhilsbhat/yamll@main?path=internal/fixtures/base2.yaml
│ └── internal/fixtures/base3.yaml
└── http://localhost:3000/database.yamlyamll detects and prevents import cycles. If an import cycle is detected, it will report an error and stop the merging
process.
Updated documentation on all available commands and flags can be found here.