dy

command module
v0.0.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 7, 2019 License: GPL-3.0 Imports: 3 Imported by: 0

README

dy Go Report Card CircleCI

Construct YAML from a directory tree

Description

The entire world seems to think declarative configuration is best represented as YAML. This is especially prevailant in the land of Kubernetes and related tools. Terrible ideas have a tendency to accumulate leading to awful solutions 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.

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 level

Consider the following example:

$ tree k8s_deployment/
k8s_deployment/
├── _header.yaml
├── metadata.yaml
└── spec
    ├── _replicas.yaml
    ├── selector.yaml
    └── template
        ├── metadata
        │   └── labels.yaml
        └── spec
            └── containers.yaml

4 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)

Installing

Homebrew
brew tap sampointer/dy
brew install dy
Manually

Download the latest release and unpack it into an appropriate place in your ${PATH}.

Documentation

The Go Gopher

There is no documentation for this package.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL