envetcd

package module
v0.3.7 Latest Latest
Warning

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

Go to latest
Published: Jul 16, 2015 License: MPL-2.0 Imports: 13 Imported by: 0

README

envetcd

Circle CI Coverage Status

envetcd provides a convienent way to populate values from etcd into a child process environment using the envetcd daemon.

The daemon envetcd allows applications to be configured with environmental variables, without having knowledge about the existence of etcd. This makes it especially easy to configure applications throughout all your environments: development, testing, production, etc.

envetcd was forked from envconsul which was inspired by envdir in its simplicity, name, and function.

Installation

You can download a released envetcd artifact from the envetcd release page on GitHub. If you wish to compile from source, you will need to have buildtools and Go installed:

$ git clone https://github.com/zvelo/envetcd.git
$ cd envetcd
$ make

This process will create envetcd which make be invoked as a binary.

Usage

Options
Option Environment Variable Default Description
peers $ENVETCD_PEERS 127.0.0.1:4001 a comma-delimited list of machine addresses in the cluster
ca-file $ENVETCD_CA_FILE certificate authority file
cert-file $ENVETCD_CERT_FILE tls client certificate file
key-file $ENVETCD_KEY_FILE tls client key file
hostname $HOSTNAME computer hostname for host specific configuration
system $ENVETCD_SYSTEM system name for system specific configuration
service $ENVETCD_SERVICE service name for service specific configuration
prefix $ENVETCD_PREFIX /config etcd prefix for all keys
log-level $ENVETCD_LOG_LEVEL WARN set log level (DEBUG, INFO, WARN, ERR)
no-sync $ENVETCD_NO_SYNC false don't synchronize cluster information before sending request
clean-env $ENVETCD_CLEAN_ENV false don't inherit any environment variables other than those pulled from etcd
no-sanitize $ENVETCD_NO_SANITIZE false don't remove bad characters from environment keys
no-upcase $ENVETCD_NO_UPCASE false don't convert all environment keys to uppercase
Command Line

The CLI interface supports all of the options detailed above.

Query the default etcd instance, rending all the keys in /config/redis, and printing the environment.

$ envetcd \
  --no-sanitize \
  --no-upcase \
  --service redis \
  --system storage \
  env

Query a local etcd instance, converting special characters in keys to undercores and uppercasing the keys:

$ envetcd \
  --peers 127.0.0.1:4001 \
  --prefix /config \
  --service redis \
  env

Examples

Redis

Redis is a command key-value storage engine. If Redis is configured to read the given environment variables, you can use envetcd to start and manage the process:

$ envetcd \
  --service redis \
  service redis start
Env

This example is a great way to see envetcd in action. In practice, it is unlikely to be a useful use of envetcd though:

$ envetcd \
  --service redis \
  env
ADDRESS=1.2.3.4
PORT=55

Contributing

To hack on envetcd, you will need a modern Go environment. To compile the envetcd binary and run the test suite, simply execute:

$ make

This will compile the envetcd binary.

If you want to run the tests:

$ make test

The etcd server default address is 127.0.0.1. To override, create the environment variable ZVELO_ETCD_HOST={etcd address}

Or to run a specific test in the suite:

go test ./... -run SomeTestFunction_name

Submit Pull Requests and Issues to the envetcd project on GitHub.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Set added in v0.1.0

func Set(service string) error

Set modifies the current environment with variables retrieved from etcd. Set will not overwrite existing variables. On linux systems, the default gateway will be automatically used as the etcd endpoint. If $ETCD_PEERS is set, it will override the default gateway. $ETCD_PEERS should look like "http://127.0.0.1:4001". service should be set by the application calling Set and not derived from an environment variable. Set will also use some other environment variables if they exist. $ENVETCD_PREFIX defaults to "/config" $HOSTNAME will be honored if it is set. An error is returned only if there was an actual error. Inability to determine the etcd endpoint as tolerated and not considered an error. In this case Set will simply not do anyting and it is up to the application to ensure that it has been configured properly through other means such as environment variables or command line flags.

Types

type Config added in v0.1.0

type Config struct {
	Etcd              *util.EtcdConfig
	Sanitize          bool
	Upcase            bool
	UseDefaultGateway bool
	Prefix            string
	System            string
	Service           string
	Hostname          string
	TemplateFiles     []string
}

Config contains all of the parameters needed to run GetKeyPairs

type KeyPairs

type KeyPairs map[string]string

KeyPairs is a slice of KeyPair pointers

func GetKeyPairs added in v0.1.0

func GetKeyPairs(config *Config) (KeyPairs, error)

GetKeyPairs takes a given config and client, and returns all key pairs

Directories

Path Synopsis
Godeps
_workspace/src/github.com/codegangsta/cli
Package cli provides a minimal framework for creating and organizing command line Go applications.
Package cli provides a minimal framework for creating and organizing command line Go applications.
_workspace/src/github.com/golang/protobuf/proto
Package proto converts data structures to and from the wire format of protocol buffers.
Package proto converts data structures to and from the wire format of protocol buffers.
_workspace/src/github.com/golang/protobuf/proto/proto3_proto
Package proto3_proto is a generated protocol buffer package.
Package proto3_proto is a generated protocol buffer package.
_workspace/src/github.com/hashicorp/logutils
Package logutils augments the standard log package with levels.
Package logutils augments the standard log package with levels.
_workspace/src/github.com/jtolds/gls
Package gls implements goroutine-local storage.
Package gls implements goroutine-local storage.
_workspace/src/github.com/smartystreets/assertions
Package assertions contains the implementations for all assertions which are referenced in goconvey's `convey` package (github.com/smartystreets/goconvey/convey) for use with the So(...) method.
Package assertions contains the implementations for all assertions which are referenced in goconvey's `convey` package (github.com/smartystreets/goconvey/convey) for use with the So(...) method.
_workspace/src/github.com/smartystreets/assertions/internal/oglematchers
Package oglematchers provides a set of matchers useful in a testing or mocking framework.
Package oglematchers provides a set of matchers useful in a testing or mocking framework.
_workspace/src/github.com/smartystreets/assertions/internal/oglemock/createmock
createmock is used to generate source code for mock versions of interfaces from installed packages.
createmock is used to generate source code for mock versions of interfaces from installed packages.
_workspace/src/github.com/smartystreets/assertions/internal/oglemock/generate
Package generate implements code generation for mock classes.
Package generate implements code generation for mock classes.
_workspace/src/github.com/smartystreets/assertions/internal/oglemock/generate/test_cases/complicated_pkg
Package complicated_pkg contains an interface with lots of interesting cases, for use in integration testing.
Package complicated_pkg contains an interface with lots of interesting cases, for use in integration testing.
_workspace/src/github.com/smartystreets/assertions/internal/oglemock/generate/test_cases/renamed_pkg
A package that calls itself something different than its package path would have you believe.
A package that calls itself something different than its package path would have you believe.
_workspace/src/github.com/smartystreets/assertions/internal/ogletest
Package ogletest provides a framework for writing expressive unit tests.
Package ogletest provides a framework for writing expressive unit tests.
Functions for working with source code.
_workspace/src/github.com/smartystreets/assertions/internal/reqtrace
Package reqtrace contains a very simple request tracing framework.
Package reqtrace contains a very simple request tracing framework.
_workspace/src/github.com/smartystreets/assertions/should
package should is simply a rewording of the assertion functions in the assertions package.
package should is simply a rewording of the assertion functions in the assertions package.
_workspace/src/github.com/smartystreets/goconvey/convey
Package convey contains all of the public-facing entry points to this project.
Package convey contains all of the public-facing entry points to this project.
_workspace/src/github.com/smartystreets/goconvey/convey/gotest
Package gotest contains internal functionality.
Package gotest contains internal functionality.
_workspace/src/github.com/smartystreets/goconvey/convey/reporting
Package reporting contains internal functionality related to console reporting and output.
Package reporting contains internal functionality related to console reporting and output.
_workspace/src/github.com/unrolled/render
Package render is a package that provides functionality for easily rendering JSON, XML, binary data, and HTML templates.
Package render is a package that provides functionality for easily rendering JSON, XML, binary data, and HTML templates.
cmd

Jump to

Keyboard shortcuts

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