From d497472389517f501f7f33bb32103c9033155b50 Mon Sep 17 00:00:00 2001 From: Eliza Weisman Date: Fri, 23 Aug 2024 10:12:12 -0700 Subject: [PATCH] `get_or_insert_with` is nicer --- dev-tools/mgs-dev/src/main.rs | 10 ++++------ nexus/tests/integration_tests/metrics.rs | 7 +++---- 2 files changed, 7 insertions(+), 10 deletions(-) diff --git a/dev-tools/mgs-dev/src/main.rs b/dev-tools/mgs-dev/src/main.rs index 2f12f633db..dee8334f38 100644 --- a/dev-tools/mgs-dev/src/main.rs +++ b/dev-tools/mgs-dev/src/main.rs @@ -55,12 +55,10 @@ impl MgsRunArgs { let (mut mgs_config, sp_sim_config) = gateway_test_utils::setup::load_test_config(); if let Some(addr) = self.nexus_address { - mgs_config.metrics = - Some(omicron_gateway::metrics::MetricsConfig { - dev: Some(omicron_gateway::metrics::DevConfig { - bind_loopback: true, - nexus_address: Some(addr), - }), + mgs_config.metrics.get_or_insert_with(Default::default).dev = + Some(gateway_test_utils::setup::MetricsDevConfig { + nexus_address: Some(addr), + bind_loopback: true, }); } diff --git a/nexus/tests/integration_tests/metrics.rs b/nexus/tests/integration_tests/metrics.rs index eea04d3521..58ff6c6f64 100644 --- a/nexus/tests/integration_tests/metrics.rs +++ b/nexus/tests/integration_tests/metrics.rs @@ -600,12 +600,11 @@ async fn test_mgs_metrics( gateway_test_utils::setup::load_test_config(); // munge the already-parsed MGS config file to point it at the test // Nexus' address. - mgs_config.metrics = Some(gateway_test_utils::setup::MetricsConfig { - dev: Some(gateway_test_utils::setup::MetricsDevConfig { + mgs_config.metrics.get_or_insert_with(Default::default).dev = + Some(gateway_test_utils::setup::MetricsDevConfig { bind_loopback: true, nexus_address: Some(cptestctx.internal_client.bind_address), - }), - }); + }); gateway_test_utils::setup::test_setup_with_config( "test_mgs_metrics", gateway_messages::SpPort::One,