server-url LOOK AT THE CONFIG
This commit is contained in:
@@ -9,6 +9,7 @@ on:
|
||||
|
||||
jobs:
|
||||
build:
|
||||
# My Machine has arm-musl stuff - or else i have to use cross :(
|
||||
runs-on: [self-hosted, linux, fedora, wsl, release]
|
||||
steps:
|
||||
- name: Checkout
|
||||
@@ -20,6 +21,7 @@ jobs:
|
||||
rustc -V
|
||||
cargo -V
|
||||
rustup target add armv7-unknown-linux-musleabihf
|
||||
# x86_64-unknown-linux-gnu86_64-pc-windows-msvc aarch64-unknown-linux-gnu
|
||||
|
||||
- name: Cache cargo
|
||||
uses: actions/cache@v4
|
||||
|
||||
@@ -44,10 +44,16 @@ pub struct ServeArgs {
|
||||
#[derive(Args)]
|
||||
pub struct EnrollArgs {
|
||||
/// 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)]
|
||||
pub server_url: String,
|
||||
pub server_url: Option<String>,
|
||||
/// 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,
|
||||
/// Path to the agent config file to write (overwritten on successful enroll).
|
||||
#[arg(long, default_value = config::DEFAULT_CONFIG_PATH)]
|
||||
|
||||
+14
-2
@@ -22,9 +22,21 @@ async fn main() -> Result<()> {
|
||||
serve::serve(args).await?
|
||||
}
|
||||
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 =
|
||||
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!("config={}", args.config.display());
|
||||
println!("config_write=updated");
|
||||
|
||||
Reference in New Issue
Block a user