mkconfig

package module
v0.0.0-...-d454fec Latest Latest
Warning

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

Go to latest
Published: Feb 19, 2015 License: ISC Imports: 5 Imported by: 0

README

mkconfig

mkconfig is a way to render configuration files for services.

It is designed to be extensible in terms of sources of service information.

See github.com/tmc/mkconfig/sources/json/json.go for a basic json file backend.

mkconfig

go get github.com/tmc/mkconfig

Example invocation:

mkconfig -source=json://./example/dummy.json -template=./example/dummy.tmpl

Output:

# example template
dummysvc:
 - 10.0.0.1:8080
 - 10.0.0.2:8080
 - 10.0.0.3:8080
 - 10.0.0.4:8080

dummy.tmpl:

# example template
dummysvc:
{{ range service "dummysvc"}} - {{.Addr}}:{{.Port}}
{{ end }}

dummy.json:

{
  "dummysvc": [
    {
      "name": "dummysvc1",
      "port": 8080,
      "addr": "10.0.0.1"
    },
    {
      "name": "dummysvc2",
      "port": 8080,
      "addr": "10.0.0.2"
    },
    {
      "name": "dummysvc3",
      "port": 8080,
      "addr": "10.0.0.3"
    },
    {
      "name": "dummysvc4",
      "port": 8080,
      "addr": "10.0.0.4"
    }
  ]
}

Documentation

Overview

Package mkconfig renders templates

Example invocation:

mkconfig -source=json://./example/dummy.json -template=./example/dummy.tmpl

Output:

# example template
dummysvc:
 - 10.0.0.1:8080
 - 10.0.0.2:8080
 - 10.0.0.3:8080
 - 10.0.0.4:8080

dummy.tmpl:

# example template
dummysvc:
{{ range service "dummysvc"}} - {{.Addr}}:{{.Port}}
{{ end }}

dummy.json:

{
  "dummysvc": [
    {
      "name": "dummysvc1",
      "port": 8080,
      "addr": "10.0.0.1"
    },
    {
      "name": "dummysvc2",
      "port": 8080,
      "addr": "10.0.0.2"
    },
    {
      "name": "dummysvc3",
      "port": 8080,
      "addr": "10.0.0.3"
    },
    {
      "name": "dummysvc4",
      "port": 8080,
      "addr": "10.0.0.4"
    }
  ]
}

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Render

func Render(source sources.Source, templateSrc io.Reader, output io.Writer, dryRun bool) error

func RenderPath

func RenderPath(source sources.Source, templatePath, outputPath string, dryRun bool) error

Types

This section is empty.

Directories

Path Synopsis
cmd
mkconfig command
mkconfig renders templates
mkconfig renders templates
Package sources provides an abstraction of services and a registry for additional source backends A source is defined by the Source interface: type Source interface { Service(name string) ([]services.Service, error) }
Package sources provides an abstraction of services and a registry for additional source backends A source is defined by the Source interface: type Source interface { Service(name string) ([]services.Service, error) }
file
Package file provides a mkconfig.sources backend that reads from a very basic flat file format Example contents of example.cfg: host1,10.0.0.1,8080 host2,10.0.0.2,8080
Package file provides a mkconfig.sources backend that reads from a very basic flat file format Example contents of example.cfg: host1,10.0.0.1,8080 host2,10.0.0.2,8080
json
Package json_source provides a mkconfig.sources backend that reads from a very basic json format Example contents of example.json: { "dummysvc": [ { "name": "dummysvc1", "port": 8080, "addr": "10.0.0.1" }, { "name": "dummysvc2", "port": 8080, "addr": "10.0.0.2" }, { "name": "dummysvc3", "port": 8080, "addr": "10.0.0.3" }, { "name": "dummysvc4", "port": 8080, "addr": "10.0.0.4" } ] }
Package json_source provides a mkconfig.sources backend that reads from a very basic json format Example contents of example.json: { "dummysvc": [ { "name": "dummysvc1", "port": 8080, "addr": "10.0.0.1" }, { "name": "dummysvc2", "port": 8080, "addr": "10.0.0.2" }, { "name": "dummysvc3", "port": 8080, "addr": "10.0.0.3" }, { "name": "dummysvc4", "port": 8080, "addr": "10.0.0.4" } ] }

Jump to

Keyboard shortcuts

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