X-Git-Url: https://git.proxmox.com/?p=pve-client.git;a=blobdiff_plain;f=PVE%2FAPIClient%2FJSONSchema.pm;h=dd0a2c66aa48ef9ef8fb2de064be70d2857124c1;hp=377d6d519582c20cc4b51b6a7c187c101fcc5d66;hb=c2bcfdb264f39e38f6e8ab4203b66eef0b95ab74;hpb=c27b93a5e3ff6e03b68f7b1f53c85f5b03a0e3f3 diff --git a/PVE/APIClient/JSONSchema.pm b/PVE/APIClient/JSONSchema.pm index 377d6d5..dd0a2c6 100644 --- a/PVE/APIClient/JSONSchema.pm +++ b/PVE/APIClient/JSONSchema.pm @@ -121,6 +121,22 @@ sub get_format { return $format_list->{$format}; } +my $renderer_hash = {}; + +sub register_renderer { + my ($name, $code) = @_; + + die "renderer '$name' already registered\n" + if $renderer_hash->{$name}; + + $renderer_hash->{$name} = $code; +} + +sub get_renderer { + my ($name) = @_; + return $renderer_hash->{$name}; +} + # register some common type for pve register_format('string', sub {}); # allow format => 'string-list' @@ -1338,7 +1354,7 @@ sub method_get_child_link { # a way to parse command line parameters, using a # schema to configure Getopt::Long sub get_options { - my ($schema, $args, $arg_param, $fixed_param, $pwcallback, $param_mapping_hash) = @_; + my ($schema, $args, $arg_param, $fixed_param, $param_mapping_hash) = @_; if (!$schema || !$schema->{properties}) { raise("too many arguments\n", code => HTTP_BAD_REQUEST) @@ -1367,11 +1383,6 @@ sub get_options { # optional and call the mapping function afterwards. push @getopt, "$prop:s"; push @interactive, [$prop, $mapping->{func}]; - } elsif ($prop eq 'password' && $pwcallback) { - # we do not accept plain password on input line, instead - # we turn this into a boolean option and ask for password below - # using $pwcallback() (for security reasons). - push @getopt, "$prop"; } elsif ($pd->{type} eq 'boolean') { push @getopt, "$prop:s"; } else { @@ -1423,14 +1434,6 @@ sub get_options { } } - if (my $pd = $schema->{properties}->{password}) { - if ($pd->{type} ne 'boolean' && $pwcallback) { - if ($opts->{password} || !$pd->{optional}) { - $opts->{password} = &$pwcallback(); - } - } - } - foreach my $entry (@interactive) { my ($opt, $func) = @$entry; my $pd = $schema->{properties}->{$opt};