Skip to content

Commit

Permalink
flowctl: show activation status in status table
Browse files Browse the repository at this point in the history
Adds a "Activation Complete" column to the status table output, which shows
whether the spec has been successfully activated in the data plane.
  • Loading branch information
psFried committed Dec 17, 2024
1 parent 6f6d629 commit e22a6d1
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 2 deletions.
11 changes: 9 additions & 2 deletions crates/flowctl/src/catalog/status.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<Self::CellValue> {
to_table_row(
let mut row = to_table_row(
&self.0,
&[
"/catalog_name",
Expand All @@ -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
}
}
10 changes: 10 additions & 0 deletions crates/models/src/status/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand Down

0 comments on commit e22a6d1

Please sign in to comment.