The forge now creates a human's account on their first authelia login, so the verb has no job left. Deletes it, HostRequest::ForgeCreateUser, its handler, provision_user_token, change_user_password and the hive's TOKEN_SCOPES. change_user_password also passed the password as an argument to `forgejo admin user change-password`, so it showed in the container's process list. ensure_user_exists and mint_token stay for the `core` bootstrap, their one caller now. ensure_user_exists loses its password parameter: only the deleted path set one. Refs #3782
66 lines
2 KiB
Rust
66 lines
2 KiB
Rust
//! `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)
|
|
}
|
|
}
|
|
}
|