| 1 | package Imager::CommandLine::UntagImages { | ||
| 2 | use MooseX::App; | ||
| 3 | use ARGV::Struct; | ||
| 4 | use CloudDeploy::AMIDB; | ||
| 5 | use Data::Printer; | ||
| 6 | use v5.10; | ||
| 7 | |||
| 8 | has find_args => ( | ||
| 9 | is => 'ro', | ||
| 10 | isa => 'HashRef[Str]', | ||
| 11 | lazy => 1, | ||
| 12 | default => sub { | ||
| 13 | my $self = shift; | ||
| 14 | return ARGV::Struct->new(argv => [ '{', @{ $self->extra_argv }, '}' ])->parse; | ||
| 15 | } | ||
| 16 | ); | ||
| 17 | |||
| 18 | parameter tag => ( | ||
| 19 | is => 'ro', | ||
| 20 | isa => 'Str', | ||
| 21 | documentation => 'The tag to assign', | ||
| 22 | required => 1, | ||
| 23 | ); | ||
| 24 | |||
| 25 | sub run { | ||
| 26 | my ($self) = @_; | ||
| 27 | |||
| 28 | die "You have to specify a filter to tag an AMI" if (keys %{ $self->find_args } == 0); | ||
| 29 | |||
| 30 | my $db = CloudDeploy::AMIDB->new; | ||
| 31 | |||
| 32 | my $tagged = $db->unset_tag_from($self->tag, %{ $self->find_args }); | ||
| 33 | |||
| 34 | foreach (@$tagged) { say "UnTagged $_" } | ||
| 35 | } | ||
| 36 | } | ||
| 37 | |||
| 38 | 1; | ||
| 39 |