convert hand-written enum as_str matches to strum derives workspace-wide
This commit is contained in:
parent
0d6c003fa8
commit
299add158f
14 changed files with 70 additions and 113 deletions
|
|
@ -31,8 +31,9 @@ use hive_jobq::TerminalState;
|
|||
/// compose into live in the node-inventory table and surrounding sections
|
||||
/// of `docs/scheduler/coordinator.md` — this enum is deliberately not a
|
||||
/// second copy of that; each variant below gets a one-line pointer.
|
||||
#[derive(Debug, Clone, PartialEq, Eq, Serialize)]
|
||||
#[derive(Debug, Clone, PartialEq, Eq, Serialize, strum::IntoStaticStr)]
|
||||
#[serde(tag = "kind", rename_all = "snake_case")]
|
||||
#[strum(serialize_all = "snake_case")]
|
||||
pub enum NodeKind {
|
||||
/// The rebuild's meta-repo preamble. `relock = false` only for
|
||||
/// meta-update cascade rebuilds (re-locking would revert the bump the
|
||||
|
|
@ -201,45 +202,13 @@ impl hive_jobq_wire::WireNode for NodeKind {
|
|||
|
||||
impl NodeKind {
|
||||
/// Wire string for the node's label on the graph wire
|
||||
/// ([`hive_jobq_wire::WireNode::label`]).
|
||||
/// ([`hive_jobq_wire::WireNode::label`]) — derived
|
||||
/// (`#[strum(serialize_all = "snake_case")]`), matching the same
|
||||
/// convention the `#[serde(rename_all = "snake_case")]` tag above
|
||||
/// uses, rather than a 31-arm hand-written match kept in sync with it
|
||||
/// by hand.
|
||||
pub fn as_str(&self) -> &'static str {
|
||||
match self {
|
||||
NodeKind::MetaSync { .. } => "meta_sync",
|
||||
NodeKind::Prebuild { .. } => "prebuild",
|
||||
NodeKind::Swap { .. } => "swap",
|
||||
NodeKind::RebuildBookkeeping { .. } => "rebuild_bookkeeping",
|
||||
NodeKind::Provision { .. } => "provision",
|
||||
NodeKind::Create { .. } => "create",
|
||||
NodeKind::DestroyContainer { .. } => "destroy_container",
|
||||
NodeKind::PurgeState { .. } => "purge_state",
|
||||
NodeKind::DestroyBookkeeping { .. } => "destroy_bookkeeping",
|
||||
NodeKind::MetaLock { .. } => "meta_lock",
|
||||
NodeKind::Reconcile { .. } => "reconcile",
|
||||
NodeKind::Start { .. } => "start",
|
||||
NodeKind::Stop { .. } => "stop",
|
||||
NodeKind::StopForUpdate { .. } => "stop_for_update",
|
||||
NodeKind::Signal { .. } => "signal",
|
||||
NodeKind::Drain { .. } => "drain",
|
||||
NodeKind::PauseSignal { .. } => "pause_signal",
|
||||
NodeKind::PauseDrain { .. } => "pause_drain",
|
||||
NodeKind::WriteDropin { .. } => "write_dropin",
|
||||
NodeKind::WritePermFile { .. } => "write_perm_file",
|
||||
NodeKind::Reparent { .. } => "reparent",
|
||||
NodeKind::DeployWindow { .. } => "deploy_window",
|
||||
NodeKind::AgentWindow { .. } => "agent_window",
|
||||
NodeKind::MergeVerify { .. } => "merge_verify",
|
||||
NodeKind::DeployApply { .. } => "deploy_apply",
|
||||
NodeKind::FinalizeDeploy { .. } => "finalize_deploy",
|
||||
NodeKind::DeployTail { .. } => "deploy_tail",
|
||||
NodeKind::ResolveApproval { .. } => "resolve_approval",
|
||||
NodeKind::EmitRebuilt { .. } => "emit_rebuilt",
|
||||
NodeKind::SetWanted { .. } => "set_wanted",
|
||||
NodeKind::ForgeSweep => "forge_sweep",
|
||||
NodeKind::MatrixSweep => "matrix_sweep",
|
||||
NodeKind::WebhookRegister => "webhook_register",
|
||||
NodeKind::KnowledgePull => "knowledge_pull",
|
||||
NodeKind::WantedPull => "wanted_pull",
|
||||
}
|
||||
self.into()
|
||||
}
|
||||
|
||||
/// The agent this node targets, or `""` for agentless kinds
|
||||
|
|
|
|||
Loading…
Reference in a new issue