add filter-type to ec2 discovery

This commit is contained in:
Colin Gagnaire 2020-04-08 22:32:26 +02:00
parent 041b8fda41
commit 506ff1c9e1
1 changed files with 10 additions and 3 deletions

View File

@ -32,7 +32,8 @@ sub new {
bless $self, $class; bless $self, $class;
$options{options}->add_options(arguments => { $options{options}->add_options(arguments => {
"prettify" => { name => 'prettify' }, "prettify" => { name => 'prettify' },
"filter-type:s" => { name => 'filter_type' },
}); });
return $self; return $self;
@ -86,8 +87,10 @@ sub run {
} }
push @{$ec2{tags}}, { key => $tag->{Key}, value => $tag->{Value} }; push @{$ec2{tags}}, { key => $tag->{Key}, value => $tag->{Value} };
} }
push @disco_data, \%ec2; push @disco_data, \%ec2 unless (defined($self->{option_results}->{filter_type})
push @disco_data, \%asg if (defined($asg{name}) && $asg{name} ne ''); && $ec2{type} !~ /$self->{option_results}->{filter_type}/);
push @disco_data, \%asg unless ((defined($self->{option_results}->{filter_type})
&& $asg{type} !~ /$self->{option_results}->{filter_type}/) || !defined($asg{name}) || $asg{name} eq '');
} }
} }
@ -123,6 +126,10 @@ EC2/ASG discovery.
=over 8 =over 8
=item B<--filter-type>
Filter type.
=item B<--prettify> =item B<--prettify>
Prettify JSON output. Prettify JSON output.