Documentation
¶
Overview ¶
`mimic`: A Go module for defining and generating config in Go:
* Define your Configuration (e.g Envoy, Prometheus, Alertmanager, Nginx, Prometheus Alerts, Rules, Grafana Dashaboards etc.) * Define your Infrastructure (e.g Terraform, Ansible, Puppet, Chef, etc) * Define your Container Management (e.g Docker compose, Kubernetes, etc) * Define any other file that you can imagine
... using simple, typed and testable Go code!
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type FilePool ¶
FilePool is a struct for storing and managing files to be generated as part of generation.
func (*FilePool) Add ¶
Add adds a file to the file pool at the current path. The file is identified by filename. Content of the file is passed via an io.Reader.
If the file with the given name has already been added at this path the code will `panic`. NOTE: See mimic/encoding for different marshallers to use as io.Reader.
type Generator ¶
type Generator struct {
FilePool
// contains filtered or unexported fields
}
Generator manages a pool of generated files.
func New ¶
New returns a new Generator that parses os.Args as command line arguments. It allows passing closure BEFORE parsing the flags to allow defining additional flags.
NOTE: Read README.md before using. This is intentionally NOT following Go library patterns like: * It uses panics as the main error handling way. * It creates CLI command inside constructor. * It does not allow custom loggers etc
func (*Generator) Generate ¶
func (g *Generator) Generate()
Generate generates the configuration files that have been defined and added to a generator.
func (*Generator) With ¶
With behaves like linux `cd` command. It allows to "walk" & organize output files in a desired way for ease of use. Example:
```
gen := gen.With("mycompany.com", "production", "eu1", "kubernetes", "thanos")
``` Giving the path `mycompany.com/production/eu1/kubernetes/thanos`.
With return a Generator pointing at the specified path which can be specified even further: Example: ```
gen := mimic.New()
// gen/
...
gen = gen.With('foo')
// gen/foo
...
{
gen := gen.With('bar')
// gen/foo/bar
}
// gen/foo
```
Directories
¶
| Path | Synopsis |
|---|---|
|
encoding is a package of default encodings supplied with mimic.
|
encoding is a package of default encodings supplied with mimic. |
|
examples
|
|
|
kubernetes-statefulset
module
|
|
|
terraform
module
|
|
|
lib
|
|
|
abstr
Abstractions are used to (as the name suggests) abstract away the underlying config and structs to the caller allowing complex configurations or concepts to be created with minimal code.
|
Abstractions are used to (as the name suggests) abstract away the underlying config and structs to the caller allowing complex configurations or concepts to be created with minimal code. |
|
schemas
Providers are a way of defining a configuration specification in Go structs for projects that either do not currently expose their configuration structs or are difficult to work with (due to deps, complexity etc.).
|
Providers are a way of defining a configuration specification in Go structs for projects that either do not currently expose their configuration structs or are difficult to work with (due to deps, complexity etc.). |
|
abstr/kubernetes
module
|
|
|
schemas/prometheus
module
|