mirror of
https://github.com/docker/compose.git
synced 2026-10-21 03:12:52 +00:00
Support bypass envvars
Signed-off-by: Ulysses Souza <ulyssessouza@gmail.com>
This commit is contained in:
parent
de8834d434
commit
f159bc4901
3 changed files with 10 additions and 20 deletions
|
|
@ -245,22 +245,6 @@ func (e Event) String() string {
|
|||
|
||||
}
|
||||
|
||||
// EnvironmentMap return RunOptions.Environment as a MappingWithEquals
|
||||
func (opts *RunOptions) EnvironmentMap() types.MappingWithEquals {
|
||||
environment := types.MappingWithEquals{}
|
||||
for _, s := range opts.Environment {
|
||||
parts := strings.SplitN(s, "=", 2)
|
||||
key := parts[0]
|
||||
switch {
|
||||
case len(parts) == 1:
|
||||
environment[key] = nil
|
||||
default:
|
||||
environment[key] = &parts[1]
|
||||
}
|
||||
}
|
||||
return environment
|
||||
}
|
||||
|
||||
// ListOptions group options of the ls API
|
||||
type ListOptions struct {
|
||||
All bool
|
||||
|
|
|
|||
|
|
@ -19,6 +19,7 @@ package compose
|
|||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/compose-spec/compose-go/types"
|
||||
"gotest.tools/v3/assert"
|
||||
)
|
||||
|
||||
|
|
@ -30,7 +31,7 @@ func TestRunOptionsEnvironmentMap(t *testing.T) {
|
|||
"QIX",
|
||||
},
|
||||
}
|
||||
env := opts.EnvironmentMap()
|
||||
env := types.NewMappingWithEquals(opts.Environment)
|
||||
assert.Equal(t, *env["FOO"], "BAR")
|
||||
assert.Equal(t, *env["ZOT"], "")
|
||||
assert.Check(t, env["QIX"] == nil)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue