The YAML File tool was originally written to serve a CLI for the ytbx
Go library. It serves as a convenience layer for the following use cases:
- Support for handling Dot-Style (
some.key.in.structure
) and Go-Patch paths (/some/key/in/name=structure
) - Retrieving a value from a YAML file at a specific location, described by a path
- Restructure the order of keys in a mapping to be more human friendly and readable
-
Retrieve a value from the YAML file:
$ yft get foobar.yml /list/name=one/somekey foobar
-
Restructure the order of keys in a mapping context to be more readable:
$ yft get restructure.yml / releases: - sha1: 5ab3b7e685ca18a47d0b4a16d0e3b60832b0a393 name: binary-buildpack version: 1.0.32 url: https://bosh.io/d/github.com/cloudfoundry/binary-buildpack-release?v=1.0.32 $ yft restructure restructure.yml releases: - name: binary-buildpack url: https://bosh.io/d/github.com/cloudfoundry/binary-buildpack-release?v=1.0.32 version: 1.0.32 sha1: 5ab3b7e685ca18a47d0b4a16d0e3b60832b0a393
-
List all paths in a YAML file:
$ yft paths foobar.yml /list/name=one/somekey /list/name=two/somekey /map/foobar/key
-
Create a list of paths that are common in two YAML files:
$ yft compare foo.yml bar.yml /list/name=one/somekey
There are different ways to get yft
. You are free to pick the one that makes the most sense for your use case.
-
On macOS systems, a Homebrew tap is available to install
yft
:brew install homeport/tap/yft
-
Use a convenience script to download the latest release to install it in a suitable location on your local machine:
curl -sL https://git.io/JvUjf | bash
We are happy to have other people contributing to the project. If you decide to do that, here's how to:
- get Go (
yft
requires Go version 1.20 or greater) - fork the project
- create a new branch
- make your changes
- open a PR.
Git commit messages should be meaningful and follow the rules nicely written down by Chris Beams:
The seven rules of a great Git commit message
- Separate subject from body with a blank line
- Limit the subject line to 50 characters
- Capitalize the subject line
- Do not end the subject line with a period
- Use the imperative mood in the subject line
- Wrap the body at 72 characters
- Use the body to explain what and why vs. how
There are multiple make targets, but running all
does everything you want in one call.
make all
Best way is to use Docker to spin up a container:
docker run \
--interactive \
--tty \
--rm \
--volume $GOPATH/src/github.com/homeport/yft:/go/src/github.com/homeport/yft \
--workdir /go/src/github.com/homeport/yft \
golang:1.20 /bin/bash
Licensed under MIT License