Documentation ¶
Index ¶
- type EnvReader
- func (r *EnvReader) GetConfigMap(namespace string, configMapName string, dataKey string) string
- func (r *EnvReader) GetEnv(key string) string
- func (r *EnvReader) GetEnvBool(key string) bool
- func (r *EnvReader) GetEnvFloat(key string) float64
- func (r *EnvReader) GetEnvOpt(key string) string
- func (r *EnvReader) GetFromFile(path string) []byte
- func (r *EnvReader) GetPodHosts(namespace string, labelSelector string) []string
- type IoutilInterface
- type ReaderOption
- type ReaderOptions
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 ¶
GetConfigMap returns the current value of a key in a Kubernetes config map
func (*EnvReader) GetEnvBool ¶
GetEnvBool returns the value of an environment variable as a bool using strconv.ParseBool. returns false if not found.
func (*EnvReader) GetEnvFloat ¶
GetEnvFloat returns the value of an environment variable as a float64 using strconv.ParseFloat(text,64)
func (*EnvReader) GetEnvOpt ¶
GetEnvOpt returns an envrironment variable, but does not return an error if the variable does not exist.
func (*EnvReader) GetFromFile ¶
GetFromFile returns the content of a file at path
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