all lists on lists.proxmox.com
 help / color / mirror / Atom feed
From: Fabian Ebner <f.ebner@proxmox.com>
To: pmg-devel@lists.proxmox.com
Subject: [pmg-devel] [PATCH pmg-api] api: apt: repos: avoid creating implicit default for enabled
Date: Fri, 16 Jul 2021 15:42:36 +0200	[thread overview]
Message-ID: <20210716134236.113436-1-f.ebner@proxmox.com> (raw)

The parameter is optional, so a check for definedness is needed before
converting to int.

Signed-off-by: Fabian Ebner <f.ebner@proxmox.com>
---
 src/PMG/API2/APT.pm | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/src/PMG/API2/APT.pm b/src/PMG/API2/APT.pm
index 6d0f651..5e132c4 100644
--- a/src/PMG/API2/APT.pm
+++ b/src/PMG/API2/APT.pm
@@ -749,9 +749,10 @@ __PACKAGE__->register_method({
     code => sub {
 	my ($param) = @_;
 
-	my $options = {
-	    enabled => int($param->{enabled}),
-	};
+	my $options = {};
+
+	my $enabled = $param->{enabled};
+	$options->{enabled} = int($enabled) if defined($enabled);
 
 	PMG::RS::APT::Repositories::change_repository(
 	    $param->{path},
-- 
2.30.2





             reply	other threads:[~2021-07-16 13:43 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-07-16 13:42 Fabian Ebner [this message]
2021-07-19 15:42 ` [pmg-devel] applied: " 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=20210716134236.113436-1-f.ebner@proxmox.com \
    --to=f.ebner@proxmox.com \
    --cc=pmg-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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal