Re: [pve-devel] [PATCH] PVE/API2/LXC.pm ssh-public-keys alias
On Wed, Jan 31, 2018 at 12:14:43AM +0100, Geert Stappers wrote: > Parameter name 'ssh-public-keys' causes trouble > when written as ssh-public-keys. Because it can read as > arthmetic expression ssh minus public minus keys. Just put quotes around it (and/or encode it properly depending on what you're actually doing). In fact I'd rather want to go the other way and get rid of the existing underscores in the API because we often also use them for command line parameters, too, where underscores are just plain weird. ___ pve-devel mailing list pve-devel@pve.proxmox.com https://pve.proxmox.com/cgi-bin/mailman/listinfo/pve-devel
Re: [pve-devel] [PATCH] PVE/API2/LXC.pm ssh-public-keys alias
On Wed, Jan 31, 2018 at 12:14:43AM +0100, Geert Stappers wrote: > Parameter name 'ssh-public-keys' causes trouble > when written as ssh-public-keys. Because it can read as > arthmetic expression ssh minus public minus keys. > > So an alias to the rescue. > Parameter name is 'ssh_public_keys'. > > Signed-off-by: Geert Stappers > --- > src/PVE/API2/LXC.pm | 12 +++- > 1 file changed, 11 insertions(+), 1 deletion(-) > > diff --git a/src/PVE/API2/LXC.pm b/src/PVE/API2/LXC.pm > index 733826e..ae3cbd8 100644 > --- a/src/PVE/API2/LXC.pm > +++ b/src/PVE/API2/LXC.pm It is from repository git://git.proxmox.com/git/pve-container.git > @@ -161,6 +161,11 @@ __PACKAGE__->register_method({ > description => "Setup public SSH keys (one key per line, " . > "OpenSSH format).", > }, > + 'ssh_public_keys' => { > + optional => 1, > + type => 'string', > + description => "Alias for ssh-public-keys", > + }, > }), > }, > returns => { > @@ -204,7 +209,12 @@ __PACKAGE__->register_method({ > > my $password = extract_param($param, 'password'); > > - my $ssh_keys = extract_param($param, 'ssh-public-keys'); > + my $ssh_keys; > + my $ssh_keys_orig = extract_param($param, 'ssh-public-keys'); > + my $ssh_keys_alias = extract_param($param, 'ssh_public_keys'); > + $ssh_keys = $ssh_keys_alias if defined($ssh_keys_alias); > + # Allow the original 'ssh-public-keys' parameter to win > + $ssh_keys = $ssh_keys_orig if defined($ssh_keys_orig); > PVE::Tools::validate_ssh_public_keys($ssh_keys) if defined($ssh_keys); > > my $pool = extract_param($param, 'pool'); > -- > 1.7.10.4 ___ pve-devel mailing list pve-devel@pve.proxmox.com https://pve.proxmox.com/cgi-bin/mailman/listinfo/pve-devel
[pve-devel] [PATCH] PVE/API2/LXC.pm ssh-public-keys alias
Parameter name 'ssh-public-keys' causes trouble when written as ssh-public-keys. Because it can read as arthmetic expression ssh minus public minus keys. So an alias to the rescue. Parameter name is 'ssh_public_keys'. Signed-off-by: Geert Stappers --- src/PVE/API2/LXC.pm | 12 +++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/PVE/API2/LXC.pm b/src/PVE/API2/LXC.pm index 733826e..ae3cbd8 100644 --- a/src/PVE/API2/LXC.pm +++ b/src/PVE/API2/LXC.pm @@ -161,6 +161,11 @@ __PACKAGE__->register_method({ description => "Setup public SSH keys (one key per line, " . "OpenSSH format).", }, + 'ssh_public_keys' => { + optional => 1, + type => 'string', + description => "Alias for ssh-public-keys", + }, }), }, returns => { @@ -204,7 +209,12 @@ __PACKAGE__->register_method({ my $password = extract_param($param, 'password'); - my $ssh_keys = extract_param($param, 'ssh-public-keys'); + my $ssh_keys; + my $ssh_keys_orig = extract_param($param, 'ssh-public-keys'); + my $ssh_keys_alias = extract_param($param, 'ssh_public_keys'); + $ssh_keys = $ssh_keys_alias if defined($ssh_keys_alias); + # Allow the original 'ssh-public-keys' parameter to win + $ssh_keys = $ssh_keys_orig if defined($ssh_keys_orig); PVE::Tools::validate_ssh_public_keys($ssh_keys) if defined($ssh_keys); my $pool = extract_param($param, 'pool'); -- 1.7.10.4 ___ pve-devel mailing list pve-devel@pve.proxmox.com https://pve.proxmox.com/cgi-bin/mailman/listinfo/pve-devel