// Env merges the App environment with any environment variables provided
// in the process.
347267
func Env(app *Manifest, process *Process) map[string]string {
	return merge(app.Env, process.Env)
}
51355
func NewEnv() (*Env, error) {
	var _env *C.MDB_env
	ret := C.mdb_env_create(&_env)
	if ret != SUCCESS {
		return nil, errno(ret)
	}
	return &Env{_env}, nil
}
563304
func environ() (env []string) {
	for _, v := range os.Environ() {
		if !strings.HasPrefix(v, "GOPATH=") {
			env = append(env, v)
		}
	}
	env = append(env, "GOPATH="+gopath)
	return
}
1223469
func (c *Command) AddEnvs(envs ...string) *Command {
	c.envs = append(c.envs, envs...)
	return c
}
610596
func (c *Gcd) AddEnvironmentVars(vars []string) {
	c.env = append(c.env, vars...)
}
592502
func (c *ConfigParser) expandEnv(v []interface{}) (interface{}, error) {
	hasDefault := false
	def := ""
	if len(v) < 1 || len(v) > 2 {
		return "", fmt.Errorf("_env expansion expected 1 or 2 args, got %d", len(v))
	}
	s, ok := v[0].(string)
	if !ok {
		return "", fmt.Errorf("Expected a string after _env expansion; got %#v", v[0])
	}
	boolDefault, wantsBool := false, false
	if len(v) == 2 {
		hasDefault = true
		switch vdef := v[1].(type) {
		case string:
			def = vdef
		case bool:
			wantsBool = true
			boolDefault = vdef
		default:
			return "", fmt.Errorf("Expected default value in %q _env expansion; got %#v", s, v[1])
		}
	}
	var err error
	expanded := envPattern.ReplaceAllStringFunc(s, func(match string) string {
		envVar := match[2 : len(match)-1]
		val := os.Getenv(envVar)
		// Special case:
		if val == "" && envVar == "USER" && runtime.GOOS == "windows" {
			val = os.Getenv("USERNAME")
		}
		if val == "" {
			if hasDefault {
				return def
			}
			err = fmt.Errorf("couldn't expand environment variable %q", envVar)
		}
		return val
	})
	if wantsBool {
		if expanded == "" {
			return boolDefault, nil
		}
		return strconv.ParseBool(expanded)
	}
	return expanded, err
}
286940
func (t *Template) WithEnv(e map[string]string) *Template {
	t.fields[env] = e
	return t
}
358458
func (c *context) Env() map[string]string {
	env := make(map[string]string)
	for _, i := range os.Environ() {
		sep := strings.Index(i, "=")
		env[i[0:sep]] = i[sep+1:]
	}
	return env
}
94403
func Env(key string, defaultValue string) string {
	val := os.Getenv(key)
	if len(val) == 0 {
		return defaultValue
	}
	return val
}
811398
func environ() map[string]string {
	if env == nil {
		env = make(map[string]string)
		envVars := os.Environ()
		for _, envVar := range envVars {
			kv := strings.SplitN(envVar, "=", 2)
			if len(kv) != 2 {
				continue
			}
			env[kv[0]] = kv[1]
		}
	}
	return env
}
1198661
func Env(env []string) map[string]string {
	vars := mapEnv(env, splitEnv)
	return vars
}
534276
func (m *Module) Getenv(key string) string {
	if _, ok := m.Env[key]; !ok {
		m.Env[key] = os.Getenv(key)
	}
	return m.Env[key]
}
453328
func ValidateEnv(vars []core.EnvVar, fldPath *field.Path) field.ErrorList {
	allErrs := field.ErrorList{}

	for i, ev := range vars {
		idxPath := fldPath.Index(i)
		if len(ev.Name) == 0 {
			allErrs = append(allErrs, field.Required(idxPath.Child("name"), ""))
		} else {
			for _, msg := range validation.IsEnvVarName(ev.Name) {
				allErrs = append(allErrs, field.Invalid(idxPath.Child("name"), ev.Name, msg))
			}
		}
		allErrs = append(allErrs, validateEnvVarValueFrom(ev, idxPath.Child("valueFrom"))...)
	}
	return allErrs
}
1248818
func (b *binary) AddEnv(entry string) {
	b.env = append(b.env, entry)
}
524403
func JoinEnvironment(a, b []corev1.EnvVar) (out []corev1.EnvVar) {
	out = a
	for i := range b {
		exists := false
		for j := range a {
			if a[j].Name == b[i].Name {
				exists = true
				break
			}
		}
		if exists {
			continue
		}
		out = append(out, b[i])
	}
	return out
}
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
}
151063
func (ev *EnvVars) Restore() {
	for key, value := range ev.vars {
		if err := os.Setenv(key, value); err != nil {
			msg := fmt.Sprintf("cannot reset environment variable %q: %v", key, err)
			ev.assert.Fail(msg)
		}
	}
}