junocfg

package module
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: May 13, 2019 License: BSD-3-Clause Imports: 10 Imported by: 0

README

junocfg GoDoc Build Status

Template based config generator / settings files merge tool

Installation

go get github.com/gojuno/junocfg/...

Usage

Modes:

  • merge - merge config data from multiply sources to one dataset
  • check-tmpl
merge multiply config files to one
$ junocfg --merge -i public.yaml,secure.yaml -o settings.yaml

$ junocfg --merge -i public.yaml,secure.yaml > settings.yaml
generate template from settings file
$ junocfg -t config.yaml.tmpl -i settings.dev.yaml -o config.yaml

$ cat settings.dev.yaml | junocfg -t config.yaml.tmpl > config.yaml
check tmpl
$ junocfg --check-tmpl -t config.yaml.tmpl
$ cat config.yaml.tmpl | junocfg --check-tmpl
full pipiline / generate template from multiply config files

merge config data from multiply sources to one dataset and apply it to template

$ junocfg --merge -i public.yaml,secure.yaml | junocfg -t config.yaml.tmpl > config.yaml
convert between json & yaml
echo '{"a":"a","b":["b1","b2","b3","b4"],"c":{"ca":"ca","cb":["cb1","cb2",{"cb3a":"cb3aa"},"cb4",{"cb5a":"cb5aa"}]},"d":"a","e":{"ea":"ea","eb":"eb","ec":"ec"}}' | junocfg --yaml2json | jq '.'

echo '{"a":"a","b":["b1","b2","b3","b4"],"c":{"ca":"ca","cb":["cb1","cb2",{"cb3a":"cb3aa"},"cb4",{"cb5a":"cb5aa"}]},"d":"a","e":{"ea":"ea","eb":"eb","ec":"ec"}}' | junocfg --json2yaml

Test

junocfg --merge -i examples/a.yaml,examples/b.yaml

junocfg --check-tmpl -t examples/c.tmpl
cat examples/c.tmpl | junocfg --check-tmpl

echo '{"a":"a","b":["b1","b2","b3","b4"],"c":{"ca":"ca","cb":["cb1","cb2",{"cb3a":"cb3aa"},"cb4",{"cb5a":"cb5aa"}]},"d":"a","e":{"ea":"ea","eb":"eb","ec":"ec"}}' | junocfg --yaml2json | jq '.' | junocfg --json2yaml

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CheckTemplate

func CheckTemplate(tmpl []byte) (*template.Template, error)

func CheckYaml

func CheckYaml(data []byte) error

func Items2Map

func Items2Map(items ItemArray) (map[string]interface{}, error)

func Map2Json

func Map2Json(data map[string]interface{}) ([]byte, error)

func Map2Yaml

func Map2Yaml(data map[string]interface{}) ([]byte, error)

func PreprocessYaml

func PreprocessYaml(input *bytes.Buffer) *bytes.Buffer

func RenderAndCheckTemplate

func RenderAndCheckTemplate(tmpl []byte, settingsMap map[string]interface{}) (string, error)

Types

type ItemArray

type ItemArray []item

func Jsons2Items

func Jsons2Items(data [][]byte) (ItemArray, error)

func Yamls2Items

func Yamls2Items(data [][]byte) (ItemArray, error)

func (ItemArray) Len

func (a ItemArray) Len() int

func (ItemArray) Less

func (a ItemArray) Less(i, j int) bool

func (ItemArray) Swap

func (a ItemArray) Swap(i, j int)

Directories

Path Synopsis
cmd
junocfg command

Jump to

Keyboard shortcuts

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