Skip to content

Commit

Permalink
add filter-type to ec2 discovery
Browse files Browse the repository at this point in the history
  • Loading branch information
cgagnaire committed Apr 8, 2020
1 parent 041b8fd commit 506ff1c
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions cloud/aws/ec2/mode/discovery.pm
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@ sub new {
bless $self, $class;

$options{options}->add_options(arguments => {
"prettify" => { name => 'prettify' },
"prettify" => { name => 'prettify' },
"filter-type:s" => { name => 'filter_type' },
});

return $self;
Expand Down Expand Up @@ -86,8 +87,10 @@ sub run {
}
push @{$ec2{tags}}, { key => $tag->{Key}, value => $tag->{Value} };
}
push @disco_data, \%ec2;
push @disco_data, \%asg if (defined($asg{name}) && $asg{name} ne '');
push @disco_data, \%ec2 unless (defined($self->{option_results}->{filter_type})
&& $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 '');
}
}

Expand Down Expand Up @@ -123,6 +126,10 @@ EC2/ASG discovery.
=over 8
=item B<--filter-type>
Filter type.
=item B<--prettify>
Prettify JSON output.
Expand Down

0 comments on commit 506ff1c

Please sign in to comment.