public inbox for pve-devel@lists.proxmox.com
 help / color / mirror / Atom feed
From: Nicolas Frey <n.frey@proxmox.com>
To: Thomas Lamprecht <t.lamprecht@proxmox.com>,
	Proxmox VE development discussion <pve-devel@lists.proxmox.com>
Subject: Re: [pve-devel] [PATCH pve-manager v2 2/4] api: add APT versions return schema
Date: Thu, 2 Oct 2025 11:25:47 +0200	[thread overview]
Message-ID: <c93559a5-f482-40ae-a68b-093b89c5e217@proxmox.com> (raw)
In-Reply-To: <cc86f63f-68d6-4824-a3f1-1f401520d677@proxmox.com>



On 10/2/25 10:50 AM, Thomas Lamprecht wrote:
> Am 24.09.25 um 13:59 schrieb n.frey@proxmox.com:
>> From: Nicolas Frey <n.frey@proxmox.com>
>>
>> listed only supported debian architectures [0] in enum for 'Arch'.
>> listed all APT package states in enum for 'CurrentState'.
> 
> This is a bit specific and the sentence seems like it starts
> somewhere in the middle, maybe this can be lead up to with
> adding a little bit more context that avoids that one starts to
> wonder what a APT version return schema has to do with Debian A+rchs.
> 

Will add context in v3, thanks!

>>
>> [0] https://wiki.debian.org/SupportedArchitectures
>>
>> Signed-off-by: Nicolas Frey <n.frey@proxmox.com>
>> ---
>>  PVE/API2/APT.pm | 113 ++++++++++++++++++++++++++++--------------------
>>  1 file changed, 67 insertions(+), 46 deletions(-)
>>
>> diff --git a/PVE/API2/APT.pm b/PVE/API2/APT.pm
>> index 0d07cf38..885b85ae 100644
>> --- a/PVE/API2/APT.pm
>> +++ b/PVE/API2/APT.pm
> 
>> @@ -769,6 +771,25 @@ __PACKAGE__->register_method({
>>      },
>>  });
>>  
>> +$apt_package_return_props->{CurrentState} = {
>> +    type => 'string',
>> +    description => 'Current state of the package installed on the system.',
>> +    # Possible CurrentState variants according to AptPkg::Cache
>> +    enum => [qw(Installed NotInstalled UnPacked HalfConfigured HalfInstalled ConfigFiles)],
>> +};
>> +
>> +$apt_package_return_props->{RunningKernel} = {
>> +    type => 'string',
>> +    description => "Kernel release, only for package 'proxmox-ve'.",
>> +    optional => 1,
>> +};
>> +
>> +$apt_package_return_props->{ManagerVersion} = {
>> +    type => 'string',
>> +    description => "Version of the currently running pve-manager API server.",
>> +    optional => 1,
>> +};
>> +
> 
> Modifying a hash reference that is already used above is rather dangerous, as just
> some code line movement can introduce different behavior and wrong return types.
> 
> You rather should create a new (cloned) variable, e.g.:
> 
> my $versions_api_return_schema = {
>     $apt_package_return_props->%*,
>     CurrentState => {
>         ...,
>     },
>     ...,
> }
> 
> As this is then only used once you can also do that inline below, as
> single-use intermediate variables are most often rather useless and just an
> extra indirection. While they sometimes the can indeed help bring clarity,
> here it would be pretty clear what's happening without that.

Thanks for the feedback! I had a feeling modifying the hash reference might
not be the best approach (still getting used to Perl).
Will address in v3.

> 
>>  __PACKAGE__->register_method({
>>      name => 'versions',
>>      path => 'versions',
>> @@ -788,7 +809,7 @@ __PACKAGE__->register_method({
>>          type => "array",
>>          items => {
>>              type => "object",
>> -            properties => {},
>> +            properties => sort $apt_package_return_props,
>>          },
>>      },
>>      code => sub {
> 



_______________________________________________
pve-devel mailing list
pve-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel


  reply	other threads:[~2025-10-02  9:25 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-09-24 11:59 [pve-devel] [PATCH pve-manager v2 0/4] api: add return schemas n.frey
2025-09-24 11:59 ` [pve-devel] [PATCH pve-manager v2 1/4] api: add ACME plugin return schema n.frey
2025-09-24 11:59 ` [pve-devel] [PATCH pve-manager v2 2/4] api: add APT versions " n.frey
2025-10-02  8:50   ` Thomas Lamprecht
2025-10-02  9:25     ` Nicolas Frey [this message]
2025-09-24 11:59 ` [pve-devel] [PATCH pve-manager v2 3/4] api: add service state " n.frey
2025-09-24 11:59 ` [pve-devel] [PATCH pve-manager v2 4/4] api: add replication config read " n.frey
2025-10-02  8:51   ` Thomas Lamprecht
2025-10-02 11:18     ` Nicolas Frey
2025-10-02  8:23 ` [pve-devel] partially-applied: [PATCH pve-manager v2 0/4] api: add return schemas Thomas Lamprecht

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=c93559a5-f482-40ae-a68b-093b89c5e217@proxmox.com \
    --to=n.frey@proxmox.com \
    --cc=pve-devel@lists.proxmox.com \
    --cc=t.lamprecht@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
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal