From: Wolfgang Bumiller <w.bumiller@proxmox.com>
To: Hannes Laimer <h.laimer@proxmox.com>
Cc: pdm-devel@lists.proxmox.com
Subject: [pdm-devel] applied: [PATCH proxmox v2] pve-api-types: schema2rust: handle `macro` keyword like we do `type`
Date: Wed, 5 Nov 2025 11:44:00 +0100 [thread overview]
Message-ID: <chivphhr2kgpegjcs4deiim77xv7yfdorvjr4ynpxkukyiqsiu@74blbahsjnyg> (raw)
In-Reply-To: <20251023141956.106640-1-h.laimer@proxmox.com>
applied, thanks
On Thu, Oct 23, 2025 at 04:19:56PM +0200, Hannes Laimer wrote:
> Firewall rules have a field named `macro`, this would trip up the
> generated rust code. This fixes that.
>
> Signed-off-by: Hannes Laimer <h.laimer@proxmox.com>
> ---
> v2:
> - include quoting of `macro`, this was missing in v1 but is needed
>
> pve-api-types/generator-lib/Schema2Rust.pm | 7 ++++---
> 1 file changed, 4 insertions(+), 3 deletions(-)
>
> diff --git a/pve-api-types/generator-lib/Schema2Rust.pm b/pve-api-types/generator-lib/Schema2Rust.pm
> index c5ac4aad..9b984abb 100644
> --- a/pve-api-types/generator-lib/Schema2Rust.pm
> +++ b/pve-api-types/generator-lib/Schema2Rust.pm
> @@ -125,8 +125,8 @@ sub api_to_string : prototype($$$$$) {
>
> local $API_TYPE_POS = "$API_TYPE_POS/$key";
>
> - # We need to quote keys with hyphens:
> - my $safe_key = ($key =~ /-/) ? "\"$key\"" : $key;
> + # We need to quote keys with hyphens or reserved keywords:
> + my $safe_key = (($key =~ /-/) || ($key eq 'macro')) ? "\"$key\"" : $key;
>
> if (exists($API_TYPE_OVERRIDES{$API_TYPE_POS})) {
> $value = $API_TYPE_OVERRIDES{$API_TYPE_POS};
> @@ -171,7 +171,7 @@ sub api_to_string : prototype($$$$$) {
> warn "api type extension for $API_TYPE_POS.$key already in schema, skipping\n";
> next;
> }
> - my $safe_key = ($key =~ /-/) ? "\"$key\"" : $key;
> + my $safe_key = (($key =~ /-/) || ($key eq 'macro')) ? "\"$key\"" : $key;
> my $value = $extra->{$key};
> print {$out} "${indent}$safe_key: $value,\n";
> }
> @@ -713,6 +713,7 @@ sub namify_field : prototype($) {
> }
>
> return 'ty' if $out eq 'type';
> + return 'r#macro' if $out eq 'macro';
>
> return $out;
> }
> --
> 2.47.3
_______________________________________________
pdm-devel mailing list
pdm-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pdm-devel
prev parent reply other threads:[~2025-11-05 10:43 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-10-23 14:19 [pdm-devel] " Hannes Laimer
2025-11-05 10:44 ` Wolfgang Bumiller [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=chivphhr2kgpegjcs4deiim77xv7yfdorvjr4ynpxkukyiqsiu@74blbahsjnyg \
--to=w.bumiller@proxmox.com \
--cc=h.laimer@proxmox.com \
--cc=pdm-devel@lists.proxmox.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox