File Coverage

blib/lib/CCfnX/LocateAMI.pm
Criterion Covered Total %
statement 12 18 66.6
branch 0 2 0.0
condition n/a
subroutine 4 6 66.6
pod 0 2 0.0
total 16 28 57.1


line stmt bran cond sub pod time code
1             package CCfnX::LocateAMI {
2 14     14   479 use Moose;
  14         284182  
  14         87  
3 14     14   83385 use Carp;
  14         33  
  14         707  
4 14     14   6378 use autodie;
  14         159983  
  14         65  
5             has name => (is => 'ro', isa => 'Str');
6 14     14   94333 use CloudDeploy::Config;
  14         50  
  14         3464  
7              
8             has account => (is => 'ro', isa => 'Str', lazy => 1, default => sub { $ENV{'CPSD_AWS_ACCOUNT'} });
9             has config => (is => 'ro', lazy => 1, default => sub { CloudDeploy::Config->new });
10             has mongo => (is => 'ro', lazy => 1, default => sub { $_[0]->config->deploy_mongo });
11              
12             sub ami {
13 0     0 0   my ($self, $region, $arch, $root) = @_;
14 0           my $body = {
15             name => $self->name,
16             account => $self->account,
17             'outputs.arch' => lc($arch),
18             'outputs.root' => lc($root),
19             region => lc($region),
20             };
21              
22 0           my $obj = $self->mongo->query(
23             $body,
24             { sort_by => { timestamp => -1 }, limit => 1 },
25             )->next;
26              
27 0 0         confess "Didn't find deployment " . $self->name . " in account " . $self->account unless defined $obj;
28              
29 0           return $obj->{outputs}->{ami};
30             }
31             sub mapping {
32 0     0 0   my ($self, $arch, $root) = @_;
33             # Create a mapping for a specified arch and root type
34             }
35             }
36              
37             1;