Exemplo n.º 1
0
// MergeEnvFromProfiles merges the environment variables stored in the specified
// profiles and target with the env parameter. It uses MergeEnv to do so.
func MergeEnvFromProfiles(concat map[string]string, ignore map[string]bool, env *envvar.Vars, target Target, profileNames ...string) ([]string, error) {
	vars := [][]string{}
	for _, name := range profileNames {
		t := LookupProfileTarget(name, target)
		if t == nil {
			return nil, fmt.Errorf("failed to lookup %v --target=%v", name, target)
		}
		vars = append(vars, t.Env.Vars)
	}
	MergeEnv(concat, ignore, env, vars...)
	return env.ToSlice(), nil
}