diff --git a/make/e2e-setup.mk b/make/e2e-setup.mk index b6a0e6073..0756445ea 100644 --- a/make/e2e-setup.mk +++ b/make/e2e-setup.mk @@ -55,6 +55,12 @@ IMAGE_kind_arm64 := $(IMAGE_kind_amd64) # Once that is done, we can consume this variable from ./make/config/lib.sh SERVICE_IP_PREFIX = 10.0.0 +# This variable is exported so that the the Vault addon in the E2E tests can set +# the image reference of the locally loaded Docker image when it installs the +# Vault Helm chart. +# The Vault Docker image is loaded into kind by `make e2e-setup`. +export E2E_VAULT_IMAGE := $(LOCALIMAGE_vaultretagged) + .PHONY: e2e-setup-kind ## Create a Kubernetes cluster using Kind, which is required for `make e2e`. ## The Kind image is pre-pulled to avoid 'kind create' from blocking other make diff --git a/test/e2e/framework/addon/vault/vault.go b/test/e2e/framework/addon/vault/vault.go index d99343dff..8c4ebb27e 100644 --- a/test/e2e/framework/addon/vault/vault.go +++ b/test/e2e/framework/addon/vault/vault.go @@ -30,6 +30,7 @@ import ( "math/big" "net" "os" + "strings" "time" corev1 "k8s.io/api/core/v1" @@ -47,12 +48,6 @@ import ( const ( vaultHelmChartRepo = "https://helm.releases.hashicorp.com" vaultHelmChartVersion = "0.24.1" - // This local Vault image is only used when the tests are run using make, - // because it downloads the Vault image, saves it in the scratch folder on - // the filesystem, and copies it to the cluster-under-test before the E2E - // tests get executed. - vaultImageRepository = "local/vault" - vaultImageTag = "local" ) // Vault describes the configuration details for an instance of Vault @@ -205,11 +200,11 @@ func (v *Vault) Setup(cfg *config.Config, leaderData ...internal.AddonTransferab // the tests on their chosen cluster, in which case we do not override the // Vault image and the default chart image will be downloaded and run // instead. - // MAKELEVEL is always set by make so that it can know whether it is being - // called recursively, so we use that variable as a marker to know whether - // the tests are being executed from our Makefile. See - // https://www.gnu.org/software/make/manual/html_node/Variables_002fRecursion.html - if os.Getenv("MAKELEVEL") != "" { + // E2E_VAULT_IMAGE is exported by `make/e2e-setup.mk`. + if vaultImage := os.Getenv("E2E_VAULT_IMAGE"); vaultImage != "" { + parts := strings.Split(vaultImage, ":") + vaultImageRepository := parts[0] + vaultImageTag := parts[1] v.chart.Vars = append( v.chart.Vars, []chart.StringTuple{