FargateStack/Builder/EFS.pm

filter: Statementstmt 46.3% 25 / 54 Branchbran 0.0% 0 / 16 Conditioncond 0.0% 0 / 13 MC/DCmcdc 0.0% 0 / 8 Subroutinesub 80.0% 8 / 10 Podpod 0.0% 0 / 2 totaltotal 32.0% 33 / 103 CC 15 SCAR 42.1
CC
15
Cov
30%
add_volumes
132.0
add_efs_policy
30.0
BEGIN
1.0
CRAP 67.1
« FargateStack/Builder/LogGroup.pm ↑ Summary FargateStack/Builder/WafV2.pm »
1 package App::FargateStack::Builder::EFS;
2  
3 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 1 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 1 ▶use Data::Dumper;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 1 ▶use English qw(-no_match_vars);
Subroutine BEGIN: called CC=1 SCAR=0.0
9 1 ▶use JSON;
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11 1 ▶use App::FargateStack::Constants;
Subroutine BEGIN: called CC=1 SCAR=0.0
12  
13 1 ▶use Role::Tiny;
Subroutine BEGIN: called CC=1 SCAR=0.0
14  
15 ########################################################################
16 0 ▶sub add_volumes {
Subroutine add_volumes: not called CC=11 SCAR=48.8
Pod undocumented
17 ########################################################################
18 0 my ( $self, $task ) = @_;
19  
20 return
21 0 ▶ if !$task->{efs};
Branch: 1 branch
BranchTrueFalseTotal
unless $task->{"efs"} 0 0 0
22  
23 0 require App::EFS;
24  
25 0 my $efs = $self->fetch_efs();
26  
27 0 my $efs_config = $task->{efs};
28  
29 0 my ( $id, $path, $mount_point ) = @{$efs_config}{qw(id path mount_point)};
30  
31 0 ▶ if ( !$mount_point ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($mount_point) 0 0 0
32 0 $self->log_error('task:efs WARNING: no mount point defined...using /mnt');
33 }
34  
35 0 my ( $arn, $readonly ) = @{$efs_config}{qw(arn readonly)};
36  
37 0 ▶ log_die( $self, 'ERROR: no id set for EFS volume' )
Branch: 1 branch
BranchTrueFalseTotal
unless $id 0 0 0
38 if !$id;
39  
40 # - validate id -
41 0 ▶ if ( !$arn || !$self->get_cache ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($arn and $self->get_cache) 0 0 0
Condition0%0/3
$arn and $self->get_cache
!ll&&!rl&&r
000
MC/DC0%0/2
$arn and $self->get_cache
$arn $self->get_cache
Truth table0%0/3
A and B
A= $arnB= $self->get_cache
ABresult
0X0
100
111
42 0 $self->log_info( 'task: validating EFS id: [%s]...', $id );
43  
44 0 my $file_system = $efs->describe_file_systems( $id, 'FileSystems' );
45  
46 0 ▶ log_die( $self, "ERROR: no such EFS file system (%s) found\n", $id )
Branch: 1 branch
BranchTrueFalseTotal
unless $file_system 0 0 0
47 if !$file_system;
48  
49 0 $arn = $efs_config->{arn} = $file_system->[0]->{FileSystemArn};
50  
51 0 $self->log_info( 'task: EFS ARN: [%s]', $arn );
52 }
53  
54 return (
55 0 ▶ [ { name => 'efs-volume',
Branch: 1 branch
BranchTrueFalseTotal
defined $readonly && $readonly ? : 0 0 0
Condition0%0/7
$path // "/"
l!l
00
$mount_point // "/mnt"
l!l
00
defined $readonly and $readonly
!ll&&!rl&&r
000
MC/DC0%0/1
$path // "/"
$path
MC/DC0%0/1
$mount_point // "/mnt"
$mount_point
MC/DC0%0/2
defined $readonly and $readonly
defined $readonly $readonly
Truth table0%0/2
A
A= $path
Aresult
11
00
Truth table0%0/2
A
A= $mount_point
Aresult
11
00
Truth table0%0/3
A and B
A= defined $readonlyB= $readonly
ABresult
0X0
100
111
56 efsVolumeConfiguration => {
57 fileSystemId => $id,
58 rootDirectory => $path // q{/},
59 transitEncryption => 'ENABLED'
60 }
61 }
62 ],
63 [ { sourceVolume => 'efs-volume',
64 containerPath => $mount_point // '/mnt',
65 readOnly => defined $readonly && $readonly ? $JSON::true : $JSON::false,
66 }
67 ]
68 );
69 }
70  
71 ########################################################################
72 0 ▶sub add_efs_policy {
Subroutine add_efs_policy: not called CC=5 SCAR=34.0
Pod undocumented
73 ########################################################################
74 0 my ($self) = @_;
75  
76 0 my $tasks = $self->get_config->{tasks};
77  
78 0 my @efs_arns;
79  
80 0 foreach my $task_name ( keys %{$tasks} ) {
81 0 my $efs = $tasks->{$task_name}->{efs};
82 0 ▶ next if !$efs || !$efs->{id};
Branch: 1 branch
BranchTrueFalseTotal
unless $efs and $efs->{"id"} 0 0 0
Condition0%0/3
$efs and $efs->{"id"}
!ll&&!rl&&r
000
MC/DC0%0/2
$efs and $efs->{"id"}
$efs $efs->{"id"}
Truth table0%0/3
A and B
A= $efsB= $efs->{"id"}
ABresult
0X0
100
111
83  
84 0 push @efs_arns, sprintf $EFS_ARN_TEMPLATE, $self->get_region, $self->get_account, $efs->{id};
85 }
86  
87 return
88 0 ▶ if !@efs_arns;
Branch: 1 branch
BranchTrueFalseTotal
unless @efs_arns 0 0 0
89  
90 return {
91 0 Effect => 'Allow',
92 Action => [
93 qw(
94 elasticfilesystem:ClientMount
95 elasticfilesystem:ClientWrite
96 elasticfilesystem:ClientRootAccess
97 )
98 ],
99 Resource => \@efs_arns,
100 };
101 }
102  
103 1 1;
« FargateStack/Builder/LogGroup.pm ↑ Summary FargateStack/Builder/WafV2.pm »