From 1f4864d824479ee956dea4a1722945082cce7a9f Mon Sep 17 00:00:00 2001 From: Shishir Mahajan Date: Wed, 16 Sep 2020 16:00:03 -0700 Subject: [PATCH] Fix review comments. --- containerd/driver.go | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/containerd/driver.go b/containerd/driver.go index e62e48f..ca64db7 100644 --- a/containerd/driver.go +++ b/containerd/driver.go @@ -358,8 +358,7 @@ func (d *Driver) StartTask(cfg *drivers.TaskConfig) (*drivers.TaskHandle, *drive // Setup environment variables. var env []string for key, val := range cfg.Env { - // Don't override $PATH. - if key == "PATH" { + if skipOverride(key) { continue } env = append(env, fmt.Sprintf("%s=%s", key, val)) @@ -411,6 +410,17 @@ func (d *Driver) StartTask(cfg *drivers.TaskConfig) (*drivers.TaskHandle, *drive return handle, nil, nil } +// skipOverride determines whether the environment variable (key) needs an override or not. +func skipOverride(key string) bool { + skipOverrideList := []string{"PATH"} + for _, k := range skipOverrideList { + if key == k { + return true + } + } + return false +} + // RecoverTask recreates the in-memory state of a task from a TaskHandle. func (d *Driver) RecoverTask(handle *drivers.TaskHandle) error { if handle == nil {