From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from gate001.proxmox.com (gate001.proxmox.com [45.144.208.40]) by lore.proxmox.com (Postfix) with ESMTPS id 1F84A1FF0E3 for ; Tue, 04 Aug 2026 13:39:26 +0200 (CEST) Received: from gate001.proxmox.com (localhost.localdomain [127.0.0.1]) by gate001.proxmox.com (Proxmox) with ESMTP id E57A6216E2; Tue, 04 Aug 2026 13:39:25 +0200 (CEST) Content-Type: text/plain; charset=UTF-8 Date: Tue, 04 Aug 2026 13:39:20 +0200 Message-Id: Subject: Re: [PATCH installer 09/16] post-hook: support creating API token if requested in answer file From: "Lukas Wagner" To: "Christoph Heiss" , Mime-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Mailer: aerc 0.21.0-0-g5549850facc2-dirty References: <20260731143910.936881-1-c.heiss@proxmox.com> <20260731143910.936881-10-c.heiss@proxmox.com> In-Reply-To: <20260731143910.936881-10-c.heiss@proxmox.com> X-Bm-Milter-Handled: 55990f41-d878-4baa-be0a-ee34c49e34d2 X-Bm-Transport-Timestamp: 1785843549008 X-SPAM-LEVEL: Spam detection results: 0 AWL 0.232 Adjusted score from AWL reputation of From: address DMARC_MISSING 0.1 Missing DMARC policy KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment (newer systems) RCVD_IN_DNSWL_LOW -0.7 Sender listed at https://www.dnswl.org/, low trust SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record Message-ID-Hash: 33DETEVHBZZNG2HR7OJPBWYBEXBFLAD7 X-Message-ID-Hash: 33DETEVHBZZNG2HR7OJPBWYBEXBFLAD7 X-MailFrom: l.wagner@proxmox.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.10 Precedence: list List-Id: Proxmox Datacenter Manager development discussion List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: On Fri Jul 31, 2026 at 4:35 PM CEST, Christoph Heiss wrote: > diff --git a/proxmox-post-hook/src/main.rs b/proxmox-post-hook/src/main.r= s > index 760ab53..f7a41c9 100644 > --- a/proxmox-post-hook/src/main.rs > +++ b/proxmox-post-hook/src/main.rs > @@ -49,8 +49,8 @@ mod detail { > AutoInstallerConfig, FqdnConfig, FqdnFromDhcpConfig, FqdnSou= rceMode, SchemaVersion, > }, > post_hook::{ > - BootInfo, CpuInfo, DiskInfo, KernelVersionInformation, Netwo= rkInterfaceInfo, > - PostHookInfo, PostHookInfoSchema, ProductInfo, SchemaVersion= , SshPublicHostKeys, > + BootInfo, CpuInfo, CreatedApiToken, DiskInfo, KernelVersionI= nformation, > + NetworkInterfaceInfo, PostHookInfo, PostHookInfoSchema, Prod= uctInfo, SshPublicHostKeys, > }, > }; > =20 > @@ -148,6 +148,24 @@ mod detail { > None > }; > =20 > + let api_token =3D if let Some(name) =3D answer > + .post_installation_webhook > + .as_ref() > + .and_then(|p| p.api_token_name.as_ref()) > + && schema_1_3_supported > + && setup_info.config.product.supports_api_token_creation() > + { > + match create_api_token(name, target_path, setup_info.config.= product, &run_cmd) { > + Ok(token) =3D> Some(token), > + Err(err) =3D> { > + eprintln!("could not create API token: {err:#}"); > + None > + } > + } You could do a=20 create_api_token(name, target_path, setup_info.config.product, &run_cmd= ) .inspect_err(|err| eprintln!("could not create API token: {err:#}")) .ok() here, seems quite a bit shorter > + } else { > + None > + }; > +