// EmptyEnvs empties the environment variables for a pod
517056
func (p *Pod) EmptyEnvs() *Pod {
	p.Env = make(map[string]string)
	return p
}
1248818
func (b *binary) AddEnv(entry string) {
	b.env = append(b.env, entry)
}
536699
func ExportEnv(env []string) string {
	if len(env) == 0 {
		return ""
	}
	out := "export"
	for _, e := range env {
		if len(e) == 0 {
			continue
		}
		out += " " + BashQuote(e)
	}
	return out + "; "
}
415840
func (m *Model) AppendEnvs(envs ...string) *Model {
	return m.SetEnvs(append(os.Environ(), envs...)...)
}
628106
func LoadEnvVars() error {
	if envLoaded {
		return nil
	}
	if len(os.Getenv("ABOT_PATH")) == 0 {
		p := filepath.Join(os.Getenv("GOPATH"), "src", "github.com",
			"itsabot", "abot")
		log.Debug("ABOT_PATH not set. defaulting to", p)
		if err := os.Setenv("ABOT_PATH", p); err != nil {
			return err
		}
	}
	if len(os.Getenv("ITSABOT_URL")) == 0 {
		log.Debug("ITSABOT_URL not set, using https://www.itsabot.org")
		err := os.Setenv("ITSABOT_URL", "https://www.itsabot.org")
		if err != nil {
			return err
		}
	}
	p := filepath.Join("abot.env")
	fi, err := os.Open(p)
	if os.IsNotExist(err) {
		// Assume the user has loaded their env variables into their
		// path
		return nil
	}
	if err != nil {
		return err
	}
	defer func() {
		if err = fi.Close(); err != nil {
			log.Info("failed to close file")
		}
	}()
	scn := bufio.NewScanner(fi)
	for scn.Scan() {
		line := scn.Text()
		fields := strings.SplitN(line, "=", 2)
		if len(fields) != 2 {
			continue
		}
		key := strings.TrimSpace(fields[0])
		if len(key) == 0 {
			continue
		}
		if len(os.Getenv(fields[0])) > 0 {
			continue
		}
		val := strings.TrimSpace(fields[1])
		if len(val) >= 2 {
			if val[0] == '"' || val[0] == '\'' {
				val = val[1 : len(val)-1]
			}
		}
		if err = os.Setenv(key, val); err != nil {
			return err
		}
	}
	if err = scn.Err(); err != nil {
		return err
	}
	envLoaded = true
	return nil
}
412951
func Env(key, fallback string) string {
	v := os.Getenv(key)
	if v != "" {
		return v
	}

	return fallback
}
1372488
func AppendPathEnvs(env *[]string, name string, v ...string) error {
	return pp(AppendPathEnv, env, name, v...)
}
286940
func (t *Template) WithEnv(e map[string]string) *Template {
	t.fields[env] = e
	return t
}
787244
func (f *Function) Setenv(name, value string) {
	f.Environment[name] = value
}
344270
func (p *PodContainer) AddEnv(name, value string) *PodContainer {
	if p.Env == nil {
		p = p.EmptyEnvs()
	}
	p.Env[name] = value
	return p
}
182795
func ReplaceEnv(arg string, environments ...map[string]string) string {
	return envRe.ReplaceAllStringFunc(arg, func(arg string) string {
		stripped := arg[2 : len(arg)-1]
		for _, env := range environments {
			if value, ok := env[stripped]; ok {
				return value
			}
		}

		return arg
	})
}
1223469
func (c *Command) AddEnvs(envs ...string) *Command {
	c.envs = append(c.envs, envs...)
	return c
}
698231
func (s *Stubs) UnsetEnv(k string) *Stubs {
	s.checkEnvKey(k)

	os.Unsetenv(k)
	return s
}
492838
func CleanEnvVar(s string, r byte) string {
	b := []byte(s)
	for i, c := range b {
		switch {
		case c == '_':
		case c == '.':
		case c >= 'a' && c <= 'z':
		case c >= 'A' && c <= 'Z':
		case i > 0 && c >= '0' && c <= '9':
		default:
			// Replace!
			b[i] = r
		}
	}
	return string(b)
}
182696
func (p *Pod) EmptyLabels() *Pod {
	p.Labels = make(map[string]string)
	return p
}
833302
func ReplaceEnvWithPlaceHolder(arg string, placeholder string) string {
	return envRe.ReplaceAllString(arg, placeholder)
}
562170
func (p *KVParam) EnvVars() (string, string) {
	if len(p.values) == 0 {
		return p.EnvName(), p.Default()
	}
	vals := make([]string, len(p.values))
	for i, v := range p.values {
		vals[i] = v.String()
	}
	return p.EnvName(), strings.Join(vals, p.sep())
}