Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/sampointer/dy
Construct YAML from a directory tree
https://github.com/sampointer/dy
cloudformation containers continuous-integration docker kubernetes yaml
Last synced: about 1 month ago
JSON representation
Construct YAML from a directory tree
- Host: GitHub
- URL: https://github.com/sampointer/dy
- Owner: sampointer
- License: gpl-3.0
- Archived: true
- Created: 2019-11-06T16:06:37.000Z (about 5 years ago)
- Default Branch: master
- Last Pushed: 2023-02-27T19:57:05.000Z (almost 2 years ago)
- Last Synced: 2024-08-02T01:25:48.693Z (4 months ago)
- Topics: cloudformation, containers, continuous-integration, docker, kubernetes, yaml
- Language: Go
- Size: 40 KB
- Stars: 123
- Watchers: 3
- Forks: 4
- Open Issues: 4
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-repositories - sampointer/dy - Construct YAML from a directory tree (Go)
README
# dy [![Go Report Card](https://goreportcard.com/badge/github.com/sampointer/dy)](https://goreportcard.com/report/github.com/sampointer/dy) [![CircleCI](https://circleci.com/gh/sampointer/dy.svg?style=shield)](https://circleci.com/gh/sampointer/dy) [![GoDoc](https://godoc.org/github.com/sampointer/dy?status.svg)](https://godoc.org/github.com/sampointer/dy)
Construct YAML from a directory tree## Description
The entire world seems to think declarative configuration is best represented as YAML. This is especially prevalent in the land of Kubernetes and related tools. Terrible ideas have a tendency to accumulate leading to [awful solutions](https://twitter.com/sam_pointer/status/1182321989895311362) to the wrong problems.Whilst this tool doesn't pretend to move the mountain it does try to nudge it back in the right direction.
Put simply, `dy` allows one to build a YAML document from a directory tree containing snippets of YAML. The aim is to make the document easier to reason about and maintain.
It is useful everywhere complex YAML configuration is employed: CI pipelines, Cloudformation, Kubernetes, etc. See the [examples](https://github.com/sampointer/dy/tree/master/examples) for inspiration, especially in tandem with [envsubst](https://www.gnu.org/software/gettext/manual/html_node/envsubst-Invocation.html).
## Introducing Divvy Yaml
> **divvy** */ˈdɪvi/* - To share out. *Informal, British* - A foolish or stupid person`dy` parses a directory tree according to the following rules:
* A directory is a text key
* A file name has contents that are rendered under a key named after the file prefix
* A file name that begins with an underscore is rendered without a key at the current indentation levelConsider the following [example](https://github.com/sampointer/dy/tree/master/examples/k8s_deployment):
```
$ tree k8s_deployment/
k8s_deployment/
├── _header.yaml
├── metadata.yaml
└── spec
├── _replicas.yaml
├── selector.yaml
└── template
├── metadata
│ └── labels.yaml
└── spec
└── containers.yaml4 directories, 6 files
``````
$ dy k8s_deployment/
apiVersion: apps/v1
kind: Deployment
metadata:
name: nginx-deployment
labels:
app: nginx
spec:
replicas: 3
selector:
matchLabels:
app: nginx
template:
metadata:
labels:
app: nginx
spec:
containers:
- name: nginx
image: nginx:1.7.9
ports:
- containerPort: 80
``````
$ dy k8s_deployment/ | kubectl apply --validate=true --dry-run=true -f -
deployment.apps/nginx-deployment created (dry run)
```You may pass multiple directories as arguments and they will each be parsed and
emitted as documents in their own right. In this way a single `dy` invocation
can be used to produce a valid multi-document YAML stream.## Installing
### Homebrew
```
brew tap sampointer/dy
brew install dy
```### Manually
Download the appropriate package for your distribution from the [releases](https://github.com/sampointer/dy/releases) page.