daemon/links: use strings.Cut()

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
Sebastiaan van Stijn 2022-10-31 19:09:36 +01:00
parent ad7f1a8dcc
commit 39f59c3289
No known key found for this signature in database
GPG key ID: 76698F39D527CE8C

View file

@ -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