Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 1 addition & 8 deletions tests/e2e/util/env/env.go → pkg/env/env.go
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
//go:build e2e

// Copyright Istio Authors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
Expand All @@ -19,18 +17,13 @@ package env
import (
"os"
"strconv"

g "github.com/onsi/ginkgo/v2"
)

func Get(key, defaultValue string) string {
value := os.Getenv(key)
if value == "" {
return defaultValue
}

g.GinkgoWriter.Printf("Env variable %s is set to %s\n", key, value)

return value
}

Expand Down
13 changes: 3 additions & 10 deletions pkg/istioversion/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ package istioversion
import (
"embed"
"fmt"
"os"

"github.com/Masterminds/semver/v3"
"github.com/istio-ecosystem/sail-operator/pkg/env"
"gopkg.in/yaml.v3"

"istio.io/istio/pkg/log"
Expand All @@ -29,17 +29,10 @@ var (
//go:embed *.yaml
versionsFiles embed.FS

versionsFilename = getenv("VERSIONS_YAML_FILE", "versions.yaml")
// versionsFilename is set via ldflags when building the binary and via an environment variable when running tests
versionsFilename = env.Get("VERSIONS_YAML_FILE", "versions.yaml")
)

func getenv(key string, defaultValue string) string {
value := os.Getenv(key)
if value == "" {
return defaultValue
}
return value
}

// Versions represents the top-level structure of versions.yaml
type Versions struct {
Versions []VersionInfo `json:"versions"`
Expand Down
2 changes: 1 addition & 1 deletion tests/e2e/ambient/ambient_suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ package ambient
import (
"testing"

"github.com/istio-ecosystem/sail-operator/pkg/env"
k8sclient "github.com/istio-ecosystem/sail-operator/tests/e2e/util/client"
"github.com/istio-ecosystem/sail-operator/tests/e2e/util/common"
"github.com/istio-ecosystem/sail-operator/tests/e2e/util/env"
"github.com/istio-ecosystem/sail-operator/tests/e2e/util/kubectl"
. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
Expand Down
2 changes: 1 addition & 1 deletion tests/e2e/controlplane/control_plane_suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ package controlplane
import (
"testing"

"github.com/istio-ecosystem/sail-operator/pkg/env"
k8sclient "github.com/istio-ecosystem/sail-operator/tests/e2e/util/client"
"github.com/istio-ecosystem/sail-operator/tests/e2e/util/common"
"github.com/istio-ecosystem/sail-operator/tests/e2e/util/env"
"github.com/istio-ecosystem/sail-operator/tests/e2e/util/kubectl"
. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
Expand Down
2 changes: 1 addition & 1 deletion tests/e2e/dualstack/dualstack_suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ package dualstack
import (
"testing"

"github.com/istio-ecosystem/sail-operator/pkg/env"
k8sclient "github.com/istio-ecosystem/sail-operator/tests/e2e/util/client"
"github.com/istio-ecosystem/sail-operator/tests/e2e/util/common"
"github.com/istio-ecosystem/sail-operator/tests/e2e/util/env"
"github.com/istio-ecosystem/sail-operator/tests/e2e/util/kubectl"
. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
Expand Down
2 changes: 1 addition & 1 deletion tests/e2e/multicluster/multicluster_suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@ import (
"path/filepath"
"testing"

"github.com/istio-ecosystem/sail-operator/pkg/env"
"github.com/istio-ecosystem/sail-operator/tests/e2e/util/certs"
k8sclient "github.com/istio-ecosystem/sail-operator/tests/e2e/util/client"
"github.com/istio-ecosystem/sail-operator/tests/e2e/util/common"
"github.com/istio-ecosystem/sail-operator/tests/e2e/util/env"
"github.com/istio-ecosystem/sail-operator/tests/e2e/util/kubectl"
. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
Expand Down
2 changes: 1 addition & 1 deletion tests/e2e/operator/operator_suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ package operator
import (
"testing"

"github.com/istio-ecosystem/sail-operator/pkg/env"
k8sclient "github.com/istio-ecosystem/sail-operator/tests/e2e/util/client"
"github.com/istio-ecosystem/sail-operator/tests/e2e/util/common"
"github.com/istio-ecosystem/sail-operator/tests/e2e/util/env"
"github.com/istio-ecosystem/sail-operator/tests/e2e/util/kubectl"
. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
Expand Down
2 changes: 1 addition & 1 deletion tests/e2e/util/common/e2e_utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,10 @@ import (
"time"

"github.com/Masterminds/semver/v3"
"github.com/istio-ecosystem/sail-operator/pkg/env"
"github.com/istio-ecosystem/sail-operator/pkg/istioversion"
"github.com/istio-ecosystem/sail-operator/pkg/kube"
"github.com/istio-ecosystem/sail-operator/pkg/test/project"
"github.com/istio-ecosystem/sail-operator/tests/e2e/util/env"
. "github.com/istio-ecosystem/sail-operator/tests/e2e/util/gomega"
"github.com/istio-ecosystem/sail-operator/tests/e2e/util/helm"
"github.com/istio-ecosystem/sail-operator/tests/e2e/util/kubectl"
Expand Down
2 changes: 1 addition & 1 deletion tests/e2e/util/istioctl/istioctl.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ package istioctl
import (
"fmt"

"github.com/istio-ecosystem/sail-operator/tests/e2e/util/env"
"github.com/istio-ecosystem/sail-operator/pkg/env"
"github.com/istio-ecosystem/sail-operator/tests/e2e/util/shell"
)

Expand Down