// Environment returns a list of environment variables which are needed to make
// BPF programs and tc aware of the actual BPFFS mount path.
4677
func Environment() []string {
	return append(
		os.Environ(),
		fmt.Sprintf("CILIUM_BPF_MNT=%s", GetMapRoot()),
		fmt.Sprintf("TC_BPF_MNT=%s", GetMapRoot()),
	)
}
302745
func GetAppEnv() (AppEnv, error) {
	appEnv := AppEnv{}
	if err := env.Populate(&appEnv); err != nil {
		return AppEnv{}, err
	}
	return appEnv, nil
}
1248818
func (b *binary) AddEnv(entry string) {
	b.env = append(b.env, entry)
}
1198661
func Env(env []string) map[string]string {
	vars := mapEnv(env, splitEnv)
	return vars
}
837361
func NewEnvironment(root, configRoot, workspace, sshKeyName string, metadata datasource.Metadata) *Environment {
	firstNonNull := func(ip net.IP, env string) string {
		if ip == nil {
			return env
		}
		return ip.String()
	}
	substitutions := map[string]string{
		"$public_ipv4":  firstNonNull(metadata.PublicIPv4, os.Getenv("COREOS_PUBLIC_IPV4")),
		"$private_ipv4": firstNonNull(metadata.PrivateIPv4, os.Getenv("COREOS_PRIVATE_IPV4")),
		"$public_ipv6":  firstNonNull(metadata.PublicIPv6, os.Getenv("COREOS_PUBLIC_IPV6")),
		"$private_ipv6": firstNonNull(metadata.PrivateIPv6, os.Getenv("COREOS_PRIVATE_IPV6")),
	}
	return &Environment{root, configRoot, workspace, sshKeyName, substitutions}
}
1098019
func (c *ServerContext) GetEnv(key string) (string, bool) {
	val, ok := c.env[key]
	return val, ok
}
750432
func EnvFormat(res []*api.GenericResource, prefix string) []string {
	envs := make(map[string][]string)
	for _, v := range res {
		key := Kind(v)
		val := Value(v)
		envs[key] = append(envs[key], val)
	}

	env := make([]string, 0, len(res))
	for k, v := range envs {
		k = strings.ToUpper(prefix + "_" + k)
		env = append(env, k+"="+strings.Join(v, ","))
	}

	return env
}
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
}
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
}
378537
func setEnv(cmd *exec.Cmd, envs map[string]string) {
	env := os.Environ()
	cmd.Env = make([]string, 0, len(env)+len(envs))
outer:
	for _, e := range env {
		for k := range envs {
			if strings.HasPrefix(e, k+"=") {
				continue outer
			}
		}
		cmd.Env = append(cmd.Env, e)
	}
	for k, v := range envs {
		cmd.Env = append(cmd.Env, k+"="+v)
	}
}
725593
func (c *Config) EnvVars() map[string]string {
	vars := make(map[string]string, len(c.Params))
	for _, p := range c.Params {
		k, v := p.EnvVars()
		vars[k] = v
	}
	return vars
}
16142
func NormalizeEnvironment(env *vpython.Environment) error {
	if env.Spec == nil {
		env.Spec = &vpython.Spec{}
	}
	if err := NormalizeSpec(env.Spec, env.Pep425Tag); err != nil {
		return err
	}

	if env.Runtime == nil {
		env.Runtime = &vpython.Runtime{}
	}

	sort.Sort(pep425TagSlice(env.Pep425Tag))
	return nil
}
1338219
func Env() Environment {
	switch {
	case os.Getenv("CI") == "true" && os.Getenv("TRAVIS") == "true":
		return Environment{
			Name:          "travis",
			Repo:          os.Getenv("TRAVIS_REPO_SLUG"),
			Commit:        os.Getenv("TRAVIS_COMMIT"),
			Branch:        os.Getenv("TRAVIS_BRANCH"),
			Tag:           os.Getenv("TRAVIS_TAG"),
			Buildnum:      os.Getenv("TRAVIS_BUILD_NUMBER"),
			IsPullRequest: os.Getenv("TRAVIS_PULL_REQUEST") != "false",
			IsCronJob:     os.Getenv("TRAVIS_EVENT_TYPE") == "cron",
		}
	case os.Getenv("CI") == "True" && os.Getenv("APPVEYOR") == "True":
		return Environment{
			Name:          "appveyor",
			Repo:          os.Getenv("APPVEYOR_REPO_NAME"),
			Commit:        os.Getenv("APPVEYOR_REPO_COMMIT"),
			Branch:        os.Getenv("APPVEYOR_REPO_BRANCH"),
			Tag:           os.Getenv("APPVEYOR_REPO_TAG_NAME"),
			Buildnum:      os.Getenv("APPVEYOR_BUILD_NUMBER"),
			IsPullRequest: os.Getenv("APPVEYOR_PULL_REQUEST_NUMBER") != "",
			IsCronJob:     os.Getenv("APPVEYOR_SCHEDULED_BUILD") == "True",
		}
	default:
		return LocalEnv()
	}
}
263599
func (ec *Envcfg) Env() string {
	if env := ec.GetKey(ec.envKey); env != "" {
		return env
	}
	return DefaultEnvironment
}
1067647
func main() {
	os.Setenv("NAME", "foo")
	os.Setenv("PORT", "9001")
	os.Setenv("ADAPTER", "shell")
	// os.Setenv("IS_ENABLED", "asdf")
	c := &Config{}
	if err := env.Process(c); err != nil {
		panic(err)
	}
	fmt.Printf("name: %s, port: %d, adapter: %s, enabled: %v\n", c.Name, c.Port, c.Adapter, c.Enabled)
}
484531
func (cfg *Config) envForName(name string, e *vpython.Environment) *Env {
	// Env-specific root directory: <BaseDir>/<name>
	venvRoot := filepath.Join(cfg.BaseDir, name)
	binDir := venvBinDir(venvRoot)
	return &Env{
		Config:               cfg,
		Root:                 venvRoot,
		Name:                 name,
		Python:               filepath.Join(binDir, "python"),
		Environment:          e,
		BinDir:               binDir,
		EnvironmentStampPath: filepath.Join(venvRoot, fmt.Sprintf("environment.%s.pb.txt", vpython.Version)),
		lockPath:             filepath.Join(cfg.BaseDir, fmt.Sprintf(".%s.lock", name)),

		completeFlagPath: filepath.Join(venvRoot, "complete.flag"),
	}
}
30528
func AddEnv(env_str string) error {
	result := regexp.MustCompile("([^:]+):([^=]+)=(.+)").FindStringSubmatch(env_str)
	if result==nil {
		return fmt.Errorf("Error parsing internal service environment variable: %s", env_str)
	}
	service := result[1]
	key     := result[2]
	val     := result[3]

	if serviceMap, ok := envPerService[service]; ok {
		serviceMap[key] = val
		return nil
	}
	svcNames := []string{}
	for key := range envPerService {
		svcNames = append(svcNames, key)
	}
	return fmt.Errorf("Error setting internal service environment:'%s'  Service '%s' must be one of [%s]'",
		env_str, service, strings.Join(svcNames, ", "))
}