envreader

package
v1.0.15 Latest Latest
Warning

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

Go to latest
Published: Sep 20, 2021 License: AGPL-3.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type EnvReader

type EnvReader struct {
	MissingKeys [][]string
	Errors      bool
	// contains filtered or unexported fields
}

EnvReader collects environmental state such as environment variables, kubernetes state, config maps, etc.

func NewEnvReader

func NewEnvReader(options ...ReaderOption) *EnvReader

NewEnvReader returns a new EnvReader with options specified

func (*EnvReader) GetConfigMap

func (r *EnvReader) GetConfigMap(namespace string, configMapName string, dataKey string) string

GetConfigMap returns the current value of a key in a Kubernetes config map

func (*EnvReader) GetEnv

func (r *EnvReader) GetEnv(key string) string

GetEnv returns an envrironment variable

func (*EnvReader) GetEnvBool

func (r *EnvReader) GetEnvBool(key string) bool

GetEnvBool returns the value of an environment variable as a bool using strconv.ParseBool. returns false if not found.

func (*EnvReader) GetEnvFloat

func (r *EnvReader) GetEnvFloat(key string) float64

GetEnvFloat returns the value of an environment variable as a float64 using strconv.ParseFloat(text,64)

func (*EnvReader) GetEnvOpt

func (r *EnvReader) GetEnvOpt(key string) string

GetEnvOpt returns an envrironment variable, but does not return an error if the variable does not exist.

func (*EnvReader) GetFromFile

func (r *EnvReader) GetFromFile(path string) []byte

GetFromFile returns the content of a file at path

func (*EnvReader) GetPodHosts

func (r *EnvReader) GetPodHosts(namespace string, labelSelector string) []string

GetPodHosts returns the host names for all pods that match the label selector.

type IoutilInterface

type IoutilInterface interface {
	ReadAll(r io.Reader) ([]byte, error)
	ReadFile(filename string) ([]byte, error)
	WriteFile(filename string, data []byte, perm os.FileMode) error
	ReadDir(dirname string) ([]os.FileInfo, error)
	NopCloser(r io.Reader) io.ReadCloser
}

IoutilInterface enforces the ioutil signature useful for testing

type ReaderOption

type ReaderOption func(*ReaderOptions)

ReaderOption defines a function to set ReaderOptions

func WithConfigMapInterface

func WithConfigMapInterface(configMapInterface v1.ConfigMapInterface) ReaderOption

WithConfigMapInterface sets the Kubernetes ConfigMap Interface for the reader. Useful for testing

func WithFilesystem

func WithFilesystem(fs IoutilInterface) ReaderOption

WithFilesystem sets the filesystem Interface for the reader. Useful for testing

func WithPodInterface

func WithPodInterface(podInterface v1.PodInterface) ReaderOption

WithPodInterface sets the Kubernetes Pod Interface for the reader. Useful for testing

type ReaderOptions

type ReaderOptions struct {
	PodInterface       v1.PodInterface
	ConfigMapInterface v1.ConfigMapInterface
	FileSystem         IoutilInterface
}

ReaderOptions define the behavior of a new reader

Jump to

Keyboard shortcuts

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