swarmctl: forge make-admin

Calls POST /api/forge/users/{name}/admin and prints what it found. It
fails with the controller's message when the user has not logged in via
SSO yet, and when the name is an agent's.

Refs #3782
This commit is contained in:
atlas 2026-09-25 02:01:57 +02:00 • committed by mara
commit d56d8f2b36
4 changed files with 157 additions and 2 deletions

View file

@ -107,7 +107,7 @@ pub(crate) fn create(socket: &Path, name: &str, hive: &str) -> Result<()> {
/// Parse a CLI-supplied name into a validated identifier, naming which
/// argument was wrong — `invalid hive` and `invalid agent name` send the
/// operator to different flags.
fn parse_ident(value: &str, what: &str) -> Result<String> {
pub(crate) fn parse_ident(value: &str, what: &str) -> Result<String> {
hive_types::Ident::parse(value)
.map(hive_types::Ident::into_string)
.map_err(|reason| anyhow::anyhow!("invalid {what} {value:?}: {reason}"))
@ -186,7 +186,7 @@ async fn post_create(socket: &Path, name: &str, hive: &str) -> Result<CreateAgen
/// `what` names the request in error messages — the operator needs to know
/// which call failed, and every other part of this function is identical
/// between the two verbs.
async fn post<Req: Serialize, Resp: serde::de::DeserializeOwned>(
pub(crate) async fn post<Req: Serialize, Resp: serde::de::DeserializeOwned>(
socket: &Path,
uri: &str,
request: &Req,