From e22a6d12f4e281f5f525fa736b0d29b867b222c5 Mon Sep 17 00:00:00 2001 From: Phil Date: Mon, 16 Dec 2024 21:20:39 -0500 Subject: [PATCH] flowctl: show activation status in status table Adds a "Activation Complete" column to the status table output, which shows whether the spec has been successfully activated in the data plane. --- crates/flowctl/src/catalog/status.rs | 11 +++++++++-- crates/models/src/status/mod.rs | 10 ++++++++++ 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/crates/flowctl/src/catalog/status.rs b/crates/flowctl/src/catalog/status.rs index 38d90948f8..aa5d7ce43f 100644 --- a/crates/flowctl/src/catalog/status.rs +++ b/crates/flowctl/src/catalog/status.rs @@ -39,11 +39,12 @@ impl crate::output::CliOutput for StatusOutput { "Live Spec Updated At", "Controller Error", "Failures", + "Activation Complete", ] } fn into_table_row(self, _alt: Self::TableAlt) -> Vec { - to_table_row( + let mut row = to_table_row( &self.0, &[ "/catalog_name", @@ -53,6 +54,12 @@ impl crate::output::CliOutput for StatusOutput { "/controller_error", "/failures", ], - ) + ); + // Activation Complete is a computed column so we need to add it manually. + let activation_complete = self.0.status.activation_status().map(|activation| { + serde_json::Value::Bool(activation.last_activated == self.0.last_build_id) + }); + row.push(JsonCell(activation_complete)); + row } } diff --git a/crates/models/src/status/mod.rs b/crates/models/src/status/mod.rs index c8b57a197d..9398317a18 100644 --- a/crates/models/src/status/mod.rs +++ b/crates/models/src/status/mod.rs @@ -78,6 +78,16 @@ impl Status { matches!(self, Status::Uninitialized) } + /// Returns the activation status, if this status is for a capture, collection, or materialization. + pub fn activation_status(&self) -> Option<&publications::ActivationStatus> { + match self { + Status::Capture(c) => Some(&c.activation), + Status::Collection(c) => Some(&c.activation), + Status::Materialization(c) => Some(&c.activation), + _ => None, + } + } + pub fn as_capture_mut(&mut self) -> anyhow::Result<&mut capture::CaptureStatus> { if self.is_uninitialized() { *self = Status::Capture(Default::default());