From f4606a2d6cfad8334ffd770296fa52daeed0313a Mon Sep 17 00:00:00 2001 From: ecpullen Date: Mon, 12 Dec 2022 14:54:38 +0000 Subject: [PATCH] testsys: Add `testsys-image-tag` to `Test.toml` --- tools/testsys-config/src/lib.rs | 40 ++++++++++++--------------------- tools/testsys/Test.toml.example | 3 +++ tools/testsys/src/run.rs | 6 ++--- 3 files changed, 20 insertions(+), 29 deletions(-) diff --git a/tools/testsys-config/src/lib.rs b/tools/testsys-config/src/lib.rs index 6ea95bc3bd6..1f31799108f 100644 --- a/tools/testsys-config/src/lib.rs +++ b/tools/testsys-config/src/lib.rs @@ -108,6 +108,9 @@ pub struct Test { /// A registry containing all TestSys images pub testsys_image_registry: Option, + + /// The tag that should be used for TestSys images + pub testsys_image_tag: Option, } /// Create a vec of relevant keys for this variant ordered from most specific to least specific. @@ -254,42 +257,27 @@ pub struct TestsysImages { impl TestsysImages { /// Create an images config for a specific registry. - pub fn new(registry: S) -> Self + pub fn new(registry: S, tag: Option) -> Self where S: Into, { let registry = registry.into(); - let agent_version = format!("v{}", TESTSYS_VERSION); + let tag = tag.unwrap_or_else(|| format!("v{}", TESTSYS_VERSION)); Self { - eks_resource_agent_image: Some(format!( - "{}/eks-resource-agent:{agent_version}", - registry - )), - ecs_resource_agent_image: Some(format!( - "{}/ecs-resource-agent:{agent_version}", - registry - )), + eks_resource_agent_image: Some(format!("{}/eks-resource-agent:{tag}", registry)), + ecs_resource_agent_image: Some(format!("{}/ecs-resource-agent:{tag}", registry)), vsphere_k8s_cluster_resource_agent_image: Some(format!( - "{}/vsphere-k8s-cluster-resource-agent:{agent_version}", - registry - )), - ec2_resource_agent_image: Some(format!( - "{}/ec2-resource-agent:{agent_version}", + "{}/vsphere-k8s-cluster-resource-agent:{tag}", registry )), + ec2_resource_agent_image: Some(format!("{}/ec2-resource-agent:{tag}", registry)), vsphere_vm_resource_agent_image: Some(format!( - "{}/vsphere-vm-resource-agent:{agent_version}", - registry - )), - sonobuoy_test_agent_image: Some(format!( - "{}/sonobuoy-test-agent:{agent_version}", - registry - )), - ecs_test_agent_image: Some(format!("{}/ecs-test-agent:{agent_version}", registry)), - migration_test_agent_image: Some(format!( - "{}/migration-test-agent:{agent_version}", + "{}/vsphere-vm-resource-agent:{tag}", registry )), + sonobuoy_test_agent_image: Some(format!("{}/sonobuoy-test-agent:{tag}", registry)), + ecs_test_agent_image: Some(format!("{}/ecs-test-agent:{tag}", registry)), + migration_test_agent_image: Some(format!("{}/migration-test-agent:{tag}", registry)), testsys_agent_pull_secret: None, } } @@ -325,7 +313,7 @@ impl TestsysImages { } pub fn public_images() -> Self { - Self::new("public.ecr.aws/bottlerocket-test-system") + Self::new("public.ecr.aws/bottlerocket-test-system", None) } } diff --git a/tools/testsys/Test.toml.example b/tools/testsys/Test.toml.example index c3b41db4299..381470ca222 100644 --- a/tools/testsys/Test.toml.example +++ b/tools/testsys/Test.toml.example @@ -11,6 +11,9 @@ repo = "default" # The registry containing alternate TestSys agent images testsys-images-registry = "public.ecr.aws/bottlerocket-test-system" +# The tag that should be used with `testsys-images-registry` for image pulls +testsys-images-registry = "latest" + # The URI for the EKS resource agent that should be used. An individual agent's provided URI will be # used even if `testsys-images-registry` is present. eks-resource-agent-image = "public.ecr.aws/bottlerocket-test-system/eks_resource_agent:v0.0.2" diff --git a/tools/testsys/src/run.rs b/tools/testsys/src/run.rs index 46d78511630..6cd7c46f540 100644 --- a/tools/testsys/src/run.rs +++ b/tools/testsys/src/run.rs @@ -189,9 +189,9 @@ impl Run { let images = vec![ Some(self.agent_images.into()), Some(test_opts.testsys_images), - test_opts - .testsys_image_registry - .map(testsys_config::TestsysImages::new), + test_opts.testsys_image_registry.map(|registry| { + testsys_config::TestsysImages::new(registry, test_opts.testsys_image_tag) + }), Some(testsys_config::TestsysImages::public_images()), ] .into_iter()