Kubernetes/Resource/Secret.pm

filter: Statementstmt 89.6% 26 / 29 Branchbran 50.0% 2 / 4 Conditioncond 50.0% 1 / 2 MC/DCmcdc 0.0% 0 / 1 Subroutinesub 100% 4 / 4 Podpod 100% 1 / 1 totaltotal 82.9% 34 / 41 CC 5 SCAR 13.5
CC
5
Cov
83%
render
5.6
BEGIN
1.0
BEGIN
1.0
CRAP 3.9
« Kubernetes/Role/APIAccess.pm ↑ Summary Kubernetes/Resource/Pod.pm »
1 package Net::Kubernetes::Resource::Secret;
2 # ABSTRACT: Object representatioon of a Kubernetes Secret
3 4 $Net::Kubernetes::Resource::Secret::VERSION = '1.03';
4 4 ▶use Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 4 ▶use File::Slurp qw(write_file);
Subroutine BEGIN: called CC=1 SCAR=0.0
7 4 ▶use MIME::Base64 qw(decode_base64);
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 4 extends 'Net::Kubernetes::Resource';
10  
11 4 has type => (
12 is => 'ro',
13 isa => 'Str',
14 required => 1
15 );
16  
17 4 has data => (
18 is => 'ro',
19 isa => 'HashRef',
20 required => 1
21 );
22  
23  
24 1 ▶sub render {
Subroutine render: called CC=5 SCAR=17.2
Pod documented
25 1 my $self = shift;
26  
27 1 my(%args);
28 1 ▶ if (ref($_[0])) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $_[0]) { } 0 1 1
29 0 %args = %{ $_[0] };
30 } else {
31 1 %args = @_;
32 }
33  
34 1 ▶ $args{force} //= 0;
Condition50%1/2
$args{"force"} //= 0
l!l
01
MC/DC0%0/1
$args{"force"} //= 0
$args{"force"}
Truth table50%1/2
A
A= $args{"force"}
Aresult
11
00
35  
36 1 ▶ if (! -d $args{directory}) {
Branch: 1 branch
BranchTrueFalseTotal
unless (-d $args{"directory"}) 0 1 1
37 0 Throwable::Error->throw(message => "Directory must exist: $args{directory}");
38 }
39  
40 1 for my $file (keys %{$self->data}) {
41 write_file("$args{directory}/$file",
42 {
43 err_mode => 'croak',
44 no_clobber => !$args{force},
45 binmode => ':raw',
46 },
47 2 decode_base64 ${$self->data}{$file}
48 );
49 }
50 # if we didn't write them all, we better have thrown an exception.
51 1 return scalar keys %{$self->data};
52 }
53  
54 4 return 42;
55  
56 __END__
« Kubernetes/Role/APIAccess.pm ↑ Summary Kubernetes/Resource/Pod.pm »