/vortex

A stupidly simple template/variable file combiner written in Go

Primary LanguageGo

   :::     :::  ::::::::  ::::::::: ::::::::::: :::::::::: :::    :::
  :+:     :+: :+:    :+: :+:    :+:    :+:     :+:        :+:    :+:  
 +:+     +:+ +:+    +:+ +:+    +:+    +:+     +:+         +:+  +:+    
+#+     +:+ +#+    +:+ +#++:++#:     +#+     +#++:++#     +#++:+      
+#+   +#+  +#+    +#+ +#+    +#+    +#+     +#+         +#+  +#+      
#+#+#+#   #+#    #+# #+#    #+#    #+#     #+#        #+#    #+#      
 ###      ########  ###    ###    ###     ########## ###    ###       

Build Status Maintainability

A simple template reader and variable injector

  • Used for when you have a bunch of templates (e.g. kubernetes files) and want to inject a yaml file of variables
  • Supports giving it a directory of nested templates and an output path (it will reproduce the directory structure)

Example

demo.tmpl

apiVersion: v1
kind: Pod
metadata:
  name: console
spec:
  restartPolicy: Always
  containers:
    - name: {{.name}}
      image: {{.image}}

vars.yaml

name: "test"
image: "us.gcr.io/test"

The result;

apiVersion: v1
kind: Pod
metadata:
  name: console
spec:
  restartPolicy: Always
  containers:
    - name: test
      image: us.gcr.io/test

Usage

vortex -template example/demo.tmpl -output test.txt -varpath example/vars.yaml

Recursive folder templating

Vortex also can recursively follow a template folder

e.g.

somefolders/
            foo/
                template.yaml
            bar/
                another.yaml

vortex -template somefolders -output anoutputfolder -var example/vars.yaml

Other examples

build:
  commands: docker build --no-cache=true -t {{ .name }}:{{ .version }} .
  docker:
    containerID: {{ .name }}:{{ .version }}
    buildArgs:
      url: {{ .repoistory }}/{{ .name }}:{{ .version }}
kubernetes:
  namespace: {{ .namespace }}
  service: |-
    kind: Service
    apiVersion: v1
    metadata:
      name: {{ .name }}
      namespace: {{ .namespace }}
    spec:
      type: NodePort
      selector:
        app: {{ .name }}
      ports:
        - protocol: TCP
          port: 9090
          name: openport