diff --git a/pkg/common/args.go b/pkg/common/args.go index b10e5bf..0185df8 100644 --- a/pkg/common/args.go +++ b/pkg/common/args.go @@ -28,6 +28,9 @@ import ( "sigs.k8s.io/hydrophone/pkg/log" ) +// ConformanceImage is used to define the container image being used to run the conformance tests +var ConformanceImage string + // ArgConfig stores the argument passed when running the program type ArgConfig struct { // Focus set the E2E_FOCUS env var to run a specific test @@ -78,6 +81,7 @@ type ArgConfig struct { // InitArgs initializes the arguments passed to the program func InitArgs() (*ArgConfig, error) { + var cfg ArgConfig outputDir, err := os.Getwd() @@ -87,8 +91,7 @@ func InitArgs() (*ArgConfig, error) { flag.StringVar(&cfg.Focus, "focus", "", "focus runs a specific e2e test. e.g. - sig-auth. allows regular expressions.") flag.StringVar(&cfg.Skip, "skip", "", "skip specific tests. allows regular expressions.") - flag.StringVar(&cfg.ConformanceImage, "conformance-image", containerImage, - "specify a conformance container image of your choice.") + flag.StringVar(&cfg.ConformanceImage, "conformance-image", "", "specify a conformance container image of your choice.") flag.StringVar(&cfg.BusyboxImage, "busybox-image", busyboxImage, "specify an alternate busybox container image.") flag.StringVar(&cfg.Kubeconfig, "kubeconfig", "", "path to the kubeconfig file.") @@ -119,6 +122,8 @@ func InitArgs() (*ArgConfig, error) { return nil, fmt.Errorf("specify either --conformance or --focus arguments, not both") } + ConformanceImage = cfg.ConformanceImage + return &cfg, nil } @@ -129,6 +134,10 @@ func PrintInfo(clientSet *kubernetes.Clientset, config *rest.Config) { log.Fatal("Error fetching server version: ", err) } + if ConformanceImage == "" { + ConformanceImage = fmt.Sprintf("registry.k8s.io/conformance:%s", serverVersion.String()) + } + log.Printf("API endpoint : %s", config.Host) log.Printf("Server version : %#v", *serverVersion) } @@ -143,7 +152,7 @@ func ValidateArgs(clientSet *kubernetes.Clientset, config *rest.Config, cfg *Arg if cfg.Skip != "" { log.Printf("Skipping tests : '%s'", cfg.Skip) } - log.Printf("Using conformance image : '%s'", cfg.ConformanceImage) + log.Printf("Using conformance image : '%s'", ConformanceImage) log.Printf("Using busybox image : '%s'", cfg.BusyboxImage) log.Printf("Test framework will start '%d' threads and use verbosity '%d'", cfg.Parallel, cfg.Verbosity) diff --git a/pkg/common/const.go b/pkg/common/const.go index 4c8448e..2db6e9b 100644 --- a/pkg/common/const.go +++ b/pkg/common/const.go @@ -17,8 +17,6 @@ limitations under the License. package common const ( - // containerImage is the default contaimer image used to run the conformance tests - containerImage = "registry.k8s.io/conformance:v1.29.0" // busyboxImage is the image used to extract the e2e logs busyboxImage = "registry.k8s.io/e2e-test-images/busybox:1.36.1-1" // Namespace is the namespace where the conformance pod is created diff --git a/pkg/service/init.go b/pkg/service/init.go index bfb78fc..e305221 100644 --- a/pkg/service/init.go +++ b/pkg/service/init.go @@ -144,7 +144,7 @@ func RunE2E(clientset *kubernetes.Clientset, cfg *common.ArgConfig) { Containers: []v1.Container{ { Name: common.ConformanceContainer, - Image: cfg.ConformanceImage, + Image: common.ConformanceImage, ImagePullPolicy: v1.PullIfNotPresent, Env: []v1.EnvVar{ { diff --git a/pkg/service/list_images.go b/pkg/service/list_images.go index a0641e3..d647cf5 100644 --- a/pkg/service/list_images.go +++ b/pkg/service/list_images.go @@ -51,7 +51,7 @@ func PrintListImages(cfg *common.ArgConfig, clientSet *kubernetes.Clientset, con Containers: []corev1.Container{ { Name: common.ConformanceContainer, - Image: cfg.ConformanceImage, + Image: common.ConformanceImage, Command: []string{ "/usr/local/bin/e2e.test", "--list-images",