MCPcopy Index your code
hub / github.com/docker/cli / buildEnvironment

Function buildEnvironment

cli/command/stack/loader.go:118–142  ·  view source on GitHub ↗
(env []string)

Source from the content-addressed store, hash-verified

116}
117
118func buildEnvironment(env []string) (map[string]string, error) {
119 result := make(map[string]string, len(env))
120 for _, s := range env {
121 if runtime.GOOS == "windows" && len(s) > 0 {
122 // cmd.exe can have special environment variables which names start with "=".
123 // They are only there for MS-DOS compatibility and we should ignore them.
124 // See TestBuildEnvironment for examples.
125 //
126 // https://ss64.com/nt/syntax-variables.html
127 // https://devblogs.microsoft.com/oldnewthing/20100506-00/?p=14133
128 // https://github.com/docker/cli/issues/4078
129 if s[0] == '=' {
130 continue
131 }
132 }
133
134 k, v, ok := strings.Cut(s, "=")
135 if !ok || k == "" {
136 return result, fmt.Errorf("unexpected environment variable '%s'", s)
137 }
138 // value may be set, but empty if "s" is like "K=", not "K".
139 result[k] = v
140 }
141 return result, nil
142}
143
144func loadConfigFiles(filenames []string, stdin io.Reader) ([]composetypes.ConfigFile, error) {
145 configFiles := make([]composetypes.ConfigFile, 0, len(filenames))

Callers 2

TestBuildEnvironmentFunction · 0.85
getConfigDetailsFunction · 0.85

Calls

no outgoing calls

Tested by 1

TestBuildEnvironmentFunction · 0.68

Used in the wild real call sites across dependent graphs

searching dependent graphs…