drop the applied repo: the hive keeps no copy of an agent's config, only the deploy markers. Refs #5913
This commit is contained in:
parent
deeb5ecd86
commit
862495530c
3 changed files with 190 additions and 1634 deletions
|
|
@ -27,14 +27,6 @@ pub struct Cli {
|
|||
|
||||
#[derive(Subcommand)]
|
||||
pub enum Cmd {
|
||||
/// Reconcile an agent's config between this hive and the forge.
|
||||
///
|
||||
/// A human's first SSO login to the forge makes their forge
|
||||
/// account.
|
||||
Forge {
|
||||
#[command(subcommand)]
|
||||
cmd: ForgeCmd,
|
||||
},
|
||||
/// Lifecycle actions on ONE managed agent container. Needs the
|
||||
/// hive-c0re daemon running.
|
||||
///
|
||||
|
|
@ -199,45 +191,6 @@ impl ScopeArgs {
|
|||
}
|
||||
}
|
||||
|
||||
#[derive(Subcommand)]
|
||||
pub enum ForgeCmd {
|
||||
/// Show + reconcile the divergence between an agent's local applied
|
||||
/// config checkout and its forge `agent-configs/<agent>` main.
|
||||
///
|
||||
/// Always prints the diff first. `--from forge` resets the local
|
||||
/// checkout to forge main (effective on the next deploy); `--from local`
|
||||
/// isn't supported yet. With no `--from`, prompts for the direction.
|
||||
ReconcileConfig {
|
||||
/// Agent whose config branches to reconcile.
|
||||
agent: String,
|
||||
/// Which side to reconcile from. Omit it and hivectl prompts you after the diff.
|
||||
#[arg(long, value_enum)]
|
||||
from: Option<ReconcileFrom>,
|
||||
/// Include the full diff (not just `--stat`) in the report.
|
||||
#[arg(long)]
|
||||
verbose: bool,
|
||||
},
|
||||
}
|
||||
|
||||
/// Which side to reconcile config branches from (`hivectl forge
|
||||
/// reconcile-config --from`). Maps to [`hive_host_sock::ReconcileDirection`].
|
||||
#[derive(Clone, Copy, clap::ValueEnum)]
|
||||
pub enum ReconcileFrom {
|
||||
/// Reset the local applied checkout to forge main.
|
||||
Forge,
|
||||
/// Advance forge main from local — not supported yet.
|
||||
Local,
|
||||
}
|
||||
|
||||
impl From<ReconcileFrom> for hive_host_sock::ReconcileDirection {
|
||||
fn from(from: ReconcileFrom) -> Self {
|
||||
match from {
|
||||
ReconcileFrom::Forge => Self::Forge,
|
||||
ReconcileFrom::Local => Self::Local,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Subcommand)]
|
||||
pub enum WgCmd {
|
||||
/// Generate this hive's WireGuard key (if absent) and print its public
|
||||
|
|
|
|||
|
|
@ -1,66 +0,0 @@
|
|||
//! `hivectl forge reconcile-config <agent>` — show and reconcile an
|
||||
//! agent's config divergence via the daemon.
|
||||
|
||||
use std::io::{self, Write};
|
||||
use std::path::Path;
|
||||
|
||||
use anyhow::Result;
|
||||
use hive_host_sock::{HostRequest, ReconcileDirection};
|
||||
|
||||
use crate::cli::ReconcileFrom;
|
||||
use crate::util::daemon_request;
|
||||
|
||||
/// `hivectl forge reconcile-config <agent> [--from <forge|local>] [--verbose]`.
|
||||
/// Always shows the divergence first (daemon computes it read-only), then
|
||||
/// applies the chosen direction — from `--from` or an interactive prompt.
|
||||
pub(crate) async fn forge_reconcile_config(
|
||||
socket: &Path,
|
||||
agent: &str,
|
||||
from: Option<ReconcileFrom>,
|
||||
verbose: bool,
|
||||
) -> Result<()> {
|
||||
daemon_request(
|
||||
socket,
|
||||
HostRequest::ReconcileConfigStatus {
|
||||
agent: crate::util::parse_ident(agent)?,
|
||||
verbose,
|
||||
},
|
||||
"forge",
|
||||
)
|
||||
.await?;
|
||||
let direction = match from {
|
||||
Some(f) => Some(f.into()),
|
||||
None => prompt_direction()?,
|
||||
};
|
||||
let Some(direction) = direction else {
|
||||
println!("forge: aborted — no changes made");
|
||||
return Ok(());
|
||||
};
|
||||
daemon_request(
|
||||
socket,
|
||||
HostRequest::ReconcileConfigApply {
|
||||
agent: crate::util::parse_ident(agent)?,
|
||||
direction,
|
||||
},
|
||||
"forge",
|
||||
)
|
||||
.await
|
||||
}
|
||||
|
||||
/// Prompt the operator for the reconcile direction after showing the diff.
|
||||
/// Returns `None` to abort (empty / `q` / unrecognized input).
|
||||
fn prompt_direction() -> Result<Option<ReconcileDirection>> {
|
||||
print!("reconcile from [forge/local] (or q to abort): ");
|
||||
io::stdout().flush()?;
|
||||
let mut line = String::new();
|
||||
io::stdin().read_line(&mut line)?;
|
||||
match line.trim().to_ascii_lowercase().as_str() {
|
||||
"forge" | "f" => Ok(Some(ReconcileDirection::Forge)),
|
||||
"local" | "l" => Ok(Some(ReconcileDirection::Local)),
|
||||
"" | "q" | "quit" => Ok(None),
|
||||
other => {
|
||||
println!("forge: unrecognized direction {other:?} — aborting");
|
||||
Ok(None)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -26,7 +26,7 @@ mod client;
|
|||
/// Rebuild-queue node progress rendering (`wait_for_nodes` + the spinner /
|
||||
/// plain renderers), split out to keep this file manageable.
|
||||
mod dag_progress;
|
||||
use cli::{Cli, Cmd, ForgeCmd, WgCmd};
|
||||
use cli::{Cli, Cmd, WgCmd};
|
||||
mod completions;
|
||||
mod quota;
|
||||
mod util;
|
||||
|
|
@ -35,11 +35,9 @@ mod open;
|
|||
use open::open_url;
|
||||
mod wg;
|
||||
use wg::{peer_config, require_hive_domain, wg_init, wg_peer, wg_status};
|
||||
mod choom;
|
||||
mod forge;
|
||||
mod watch;
|
||||
use forge::forge_reconcile_config;
|
||||
mod agents;
|
||||
mod choom;
|
||||
mod watch;
|
||||
use agents::{agents_list, run_agent};
|
||||
mod power;
|
||||
use power::{restart, start, stop};
|
||||
|
|
@ -56,13 +54,6 @@ async fn main() -> Result<()> {
|
|||
let cli = Cli::parse();
|
||||
let socket = cli.socket;
|
||||
match cli.cmd {
|
||||
Cmd::Forge { cmd } => match cmd {
|
||||
ForgeCmd::ReconcileConfig {
|
||||
agent,
|
||||
from,
|
||||
verbose,
|
||||
} => forge_reconcile_config(&socket, &agent, from, verbose).await,
|
||||
},
|
||||
Cmd::Agent { name, cmd } => run_agent(&socket, &name, cmd).await,
|
||||
Cmd::ListAgents { json } => agents_list(&socket, json).await,
|
||||
Cmd::QuotaEnable => quota::quota_enable(&socket).await,
|
||||
|
|
|
|||
Loading…
Reference in a new issue