env

package
v0.0.0-...-87af2f9 Latest Latest
Warning

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

Go to latest
Published: Jan 16, 2018 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package Env allows developers to use the consul(https://github.com/hashicorp/consul) api as a storage for environment variables.

At the production level this package abstracts out the consul.KV() api and at the dev level it abstracts out the core `os` package.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DefaultConfig

func DefaultConfig() *consul.Config

DefaultConfig() abstracts out the api.DefaultConfig call entirely. This is so in default usecases you will only ever need to import this one package. Obviously if you require more power you have the ability to import github.com/hashicorp/consul/api and configure your client as needed.

Types

type Env

type Env struct {
	// contains filtered or unexported fields
}

func New

func New(config *consul.Config) (Env, error)

New is used to return a new instance of a KV() consul client. It is provided a config to create the client. No default namespace is used.

func (Env) Get

func (env Env) Get(key string) string

func (Env) List

func (env Env) List() []string

List calls the consul.List() method to retrieve all values from a particular namespace. For backwards compatability, each KV Pair is formatted to match a standard k=v as per os.Environ.

func (Env) Namespace

func (env Env) Namespace() string

Namespace returns the set namespace

func (Env) Set

func (env Env) Set(key, value string) error

Set calls the consul.Put() method to save a value.

func (Env) SetNamespace

func (env Env) SetNamespace(ns string) Env

Namespace allows you to set and change the namespace.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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