Skip to content

Commit

Permalink
🐛 Fix labels validation print (#251)
Browse files Browse the repository at this point in the history
* Fix labels validation print

Fixing fmt.Fprintln to correctly recognize first argument as a writer
buffer. Bug was introduced in #243

Should fix kantra CI.

Signed-off-by: Marek Aufart <[email protected]>

* Force runnerImg env lookup

Signed-off-by: Marek Aufart <[email protected]>

* Fix env config load override

Signed-off-by: Marek Aufart <[email protected]>

* Revert "Fix env config load override"

This reverts commit 2950638.

Signed-off-by: Marek Aufart <[email protected]>

* Update env settings with field values

Signed-off-by: Marek Aufart <[email protected]>

* Adding RUNNER_IMG setting test

Signed-off-by: Marek Aufart <[email protected]>

* Revert Settings changes

Signed-off-by: Marek Aufart <[email protected]>

---------

Signed-off-by: Marek Aufart <[email protected]>
  • Loading branch information
aufi authored Jun 3, 2024
1 parent 52f87d7 commit 6d5fd4c
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 4 deletions.
6 changes: 3 additions & 3 deletions cmd/analyze.go
Original file line number Diff line number Diff line change
Expand Up @@ -495,12 +495,12 @@ func listOptionsFromLabels(sl []string, label string, out io.Writer) {
sort.Strings(newSl)

if label == outputv1.SourceTechnologyLabel {
fmt.Println(out, "available source technologies:")
fmt.Fprintln(out, "available source technologies:")
} else {
fmt.Println(out, "available target technologies:")
fmt.Fprintln(out, "available target technologies:")
}
for _, tech := range newSl {
fmt.Println(out, tech)
fmt.Fprintln(out, tech)
}
}

Expand Down
7 changes: 6 additions & 1 deletion cmd/settings.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,13 @@ 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"
}
// if version tag is given in image
img := strings.TrimSuffix(RunnerImage, fmt.Sprintf(":%v", Version))
img := strings.TrimSuffix(runnerImg, fmt.Sprintf(":%v", Version))
updatedImg := fmt.Sprintf("%v:%v", img, Version)
err := os.Setenv("RUNNER_IMG", updatedImg)
if err != nil {
Expand Down
25 changes: 25 additions & 0 deletions cmd/settings_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package cmd

import (
"os"
"testing"
)

// Test RUNNER_IMG settings
func TestRunnerImgDefault(t *testing.T) {
os.Unsetenv("RUNNER_IMG") // Ensure empty variable
s := &Config{}
s.Load();
if s.RunnerImage != "quay.io/konveyor/kantra:latest" {
t.Errorf("Unexpected RUNNER_IMG default: %s", s.RunnerImage)
}
}

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" {
t.Errorf("Unexpected RUNNER_IMG: %s", s.RunnerImage)
}
}

0 comments on commit 6d5fd4c

Please sign in to comment.