server-url LOOK AT THE CONFIG

This commit is contained in:
lda
2026-04-14 05:24:58 +07:00 Unverified
parent 91359db3d7
commit 3053009a7e
3 changed files with 25 additions and 5 deletions
+2
View File
@@ -9,6 +9,7 @@ on:
jobs: jobs:
build: build:
# My Machine has arm-musl stuff - or else i have to use cross :(
runs-on: [self-hosted, linux, fedora, wsl, release] runs-on: [self-hosted, linux, fedora, wsl, release]
steps: steps:
- name: Checkout - name: Checkout
@@ -20,6 +21,7 @@ jobs:
rustc -V rustc -V
cargo -V cargo -V
rustup target add armv7-unknown-linux-musleabihf rustup target add armv7-unknown-linux-musleabihf
# x86_64-unknown-linux-gnu86_64-pc-windows-msvc aarch64-unknown-linux-gnu
- name: Cache cargo - name: Cache cargo
uses: actions/cache@v4 uses: actions/cache@v4
+8 -2
View File
@@ -44,10 +44,16 @@ pub struct ServeArgs {
#[derive(Args)] #[derive(Args)]
pub struct EnrollArgs { pub struct EnrollArgs {
/// Base HTTPS URL of the control plane. /// Base HTTPS URL of the control plane.
///
/// Resolution order:
/// 1) `--server-url` flag
/// 2) existing `server_url` value in `--config`
///
/// If neither source is available, enroll exits with an error.
#[arg(long)] #[arg(long)]
pub server_url: String, pub server_url: Option<String>,
/// One-time or short-lived enroll token provided by the control plane. /// One-time or short-lived enroll token provided by the control plane.
#[arg(long)] #[arg(long, short = 't', visible_alias = "token")]
pub enroll_token: String, pub enroll_token: String,
/// Path to the agent config file to write (overwritten on successful enroll). /// Path to the agent config file to write (overwritten on successful enroll).
#[arg(long, default_value = config::DEFAULT_CONFIG_PATH)] #[arg(long, default_value = config::DEFAULT_CONFIG_PATH)]
+14 -2
View File
@@ -22,9 +22,21 @@ async fn main() -> Result<()> {
serve::serve(args).await? serve::serve(args).await?
} }
Command::Enroll(args) => { Command::Enroll(args) => {
::tracing::info!(server_url = %args.server_url, config = %args.config.display(), "wakey-agent command: enroll"); let resolved_server_url = if let Some(server_url) = args.server_url.as_deref() {
server_url.to_string()
} else {
match config::load_config(&args.config) {
Ok(cfg) => cfg.server_url,
Err(_) => anyhow::bail!(
"missing control-plane URL: pass --server-url or provide server_url in {}",
args.config.display()
),
}
};
::tracing::info!(server_url = %resolved_server_url, config = %args.config.display(), "wakey-agent command: enroll");
let outcome = let outcome =
enroll::enroll(&args.server_url, &args.enroll_token, &args.config).await?; enroll::enroll(&resolved_server_url, &args.enroll_token, &args.config).await?;
println!("agent_id={}", outcome.config.agent_id); println!("agent_id={}", outcome.config.agent_id);
println!("config={}", args.config.display()); println!("config={}", args.config.display());
println!("config_write=updated"); println!("config_write=updated");