From 6eba6241ce6df95134c027cb4b048e36f1bc92f7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Smolarek?= <34063647+Razz4780@users.noreply.github.com> Date: Tue, 3 Sep 2024 11:40:11 +0200 Subject: [PATCH] Reverted deploy->deployment change (#2717) --- changelog.d/+fix-target-url.internal.md | 1 + mirrord/operator/src/crd.rs | 25 ++++++++++++++----------- 2 files changed, 15 insertions(+), 11 deletions(-) create mode 100644 changelog.d/+fix-target-url.internal.md diff --git a/changelog.d/+fix-target-url.internal.md b/changelog.d/+fix-target-url.internal.md new file mode 100644 index 00000000000..a6a3009cc32 --- /dev/null +++ b/changelog.d/+fix-target-url.internal.md @@ -0,0 +1 @@ +Fixed urlfied form of target types. diff --git a/mirrord/operator/src/crd.rs b/mirrord/operator/src/crd.rs index b915da2aad5..406d64beccb 100644 --- a/mirrord/operator/src/crd.rs +++ b/mirrord/operator/src/crd.rs @@ -8,7 +8,7 @@ use kube_target::{KubeTarget, UnknownTargetType}; pub use mirrord_config::feature::split_queues::QueueId; use mirrord_config::{ feature::split_queues::{SplitQueuesConfig, SqsMessageFilter}, - target::{Target, TargetConfig, TargetDisplay}, + target::{Target, TargetConfig}, }; use schemars::JsonSchema; use semver::Version; @@ -46,17 +46,20 @@ impl TargetCrd { /// `deploy.nginx.container.pyrex`; /// /// It's used to connect to a resource through the operator. + /// + /// # Warning + /// + /// Do **not** change url paths here, even if the operator recognizes the other format. + /// It can break exisiting [`MirrordPolicy`]s (see [`MirrordPolicySpec::target_path`]). pub fn urlfied_name(target: &Target) -> String { - let type_name = target.type_(); - - let (target, container) = match target { - Target::Deployment(target) => (&target.deployment, &target.container), - Target::Pod(target) => (&target.pod, &target.container), - Target::Rollout(target) => (&target.rollout, &target.container), - Target::Job(target) => (&target.job, &target.container), - Target::CronJob(target) => (&target.cron_job, &target.container), - Target::StatefulSet(target) => (&target.stateful_set, &target.container), - Target::Targetless => return type_name.to_string(), + let (type_name, target, container) = match target { + Target::Deployment(target) => ("deploy", &target.deployment, &target.container), + Target::Pod(target) => ("pod", &target.pod, &target.container), + Target::Rollout(target) => ("rollout", &target.rollout, &target.container), + Target::Job(target) => ("job", &target.job, &target.container), + Target::CronJob(target) => ("cronjob", &target.cron_job, &target.container), + Target::StatefulSet(target) => ("statefulset", &target.stateful_set, &target.container), + Target::Targetless => return TARGETLESS_TARGET_NAME.to_string(), }; if let Some(container) = container {