Merge pull request #117 from tonistiigi/compose-env

bake: replace env in compose files
pull/118/head
Tibor Vass 6 years ago committed by GitHub
commit 73645c8348
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -2,7 +2,9 @@ package bake
import (
"fmt"
"os"
"reflect"
"strings"
"github.com/docker/cli/cli/compose/loader"
composetypes "github.com/docker/cli/cli/compose/types"
@ -19,9 +21,22 @@ func parseCompose(dt []byte) (*composetypes.Config, error) {
Config: parsed,
},
},
Environment: envMap(os.Environ()),
})
}
func envMap(env []string) map[string]string {
result := make(map[string]string, len(env))
for _, s := range env {
kv := strings.SplitN(s, "=", 2)
if len(kv) != 2 {
continue
}
result[kv[0]] = kv[1]
}
return result
}
func ParseCompose(dt []byte) (*Config, error) {
cfg, err := parseCompose(dt)
if err != nil {

Loading…
Cancel
Save