daemon/links: use strings.Cut()
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
parent
ad7f1a8dcc
commit
39f59c3289
1 changed files with 4 additions and 4 deletions
|
@ -94,15 +94,15 @@ func (l *Link) ToEnv() []string {
|
|||
|
||||
if l.ChildEnvironment != nil {
|
||||
for _, v := range l.ChildEnvironment {
|
||||
parts := strings.SplitN(v, "=", 2)
|
||||
if len(parts) < 2 {
|
||||
name, val, ok := strings.Cut(v, "=")
|
||||
if !ok {
|
||||
continue
|
||||
}
|
||||
// Ignore a few variables that are added during docker build (and not really relevant to linked containers)
|
||||
if parts[0] == "HOME" || parts[0] == "PATH" {
|
||||
if name == "HOME" || name == "PATH" {
|
||||
continue
|
||||
}
|
||||
env = append(env, fmt.Sprintf("%s_ENV_%s=%s", alias, parts[0], parts[1]))
|
||||
env = append(env, fmt.Sprintf("%s_ENV_%s=%s", alias, name, val))
|
||||
}
|
||||
}
|
||||
return env
|
||||
|
|
Loading…
Reference in a new issue