line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package CCfnX::UserData { |
2
|
14
|
|
|
14
|
|
95
|
use Moose; |
|
14
|
|
|
|
|
30
|
|
|
14
|
|
|
|
|
107
|
|
3
|
14
|
|
|
14
|
|
92248
|
use Cfn; |
|
14
|
|
|
|
|
46
|
|
|
14
|
|
|
|
|
2505
|
|
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
|
|
|
|
28
|
return $line if (ref($line)); |
13
|
|
|
|
|
|
|
# Use a capturing group in split so that #-#...#-# is returned |
14
|
8
|
|
|
|
|
48
|
my @elements = split /(\#\-\#.*?\#\-\#)/, $line; |
15
|
|
|
|
|
|
|
@elements = map { |
16
|
8
|
100
|
|
|
|
23
|
($_ =~ m/^#\-\#(.*?)\#\-\#$/) ? |
|
22
|
|
|
|
|
2314
|
|
17
|
|
|
|
|
|
|
_process_tiefighter("$1") : $_ |
18
|
|
|
|
|
|
|
} @elements; |
19
|
8
|
|
|
|
|
1205
|
return @elements; |
20
|
|
|
|
|
|
|
} |
21
|
|
|
|
|
|
|
|
22
|
14
|
|
|
14
|
|
114
|
use CCfnX::Shortcuts; |
|
14
|
|
|
|
|
32
|
|
|
14
|
|
|
|
|
6408
|
|
23
|
|
|
|
|
|
|
sub _process_tiefighter { |
24
|
8
|
|
|
8
|
|
18
|
my ($tfighter) = @_; |
25
|
8
|
100
|
|
|
|
51
|
if ($tfighter =~ m/^([A-Za-z0-9:-]+?)\-\>([A-Za-z0-9.:-]+?)$/) { |
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
26
|
1
|
|
|
|
|
7
|
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
|
|
|
|
|
12
|
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
|
|
|
|
|
10
|
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
|
15
|
my $self = shift; |
42
|
8
|
50
|
|
|
|
179
|
if (defined $self->text) { |
43
|
8
|
50
|
|
|
|
156
|
if (ref($self->text) eq 'ARRAY'){ |
44
|
0
|
|
|
|
|
0
|
return [ map { $self->parse_line($_) } @{ $self->text } ]; |
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
45
|
|
|
|
|
|
|
} else { |
46
|
8
|
|
|
|
|
158
|
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
|
17
|
my ($self, $ctx) = @_; |
55
|
|
|
|
|
|
|
return [ map { |
56
|
22
|
100
|
100
|
|
|
127
|
(not ref($_) or ref($_) eq 'HASH')?$_:$_->as_hashref($ctx); |
57
|
8
|
|
|
|
|
15
|
} @{ $self->get_lines } ] |
|
8
|
|
|
|
|
19
|
|
58
|
|
|
|
|
|
|
} |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
sub as_hashref_joins { |
61
|
8
|
|
|
8
|
0
|
2591
|
my $self = shift; |
62
|
|
|
|
|
|
|
return { |
63
|
8
|
|
|
|
|
28
|
'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; |