From ea0ef8a0215c48f8404a2963cef77f2b80ffba4f Mon Sep 17 00:00:00 2001 From: Emily McMullan Date: Thu, 6 Jun 2024 09:54:45 -0400 Subject: [PATCH] Don't override set RUNNER_IMG (#253) don't override set runner img Signed-off-by: Emily McMullan --- cmd/settings.go | 8 ++++---- cmd/settings_test.go | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/cmd/settings.go b/cmd/settings.go index cd2d176..55508de 100644 --- a/cmd/settings.go +++ b/cmd/settings.go @@ -86,12 +86,12 @@ func (c *Config) trySetDefaultPodmanBin(file string) (found bool, err error) { func (c *Config) loadRunnerImg() error { // TODO(maufart): ensure Config struct works/parses it values from ENV and defaults correctly - runnerImg, found := os.LookupEnv("RUNNER_IMG"); - if !found { - runnerImg = "quay.io/konveyor/kantra" + // Respect existing RUNNER_IMG setting + if os.Getenv("RUNNER_IMG") != "" { + return nil } // if version tag is given in image - img := strings.TrimSuffix(runnerImg, fmt.Sprintf(":%v", Version)) + img := strings.TrimSuffix(RunnerImage, fmt.Sprintf(":%v", Version)) updatedImg := fmt.Sprintf("%v:%v", img, Version) err := os.Setenv("RUNNER_IMG", updatedImg) if err != nil { diff --git a/cmd/settings_test.go b/cmd/settings_test.go index 525edd2..8113d8e 100644 --- a/cmd/settings_test.go +++ b/cmd/settings_test.go @@ -7,9 +7,9 @@ import ( // Test RUNNER_IMG settings func TestRunnerImgDefault(t *testing.T) { - os.Unsetenv("RUNNER_IMG") // Ensure empty variable + os.Unsetenv("RUNNER_IMG") // Ensure empty variable s := &Config{} - s.Load(); + s.Load() if s.RunnerImage != "quay.io/konveyor/kantra:latest" { t.Errorf("Unexpected RUNNER_IMG default: %s", s.RunnerImage) } @@ -18,8 +18,8 @@ func TestRunnerImgDefault(t *testing.T) { func TestRunnerImgCustom(t *testing.T) { os.Setenv("RUNNER_IMG", "quay.io/some-contributor/my-kantra") s := &Config{} - s.Load(); - if s.RunnerImage != "quay.io/some-contributor/my-kantra:latest" { + s.Load() + if s.RunnerImage != "quay.io/some-contributor/my-kantra" { t.Errorf("Unexpected RUNNER_IMG: %s", s.RunnerImage) } }