line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package CCfnX::UserData { |
2
|
14
|
|
|
14
|
|
109
|
use Moose; |
|
14
|
|
|
|
|
34
|
|
|
14
|
|
|
|
|
114
|
|
3
|
14
|
|
|
14
|
|
105068
|
use Cfn; |
|
14
|
|
|
|
|
43
|
|
|
14
|
|
|
|
|
3267
|
|
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
extends 'Cfn::Value'; |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
has '+Value' => (required => 0); |
8
|
|
|
|
|
|
|
has text => (is => 'ro', required => 1, isa => 'Str|ArrayRef'); |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
sub parse_line { |
11
|
8
|
|
|
8
|
0
|
16
|
my ($self, $line) = @_; |
12
|
8
|
50
|
|
|
|
20
|
return $line if (ref($line)); |
13
|
|
|
|
|
|
|
# Use a capturing group in split so that #-#...#-# is returned |
14
|
8
|
|
|
|
|
56
|
my @elements = split /(\#\-\#.*?\#\-\#)/, $line; |
15
|
|
|
|
|
|
|
@elements = map { |
16
|
8
|
100
|
|
|
|
18
|
($_ =~ m/^#\-\#(.*?)\#\-\#$/) ? |
|
22
|
|
|
|
|
2672
|
|
17
|
|
|
|
|
|
|
_process_tiefighter("$1") : $_ |
18
|
|
|
|
|
|
|
} @elements; |
19
|
8
|
|
|
|
|
1353
|
return @elements; |
20
|
|
|
|
|
|
|
} |
21
|
|
|
|
|
|
|
|
22
|
14
|
|
|
14
|
|
187
|
use CCfnX::Shortcuts; |
|
14
|
|
|
|
|
34
|
|
|
14
|
|
|
|
|
8651
|
|
23
|
|
|
|
|
|
|
sub _process_tiefighter { |
24
|
8
|
|
|
8
|
|
18
|
my ($tfighter) = @_; |
25
|
8
|
100
|
|
|
|
56
|
if ($tfighter =~ m/^([A-Za-z0-9:-]+?)\-\>([A-Za-z0-9.:-]+?)$/) { |
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
26
|
1
|
|
|
|
|
10
|
return { 'Fn::GetAtt' => [ "$1", "$2" ] }; |
27
|
|
|
|
|
|
|
} elsif ($tfighter =~ m/^Parameter\(['"]{0,1}([A-Za-z0-9:_-]+?)['"]{0,1}\)$/) { |
28
|
3
|
|
|
|
|
7
|
my $param = "$1"; |
29
|
3
|
|
|
|
|
9
|
return CCfnX::Shortcuts::Parameter($param); |
30
|
|
|
|
|
|
|
} elsif ($tfighter =~ m/^Attribute\(([A-Za-z0-9.:_-]+?)\)$/) { |
31
|
3
|
|
|
|
|
9
|
my $path = "$1"; |
32
|
3
|
|
|
|
|
11
|
return CCfnX::Shortcuts::Attribute($path); |
33
|
|
|
|
|
|
|
} elsif ($tfighter =~ m/^([A-Za-z0-9:-]+)$/) { |
34
|
1
|
|
|
|
|
6
|
return { Ref => "$1" } |
35
|
|
|
|
|
|
|
} else { |
36
|
0
|
|
|
|
|
0
|
die "Unrecognized tiefighter syntax for $tfighter"; |
37
|
|
|
|
|
|
|
} |
38
|
|
|
|
|
|
|
} |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
sub get_lines { |
41
|
8
|
|
|
8
|
0
|
10
|
my $self = shift; |
42
|
8
|
50
|
|
|
|
261
|
if (defined $self->text) { |
43
|
8
|
50
|
|
|
|
211
|
if (ref($self->text) eq 'ARRAY'){ |
44
|
0
|
|
|
|
|
0
|
return [ map { $self->parse_line($_) } @{ $self->text } ]; |
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
45
|
|
|
|
|
|
|
} else { |
46
|
8
|
|
|
|
|
200
|
return [ $self->parse_line($self->text) ]; |
47
|
|
|
|
|
|
|
} |
48
|
|
|
|
|
|
|
} else { |
49
|
0
|
|
|
|
|
0
|
die "No text for generating UserData"; |
50
|
|
|
|
|
|
|
} |
51
|
|
|
|
|
|
|
} |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
sub process_with_context { |
54
|
8
|
|
|
8
|
0
|
15
|
my ($self, $ctx) = @_; |
55
|
|
|
|
|
|
|
return [ map { |
56
|
22
|
100
|
100
|
|
|
142
|
(not ref($_) or ref($_) eq 'HASH')?$_:$_->as_hashref($ctx); |
57
|
8
|
|
|
|
|
15
|
} @{ $self->get_lines } ] |
|
8
|
|
|
|
|
20
|
|
58
|
|
|
|
|
|
|
} |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
sub as_hashref_joins { |
61
|
8
|
|
|
8
|
0
|
3069
|
my $self = shift; |
62
|
|
|
|
|
|
|
return { |
63
|
8
|
|
|
|
|
31
|
'Fn::Join' => [ '', $self->process_with_context(@_) ] |
64
|
|
|
|
|
|
|
} |
65
|
|
|
|
|
|
|
} |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
around as_hashref => sub { |
68
|
|
|
|
|
|
|
my ($orig, $self, @rest) = @_; |
69
|
|
|
|
|
|
|
return { |
70
|
|
|
|
|
|
|
'Fn::Base64' => $self->as_hashref_joins(@rest) |
71
|
|
|
|
|
|
|
} |
72
|
|
|
|
|
|
|
}; |
73
|
|
|
|
|
|
|
} |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
1; |