blib/lib/Kubernetes/Comb/CRD/CombSpec.pm

filter: Statementstmt 100% 30 / 30 Branchbran 100% 10 / 10 Conditioncond 87.5% 7 / 8 MC/DCmcdc 80.0% 4 / 5 Subroutinesub 100% 5 / 5 Podpod 100% 1 / 1 totaltotal 96.6% 57 / 59 CC 10 SCAR 16.9
CC
10
Cov
98%
FROM_STRUCT
8.0
__ANON__
3.0
BEGIN
1.0
CRAP 5.4
« blib/lib/Kubernetes/Comb/CRD/Comb.pm ↑ Summary blib/lib/Kubernetes/Comb/Upstream/K8s.pm »
1 package Kubernetes::Comb::CRD::CombSpec;
2 # ABSTRACT: Spec of the Comb custom resource
3 28 our $VERSION = '0.002';
4  
5 28 ▶use IO::K8s::Resource;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 28 ▶use IO::K8s::Types qw( Opaque );
Subroutine BEGIN: called CC=1 SCAR=0.0
7 28 ▶use Carp qw( croak );
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9  
10 28 k8s class => Str, {
11 required => 1,
12 description => 'Perl class of the Comb; a stub is just another class'
13 };
14  
15  
16 28 k8s dependsOn => [Str], {
17 description => 'Combs this one needs, as "name" or "namespace/name"'
18 };
19  
20  
21 28 k8s config => Opaque, {
22 preserve_unknown => 1,
23 description => 'Free-form configuration for the class'
24 };
25  
26  
27 28 k8s enabled => Bool, {
28 description => 'Unset: automatic, false: off, true: on'
29 };
30  
31  
32 28 k8s upstream => Opaque, {
33 nullable => 1,
34 preserve_unknown => 1,
35 description => 'Where the Comb borrows its service from: class plus'
36 .' upstream-specific keys; null means local'
37 };
38  
39 28 has '+upstream' => ( predicate => 1 );
40  
41  
42 723 ▶sub FROM_STRUCT {
Subroutine FROM_STRUCT: called CC=8 SCAR=20.8
Pod documented
43 723 my ( $class, $struct ) = @_;
44 723 ▶ croak $class.'->FROM_STRUCT needs a hashref, got '.( ref $struct || 'a plain scalar' )
Branch: 1 branch
BranchTrueFalseTotal
unless ref $struct eq "HASH" 1 722 723
Condition50%1/2
ref $struct || 'a plain scalar'
l!l
10
MC/DC0%0/1
ref $struct || 'a plain scalar'
ref $struct
Truth table50%1/2
A
A= ref $struct
Aresult
11
00
45 unless ref $struct eq 'HASH';
46 722 my %args;
47 722 for my $key ( keys %$struct ) {
48 1153 my $value = $struct->{$key};
49 1153 ▶ next unless defined $value || $key eq 'upstream';
Branch: 1 branch
BranchTrueFalseTotal
unless defined $value or $key eq "upstream" 2 1151 1153
Condition100%3/3
defined $value or $key eq "upstream"
l!l&&r!l&&!r
1095562
MC/DC100%2/2
defined $value or $key eq "upstream"
defined $value $key eq "upstream"
Truth table100%3/3
A or B
A= defined $valueB= $key eq "upstream"
ABresult
1X1
011
000
50 1151 ▶ $args{$key} = ref $value eq 'HASH' ? { %$value }
Branch: 2 branches
BranchTrueFalseTotal
ref $value eq 'HASH' ? : 216 935 1151
ref $value eq 'ARRAY' ? : 95 840 935
51 : ref $value eq 'ARRAY' ? [ @$value ]
52 : $value;
53 }
54 722 return $class->new(%args);
55 }
56  
57  
58 625 ▶around TO_JSON => sub {
Subroutine __ANON__: called CC=3 SCAR=11.0
59 625 my ( $orig, $self, @args ) = @_;
60 625 my $data = $self->$orig(@args);
61 625 ▶ $data->{upstream} = undef if $self->has_upstream && !defined $self->upstream;
Branch: 1 branch
BranchTrueFalseTotal
if $self->has_upstream and not defined $self->upstream 46 579 625
Condition100%3/3
$self->has_upstream and not defined $self->upstream
!ll&&!rl&&r
42315646
MC/DC100%2/2
$self->has_upstream and not defined $self->upstream
$self->has_upstream not defined $self->upstream
Truth table100%3/3
A and not(B)
A= $self->has_upstreamB= not defined $self->upstream
ABresult
0X0
100
111
62 625 return $data;
63 28 };
64  
65  
66 28 1;
67  
68 __END__
« blib/lib/Kubernetes/Comb/CRD/Comb.pm ↑ Summary blib/lib/Kubernetes/Comb/Upstream/K8s.pm »