yutil
Common functionality for working with YAML files
Table of contents
Features
Getting started
Installation
Install yutil
with your preferred method:
deb/rpm/apk:
Download the .deb, .rpm or .apk from the latest release and install them with the appropriate tools.
Manual
Download the .tar.gz
from the latest release and add the binary to your path.
Go users
go install github.com/amplia-iiot/yutil@latest
Test installation
yutil version
Quick Start
yutil help
Merge
This outputs a formatted (ordered and cleaned) YAML file resulting of merging the passed yaml files (or content).
The files are merged in ascending level of importance in the hierarchy. A yaml node in the last file replaces values in
any previous file. You may pass as many YAML files as desired:
yutil merge base.yml changes.yml
yutil merge base.yml changes.yml important.yml
Use -o
(--output
) option if you want to output to a file instead of stdout.
yutil merge base.yml changes.yml -o merged.yml
By default yutil
uses stdin as the first YAML content:
cat base.yml | yutil merge changes.yml > merged.yml
You may ignore this input if you can't control what's piped to yutil
:
echo "this is not a yaml" | yutil --no-input merge base.yml changes.yml
External configuration
You may want to always use the same config without writting the flags, yutil
reads a YAML file to configure itself from the current folder or the user home dir in these order of precedence:
.yutil.yaml
in current folder
.yutil.yml
in current folder
.yutil
in current folder
.yutil.yaml
in user home dir
.yutil.yml
in user home dir
.yutil
in user home dir
Sample configuration file:
# Disable stdin
no-input: true
# Merge specific config
merge:
# Merge output file
output: /tmp/merged.yml
You may pass as argument the desired config file:
# Including extension to support multiple config types
./yutil version --config config.properties
Supported formats: JSON, TOML, YAML, HCL, envfile and Java properties config files
Development
- Use Golang version
>= 1.16
- Fork (https://github.com/amplia-iiot/yutil)
- Run
make set-up
to install dev tools
- Create a feature branch
- Check changes (test & lint) with
make check
- Commit your changes following Conventional Commits
- Rebase your local changes against the upstream main branch
- Create a Pull Request
You are welcome to report bugs or add feature requests and comments in issues.
Release Process
make version
contains the steps to generate a new version. It uses svu
to calculate the next version number based on the git log and generates the CHANGELOG.md with git-chglog
Push the generated tag and the release github action will generate the release.
CHANGELOG
See CHANGELOG.md
License
MIT © amplia-iiot