environ

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Mar 28, 2019 License: GPL-3.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Marshallers added in v1.0.0

func Marshallers() []string

Marshallers returns a list of all valid serializers extensions

func RegisterProvider

func RegisterProvider(name string, fn ProviderFactory)

RegisterProvider adds the named Provider's factory function to the map of known Providers

Types

type Environ

type Environ struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

Environ is a concurrency safe-ish map[string]string for holding environment variables

func New added in v0.2.0

func New() *Environ

New returns a new blank Environ instance

func NewFromEnv added in v0.2.0

func NewFromEnv() *Environ

NewFromEnv returns a new Environ instance populated from os.Environ

func (*Environ) Delete

func (e *Environ) Delete(key string) (v string)

Delete takes a key and removes it from this Environ, returning the value

func (*Environ) Len

func (e *Environ) Len() (l int)

Len returns the length of this Environ

func (*Environ) Load

func (e *Environ) Load(k string) (v string, ok bool)

Load takes a key and returns the value if it exists or false

func (*Environ) Map added in v0.2.0

func (e *Environ) Map() map[string]string

Map returns a copy of the underlying map[string]string

func (*Environ) Merge

func (e *Environ) Merge(m map[string]string)

Merge takes a map[string]string and adds it to this Environ, overwriting any conflicting keys.

func (*Environ) Populate added in v1.0.0

func (e *Environ) Populate(providers []string)

Populate adds secrets to the Environ from the given providers

func (*Environ) SafeAppend added in v0.2.0

func (e *Environ) SafeAppend(s []string)

SafeAppend takes a slice in the form of os.Environ() - '=' delimited - and appends it to Environ without overwriting keys.

func (*Environ) SafeMerge

func (e *Environ) SafeMerge(m map[string]string)

SafeMerge takes a map[string]string and adds it to this Environ without overwriting keys

func (*Environ) Set

func (e *Environ) Set(k, v string)

Set takes a key / value pair and adds it to this Environ

func (*Environ) SetMarshaller added in v0.2.0

func (e *Environ) SetMarshaller(m string)

SetMarshaller sets the marshalling function for the Environ object.

func (*Environ) Slice

func (e *Environ) Slice() []string

Slice returns a sorted []string of key / value pairs from this Environ instance suitable for use in palce of os.Environ()

func (*Environ) String

func (e *Environ) String() string

String returns a stringified representation of this Environ

func (*Environ) Write added in v0.2.0

func (e *Environ) Write(w io.Writer) error

Write writes the marshalled byte slice of the underlying map to the given io.Writer

type Provider

type Provider interface {
	AddToEnviron(*Environ) error
}

Provider is a secrets provider able to inject variables into the environment

func GetProvider

func GetProvider(name string) (Provider, error)

GetProvider returns a new instance of the named Provider or an unregistered provider error

type ProviderFactory

type ProviderFactory func() (Provider, error)

ProviderFactory is a func that returns a new Provider

Directories

Path Synopsis
providers

Jump to

Keyboard shortcuts

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