public inbox for pmg-devel@lists.proxmox.com
 help / color / mirror / Atom feed
From: Thomas Lamprecht <t.lamprecht@proxmox.com>
To: Wolfgang Bumiller <w.bumiller@proxmox.com>, pmg-devel@lists.proxmox.com
Subject: Re: [pmg-devel] [PATCH api 2/4] support forced account deactivation
Date: Wed, 17 Mar 2021 11:33:57 +0100	[thread overview]
Message-ID: <47566280-fade-6a5c-6ad8-a6b1b3bdb4ce@proxmox.com> (raw)
In-Reply-To: <20210317100216.8008-3-w.bumiller@proxmox.com>

On 17.03.21 11:02, Wolfgang Bumiller wrote:
> Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
> ---
>  src/PMG/API2/ACME.pm | 27 ++++++++++++++++++++++-----
>  1 file changed, 22 insertions(+), 5 deletions(-)
> 

applied, thanks - squashed one change into it though.

> diff --git a/src/PMG/API2/ACME.pm b/src/PMG/API2/ACME.pm
> index 60b5986..d6dbf2f 100644
> --- a/src/PMG/API2/ACME.pm
> +++ b/src/PMG/API2/ACME.pm
> @@ -173,7 +173,7 @@ __PACKAGE__->register_method ({
>      }});
>  
>  my $update_account = sub {
> -    my ($param, $msg, %info) = @_;
> +    my ($param, $msg, $force_deactivate, %info) = @_;
>  
>      my ($account_name, $account_file) = extract_account_name($param);
>  
> @@ -190,7 +190,15 @@ my $update_account = sub {
>  		if ! -e $account_file;
>  
>  	    my $acme = PMG::RS::Acme->load($account_file);
> -	    $acme->update_account(\%info);
> +	    eval {
> +		$acme->update_account(\%info);
> +	    };
> +	    my $err = $@;
> +	    if ($force_deactivate) {
> +		warn $err if $err;
> +	    } else {
> +		die $2;

fixed up above typo and logic

> +	    }
>  	    if ($info{status} && $info{status} eq 'deactivated') {
>  		my $deactivated_name;
>  		for my $i (0..100) {
> @@ -239,9 +247,9 @@ __PACKAGE__->register_method ({
>  
>  	my $contact = $account_contact_from_param->($param);
>  	if (scalar @$contact) {
> -	    return $update_account->($param, 'update', contact => $contact);
> +	    return $update_account->($param, 'update', 0, contact => $contact);
>  	} else {
> -	    return $update_account->($param, 'refresh');
> +	    return $update_account->($param, 'refresh', 0);
>  	}
>      }});
>  
> @@ -311,6 +319,13 @@ __PACKAGE__->register_method ({
>  	additionalProperties => 0,
>  	properties => {
>  	    name => get_standard_option('pmg-acme-account-name'),
> +	    force => {
> +		type => 'boolean',
> +		description =>
> +		    'Delete account data even if the server refuses to deactivate the account.',
> +		optional => 1,
> +		default => 0,
> +	    },
>  	},
>      },
>      returns => {
> @@ -319,7 +334,9 @@ __PACKAGE__->register_method ({
>      code => sub {
>  	my ($param) = @_;
>  
> -	return $update_account->($param, 'deactivate', status => 'deactivated');
> +	my $force_deactivate = extract_param($param, 'force');
> +
> +	return $update_account->($param, 'deactivate', $force_deactivate, status => 'deactivated');
>      }});
>  
>  __PACKAGE__->register_method ({
> 





  reply	other threads:[~2021-03-17 10:33 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-03-17 10:02 [pmg-devel] [PATCH api 0/4] ACME updates Wolfgang Bumiller
2021-03-17 10:02 ` [pmg-devel] [PATCH api 1/4] add missing use statement Wolfgang Bumiller
2021-03-17 10:02 ` [pmg-devel] [PATCH api 2/4] support forced account deactivation Wolfgang Bumiller
2021-03-17 10:33   ` Thomas Lamprecht [this message]
2021-03-17 10:02 ` [pmg-devel] [PATCH api 3/4] add PMG::NodeConfig::filter_domains_by_type helper Wolfgang Bumiller
2021-03-17 10:02 ` [pmg-devel] [PATCH api 4/4] check acme cert expiration in pmg-daily Wolfgang Bumiller
2021-03-17 10:34 ` [pmg-devel] applied-series: [PATCH api 0/4] ACME updates 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=47566280-fade-6a5c-6ad8-a6b1b3bdb4ce@proxmox.com \
    --to=t.lamprecht@proxmox.com \
    --cc=pmg-devel@lists.proxmox.com \
    --cc=w.bumiller@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