env

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Feb 18, 2021 License: Apache-2.0 Imports: 3 Imported by: 2

Documentation

Index

Constants

View Source
const (
	// KubeConfig is the ENV variable to fetch kubernetes kubeconfig
	KubeConfig = "OPENEBS_IO_KUBE_CONFIG"

	// KubeMaster is the ENV variable to fetch kubernetes master's address
	KubeMaster = "OPENEBS_IO_K8S_MASTER"
)

Variables

This section is empty.

Functions

func Get

func Get(envKey string) (value string)

Get fetches value from the provided environment variable

NOTE:

This is an implementation of EnvironmentGetter

func GetOrDefault

func GetOrDefault(e string, defaultValue string) (value string)

GetOrDefault fetches value from the provided environment variable which on empty returns the defaultValue NOTE: os.Getenv is used here instead of os.LookupEnv because it is not required to know if the environment variable is defined on the system

func Lookup

func Lookup(envKey string) (value string, present bool)

Lookup looks up an environment variable

NOTE:

This is an implementation of EnvironmentLookup

func LookupOrFalse

func LookupOrFalse(envKey string) string

LookupOrFalse looks up an environment variable and returns a string "false" if environment variable is not present. It returns appropriate values for other cases.

func Set

func Set(envKey string, value string) (err error)

Set sets the provided environment variable

NOTE:

This is an implementation of EnvironmentSetter

func Truthy

func Truthy(envKey string) (truth bool)

Truthy returns boolean based on the environment variable's value

The lookup value can be truthy (i.e. 1, t, TRUE, true) or falsy (0, false, etc) based on strconv.ParseBool logic

Types

type EnvironmentGetter

type EnvironmentGetter func(envKey string) (value string)

EnvironmentGetter abstracts fetching value from an environment variable

type EnvironmentLookup

type EnvironmentLookup func(envKey string) (value string, present bool)

EnvironmentLookup abstracts looking up an environment variable

type EnvironmentSetter

type EnvironmentSetter func(envKey string, value string) (err error)

EnvironmentSetter abstracts setting of environment variable

Jump to

Keyboard shortcuts

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