MCPcopy
hub / github.com/docker/compose / getEnvironment

Method getEnvironment

cmd/compose/run.go:122–143  ·  view source on GitHub ↗
(resolve func(string) (string, bool))

Source from the content-addressed store, hash-verified

120}
121
122func (options runOptions) getEnvironment(resolve func(string) (string, bool)) (types.Mapping, error) {
123 environment := types.NewMappingWithEquals(options.environment).Resolve(resolve).ToMapping()
124 for _, file := range options.envFiles {
125 f, err := os.Open(file)
126 if err != nil {
127 return nil, err
128 }
129 vars, err := dotenv.ParseWithLookup(f, func(k string) (string, bool) {
130 value, ok := environment[k]
131 return value, ok
132 })
133 if err != nil {
134 return nil, nil
135 }
136 for k, v := range vars {
137 if _, ok := environment[k]; !ok {
138 environment[k] = v
139 }
140 }
141 }
142 return environment, nil
143}
144
145func runCommand(p *ProjectOptions, dockerCli command.Cli, backendOptions *BackendOptions) *cobra.Command {
146 options := runOptions{

Callers 1

runRunFunction · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected