// Env gets a map of the environment variables.
500082
func (c Context) Env() map[string]string {
	osEnv := os.Environ()
	envVars := make(map[string]string, len(osEnv))
	for _, env := range osEnv {
		data := strings.SplitN(env, "=", 2)
		if len(data) == 2 && len(data[0]) > 0 {
			envVars[data[0]] = data[1]
		}
	}
	return envVars
}
1246241
func GetEnv(envName, defaultValue string) string {
	value := os.Getenv(envName)
	if value == "" {
		return defaultValue
	}
	return value
}
302745
func GetAppEnv() (AppEnv, error) {
	appEnv := AppEnv{}
	if err := env.Populate(&appEnv); err != nil {
		return AppEnv{}, err
	}
	return appEnv, nil
}
921784
func (b *Builder) SetHookEnv(hook string, envs map[string]string) *Builder {
	b.mu.Lock()
	defer b.mu.Unlock()
	return b.setHookEnvLocked(hook, envs)
}
1371916
func FromEnvP(env string, value interface{}) interface{} {
	ev, err := FromEnv(env, value)
	if err != nil {
		panic(err)
	}
	return ev
}
151920
func (e Environment) Add(envs ...map[string]string) {
	for _, env := range envs {
		for k, v := range env {
			e[k] = v
		}
	}
}
428849
func Environ(c *yaml.Config, envs map[string]string) error {
	for _, p := range c.Pipeline {
		if p.Environment == nil {
			p.Environment = map[string]string{}
		}
		for k, v := range envs {
			if v == "" {
				continue
			}
			p.Environment[k] = v
		}
		if httpProxy != "" {
			p.Environment["HTTP_PROXY"] = httpProxy
			p.Environment["http_proxy"] = strings.ToUpper(httpProxy)
		}
		if httpsProxy != "" {
			p.Environment["HTTPS_PROXY"] = httpsProxy
			p.Environment["https_proxy"] = strings.ToUpper(httpsProxy)
		}
		if noProxy != "" {
			p.Environment["NO_PROXY"] = noProxy
			p.Environment["no_proxy"] = strings.ToUpper(noProxy)
		}
	}
	return nil
}
649573
func mergeEnv(sysEnv []string, cmdEnv map[string]string) []string {
	var env []string
	// cmdEnv has precedence and overwrites any duplicate vars
	for k, v := range cmdEnv {
		env = append(env, k+"="+v)
	}
	for _, s := range sysEnv {
		if n := strings.IndexByte(s, '='); n != -1 {
			k := s[:n] // key
			if _, found := cmdEnv[k]; !found {
				env = append(env, s)
			}
		}
	}
	return env
}
976283
func envOr(name, def string) string {
	s := os.Getenv(name)
	if s == "" {
		return def
	}
	return s
}
1082271
func GetEnvironment() Environment {
	v := strings.ToLower(os.Getenv(EnvVarName))
	for env, l := range EnvMap {
		for _, e := range l {
			if e == v {
				return env
			}
		}
	}
	return EnvUnknown
}
676462
func Getenv(key, userDefault string) string {
	if val := os.Getenv(key); val != "" {
		return val
	}
	return userDefault
}
1150558
func (opts *runOpts) goEnv() []string {
	env := append(os.Environ(), "NOMAD_E2E=1")
	if opts.nomadAddr != "" {
		env = append(env, "NOMAD_ADDR="+opts.nomadAddr)
	}
	if opts.consulAddr != "" {
		env = append(env, fmt.Sprintf("%s=%s", capi.HTTPAddrEnvName, opts.consulAddr))
	}
	if opts.vaultAddr != "" {
		env = append(env, fmt.Sprintf("%s=%s", vapi.EnvVaultAddress, opts.consulAddr))
	}

	return env
}
1074657
func (ns *Namespace) Getenv(key interface{}) (string, error) {
	skey, err := cast.ToStringE(key)
	if err != nil {
		return "", nil
	}

	return _os.Getenv(skey), nil
}
1248818
func (b *binary) AddEnv(entry string) {
	b.env = append(b.env, entry)
}
836959
func ProcessEnv(env *Configuration) {
	// TODO: allow reading from etcd

	ProcessLogxiEnv(env.Levels)
	ProcessLogxiColorsEnv(env.Colors)
	ProcessLogxiFormatEnv(env.Format)
}
162039
func (c *ServerContext) SetEnv(key, val string) {
	c.env[key] = val
}
742228
func (p *ListParam) EnvVars() (string, string) {
	if len(p.values) == 0 {
		return p.EnvName(), p.Default()
	}
	out := make([]string, len(p.values))
	for i, v := range p.values {
		_, out[i] = v.EnvVars()
	}
	return p.el.EnvName(), strings.Join(out, ",")
}