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   667 use Moose;
  14         327187  
  14         106  
3 14     14   98644 use Carp;
  14         35  
  14         762  
4 14     14   7661 use autodie;
  14         196854  
  14         72  
5             has name => (is => 'ro', isa => 'Str');
6 14     14   107285 use CloudDeploy::Config;
  14         49  
  14         4485  
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;