add prettify option in azure discovery
This commit is contained in:
parent
a95412b484
commit
c7de8dc9da
|
@ -32,12 +32,12 @@ sub new {
|
||||||
bless $self, $class;
|
bless $self, $class;
|
||||||
|
|
||||||
$self->{version} = '1.0';
|
$self->{version} = '1.0';
|
||||||
$options{options}->add_options(arguments =>
|
$options{options}->add_options(arguments => {
|
||||||
{
|
|
||||||
"namespace:s" => { name => 'namespace' },
|
"namespace:s" => { name => 'namespace' },
|
||||||
"type:s" => { name => 'type' },
|
"type:s" => { name => 'type' },
|
||||||
"resource-group:s" => { name => 'resource_group' },
|
"resource-group:s" => { name => 'resource_group' },
|
||||||
"location:s" => { name => 'location' },
|
"location:s" => { name => 'location' },
|
||||||
|
"prettify" => { name => 'prettify' },
|
||||||
});
|
});
|
||||||
|
|
||||||
return $self;
|
return $self;
|
||||||
|
@ -88,7 +88,11 @@ sub run {
|
||||||
|
|
||||||
my $encoded_data;
|
my $encoded_data;
|
||||||
eval {
|
eval {
|
||||||
$encoded_data = encode_json($disco_stats);
|
if (defined($self->{option_results}->{prettify})) {
|
||||||
|
$encoded_data = JSON::XS->new->utf8->pretty->encode($disco_stats);
|
||||||
|
} else {
|
||||||
|
$encoded_data = JSON::XS->new->utf8->encode($disco_stats);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
if ($@) {
|
if ($@) {
|
||||||
$encoded_data = '{"code":"encode_error","message":"Cannot encode discovered data into JSON format"}';
|
$encoded_data = '{"code":"encode_error","message":"Cannot encode discovered data into JSON format"}';
|
||||||
|
|
Loading…
Reference in New Issue