blib/lib/Langertha/Holmgang/Sim/Linux/Kubernetes.pm

filter: Statementstmt 79.0% 1610 / 2036 Branchbran 57.5% 903 / 1570 Conditioncond 44.3% 754 / 1699 MC/DCmcdc 14.3% 121 / 846 Subroutinesub 88.9% 113 / 127 Podpod 100% 5 / 5 totaltotal 55.8% 3506 / 6283 CC 1592 SCAR 66.2
CC
1592
Cov
62%
_v_get
4672.5
_describe_gen
1125.2
_v_describe
1109.7
CRAP 748.0
« blib/lib/Langertha/Holmgang/Sim/Linux/Redis.pm ↑ Summary blib/lib/Langertha/Holmgang/Shell.pm »
1 package Langertha::Holmgang::Sim::Linux::Kubernetes;
2 # ABSTRACT: Kubernetes cluster behind kubectl on a simulated Linux server — stored resources, derived status
3  
4 5 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 5 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 5 ▶use utf8;
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 5 ▶use Digest::SHA ();
Subroutine BEGIN: called CC=1 SCAR=0.0
9 5 ▶use Encode ();
Subroutine BEGIN: called CC=1 SCAR=0.0
10 5 ▶use JSON::PP ();
Subroutine BEGIN: called CC=1 SCAR=0.0
11 5 ▶use JSON::MaybeXS ();
Subroutine BEGIN: called CC=1 SCAR=0.0
12 5 ▶use MIME::Base64 ();
Subroutine BEGIN: called CC=1 SCAR=0.0
13 5 ▶use YAML::XS ();
Subroutine BEGIN: called CC=1 SCAR=0.0
14  
15 5 our $VERSION = '0.001';
16  
17  
18 5 our @GAPS;
19  
20 5 my $J = JSON::MaybeXS->new( canonical => 1, utf8 => 0, pretty => 1 );
21  
22 # Ausgabe von -o json wie kubectl (Go encoding/json): "key": value, vier
23 # Leerzeichen. $J bleibt fuer Hashes und Vergleiche (Namen der Pods haengen daran).
24 5 my $OUT_JSON = JSON::PP->new->canonical->indent->indent_length(4)->space_after;
25  
26 5 our %KIND = (
27 pod => 'pods', pods => 'pods', po => 'pods',
28 deployment => 'deployments', deployments => 'deployments', deploy => 'deployments',
29 service => 'services', services => 'services', svc => 'services',
30 secret => 'secrets', secrets => 'secrets',
31 configmap => 'configmaps', configmaps => 'configmaps', cm => 'configmaps',
32 persistentvolumeclaim => 'pvcs', persistentvolumeclaims => 'pvcs', pvc => 'pvcs',
33 networkpolicy => 'networkpolicies', networkpolicies => 'networkpolicies', netpol => 'networkpolicies',
34 endpoints => 'endpoints', ep => 'endpoints',
35 storageclass => 'storageclasses', storageclasses => 'storageclasses', sc => 'storageclasses',
36 namespace => 'namespaces', namespaces => 'namespaces', ns => 'namespaces',
37 node => 'nodes', nodes => 'nodes', no => 'nodes',
38 event => 'events', events => 'events', ev => 'events',
39 replicaset => 'replicasets', replicasets => 'replicasets', rs => 'replicasets',
40 ingress => 'ingresses', ingresses => 'ingresses', ing => 'ingresses',
41 ingressclass => 'ingressclasses', ingressclasses => 'ingressclasses',
42 serviceaccount => 'serviceaccounts', serviceaccounts => 'serviceaccounts', sa => 'serviceaccounts',
43 role => 'roles', roles => 'roles', rolebinding => 'rolebindings', rolebindings => 'rolebindings',
44 clusterrole => 'clusterroles', clusterroles => 'clusterroles',
45 clusterrolebinding => 'clusterrolebindings', clusterrolebindings => 'clusterrolebindings',
46 certificate => 'certificates', certificates => 'certificates', cert => 'certificates', certs => 'certificates',
47 issuer => 'issuers', issuers => 'issuers', clusterissuer => 'clusterissuers', clusterissuers => 'clusterissuers',
48 certificaterequest => 'certificaterequests', certificaterequests => 'certificaterequests', cr => 'certificaterequests', crs => 'certificaterequests',
49 challenge => 'challenges', challenges => 'challenges', order => 'orders', orders => 'orders',
50 );
51  
52 # Arten, die im Zustand in API-Form stehen (ohne apiVersion, kind, Name,
53 # Namespace und Status): [ apiVersion, kind, ohne Namespace, Name fuer Meldungen ]
54 5 our %GEN = (
55 ingresses => [ 'networking.k8s.io/v1', 'Ingress', 0, 'ingress.networking.k8s.io' ],
56 ingressclasses => [ 'networking.k8s.io/v1', 'IngressClass', 1, 'ingressclass.networking.k8s.io' ],
57 serviceaccounts => [ 'v1', 'ServiceAccount', 0, 'serviceaccount' ],
58 roles => [ 'rbac.authorization.k8s.io/v1', 'Role', 0, 'role.rbac.authorization.k8s.io' ],
59 rolebindings => [ 'rbac.authorization.k8s.io/v1', 'RoleBinding', 0, 'rolebinding.rbac.authorization.k8s.io' ],
60 clusterroles => [ 'rbac.authorization.k8s.io/v1', 'ClusterRole', 1, 'clusterrole.rbac.authorization.k8s.io' ],
61 clusterrolebindings => [ 'rbac.authorization.k8s.io/v1', 'ClusterRoleBinding', 1, 'clusterrolebinding.rbac.authorization.k8s.io' ],
62 certificates => [ 'cert-manager.io/v1', 'Certificate', 0, 'certificate.cert-manager.io' ],
63 issuers => [ 'cert-manager.io/v1', 'Issuer', 0, 'issuer.cert-manager.io' ],
64 clusterissuers => [ 'cert-manager.io/v1', 'ClusterIssuer', 1, 'clusterissuer.cert-manager.io' ],
65 );
66 # abgeleitet, nur zum Lesen
67 5 our %DERIVED = map { $_ => 1 } qw( certificaterequests challenges orders );
68 5 our %CLUSTER = ( ( map { $_ => 1 } qw( namespaces storageclasses nodes ) ), map { $_ => 1 } grep { $GEN{$_}[2] } keys %GEN );
69 our %SINGULAR = ( pods => 'pod', deployments => 'deployment.apps', services => 'service', secrets => 'secret',
70 configmaps => 'configmap', pvcs => 'persistentvolumeclaim', networkpolicies => 'networkpolicy.networking.k8s.io',
71 storageclasses => 'storageclass.storage.k8s.io', namespaces => 'namespace', endpoints => 'endpoints', nodes => 'node',
72 5 replicasets => 'replicaset.apps', ( map { $_ => $GEN{$_}[3] } keys %GEN ),
73 certificaterequests => 'certificaterequest.cert-manager.io', challenges => 'challenge.acme.cert-manager.io', orders => 'order.acme.cert-manager.io' );
74 my %APIKIND = ( deployments => 'Deployment', services => 'Service', secrets => 'Secret', configmaps => 'ConfigMap',
75 pvcs => 'PersistentVolumeClaim', networkpolicies => 'NetworkPolicy', storageclasses => 'StorageClass', namespaces => 'Namespace',
76 5 map { $_ => $GEN{$_}[1] } keys %GEN );
77 5 my %FROM_APIKIND = reverse %APIKIND;
78  
79 516 ▶sub _hash { my ($t) = @_; my $h = Digest::SHA::sha1_hex( $J->encode($t) ); $h =~ tr/0-9a-f/bcdfghjklmnpqrst/; return substr( $h, 0, 10 ) }
Subroutine _hash: called CC=1 SCAR=0.0
80  
81 67 ▶sub _sel_match {
Subroutine _sel_match: called CC=5 SCAR=16.1
82 67 my ( $sel, $labels ) = @_;
83 67 ▶ for my $k ( keys %{ $sel || {} } ) { return 0 unless defined $labels->{$k} && $labels->{$k} eq $sel->{$k} }
Branch: 1 branch
BranchTrueFalseTotal
unless defined $$labels{$k} and $$labels{$k} eq $$sel{$k} 34 30 64
Condition80%4/5
$sel || {}
l!l
670
defined $$labels{$k} and $$labels{$k} eq $$sel{$k}
!ll&&!rl&&r
13330
MC/DC0%0/1
$sel || {}
$sel
MC/DC100%2/2
defined $$labels{$k} and $$labels{$k} eq $$sel{$k}
defined $$labels{$k} $$labels{$k} eq $$sel{$k}
Truth table50%1/2
A
A= $sel
Aresult
11
00
Truth table100%3/3
A and B
A= defined $$labels{$k}B= $$labels{$k} eq $$sel{$k}
ABresult
0X0
100
111
84 33 return 1;
85 }
86  
87 # --- abgeleiteter Zustand ------------------------------------------------------
88  
89 5 ▶sub _pvc_phase {
Subroutine _pvc_phase: called CC=5 SCAR=17.0
90 5 my ( $k, $ns, $name ) = @_;
91 5 ▶ my $p = $k->{namespaces}{$ns}{pvcs}{$name} or return 'Missing';
Branch: 1 branch
BranchTrueFalseTotal
my $p = $$k{"namespaces"}{$ns}{"pvcs"}{$name} or return "Missing" 5 0 5
92 5 my $sc = $p->{storage_class};
93 5 ▶ my $scs = $k->{storageclasses} || {};
Condition50%1/2
$$k{'storageclasses'} || {}
l!l
50
MC/DC0%0/1
$$k{'storageclasses'} || {}
$$k{'storageclasses'}
Truth table50%1/2
A
A= $$k{'storageclasses'}
Aresult
11
00
94 0 ▶ return 'Bound' if defined $sc ? $scs->{$sc} : grep { $scs->{$_}{default} } keys %$scs;
Branch: 2 branches
BranchTrueFalseTotal
if defined $sc ? $$scs{$sc} : grep({$$scs{$_}{"default"};} keys %$scs) 1 4 5
defined $sc ? : 5 0 5
95 4 return 'Pending';
96 }
97  
98 # Status eines Containers bzw. Pods einer Vorlage: ( phase, ready(0/1), reason, message )
99 204 ▶sub _pod_state {
Subroutine _pod_state: called CC=34 SCAR=41.4
100 204 my ( $k, $ns, $tpl ) = @_;
101 204 my $o = $k->{namespaces}{$ns};
102 204 ▶ for my $c ( @{ $tpl->{containers} || [] } ) {
Condition50%1/2
$$tpl{'containers'} || []
l!l
2040
MC/DC0%0/1
$$tpl{'containers'} || []
$$tpl{'containers'}
Truth table50%1/2
A
A= $$tpl{'containers'}
Aresult
11
00
103 204 ▶ for my $v ( @{ $c->{volumes} || [] } ) {
Condition50%1/2
$$c{'volumes'} || []
l!l
0204
MC/DC0%0/1
$$c{'volumes'} || []
$$c{'volumes'}
Truth table50%1/2
A
A= $$c{'volumes'}
Aresult
11
00
104 0 my $ph = _pvc_phase( $k, $ns, $v->{claim} );
105 0 ▶ return ( 'Pending', 0, 'Unschedulable', $ph eq 'Missing'
Branch: 2 branches
BranchTrueFalseTotal
if $ph ne "Bound" 0 0 0
$ph eq 'Missing' ? : 0 0 0
106 ? qq{persistentvolumeclaim "$v->{claim}" not found}
107 : '0/3 nodes are available: pod has unbound immediate PersistentVolumeClaims. preemption: 0/3 nodes are available: 3 Preemption is not helpful for scheduling.' )
108 if $ph ne 'Bound';
109 }
110 }
111 204 ▶ for my $c ( @{ $tpl->{containers} || [] } ) {
Condition50%1/2
$$tpl{'containers'} || []
l!l
2040
MC/DC0%0/1
$$tpl{'containers'} || []
$$tpl{'containers'}
Truth table50%1/2
A
A= $$tpl{'containers'}
Aresult
11
00
112 204 ▶ my %reg = map { $_ => 1 } @{ $k->{registry} || [] };
Condition50%1/2
$$k{'registry'} || []
l!l
2040
MC/DC0%0/1
$$k{'registry'} || []
$$k{'registry'}
Truth table50%1/2
A
A= $$k{'registry'}
Aresult
11
00
113 204 ▶ return ( 'Pending', 0, 'ImagePullBackOff', qq{Back-off pulling image "$c->{image}"}, $c ) unless $reg{ $c->{image} };
Branch: 1 branch
BranchTrueFalseTotal
unless $reg{$$c{"image"}} 2 202 204
114 202 my %env;
115 202 ▶ for my $e ( @{ $c->{env} || [] } ) {
Condition100%2/2
$$c{'env'} || []
l!l
62140
MC/DC100%1/1
$$c{'env'} || []
$$c{'env'}
Truth table100%2/2
A
A= $$c{'env'}
Aresult
11
00
116 60 ▶ if ( defined $e->{secret} ) {
Branch: 2 branches
BranchTrueFalseTotal
if (defined $$e{'secret'}) { } 25 35 60
elsif (defined $$e{'configmap'}) { } 0 35 35
117 25 my $s = $o->{secrets}{ $e->{secret} };
118 25 ▶ return ( 'Pending', 0, 'CreateContainerConfigError', qq{secret "$e->{secret}" not found}, $c ) if !$s && !$e->{optional};
Branch: 1 branch
BranchTrueFalseTotal
unless $s or $$e{"optional"} 0 25 25
Condition66%2/3
$s or $$e{"optional"}
l!l&&r!l&&!r
2410
MC/DC0%0/2
$s or $$e{"optional"}
$s $$e{"optional"}
Truth table66%2/3
A or B
A= $sB= $$e{"optional"}
ABresult
1X1
011
000
119 25 ▶ if ( $s && exists $s->{ $e->{key} } ) { $env{ $e->{name} } = 1 }
Branch: 2 branches
BranchTrueFalseTotal
if ($s and exists $$s{$$e{'key'}}) { } 22 3 25
elsif (not $$e{'optional'}) { } 0 3 3
Condition100%3/3
$s and exists $$s{$$e{"key"}}
!ll&&!rl&&r
1222
MC/DC100%2/2
$s and exists $$s{$$e{"key"}}
$s exists $$s{$$e{"key"}}
Truth table100%3/3
A and B
A= $sB= exists $$s{$$e{"key"}}
ABresult
0X0
100
111
120 0 elsif ( !$e->{optional} ) { return ( 'Pending', 0, 'CreateContainerConfigError', qq{couldn't find key $e->{key} in Secret $ns/$e->{secret}}, $c ) }
121 }
122 elsif ( defined $e->{configmap} ) {
123 0 my $m = $o->{configmaps}{ $e->{configmap} };
124 0 ▶ $env{ $e->{name} } = 1 if $m && exists $m->{ $e->{key} };
Branch: 1 branch
BranchTrueFalseTotal
if $m and exists $$m{$$e{"key"}} 0 0 0
Condition0%0/3
$m and exists $$m{$$e{"key"}}
!ll&&!rl&&r
000
MC/DC0%0/2
$m and exists $$m{$$e{"key"}}
$m exists $$m{$$e{"key"}}
Truth table0%0/3
A and B
A= $mB= exists $$m{$$e{"key"}}
ABresult
0X0
100
111
125 }
126 35 else { $env{ $e->{name} } = 1 }
127 }
128 202 ▶ return ( 'Running', 0, 'CrashLoopBackOff', 'back-off 5m0s restarting failed container', $c ) if grep { !$env{$_} } @{ $c->{needs_env} || [] };
Branch: 1 branch
BranchTrueFalseTotal
if grep {not $env{$_};} @{$$c{"needs_env"} or [];} 3 199 202
Condition100%2/2
$$c{'needs_env'} || []
l!l
25177
MC/DC100%1/1
$$c{'needs_env'} || []
$$c{'needs_env'}
Truth table100%2/2
A
A= $$c{'needs_env'}
Aresult
11
00
129 199 ▶ if ( my $deny = _rbac_denied( $k, $ns, $tpl, $c ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $deny = _rbac_denied($k, $ns, $tpl, $c)) 33 166 199
130 return ( 'Running', 0, 'CrashLoopBackOff', 'back-off 5m0s restarting failed container',
131 33 ▶ { %$c, crash_log => [ @{ $c->{rbac_log} || [] }, defined $c->{rbac_prefix} ? $c->{rbac_prefix} . $deny : 'level=fatal msg="' . ( $deny =~ s/"/\\"/gr ) . '"' ] } );
Branch: 1 branch
BranchTrueFalseTotal
defined $$c{'rbac_prefix'} ? : 0 33 33
Condition50%1/2
$$c{'rbac_log'} || []
l!l
330
MC/DC0%0/1
$$c{'rbac_log'} || []
$$c{'rbac_log'}
Truth table50%1/2
A
A= $$c{'rbac_log'}
Aresult
11
00
132 }
133 }
134 166 ▶ for my $c ( @{ $tpl->{containers} || [] } ) {
Condition50%1/2
$$tpl{'containers'} || []
l!l
1660
MC/DC0%0/1
$$tpl{'containers'} || []
$$tpl{'containers'}
Truth table50%1/2
A
A= $$tpl{'containers'}
Aresult
11
00
135 166 ▶ my $r = $c->{readiness} or next;
Branch: 1 branch
BranchTrueFalseTotal
my $r = $$c{"readiness"} or next 22 144 166
136 return ( 'Running', 0, 'NotReady', "Readiness probe failed: Get \"http://10.42.1.17:$r->{port}" . ( $r->{path} // '/' ) . "\": dial tcp 10.42.1.17:$r->{port}: connect: connection refused", $c )
137 22 ▶ unless grep { $_ == $r->{port} } @{ $c->{listens} || $c->{ports} || [] };
Branch: 1 branch
BranchTrueFalseTotal
unless grep {$_ == $$r{"port"};} @{$$c{"listens"} or $$c{"ports"} or [];} 1 21 22
Condition42%3/7
$$c{'listens'} || $$c{'ports'} || []
l!l
220
$$c{"listens"} or $$c{"ports"}
l!l&&r!l&&!r
2200
$$r{"path"} // "/"
l!l
10
MC/DC0%0/2
$$c{'listens'} || $$c{'ports'} || []
$$c{"listens"} $$c{"ports"}
MC/DC0%0/1
$$r{"path"} // "/"
$$r{"path"}
Truth table33%1/3
A or B
A= $$c{"listens"}B= $$c{"ports"}
ABresult
1X1
011
000
Truth table50%1/2
A
A= $$r{"path"}
Aresult
11
00
138 }
139 165 return ( 'Running', 1, '', '' );
140 }
141  
142 # Pods aller Deployments eines Namespace
143 68 ▶sub _pods {
Subroutine _pods: called CC=10 SCAR=23.3
144 68 my ( $k, $ns ) = @_;
145 68 my @p;
146 68 ▶ my $o = $k->{namespaces}{$ns} or return ();
Branch: 1 branch
BranchTrueFalseTotal
my $o = $$k{"namespaces"}{$ns} or return () 67 1 68
147 67 ▶ for my $d ( sort keys %{ $o->{deployments} || {} } ) {
Condition50%1/2
$$o{'deployments'} || {}
l!l
670
MC/DC0%0/1
$$o{'deployments'} || {}
$$o{'deployments'}
Truth table50%1/2
A
A= $$o{'deployments'}
Aresult
11
00
148 208 my $dep = $o->{deployments}{$d};
149 208 ▶ next unless _sa_exists( $k, $ns, $dep->{template}{service_account} ); # ReplicaSet kann keine Pods anlegen
Branch: 1 branch
BranchTrueFalseTotal
unless _sa_exists($k, $ns, $$dep{"template"}{"service_account"}) 4 204 208
150 204 ▶ my $h = _hash( [ $dep->{template}, $dep->{restarted_at} // '' ] );
Condition50%1/2
$$dep{"restarted_at"} // ""
l!l
0204
MC/DC0%0/1
$$dep{"restarted_at"} // ""
$$dep{"restarted_at"}
Truth table50%1/2
A
A= $$dep{"restarted_at"}
Aresult
11
00
151 204 my ( $phase, $ready, $reason, $msg, $c ) = _pod_state( $k, $ns, $dep->{template} );
152 204 ▶ for my $i ( 1 .. ( $dep->{replicas} // 1 ) ) {
Condition50%1/2
$$dep{"replicas"} // 1
l!l
2040
MC/DC0%0/1
$$dep{"replicas"} // 1
$$dep{"replicas"}
Truth table50%1/2
A
A= $$dep{"replicas"}
Aresult
11
00
153 301 my $suffix = substr( _hash( [ $h, $i ] ), 0, 5 );
154 301 ▶ push @p, { name => "$d-$h-$suffix", deployment => $d, labels => { %{ $dep->{template}{labels} || {} }, 'pod-template-hash' => $h },
Branch: 1 branch
BranchTrueFalseTotal
$reason eq 'CrashLoopBackOff' ? : 39 262 301
Condition50%1/2
$$dep{'template'}{'labels'} || {}
l!l
3010
MC/DC0%0/1
$$dep{'template'}{'labels'} || {}
$$dep{'template'}{'labels'}
Truth table50%1/2
A
A= $$dep{'template'}{'labels'}
Aresult
11
00
155 phase => $phase, ready => $ready, reason => $reason, message => $msg, container => $c, template => $dep->{template},
156 301 restarts => $reason eq 'CrashLoopBackOff' ? 7 : 0, ip => "10.42." . ( $i % 3 + 1 ) . '.' . ( 10 + ( hex( substr( Digest::SHA::sha1_hex($d), 0, 4 ) ) % 200 ) + $i ) }; # je Deployment eigene Adressen
157 }
158 }
159 67 return @p;
160 }
161  
162 13 ▶sub _endpoints {
Subroutine _endpoints: called CC=3 SCAR=11.0
163 13 my ( $k, $ns, $svc ) = @_;
164 13 ▶ my $s = $k->{namespaces}{$ns}{services}{$svc} or return ();
Branch: 1 branch
BranchTrueFalseTotal
my $s = $$k{"namespaces"}{$ns}{"services"}{$svc} or return () 13 0 13
165 13 ▶ return grep { $_->{ready} && _sel_match( $s->{selector}, $_->{labels} ) } _pods( $k, $ns );
Condition100%3/3
$$_{'ready'} && _sel_match($$s{'selector'}, $$_{'labels'})
!ll&&!rl&&r
83316
MC/DC100%2/2
$$_{'ready'} && _sel_match($$s{'selector'}, $$_{'labels'})
$$_{'ready'} _sel_match($$s{'selector'}, $$_{'labels'})
Truth table100%3/3
A && B
A= $$_{'ready'}B= _sel_match($$s{'selector'}, $$_{'labels'})
ABresult
0X0
100
111
166 }
167  
168 # --- Ausgabe ------------------------------------------------------------------
169  
170 34 ▶sub _cols {
Subroutine _cols: called CC=6 SCAR=17.9
171 34 my (@rows) = @_;
172 34 my @w;
173 34 ▶ for my $r (@rows) { for ( 0 .. $#$r ) { $w[$_] = length $r->[$_] if !defined $w[$_] || length $r->[$_] > $w[$_] } }
Branch: 1 branch
BranchTrueFalseTotal
if not defined $w[$_] or length $$r[$_] > $w[$_] 253 282 535
Condition100%3/3
not defined $w[$_] or length $$r[$_] > $w[$_]
l!l&&r!l&&!r
17281282
MC/DC100%2/2
not defined $w[$_] or length $$r[$_] > $w[$_]
not defined $w[$_] length $$r[$_] > $w[$_]
Truth table100%3/3
not(A) or B
A= not defined $w[$_]B= length $$r[$_] > $w[$_]
ABresult
1X1
011
000
174 34 ▶ return join "\n", map { my $r = $_; join( ' ', map { $_ == $#$r ? $r->[$_] : sprintf( "%-$w[$_]s", $r->[$_] ) } 0 .. $#$r ) =~ s/\s+\z//r } @rows;
Branch: 1 branch
BranchTrueFalseTotal
$_ == $r->$#* ? : 107 428 535
175 }
176  
177 0 ▶sub _age { return $_[0] // '3d' }
Subroutine _age: not called CC=2 SCAR=17.9
Condition0%0/2
$_[0] // "3d"
l!l
00
MC/DC0%0/1
$_[0] // "3d"
$_[0]
Truth table0%0/2
A
A= $_[0]
Aresult
11
00
178  
179 0 ▶sub _labels_text { my ($l) = @_; return join( ',', map {"$_=$l->{$_}"} sort keys %{ $l || {} } ) || '<none>' }
Subroutine _labels_text: not called CC=3 SCAR=24.8
Condition0%0/4
join(',', map({"$_=$$l{$_}";} sort(keys %{$l or {};}))) || '<none>'
l!l
00
$l || {}
l!l
00
MC/DC0%0/1
join(',', map({"$_=$$l{$_}";} sort(keys %{$l or {};}))) || '<none>'
join(',', map({"$_=$$l{$_}";} sort(keys %{$l or {};})))
MC/DC0%0/1
$l || {}
$l
Truth table0%0/2
A
A= join(',', map({"$_=$$l{$_}";} sort(keys %{$l or {};})))
Aresult
11
00
Truth table0%0/2
A
A= $l
Aresult
11
00
180  
181 # --- Kommandozeile -------------------------------------------------------------
182  
183  
184 133 ▶sub kubectl {
Subroutine kubectl: called CC=85 SCAR=55.2
Pod documented
185 133 my ( $dev, $av, $ctx, $stdin ) = @_;
186 133 ▶ my $k = $dev->{kubernetes} or return ( 'error: no configuration has been provided, try setting KUBERNETES_MASTER environment variable', 0 );
Branch: 1 branch
BranchTrueFalseTotal
my $k = $$dev{"kubernetes"} or return "error: no configuration has been provided, try setting KUBERNETES_MASTER environment variable", 0 133 0 133
187 133 ▶ my %o = ( ns => $k->{default_namespace} // 'default' );
Condition50%1/2
$$k{"default_namespace"} // "default"
l!l
1330
MC/DC0%0/1
$$k{"default_namespace"} // "default"
$$k{"default_namespace"}
Truth table50%1/2
A
A= $$k{"default_namespace"}
Aresult
11
00
188 133 my @a;
189 133 my @in = @$av;
190 133 ▶ while (@in) {
Branch: 1 branch
BranchTrueFalseTotal
if (@in) 600 115 715
191 600 my $x = shift @in;
192 600 ▶ if ( $x eq '-n' || $x eq '--namespace' ) { $o{ns} = shift @in }
Branch: 33 branches
BranchTrueFalseTotal
if ($x eq '-n' or $x eq '--namespace') { } 122 478 600
elsif ($x =~ /\A(?:-n|--namespace=)(.+)\z/) { } 0 478 478
elsif ($x eq '-A' or $x eq '--all-namespaces') { } 1 477 478
elsif ($x eq '-o' or $x eq '--output') { } 22 455 477
elsif ($x =~ /\A(?:-o|--output=)(.+)\z/) { } 0 455 455
elsif ($x eq '-l' or $x eq '--selector') { } 6 449 455
elsif ($x =~ /\A(?:-l|--selector=)(.+)\z/) { } 0 449 449
elsif ($x eq '-f' or $x eq '--filename') { } 5 444 449
elsif ($x =~ /\A--filename=(.+)\z/) { } 0 444 444
elsif ($x eq '-p' or $x eq '--patch') { } 12 432 444
elsif ($x =~ /\A(?:--patch|-p)=(.+)\z/s) { } 0 432 432
elsif ($x =~ /\A--type=(.+)\z/) { } 0 432 432
elsif ($x eq '--type') { } 8 424 432
elsif ($x =~ /\A--replicas=(\d+)\z/) { } 0 424 424
elsif ($x =~ /\A--from-literal=([^=]+)=(.*)\z/s) { } 2 422 424
elsif ($x =~ /\A--from-file=(?:([^=]+)=)?(.+)\z/s) { } 2 420 422
elsif ($x eq '--show-labels') { } 0 420 420
elsif ($x eq '--previous' or $x eq '-p' and 0) { } 0 420 420
elsif ($x =~ /\A--tail(?:=(\d+))?\z/) { } 0 420 420
elsif ($x eq '-c' or $x eq '--container') { } 6 414 420
elsif ($x =~ /\A(?:-c|--containers?)=(.+)\z/) { } 2 412 414
elsif ($x eq '--containers') { } 1 411 412
elsif ($x =~ /\A--(from|keys|prefix)=(.*)\z/s) { } 9 402 411
elsif ($x =~ /\A--(from|keys|prefix)\z/) { } 1 401 402
elsif ($x eq '--list') { } 1 400 401
elsif ($x eq '--') { } 18 382 400
elsif ($x =~ /\A--(verb|resource-name|resource|role|clusterrole|serviceaccount|user|group|cert|key|as-group|as)(?:=(.*))?\z/s) { } 23 359 382
elsif ($x eq '--list') { } 0 359 359
elsif ($x =~ /\A--sort-by(?:=.+)?\z/) { } 2 357 359
elsif ($x =~ /\A--field-selector(?:=(.+))?\z/) { } 1 356 357
elsif ($x =~ /\A--(?:overwrite|wait|now|force|all|dry-run=\w+|record|grace-period=\d+|timeout=\S+|watch=false)\z/) { } 4 352 356
elsif ($x eq '-w' or $x eq '--watch' or $x eq '-it' or $x eq '-i' or $x eq '-t' or $x eq '--stdin' or $x eq '--tty') { } 1 351 352
elsif ($x =~ /\A-/) { } 0 351 351
Condition66%2/3
$x eq "-n" or $x eq "--namespace"
l!l&&r!l&&!r
1220478
MC/DC50%1/2
$x eq "-n" or $x eq "--namespace"
$x eq "-n" $x eq "--namespace"
Truth table66%2/3
A or B
A= $x eq "-n"B= $x eq "--namespace"
ABresult
1X1
011
000
193 0 elsif ( $x =~ /\A(?:-n|--namespace=)(.+)\z/ ) { $o{ns} = $1 }
194 1 ▶ elsif ( $x eq '-A' || $x eq '--all-namespaces' ) { $o{all} = 1 }
Condition66%2/3
$x eq "-A" or $x eq "--all-namespaces"
l!l&&r!l&&!r
10477
MC/DC50%1/2
$x eq "-A" or $x eq "--all-namespaces"
$x eq "-A" $x eq "--all-namespaces"
Truth table66%2/3
A or B
A= $x eq "-A"B= $x eq "--all-namespaces"
ABresult
1X1
011
000
195 22 ▶ elsif ( $x eq '-o' || $x eq '--output' ) { $o{out} = shift @in }
Condition66%2/3
$x eq "-o" or $x eq "--output"
l!l&&r!l&&!r
220455
MC/DC50%1/2
$x eq "-o" or $x eq "--output"
$x eq "-o" $x eq "--output"
Truth table66%2/3
A or B
A= $x eq "-o"B= $x eq "--output"
ABresult
1X1
011
000
196 0 elsif ( $x =~ /\A(?:-o|--output=)(.+)\z/ ) { $o{out} = $1 }
197 6 ▶ elsif ( $x eq '-l' || $x eq '--selector' ) { $o{sel} = shift @in }
Condition66%2/3
$x eq "-l" or $x eq "--selector"
l!l&&r!l&&!r
60449
MC/DC50%1/2
$x eq "-l" or $x eq "--selector"
$x eq "-l" $x eq "--selector"
Truth table66%2/3
A or B
A= $x eq "-l"B= $x eq "--selector"
ABresult
1X1
011
000
198 0 elsif ( $x =~ /\A(?:-l|--selector=)(.+)\z/ ) { $o{sel} = $1 }
199 5 ▶ elsif ( $x eq '-f' || $x eq '--filename' ) { push @{ $o{files} }, shift @in }
Condition66%2/3
$x eq "-f" or $x eq "--filename"
l!l&&r!l&&!r
50444
MC/DC50%1/2
$x eq "-f" or $x eq "--filename"
$x eq "-f" $x eq "--filename"
Truth table66%2/3
A or B
A= $x eq "-f"B= $x eq "--filename"
ABresult
1X1
011
000
200 0 elsif ( $x =~ /\A--filename=(.+)\z/ ) { push @{ $o{files} }, $1 }
201 12 ▶ elsif ( $x eq '-p' || $x eq '--patch' ) { $o{patch} = shift @in }
Condition66%2/3
$x eq "-p" or $x eq "--patch"
l!l&&r!l&&!r
120432
MC/DC50%1/2
$x eq "-p" or $x eq "--patch"
$x eq "-p" $x eq "--patch"
Truth table66%2/3
A or B
A= $x eq "-p"B= $x eq "--patch"
ABresult
1X1
011
000
202 0 elsif ( $x =~ /\A(?:--patch|-p)=(.+)\z/s ) { $o{patch} = $1 }
203 0 elsif ( $x =~ /\A--type=(.+)\z/ ) { $o{type} = $1 }
204 8 elsif ( $x eq '--type' ) { $o{type} = shift @in }
205 0 elsif ( $x =~ /\A--replicas=(\d+)\z/ ) { $o{replicas} = $1 }
206 2 elsif ( $x =~ /\A--from-literal=([^=]+)=(.*)\z/s ) { push @{ $o{literal} }, [ $1, $2 ] }
207 2 elsif ( $x =~ /\A--from-file=(?:([^=]+)=)?(.+)\z/s ) { push @{ $o{from_file} }, [ $1, $2 ] }
208 0 elsif ( $x eq '--show-labels' ) { $o{show_labels} = 1 }
209 0 ▶ elsif ( $x eq '--previous' || $x eq '-p' && 0 ) { $o{previous} = 1 }
Condition40%2/5
$x eq "--previous" or $x eq "-p" and 0
l!l&&r!l&&!r
00420
$x eq "-p" and 0
!ll
4200
MC/DC0%0/2
$x eq "--previous" or $x eq "-p" and 0
$x eq "--previous" $x eq "-p"
Truth table33%1/3
A or B
A= $x eq "--previous"B= $x eq "-p"
ABresult
1X1
011
000
210 0 ▶ elsif ( $x =~ /\A--tail(?:=(\d+))?\z/ ) { $o{tail} = $1 // shift @in }
Condition0%0/3
$1 // shift @in
l!l&&r!l&&!r
000
MC/DC0%0/2
$1 // shift @in
$1 shift @in
Truth table0%0/3
A // B
A= $1B= shift @in
ABresult
1X1
011
000
211 6 ▶ elsif ( $x eq '-c' || $x eq '--container' ) { $o{container} = shift @in }
Condition66%2/3
$x eq "-c" or $x eq "--container"
l!l&&r!l&&!r
60414
MC/DC50%1/2
$x eq "-c" or $x eq "--container"
$x eq "-c" $x eq "--container"
Truth table66%2/3
A or B
A= $x eq "-c"B= $x eq "--container"
ABresult
1X1
011
000
212 # set env: --containers, --from=secret/x, --keys, --prefix
213 2 elsif ( $x =~ /\A(?:-c|--containers?)=(.+)\z/ ) { $o{container} = $1 }
214 1 elsif ( $x eq '--containers' ) { $o{container} = shift @in }
215 9 elsif ( $x =~ /\A--(from|keys|prefix)=(.*)\z/s ) { $o{"env_$1"} = $2 }
216 1 elsif ( $x =~ /\A--(from|keys|prefix)\z/ ) { $o{"env_$1"} = shift @in }
217 1 elsif ( $x eq '--list' ) { $o{env_list} = 1 }
218 18 elsif ( $x eq '--' ) { $o{rest} = [@in]; last }
219 # create role|rolebinding|secret tls …, auth can-i, annotate
220 23 ▶ elsif ( $x =~ /\A--(verb|resource-name|resource|role|clusterrole|serviceaccount|user|group|cert|key|as-group|as)(?:=(.*))?\z/s ) { push @{ $o{f}{$1} }, defined $2 ? $2 : shift @in }
Branch: 1 branch
BranchTrueFalseTotal
defined $2 ? : 23 0 23
221 0 elsif ( $x eq '--list' ) { $o{list} = 1 }
222 # Reihenfolge der Zeilen spielt hier keine Rolle; Feldfilter sind nicht nachgebildet
223 2 ▶ elsif ( $x =~ /\A--sort-by(?:=.+)?\z/ ) { shift @in if $x eq '--sort-by' }
Branch: 1 branch
BranchTrueFalseTotal
if $x eq "--sort-by" 1 1 2
224 1 ▶ elsif ( $x =~ /\A--field-selector(?:=(.+))?\z/ ) { push @GAPS, 'kubectl --field-selector ' . ( $1 // shift(@in) // '' ) }
Condition40%2/5
($1 // shift @in) // ""
l!l
10
$1 // shift @in
l!l&&r!l&&!r
010
MC/DC0%0/2
($1 // shift @in) // ""
$1 shift @in
Truth table33%1/3
A // B
A= $1B= shift @in
ABresult
1X1
011
000
225 4 elsif ( $x =~ /\A--(?:overwrite|wait|now|force|all|dry-run=\w+|record|grace-period=\d+|timeout=\S+|watch=false)\z/ ) { $o{flags}{$x} = 1 }
226 1 ▶ elsif ( $x eq '-w' || $x eq '--watch' || $x eq '-it' || $x eq '-i' || $x eq '-t' || $x eq '--stdin' || $x eq '--tty' ) { $o{interactive} = $x }
Condition61%11/18
$x eq "-w" or $x eq "--watch" or $x eq "-it" or $x eq "-i" or $x eq "-t" or $x eq "--stdin" or $x eq "--tty"
l!l&&r!l&&!r
10351
$x eq "-w" or $x eq "--watch" or $x eq "-it" or $x eq "-i" or $x eq "-t" or $x eq "--stdin"
l!l&&r!l&&!r
10351
$x eq "-w" or $x eq "--watch" or $x eq "-it" or $x eq "-i" or $x eq "-t"
l!l&&r!l&&!r
10351
$x eq "-w" or $x eq "--watch" or $x eq "-it" or $x eq "-i"
l!l&&r!l&&!r
10351
$x eq "-w" or $x eq "--watch" or $x eq "-it"
l!l&&r!l&&!r
01351
$x eq "-w" or $x eq "--watch"
l!l&&r!l&&!r
00352
MC/DC14%1/7
$x eq "-w" or $x eq "--watch" or $x eq "-it" or $x eq "-i" or $x eq "-t" or $x eq "--stdin" or $x eq "--tty"
$x eq "-w" $x eq "--watch" $x eq "-it" $x eq "-i" $x eq "-t" $x eq "--stdin" $x eq "--tty"
Truth table25%2/8
A or B or C or D or E or F or G
A= $x eq "-w"B= $x eq "--watch"C= $x eq "-it"D= $x eq "-i"E= $x eq "-t"F= $x eq "--stdin"G= $x eq "--tty"
ABCDEFGresult
1XXXXXX1
01XXXXX1
001XXXX1
0001XXX1
00001XX1
000001X1
00000011
00000000
227 0 elsif ( $x =~ /\A-/ ) { return ( "error: unknown flag: $x\nSee 'kubectl --help' for usage.", 0 ) }
228 351 else { push @a, $x }
229 }
230 133 ▶ if ( ( $o{out} // '' ) =~ /\A(jsonpath|custom-columns)(?:-as-json)?=(.*)\z/s && ( $a[0] // '' ) eq 'get' ) {
Branch: 1 branch
BranchTrueFalseTotal
if (($o{"out"} // "") =~ /\A(jsonpath|custom-columns)(?:-as-json)?=(.*)\z/s and ($a[0] // "") eq "get") 10 123 133
Condition71%5/7
($o{"out"} // "") =~ /\A(jsonpath|custom-columns)(?:-as-json)?=(.*)\z/s and ($a[0] // "") eq "get"
!ll&&!rl&&r
123010
$o{"out"} // ""
l!l
22111
$a[0] // ""
l!l
100
MC/DC50%1/2
($o{"out"} // "") =~ /\A(jsonpath|custom-columns)(?:-as-json)?=(.*)\z/s and ($a[0] // "") eq "get"
$o{"out"} $a[0]
Truth table66%2/3
A and B
A= $o{"out"}B= $a[0]
ABresult
0X0
100
111
231 10 my ( $how, $expr ) = ( $1, $2 );
232 10 my $copy = JSON::MaybeXS->new( canonical => 1 )->decode( JSON::MaybeXS->new( canonical => 1 )->encode($k) );
233 10 my ( $j, $ok ) = _v_get( $copy, [ @a[ 1 .. $#a ] ], { %o, out => 'json' } );
234 10 ▶ return ( $j, 0 ) unless $ok;
Branch: 1 branch
BranchTrueFalseTotal
unless $ok 0 10 10
235 10 my $data = eval { JSON::MaybeXS->new->decode($j) };
236 0 ▶ unless ( ref $data ) { push @GAPS, "kubectl -o $how"; return ( '', 0 ) }
Branch: 1 branch
BranchTrueFalseTotal
unless (ref $data) 0 10 10
237 # ohne Namen ist es immer eine Liste (auch mit einem Eintrag)
238 10 ▶ $data = { apiVersion => 'v1', kind => 'List', items => [$data] } if ( $data->{kind} // '' ) ne 'List' && !defined $a[2] && ( $a[1] // '' ) !~ m{/};
Branch: 1 branch
BranchTrueFalseTotal
if ($$data{"kind"} // "") ne "List" and not defined $a[2] and not +($a[1] // "") =~ m[/] 1 9 10
Condition70%7/10
($$data{"kind"} // "") ne "List" and not defined $a[2] and not +($a[1] // "") =~ m[/]
!ll&&!rl&&r
901
($$data{"kind"} // "") ne "List" and not defined $a[2]
!ll&&!rl&&r
361
$$data{"kind"} // ""
l!l
100
$a[1] // ""
l!l
10
MC/DC0%0/3
($$data{"kind"} // "") ne "List" and not defined $a[2] and not +($a[1] // "") =~ m[/]
$$data{"kind"} not defined $a[2] $a[1]
Truth table50%2/4
A and not(B) and not(C)
A= $$data{"kind"}B= not defined $a[2]C= $a[1]
ABCresult
0XX0
10X0
1110
1101
239 10 ▶ my ( $out, $err ) = $how eq 'jsonpath' ? jsonpath( $data, $expr ) : _custom_columns( $data, $expr );
Branch: 1 branch
BranchTrueFalseTotal
$how eq 'jsonpath' ? : 9 1 10
240 10 ▶ return defined $err ? ( $err, 0 ) : ( $out, 1 );
Branch: 1 branch
BranchTrueFalseTotal
defined $err ? : 0 10 10
241 }
242 0 ▶ if ( ( $o{out} // '' ) =~ /\A(jsonpath|custom-columns|go-template|template)/ ) { push @GAPS, "kubectl -o $1"; return ( '', 0 ) }
Branch: 1 branch
BranchTrueFalseTotal
if (($o{"out"} // "") =~ /\A(jsonpath|custom-columns|go-template|template)/) 0 123 123
Condition100%2/2
$o{"out"} // ""
l!l
12111
MC/DC100%1/1
$o{"out"} // ""
$o{"out"}
Truth table100%2/2
A
A= $o{"out"}
Aresult
11
00
243 123 ▶ my $verb = shift(@a) // return ( "kubectl controls the Kubernetes cluster manager.\n\nUse \"kubectl <command> --help\" for more information about a given command.", 1 );
Condition50%1/2
shift @a // (return "kubectl controls the Kubernetes cluster manager.\n\nUse \"kubectl <command> --help\" for more information about a given command.", 1)
l!l
1230
MC/DC0%0/1
shift @a // (return "kubectl controls the Kubernetes cluster manager.\n\nUse \"kubectl <command> --help\" for more information about a given command.", 1)
shift @a
Truth table50%1/2
A
A= shift @a
Aresult
11
00
244 123 ( my $sub = "_v_$verb" ) =~ s/-/_/g;
245 0 ▶ my $f = $verb =~ /\A[a-z-]+\z/ && __PACKAGE__->can($sub) or do { push @GAPS, "kubectl $verb"; return ( '', 0 ) };
Branch: 1 branch
BranchTrueFalseTotal
my $f = $verb =~ /\A[a-z-]+\z/ && __PACKAGE__->can($sub) or do { push @Langertha::Holmgang::Sim::Linux::Kubernetes::GAPS, "kubectl $verb"; return "", 0 } 123 0 123
Condition33%1/3
$verb =~ /\A[a-z-]+\z/ && __PACKAGE__->can($sub)
!ll&&!rl&&r
00123
MC/DC0%0/2
$verb =~ /\A[a-z-]+\z/ && __PACKAGE__->can($sub)
$verb =~ /\A[a-z-]+\z/ __PACKAGE__->can($sub)
Truth table33%1/3
A && B
A= $verb =~ /\A[a-z-]+\z/B= __PACKAGE__->can($sub)
ABresult
0X0
100
111
246 # Lesen auf einer Kopie (kein Nebeneffekt durch Zugriffe); Aendern nur in
247 # einem vorhandenen Namespace (ausser Ressourcen ohne Namespace)
248 123 ▶ my $read = $verb =~ /\A(?:get|describe|logs|exec|version|config|cluster-info|top|explain|auth|api-resources|api-versions)\z/
Condition62%5/8
$verb =~ /\A(?:get|describe|logs|exec|version|config|cluster-info|top|explain|auth|api-resources|api-versions)\z/ || $verb eq 'rollout' && ($a[0] // '') =~ /\A(?:status|history)\z/
l!l&&r!l&&!r
76047
$verb eq "rollout" and ($a[0] // "") =~ /\A(?:status|history)\z/
!ll&&!rl&&r
4610
$a[0] // ""
l!l
10
MC/DC66%2/3
$verb =~ /\A(?:get|describe|logs|exec|version|config|cluster-info|top|explain|auth|api-resources|api-versions)\z/ || $verb eq 'rollout' && ($a[0] // '') =~ /\A(?:status|history)\z/
$verb =~ /\A(?:get|describe|logs|exec|version|config|cluster-info|top|explain|auth|api-resources|api-versions)\z/ $verb eq "rollout" $a[0]
Truth table75%3/4
A || B and C
A= $verb =~ /\A(?:get|describe|logs|exec|version|config|cluster-info|top|explain|auth|api-resources|api-versions)\z/B= $verb eq "rollout"C= $a[0]
ABCresult
1XX1
0111
00X0
0100
249 || $verb eq 'rollout' && ( $a[0] // '' ) =~ /\A(?:status|history)\z/;
250 123 ▶ if ($read) {
Branch: 1 branch
BranchTrueFalseTotal
if ($read) 76 47 123
251 76 my $copy = JSON::MaybeXS->new( canonical => 1 )->decode( JSON::MaybeXS->new( canonical => 1 )->encode($k) );
252 76 return $f->( $copy, \@a, \%o, $dev, $stdin );
253 }
254 47 ▶ my ($kind) = $verb =~ /\A(?:delete|patch|label|annotate)\z/ ? _kind_name( \@a ) : ();
Branch: 1 branch
BranchTrueFalseTotal
$verb =~ /\A(?:delete|patch|label|annotate)\z/ ? : 16 31 47
255 return ( qq{Error from server (NotFound): namespaces "$o{ns}" not found}, 0 )
256 47 ▶ if !$k->{namespaces}{ $o{ns} } && $verb !~ /\A(?:apply|create)\z/ && !( $kind && $CLUSTER{$kind} );
Branch: 1 branch
BranchTrueFalseTotal
unless $$k{"namespaces"}{$o{"ns"}} or $verb =~ /\A(?:apply|create)\z/ or $kind and $Langertha::Holmgang::Sim::Linux::Kubernetes::CLUSTER{$kind} 0 47 47
Condition66%6/9
$$k{"namespaces"}{$o{"ns"}} or $verb =~ /\A(?:apply|create)\z/ or $kind and $Langertha::Holmgang::Sim::Linux::Kubernetes::CLUSTER{$kind}
l!l&&r!l&&!r
4610
$$k{"namespaces"}{$o{"ns"}} or $verb =~ /\A(?:apply|create)\z/
l!l&&r!l&&!r
4151
$kind and $Langertha::Holmgang::Sim::Linux::Kubernetes::CLUSTER{$kind}
!ll&&!rl&&r
001
MC/DC0%0/4
$$k{"namespaces"}{$o{"ns"}} or $verb =~ /\A(?:apply|create)\z/ or $kind and $Langertha::Holmgang::Sim::Linux::Kubernetes::CLUSTER{$kind}
$$k{"namespaces"}{$o{"ns"}} $verb =~ /\A(?:apply|create)\z/ $kind $Langertha::Holmgang::Sim::Linux::Kubernetes::CLUSTER{$kind}
Truth table60%3/5
A or B or C and D
A= $$k{"namespaces"}{$o{"ns"}}B= $verb =~ /\A(?:apply|create)\z/C= $kindD= $Langertha::Holmgang::Sim::Linux::Kubernetes::CLUSTER{$kind}
ABCDresult
1XXX1
01XX1
00111
000X0
00100
257 # gescheiterte Aenderungen hinterlassen nichts (auch keine angelegten leeren Abschnitte)
258 47 my $copy = JSON::MaybeXS->new( canonical => 1 )->decode( JSON::MaybeXS->new( canonical => 1 )->encode($k) );
259 47 my ( $out, $ok ) = $f->( $copy, \@a, \%o, $dev, $stdin );
260 47 ▶ $dev->{kubernetes} = $copy if $ok;
Branch: 1 branch
BranchTrueFalseTotal
if $ok 40 7 47
261 47 return ( $out, $ok );
262 }
263  
264 48 ▶sub _ns_list { my ( $k, $o ) = @_; return $o->{all} ? sort keys %{ $k->{namespaces} || {} } : ( $o->{ns} ) }
Subroutine _ns_list: called CC=3 SCAR=11.1
Branch: 1 branch
BranchTrueFalseTotal
$$o{'all'} ? : 1 47 48
Condition50%1/2
$$k{'namespaces'} || {}
l!l
10
MC/DC0%0/1
$$k{'namespaces'} || {}
$$k{'namespaces'}
Truth table50%1/2
A
A= $$k{'namespaces'}
Aresult
11
00
265  
266 101 ▶sub _kind_name {
Subroutine _kind_name: called CC=4 SCAR=15.2
267 101 my ( $a ) = @_;
268 101 my ( $kind, $name ) = @$a;
269 101 ▶ ( $kind, $name ) = split m{/}, $kind, 2 if defined $kind && $kind =~ m{/};
Branch: 1 branch
BranchTrueFalseTotal
if defined $kind and $kind =~ m[/] 0 101 101
Condition33%1/3
defined $kind and $kind =~ m[/]
!ll&&!rl&&r
01010
MC/DC0%0/2
defined $kind and $kind =~ m[/]
defined $kind $kind =~ m[/]
Truth table33%1/3
A and B
A= defined $kindB= $kind =~ m[/]
ABresult
0X0
100
111
270 101 ▶ ( my $base = lc( $kind // '' ) ) =~ s/\.(?:apps|networking\.k8s\.io|storage\.k8s\.io|rbac\.authorization\.k8s\.io|cert-manager\.io|acme\.cert-manager\.io)\z//;
Condition50%1/2
$kind // ""
l!l
1010
MC/DC0%0/1
$kind // ""
$kind
Truth table50%1/2
A
A= $kind
Aresult
11
00
271 101 return ( $KIND{$base}, $name, $kind );
272 }
273  
274 0 ▶sub _v_version { return ( "Client Version: v1.30.4\nKustomize Version: v5.0.4-0.20230601165947-6ce0bf390ce3\nServer Version: v1.30.4+k3s1", 1 ) }
Subroutine _v_version: not called CC=1 SCAR=6.9
275  
276 0 ▶sub _v_config {
Subroutine _v_config: not called CC=4 SCAR=30.0
277 0 my ( $k, $a ) = @_;
278 0 ▶ return ( $k->{context} // 'default', 1 ) if ( $a->[0] // '' ) eq 'current-context';
Branch: 1 branch
BranchTrueFalseTotal
if ($$a[0] // "") eq "current-context" 0 0 0
Condition0%0/4
$$a[0] // ""
l!l
00
$$k{"context"} // "default"
l!l
00
MC/DC0%0/1
$$a[0] // ""
$$a[0]
MC/DC0%0/1
$$k{"context"} // "default"
$$k{"context"}
Truth table0%0/2
A
A= $$a[0]
Aresult
11
00
Truth table0%0/2
A
A= $$k{"context"}
Aresult
11
00
279 0 push @GAPS, "kubectl config @$a";
280 0 return ( '', 0 );
281 }
282  
283 0 ▶sub _v_cluster_info { return ( "Kubernetes control plane is running at https://10.30.0.10:6443\nCoreDNS is running at https://10.30.0.10:6443/api/v1/namespaces/kube-system/services/kube-dns:dns/proxy", 1 ) }
Subroutine _v_cluster_info: not called CC=1 SCAR=6.9
284  
285 49 ▶sub _v_get {
Subroutine _v_get: called CC=214 SCAR=84.5
286 49 my ( $k, $a, $o ) = @_;
287 # mehrere Arten (pods,svc): je Art ein Block, Namen mit Art davor wie kubectl
288 49 ▶ if ( ( $a->[0] // '' ) =~ /,/ && $a->[0] !~ m{/} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (($$a[0] // "") =~ /,/ and not $$a[0] =~ m[/]) 0 49 49
Condition40%2/5
($$a[0] // "") =~ /,/ and not $$a[0] =~ m[/]
!ll&&!rl&&r
4900
$$a[0] // ""
l!l
490
MC/DC0%0/2
($$a[0] // "") =~ /,/ and not $$a[0] =~ m[/]
$$a[0] not $$a[0] =~ m[/]
Truth table0%0/3
A and not(B)
A= $$a[0]B= not $$a[0] =~ m[/]
ABresult
0X0
100
111
289 0 my @out;
290 0 for my $kind ( split /,/, $a->[0] ) {
291 0 my ( $t, $ok ) = _v_get( $k, [ $kind, @$a[ 1 .. $#$a ] ], $o );
292 0 ▶ return ( $t, 0 ) unless $ok;
Branch: 1 branch
BranchTrueFalseTotal
unless $ok 0 0 0
293 0 ▶ my $pre = ( $SINGULAR{ $KIND{ lc $kind } // '' } // $kind ) . '/';
Condition0%0/5
$Langertha::Holmgang::Sim::Linux::Kubernetes::SINGULAR{$Langertha::Holmgang::Sim::Linux::Kubernetes::KIND{lc $kind} // ""} // $kind
l!l&&r!l&&!r
000
$Langertha::Holmgang::Sim::Linux::Kubernetes::KIND{lc $kind} // ""
l!l
00
MC/DC0%0/2
$Langertha::Holmgang::Sim::Linux::Kubernetes::SINGULAR{$Langertha::Holmgang::Sim::Linux::Kubernetes::KIND{lc $kind} // ""} // $kind
$Langertha::Holmgang::Sim::Linux::Kubernetes::SINGULAR{$Langertha::Holmgang::Sim::Linux::Kubernetes::KIND{lc $kind} // ""} $kind
MC/DC0%0/1
$Langertha::Holmgang::Sim::Linux::Kubernetes::KIND{lc $kind} // ""
$Langertha::Holmgang::Sim::Linux::Kubernetes::KIND{lc $kind}
Truth table0%0/3
A // B
A= $Langertha::Holmgang::Sim::Linux::Kubernetes::SINGULAR{$Langertha::Holmgang::Sim::Linux::Kubernetes::KIND{lc $kind} // ""}B= $kind
ABresult
1X1
011
000
Truth table0%0/2
A
A= $Langertha::Holmgang::Sim::Linux::Kubernetes::KIND{lc $kind}
Aresult
11
00
294 0 ▶ $t =~ s/^(?!NAME\b|NAMESPACE\b|No resources)(\S)/$pre$1/mg unless $o->{all};
Branch: 1 branch
BranchTrueFalseTotal
unless $$o{"all"} 0 0 0
295 0 push @out, $t;
296 }
297 0 return ( join( "\n\n", @out ), 1 );
298 }
299 # mehrere Namen einer Art (get svc a b): eine Tabelle, ein Kopf
300 0 ▶ if ( @$a > 2 && $a->[0] !~ m{/} && !grep {m{/}} @$a ) {
Branch: 1 branch
BranchTrueFalseTotal
if (@$a > 2 and not $$a[0] =~ m[/] and not grep({m[/];} @$a)) 0 49 49
Condition33%2/6
@$a > 2 and not $$a[0] =~ m[/] and not grep({m[/];} @$a)
!ll&&!rl&&r
4900
@$a > 2 and not $$a[0] =~ m[/]
!ll&&!rl&&r
4900
MC/DC0%0/3
@$a > 2 and not $$a[0] =~ m[/] and not grep({m[/];} @$a)
@$a > 2 not $$a[0] =~ m[/] not grep({m[/];} @$a)
Truth table25%1/4
A and not(B) and not(C)
A= @$a > 2B= not $$a[0] =~ m[/]C= not grep({m[/];} @$a)
ABCresult
0XX0
10X0
1100
1111
301 0 my @out;
302 0 for my $n ( @$a[ 1 .. $#$a ] ) {
303 0 my ( $t, $ok ) = _v_get( $k, [ $a->[0], $n ], $o );
304 0 ▶ return ( $t, 0 ) unless $ok;
Branch: 1 branch
BranchTrueFalseTotal
unless $ok 0 0 0
305 0 ▶ $t =~ s/\A[^\n]*\n?// if @out && $t =~ /\A(?:NAME|NAMESPACE)\b/;
Branch: 1 branch
BranchTrueFalseTotal
if @out and $t =~ /\A(?:NAME|NAMESPACE)\b/ 0 0 0
Condition0%0/3
@out and $t =~ /\A(?:NAME|NAMESPACE)\b/
!ll&&!rl&&r
000
MC/DC0%0/2
@out and $t =~ /\A(?:NAME|NAMESPACE)\b/
@out $t =~ /\A(?:NAME|NAMESPACE)\b/
Truth table0%0/3
A and B
A= @outB= $t =~ /\A(?:NAME|NAMESPACE)\b/
ABresult
0X0
100
111
306 0 push @out, $t;
307 }
308 0 return ( join( "\n", @out ), 1 );
309 }
310 49 my ( $kind, $name, $raw ) = _kind_name($a);
311 49 ▶ return ( qq{error: the server doesn't have a resource type "} . ( $raw // '' ) . '"', 0 ) unless $kind;
Branch: 1 branch
BranchTrueFalseTotal
unless $kind 0 49 49
Condition0%0/2
$raw // ""
l!l
00
MC/DC0%0/1
$raw // ""
$raw
Truth table0%0/2
A
A= $raw
Aresult
11
00
312 49 ▶ if ( $kind eq 'namespaces' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($kind eq "namespaces") 0 49 49
313 0 ▶ my @n = grep { !defined $name || $_ eq $name } sort keys %{ $k->{namespaces} };
Condition0%0/3
!defined($name) || $_ eq $name
l!l&&r!l&&!r
000
MC/DC0%0/2
!defined($name) || $_ eq $name
!defined($name) $_ eq $name
Truth table0%0/3
not(A) || B
A= !defined($name)B= $_ eq $name
ABresult
1X1
011
000
314 0 ▶ return ( qq{Error from server (NotFound): namespaces "$name" not found}, 0 ) if defined $name && !@n;
Branch: 1 branch
BranchTrueFalseTotal
if defined $name and not @n 0 0 0
Condition0%0/3
defined $name and not @n
!ll&&!rl&&r
000
MC/DC0%0/2
defined $name and not @n
defined $name not @n
Truth table0%0/3
A and not(B)
A= defined $nameB= not @n
ABresult
0X0
100
111
315 0 return ( _cols( [qw( NAME STATUS AGE )], map { [ $_, 'Active', '41d' ] } @n ), 1 );
316 }
317 49 ▶ if ( $kind eq 'nodes' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($kind eq "nodes") 0 49 49
318 0 ▶ return ( _cols( [qw( NAME STATUS ROLES AGE VERSION )], map { [ $_, $k->{nodes}{$_}{ready} ? 'Ready' : 'NotReady', $k->{nodes}{$_}{roles} // '<none>', '41d', 'v1.30.4+k3s1' ] } sort keys %{ $k->{nodes} || {} } ), 1 );
Branch: 1 branch
BranchTrueFalseTotal
$$k{'nodes'}{$_}{'ready'} ? : 0 0 0
Condition0%0/4
$$k{"nodes"}{$_}{"roles"} // "<none>"
l!l
00
$$k{'nodes'} || {}
l!l
00
MC/DC0%0/1
$$k{"nodes"}{$_}{"roles"} // "<none>"
$$k{"nodes"}{$_}{"roles"}
MC/DC0%0/1
$$k{'nodes'} || {}
$$k{'nodes'}
Truth table0%0/2
A
A= $$k{"nodes"}{$_}{"roles"}
Aresult
11
00
Truth table0%0/2
A
A= $$k{'nodes'}
Aresult
11
00
319 }
320 49 ▶ if ( $kind eq 'storageclasses' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($kind eq "storageclasses") 1 48 49
321 1 ▶ my $s = $k->{storageclasses} || {};
Condition50%1/2
$$k{'storageclasses'} || {}
l!l
10
MC/DC0%0/1
$$k{'storageclasses'} || {}
$$k{'storageclasses'}
Truth table50%1/2
A
A= $$k{'storageclasses'}
Aresult
11
00
322 1 ▶ my @n = grep { !defined $name || $_ eq $name } sort keys %$s;
Condition33%1/3
!defined($name) || $_ eq $name
l!l&&r!l&&!r
100
MC/DC0%0/2
!defined($name) || $_ eq $name
!defined($name) $_ eq $name
Truth table33%1/3
not(A) || B
A= !defined($name)B= $_ eq $name
ABresult
1X1
011
000
323 1 ▶ return ( qq{Error from server (NotFound): storageclasses.storage.k8s.io "$name" not found}, 0 ) if defined $name && !@n;
Branch: 1 branch
BranchTrueFalseTotal
if defined $name and not @n 0 1 1
Condition33%1/3
defined $name and not @n
!ll&&!rl&&r
100
MC/DC0%0/2
defined $name and not @n
defined $name not @n
Truth table33%1/3
A and not(B)
A= defined $nameB= not @n
ABresult
0X0
100
111
324 0 ▶ return _structured( $o, 'storageclasses', { map { $_ => $s->{$_} } @n } ) if $o->{out} && $o->{out} =~ /\A(?:yaml|json)/;
Branch: 1 branch
BranchTrueFalseTotal
if $$o{"out"} and $$o{"out"} =~ /\A(?:yaml|json)/ 0 1 1
Condition33%1/3
$$o{"out"} and $$o{"out"} =~ /\A(?:yaml|json)/
!ll&&!rl&&r
100
MC/DC0%0/2
$$o{"out"} and $$o{"out"} =~ /\A(?:yaml|json)/
$$o{"out"} $$o{"out"} =~ /\A(?:yaml|json)/
Truth table33%1/3
A and B
A= $$o{"out"}B= $$o{"out"} =~ /\A(?:yaml|json)/
ABresult
0X0
100
111
325 return ( _cols( [qw( NAME PROVISIONER RECLAIMPOLICY VOLUMEBINDINGMODE ALLOWVOLUMEEXPANSION AGE )],
326 1 ▶ map { [ $_ . ( $s->{$_}{default} ? ' (default)' : '' ), $s->{$_}{provisioner} // 'kubernetes.io/no-provisioner', 'Delete', 'Immediate', 'false', '41d' ] } @n ), 1 );
Branch: 1 branch
BranchTrueFalseTotal
$$s{$_}{'default'} ? : 1 0 1
Condition50%1/2
$$s{$_}{"provisioner"} // "kubernetes.io/no-provisioner"
l!l
10
MC/DC0%0/1
$$s{$_}{"provisioner"} // "kubernetes.io/no-provisioner"
$$s{$_}{"provisioner"}
Truth table50%1/2
A
A= $$s{$_}{"provisioner"}
Aresult
11
00
327 }
328 48 ▶ if ( $GEN{$kind} || $DERIVED{$kind} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($Langertha::Holmgang::Sim::Linux::Kubernetes::GEN{$kind} or $Langertha::Holmgang::Sim::Linux::Kubernetes::DERIVED{$kind}) 8 40 48
Condition100%3/3
$Langertha::Holmgang::Sim::Linux::Kubernetes::GEN{$kind} or $Langertha::Holmgang::Sim::Linux::Kubernetes::DERIVED{$kind}
l!l&&r!l&&!r
5340
MC/DC100%2/2
$Langertha::Holmgang::Sim::Linux::Kubernetes::GEN{$kind} or $Langertha::Holmgang::Sim::Linux::Kubernetes::DERIVED{$kind}
$Langertha::Holmgang::Sim::Linux::Kubernetes::GEN{$kind} $Langertha::Holmgang::Sim::Linux::Kubernetes::DERIVED{$kind}
Truth table100%3/3
A or B
A= $Langertha::Holmgang::Sim::Linux::Kubernetes::GEN{$kind}B= $Langertha::Holmgang::Sim::Linux::Kubernetes::DERIVED{$kind}
ABresult
1X1
011
000
329 8 ▶ my $cluster = $GEN{$kind} && $GEN{$kind}[2];
Condition66%2/3
$Langertha::Holmgang::Sim::Linux::Kubernetes::GEN{$kind} && $Langertha::Holmgang::Sim::Linux::Kubernetes::GEN{$kind}[2]
!ll&&!rl&&r
350
MC/DC0%0/2
$Langertha::Holmgang::Sim::Linux::Kubernetes::GEN{$kind} && $Langertha::Holmgang::Sim::Linux::Kubernetes::GEN{$kind}[2]
$Langertha::Holmgang::Sim::Linux::Kubernetes::GEN{$kind} $Langertha::Holmgang::Sim::Linux::Kubernetes::GEN{$kind}[2]
Truth table66%2/3
A && B
A= $Langertha::Holmgang::Sim::Linux::Kubernetes::GEN{$kind}B= $Langertha::Holmgang::Sim::Linux::Kubernetes::GEN{$kind}[2]
ABresult
0X0
100
111
330 8 ▶ my $multi = $o->{all} && !$cluster;
Condition33%1/3
$$o{'all'} && !$cluster
!ll&&!rl&&r
800
MC/DC0%0/2
$$o{'all'} && !$cluster
$$o{'all'} !$cluster
Truth table33%1/3
A && not(B)
A= $$o{'all'}B= !$cluster
ABresult
0X0
100
111
331 8 my @rows;
332 8 ▶ for my $ns ( $cluster ? (undef) : _ns_list( $k, $o ) ) {
Branch: 1 branch
BranchTrueFalseTotal
$cluster ? : 0 8 8
333 8 my @r;
334 8 ▶ if ( $DERIVED{$kind} && $o->{out} && $o->{out} =~ /\A(yaml|json)/ ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($Langertha::Holmgang::Sim::Linux::Kubernetes::DERIVED{$kind} and $$o{"out"} and $$o{"out"} =~ /\A(yaml|json)/) 1 7 8
Condition83%5/6
$Langertha::Holmgang::Sim::Linux::Kubernetes::DERIVED{$kind} and $$o{"out"} and $$o{"out"} =~ /\A(yaml|json)/
!ll&&!rl&&r
701
$Langertha::Holmgang::Sim::Linux::Kubernetes::DERIVED{$kind} and $$o{"out"}
!ll&&!rl&&r
521
MC/DC66%2/3
$Langertha::Holmgang::Sim::Linux::Kubernetes::DERIVED{$kind} and $$o{"out"} and $$o{"out"} =~ /\A(yaml|json)/
$Langertha::Holmgang::Sim::Linux::Kubernetes::DERIVED{$kind} $$o{"out"} $$o{"out"} =~ /\A(yaml|json)/
Truth table75%3/4
A and B and C
A= $Langertha::Holmgang::Sim::Linux::Kubernetes::DERIVED{$kind}B= $$o{"out"}C= $$o{"out"} =~ /\A(yaml|json)/
ABCresult
0XX0
10X0
1100
1111
335 1 my $objs = _derived_objs( $k, $kind, $ns );
336 1 ▶ my @n = grep { !defined $name || $_ eq $name } sort keys %$objs;
Condition33%1/3
!defined($name) || $_ eq $name
l!l&&r!l&&!r
100
MC/DC0%0/2
!defined($name) || $_ eq $name
!defined($name) $_ eq $name
Truth table33%1/3
not(A) || B
A= !defined($name)B= $_ eq $name
ABresult
1X1
011
000
337 1 ▶ return ( qq{Error from server (NotFound): $SINGULAR{$kind} "$name" not found}, 0 ) if defined $name && !@n;
Branch: 1 branch
BranchTrueFalseTotal
if defined $name and not @n 0 1 1
Condition33%1/3
defined $name and not @n
!ll&&!rl&&r
100
MC/DC0%0/2
defined $name and not @n
defined $name not @n
Truth table33%1/3
A and not(B)
A= defined $nameB= not @n
ABresult
0X0
100
111
338 1 ▶ my $data = @n == 1 && defined $name ? $objs->{ $n[0] } : { apiVersion => 'v1', kind => 'List', items => [ @{$objs}{@n} ] };
Branch: 1 branch
BranchTrueFalseTotal
@n == 1 && defined $name ? : 0 1 1
Condition33%1/3
@n == 1 and defined $name
!ll&&!rl&&r
010
MC/DC0%0/2
@n == 1 and defined $name
@n == 1 defined $name
Truth table33%1/3
A and B
A= @n == 1B= defined $name
ABresult
0X0
100
111
339 0 ▶ return ( $1 eq 'json' ? $OUT_JSON->encode($data) =~ s/\s+\z//r : do { local $YAML::XS::Boolean = 'JSON::PP'; YAML::XS::Dump($data) =~ s/\A---\n//r =~ s/\s+\z//r }, 1 );
Branch: 1 branch
BranchTrueFalseTotal
$1 eq 'json' ? : 1 0 1
340 }
341 7 ▶ if ( $DERIVED{$kind} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($Langertha::Holmgang::Sim::Linux::Kubernetes::DERIVED{$kind}) { } 2 5 7
342 2 ( undef, @r ) = _derived_rows( $k, $kind, $ns );
343 0 ▶ @r = grep { $_->[0] eq $name } @r if defined $name;
Branch: 1 branch
BranchTrueFalseTotal
if defined $name 0 2 2
344 }
345 else {
346 5 my ( $res, $err ) = _gen_rows( $k, $kind, $ns, $o, $name );
347 0 ▶ if ( !$res ) { next if $multi; return ( $err, 0 ) }
Branch: 2 branches
BranchTrueFalseTotal
unless ($res) 0 5 5
if $multi 0 0 0
348 5 ▶ return _structured( { %$o, ns => $ns }, $kind, $res ) if ref $res eq 'HASH';
Branch: 1 branch
BranchTrueFalseTotal
if ref $res eq "HASH" 2 3 5
349 3 ( undef, @r ) = @$res;
350 }
351 0 ▶ return ( join( "\n", map { "$SINGULAR{$kind}/$_->[0]" } @r ), 1 ) if ( $o->{out} // '' ) eq 'name';
Branch: 1 branch
BranchTrueFalseTotal
if ($$o{"out"} // "") eq "name" 0 5 5
Condition50%1/2
$$o{"out"} // ""
l!l
05
MC/DC0%0/1
$$o{"out"} // ""
$$o{"out"}
Truth table50%1/2
A
A= $$o{"out"}
Aresult
11
00
352 5 ▶ push @rows, map { [ ( $multi ? $ns : () ), @$_ ] } @r;
Branch: 1 branch
BranchTrueFalseTotal
$multi ? : 0 7 7
353 }
354 5 ▶ return ( qq{Error from server (NotFound): $SINGULAR{$kind} "$name" not found}, 0 ) if defined $name && !@rows;
Branch: 1 branch
BranchTrueFalseTotal
if defined $name and not @rows 0 5 5
Condition66%2/3
defined $name and not @rows
!ll&&!rl&&r
410
MC/DC0%0/2
defined $name and not @rows
defined $name not @rows
Truth table66%2/3
A and not(B)
A= defined $nameB= not @rows
ABresult
0X0
100
111
355 5 ▶ return ( $multi || $cluster ? 'No resources found' : "No resources found in $o->{ns} namespace.", 1 ) unless @rows;
Branch: 2 branches
BranchTrueFalseTotal
unless @rows 0 5 5
$multi || $cluster ? : 0 0 0
Condition0%0/3
$multi or $cluster
l!l&&r!l&&!r
000
MC/DC0%0/2
$multi or $cluster
$multi $cluster
Truth table0%0/3
A or B
A= $multiB= $cluster
ABresult
1X1
011
000
356 5 ▶ my ($head) = $DERIVED{$kind} ? _derived_rows( $k, $kind, $o->{ns} ) : @{ ( _gen_rows( $k, $kind, $o->{ns}, { %$o, out => $o->{out} && $o->{out} eq 'wide' ? 'wide' : undef }, undef ) )[0] || [ [] ] };
Branch: 2 branches
BranchTrueFalseTotal
$Langertha::Holmgang::Sim::Linux::Kubernetes::DERIVED{$kind} ? : 2 3 5
$$o{'out'} && $$o{'out'} eq 'wide' ? : 0 3 3
Condition40%2/5
(_gen_rows($k, $kind, $$o{'ns'}, {%$o, 'out', $$o{'out'} && $$o{'out'} eq 'wide' ? 'wide' : undef}, undef))[0] || [[]]
l!l
30
$$o{"out"} and $$o{"out"} eq "wide"
!ll&&!rl&&r
300
MC/DC0%0/1
(_gen_rows($k, $kind, $$o{'ns'}, {%$o, 'out', $$o{'out'} && $$o{'out'} eq 'wide' ? 'wide' : undef}, undef))[0] || [[]]
(_gen_rows($k, $kind, $$o{'ns'}, {%$o, 'out', $$o{'out'} && $$o{'out'} eq 'wide' ? 'wide' : undef}, undef))[0]
MC/DC0%0/2
$$o{"out"} and $$o{"out"} eq "wide"
$$o{"out"} $$o{"out"} eq "wide"
Truth table50%1/2
A
A= (_gen_rows($k, $kind, $$o{'ns'}, {%$o, 'out', $$o{'out'} && $$o{'out'} eq 'wide' ? 'wide' : undef}, undef))[0]
Aresult
11
00
Truth table33%1/3
A and B
A= $$o{"out"}B= $$o{"out"} eq "wide"
ABresult
0X0
100
111
357 5 ▶ return ( _cols( [ ( $multi ? 'NAMESPACE' : () ), @$head ], @rows ), 1 );
Branch: 1 branch
BranchTrueFalseTotal
$multi ? : 0 5 5
358 }
359 40 my ( @out, @all );
360 40 my $multi = $o->{all};
361 40 for my $ns ( _ns_list( $k, $o ) ) {
362 41 ▶ my $obj = $k->{namespaces}{$ns} || {};
Condition100%2/2
$$k{'namespaces'}{$ns} || {}
l!l
401
MC/DC100%1/1
$$k{'namespaces'}{$ns} || {}
$$k{'namespaces'}{$ns}
Truth table100%2/2
A
A= $$k{'namespaces'}{$ns}
Aresult
11
00
363 41 my @rows;
364 41 ▶ if ( $kind eq 'pods' ) {
Branch: 9 branches
BranchTrueFalseTotal
if ($kind eq 'pods') { } 16 25 41
elsif ($kind eq 'deployments') { } 8 17 25
elsif ($kind eq 'services') { } 1 16 17
elsif ($kind eq 'endpoints') { } 3 13 16
elsif ($kind eq 'pvcs') { } 2 11 13
elsif ($kind eq 'networkpolicies') { } 0 11 11
elsif ($kind eq 'secrets' or $kind eq 'configmaps') { } 6 5 11
elsif ($kind eq 'events') { } 4 1 5
elsif ($kind eq 'replicasets') { } 1 0 1
365 16 ▶ my @p = grep { ( !defined $name || $_->{name} eq $name ) && _label_sel( $o->{sel}, $_->{labels} ) } _pods( $k, $ns );
Condition50%3/6
(!defined($name) || $$_{'name'} eq $name) && _label_sel($$o{'sel'}, $$_{'labels'})
!ll&&!rl&&r
01153
not defined $name or $$_{"name"} eq $name
l!l&&r!l&&!r
6400
MC/DC33%1/3
(!defined($name) || $$_{'name'} eq $name) && _label_sel($$o{'sel'}, $$_{'labels'})
not defined $name $$_{"name"} eq $name _label_sel($$o{'sel'}, $$_{'labels'})
Truth table40%2/5
not(A) or B && C
A= not defined $nameB= $$_{"name"} eq $nameC= _label_sel($$o{'sel'}, $$_{'labels'})
ABCresult
00X0
1X00
0100
1X11
0111
366 16 ▶ return ( qq{Error from server (NotFound): pods "$name" not found}, 0 ) if defined $name && !@p;
Branch: 1 branch
BranchTrueFalseTotal
if defined $name and not @p 0 16 16
Condition33%1/3
defined $name and not @p
!ll&&!rl&&r
1600
MC/DC0%0/2
defined $name and not @p
defined $name not @p
Truth table33%1/3
A and not(B)
A= defined $nameB= not @p
ABresult
0X0
100
111
367 16 ▶ return ( join( "\n", map {"pod/$_->{name}"} @p ), 1 ) if ( $o->{out} // '' ) eq 'name';
Branch: 1 branch
BranchTrueFalseTotal
if ($$o{"out"} // "") eq "name" 4 12 16
Condition100%2/2
$$o{"out"} // ""
l!l
412
MC/DC100%1/1
$$o{"out"} // ""
$$o{"out"}
Truth table100%2/2
A
A= $$o{"out"}
Aresult
11
00
368 0 ▶ return _structured( $o, 'pods', { map { $_->{name} => _pod_obj($_) } @p } ) if $o->{out} && $o->{out} =~ /\A(?:yaml|json)/;
Branch: 1 branch
BranchTrueFalseTotal
if $$o{"out"} and $$o{"out"} =~ /\A(?:yaml|json)/ 0 12 12
Condition33%1/3
$$o{"out"} and $$o{"out"} =~ /\A(?:yaml|json)/
!ll&&!rl&&r
1200
MC/DC0%0/2
$$o{"out"} and $$o{"out"} =~ /\A(?:yaml|json)/
$$o{"out"} $$o{"out"} =~ /\A(?:yaml|json)/
Truth table33%1/3
A and B
A= $$o{"out"}B= $$o{"out"} =~ /\A(?:yaml|json)/
ABresult
0X0
100
111
369 12 push @rows, map { [ ( $multi ? $ns : () ), $_->{name}, ( $_->{ready} ? '1/1' : '0/1' ), ( $_->{reason} && $_->{reason} ne 'NotReady' && $_->{reason} ne 'Unschedulable' ? $_->{reason} : $_->{phase} ),
370 $_->{restarts} . ( $_->{restarts} ? ' (2m ago)' : '' ), '12m', ( ( $o->{out} // '' ) eq 'wide' ? ( $_->{phase} eq 'Pending' && $_->{reason} eq 'Unschedulable' ? ( '<none>', '<none>' ) : ( $_->{ip}, 'node1' ) ) : () ),
371 39 ▶ ( $o->{show_labels} ? _labels_text( $_->{labels} ) : () ) ] } @p;
Branch: 7 branches
BranchTrueFalseTotal
$multi ? : 5 34 39
$$_{'ready'} ? : 31 8 39
$$_{'reason'} && $$_{'reason'} ne 'NotReady' && $$_{'reason'} ne 'Unschedulable' ? : 8 31 39
$$_{'restarts'} ? : 6 33 39
($$o{'out'} // '') eq 'wide' ? : 0 39 39
$$_{'phase'} eq 'Pending' && $$_{'reason'} eq 'Unschedulable' ? : 0 0 0
$$o{'show_labels'} ? : 0 39 39
Condition45%5/11
$$_{"reason"} and $$_{"reason"} ne "NotReady" and $$_{"reason"} ne "Unschedulable"
!ll&&!rl&&r
3108
$$_{"reason"} and $$_{"reason"} ne "NotReady"
!ll&&!rl&&r
3108
$$o{"out"} // ""
l!l
039
$$_{"phase"} eq "Pending" and $$_{"reason"} eq "Unschedulable"
!ll&&!rl&&r
000
MC/DC33%1/3
$$_{"reason"} and $$_{"reason"} ne "NotReady" and $$_{"reason"} ne "Unschedulable"
$$_{"reason"} $$_{"reason"} ne "NotReady" $$_{"reason"} ne "Unschedulable"
MC/DC0%0/1
$$o{"out"} // ""
$$o{"out"}
MC/DC0%0/2
$$_{"phase"} eq "Pending" and $$_{"reason"} eq "Unschedulable"
$$_{"phase"} eq "Pending" $$_{"reason"} eq "Unschedulable"
Truth table50%2/4
A and B and C
A= $$_{"reason"}B= $$_{"reason"} ne "NotReady"C= $$_{"reason"} ne "Unschedulable"
ABCresult
0XX0
10X0
1100
1111
Truth table50%1/2
A
A= $$o{"out"}
Aresult
11
00
Truth table0%0/3
A and B
A= $$_{"phase"} eq "Pending"B= $$_{"reason"} eq "Unschedulable"
ABresult
0X0
100
111
372 12 ▶ unshift @rows, [ ( $multi ? 'NAMESPACE' : () ), qw( NAME READY STATUS RESTARTS AGE ), ( ( $o->{out} // '' ) eq 'wide' ? qw( IP NODE ) : () ), ( $o->{show_labels} ? 'LABELS' : () ) ] if @rows;
Branch: 4 branches
BranchTrueFalseTotal
if @rows 11 1 12
$multi ? : 2 9 11
($$o{'out'} // '') eq 'wide' ? : 0 11 11
$$o{'show_labels'} ? : 0 11 11
Condition50%1/2
$$o{"out"} // ""
l!l
011
MC/DC0%0/1
$$o{"out"} // ""
$$o{"out"}
Truth table50%1/2
A
A= $$o{"out"}
Aresult
11
00
373 }
374 elsif ( $kind eq 'deployments' ) {
375 8 ▶ my $d = $obj->{deployments} || {};
Condition50%1/2
$$obj{'deployments'} || {}
l!l
80
MC/DC0%0/1
$$obj{'deployments'} || {}
$$obj{'deployments'}
Truth table50%1/2
A
A= $$obj{'deployments'}
Aresult
11
00
376 8 ▶ my @n = grep { ( !defined $name || $_ eq $name ) } sort keys %$d;
Condition100%3/3
!defined($name) || $_ eq $name
l!l&&r!l&&!r
1046
MC/DC100%2/2
!defined($name) || $_ eq $name
!defined($name) $_ eq $name
Truth table100%3/3
not(A) || B
A= !defined($name)B= $_ eq $name
ABresult
1X1
011
000
377 8 ▶ return ( qq{Error from server (NotFound): deployments.apps "$name" not found}, 0 ) if defined $name && !@n;
Branch: 1 branch
BranchTrueFalseTotal
if defined $name and not @n 0 8 8
Condition66%2/3
defined $name and not @n
!ll&&!rl&&r
440
MC/DC0%0/2
defined $name and not @n
defined $name not @n
Truth table66%2/3
A and not(B)
A= defined $nameB= not @n
ABresult
0X0
100
111
378 8 ▶ return _structured( $o, 'deployments', { map { $_ => $d->{$_} } @n } ) if $o->{out} && $o->{out} =~ /\A(?:yaml|json)/;
Branch: 1 branch
BranchTrueFalseTotal
if $$o{"out"} and $$o{"out"} =~ /\A(?:yaml|json)/ 7 1 8
Condition66%2/3
$$o{"out"} and $$o{"out"} =~ /\A(?:yaml|json)/
!ll&&!rl&&r
107
MC/DC50%1/2
$$o{"out"} and $$o{"out"} =~ /\A(?:yaml|json)/
$$o{"out"} $$o{"out"} =~ /\A(?:yaml|json)/
Truth table66%2/3
A and B
A= $$o{"out"}B= $$o{"out"} =~ /\A(?:yaml|json)/
ABresult
0X0
100
111
379 push @rows, map {
380 1 my $n = $_;
381 2 my @p = grep { $_->{deployment} eq $n } _pods( $k, $ns );
382 2 my $r = grep { $_->{ready} } @p;
383 [ ( $multi ? $ns : () ), $n, "$r/" . scalar(@p), scalar(@p), $r, '41d',
384 0 ▶ ( ( $o->{out} // '' ) eq 'wide' ? ( join( ',', map { $_->{name} } @{ $d->{$n}{template}{containers} } ), join( ',', map { $_->{image} } @{ $d->{$n}{template}{containers} } ), _labels_text( $d->{$n}{selector} ) ) : () ) ];
Branch: 2 branches
BranchTrueFalseTotal
$multi ? : 0 2 2
($$o{'out'} // '') eq 'wide' ? : 0 2 2
Condition50%1/2
$$o{"out"} // ""
l!l
02
MC/DC0%0/1
$$o{"out"} // ""
$$o{"out"}
Truth table50%1/2
A
A= $$o{"out"}
Aresult
11
00
385 } @n;
386 1 ▶ unshift @rows, [ ( $multi ? 'NAMESPACE' : () ), qw( NAME READY UP-TO-DATE AVAILABLE AGE ), ( ( $o->{out} // '' ) eq 'wide' ? qw( CONTAINERS IMAGES SELECTOR ) : () ) ] if @rows;
Branch: 3 branches
BranchTrueFalseTotal
if @rows 1 0 1
$multi ? : 0 1 1
($$o{'out'} // '') eq 'wide' ? : 0 1 1
Condition50%1/2
$$o{"out"} // ""
l!l
01
MC/DC0%0/1
$$o{"out"} // ""
$$o{"out"}
Truth table50%1/2
A
A= $$o{"out"}
Aresult
11
00
387 }
388 elsif ( $kind eq 'services' ) {
389 1 ▶ my $s = $obj->{services} || {};
Condition50%1/2
$$obj{'services'} || {}
l!l
10
MC/DC0%0/1
$$obj{'services'} || {}
$$obj{'services'}
Truth table50%1/2
A
A= $$obj{'services'}
Aresult
11
00
390 1 ▶ my @n = grep { !defined $name || $_ eq $name } sort keys %$s;
Condition33%1/3
!defined($name) || $_ eq $name
l!l&&r!l&&!r
200
MC/DC0%0/2
!defined($name) || $_ eq $name
!defined($name) $_ eq $name
Truth table33%1/3
not(A) || B
A= !defined($name)B= $_ eq $name
ABresult
1X1
011
000
391 1 ▶ return ( qq{Error from server (NotFound): services "$name" not found}, 0 ) if defined $name && !@n;
Branch: 1 branch
BranchTrueFalseTotal
if defined $name and not @n 0 1 1
Condition33%1/3
defined $name and not @n
!ll&&!rl&&r
100
MC/DC0%0/2
defined $name and not @n
defined $name not @n
Truth table33%1/3
A and not(B)
A= defined $nameB= not @n
ABresult
0X0
100
111
392 1 ▶ return _structured( $o, 'services', { map { $_ => $s->{$_} } @n } ) if $o->{out} && $o->{out} =~ /\A(?:yaml|json)/;
Branch: 1 branch
BranchTrueFalseTotal
if $$o{"out"} and $$o{"out"} =~ /\A(?:yaml|json)/ 1 0 1
Condition33%1/3
$$o{"out"} and $$o{"out"} =~ /\A(?:yaml|json)/
!ll&&!rl&&r
001
MC/DC0%0/2
$$o{"out"} and $$o{"out"} =~ /\A(?:yaml|json)/
$$o{"out"} $$o{"out"} =~ /\A(?:yaml|json)/
Truth table33%1/3
A and B
A= $$o{"out"}B= $$o{"out"} =~ /\A(?:yaml|json)/
ABresult
0X0
100
111
393 0 push @rows, map { [ ( $multi ? $ns : () ), $_, $s->{$_}{type} // 'ClusterIP', $s->{$_}{cluster_ip} // '10.43.' . ( 10 + hex( substr( Digest::SHA::sha1_hex($_), 0, 2 ) ) % 200 ) . '.' . ( 10 + hex( substr( Digest::SHA::sha1_hex($_), 2, 2 ) ) % 240 ), '<none>',
394 0 ▶ join( ',', map { "$_->{port}/TCP" } @{ $s->{$_}{ports} || [] } ), '41d', ( ( $o->{out} // '' ) eq 'wide' ? _labels_text( $s->{$_}{selector} ) : () ) ] } @n;
Branch: 2 branches
BranchTrueFalseTotal
$multi ? : 0 0 0
($$o{'out'} // '') eq 'wide' ? : 0 0 0
Condition0%0/8
$$s{$_}{"type"} // "ClusterIP"
l!l
00
$$s{$_}{"cluster_ip"} // '10.43.' . (10 + hex(substr &Digest::SHA::sha1_hex($_), 0, 2) % 200) . '.' . (10 + hex(substr &Digest::SHA::sha1_hex($_), 2, 2) % 240)
l!l
00
$$s{$_}{'ports'} || []
l!l
00
$$o{"out"} // ""
l!l
00
MC/DC0%0/1
$$s{$_}{"type"} // "ClusterIP"
$$s{$_}{"type"}
MC/DC0%0/1
$$s{$_}{"cluster_ip"} // '10.43.' . (10 + hex(substr &Digest::SHA::sha1_hex($_), 0, 2) % 200) . '.' . (10 + hex(substr &Digest::SHA::sha1_hex($_), 2, 2) % 240)
$$s{$_}{"cluster_ip"}
MC/DC0%0/1
$$s{$_}{'ports'} || []
$$s{$_}{'ports'}
MC/DC0%0/1
$$o{"out"} // ""
$$o{"out"}
Truth table0%0/2
A
A= $$s{$_}{"type"}
Aresult
11
00
Truth table0%0/2
A
A= $$s{$_}{"cluster_ip"}
Aresult
11
00
Truth table0%0/2
A
A= $$s{$_}{'ports'}
Aresult
11
00
Truth table0%0/2
A
A= $$o{"out"}
Aresult
11
00
395 0 ▶ unshift @rows, [ ( $multi ? 'NAMESPACE' : () ), qw( NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE ), ( ( $o->{out} // '' ) eq 'wide' ? 'SELECTOR' : () ) ] if @rows;
Branch: 3 branches
BranchTrueFalseTotal
if @rows 0 0 0
$multi ? : 0 0 0
($$o{'out'} // '') eq 'wide' ? : 0 0 0
Condition0%0/2
$$o{"out"} // ""
l!l
00
MC/DC0%0/1
$$o{"out"} // ""
$$o{"out"}
Truth table0%0/2
A
A= $$o{"out"}
Aresult
11
00
396 }
397 elsif ( $kind eq 'endpoints' ) {
398 3 ▶ my $s = $obj->{services} || {};
Condition50%1/2
$$obj{'services'} || {}
l!l
30
MC/DC0%0/1
$$obj{'services'} || {}
$$obj{'services'}
Truth table50%1/2
A
A= $$obj{'services'}
Aresult
11
00
399 3 ▶ my @n = grep { !defined $name || $_ eq $name } sort keys %$s;
Condition33%1/3
!defined($name) || $_ eq $name
l!l&&r!l&&!r
030
MC/DC0%0/2
!defined($name) || $_ eq $name
!defined($name) $_ eq $name
Truth table33%1/3
not(A) || B
A= !defined($name)B= $_ eq $name
ABresult
1X1
011
000
400 3 ▶ return ( qq{Error from server (NotFound): endpoints "$name" not found}, 0 ) if defined $name && !@n;
Branch: 1 branch
BranchTrueFalseTotal
if defined $name and not @n 0 3 3
Condition33%1/3
defined $name and not @n
!ll&&!rl&&r
030
MC/DC0%0/2
defined $name and not @n
defined $name not @n
Truth table33%1/3
A and not(B)
A= defined $nameB= not @n
ABresult
0X0
100
111
401 push @rows, map {
402 3 my $svc = $s->{$_};
403 3 my @e = _endpoints( $k, $ns, $_ );
404 3 ▶ my @t = map { my $p = $_; map {"$_->{ip}:$p->{target}"} @e } @{ $svc->{ports} || [] };
Condition50%1/2
$$svc{'ports'} || []
l!l
30
MC/DC0%0/1
$$svc{'ports'} || []
$$svc{'ports'}
Truth table50%1/2
A
A= $$svc{'ports'}
Aresult
11
00
405 3 ▶ [ ( $multi ? $ns : () ), $_, @t ? join( ',', @t ) : '<none>', '41d' ];
Branch: 2 branches
BranchTrueFalseTotal
$multi ? : 0 3 3
@t ? : 2 1 3
406 } @n;
407 3 ▶ unshift @rows, [ ( $multi ? 'NAMESPACE' : () ), qw( NAME ENDPOINTS AGE ) ] if @rows;
Branch: 2 branches
BranchTrueFalseTotal
if @rows 3 0 3
$multi ? : 0 3 3
408 }
409 elsif ( $kind eq 'pvcs' ) {
410 2 ▶ my $p = $obj->{pvcs} || {};
Condition50%1/2
$$obj{'pvcs'} || {}
l!l
20
MC/DC0%0/1
$$obj{'pvcs'} || {}
$$obj{'pvcs'}
Truth table50%1/2
A
A= $$obj{'pvcs'}
Aresult
11
00
411 2 ▶ my @n = grep { !defined $name || $_ eq $name } sort keys %$p;
Condition66%2/3
!defined($name) || $_ eq $name
l!l&&r!l&&!r
110
MC/DC0%0/2
!defined($name) || $_ eq $name
!defined($name) $_ eq $name
Truth table66%2/3
not(A) || B
A= !defined($name)B= $_ eq $name
ABresult
1X1
011
000
412 2 ▶ return ( qq{Error from server (NotFound): persistentvolumeclaims "$name" not found}, 0 ) if defined $name && !@n;
Branch: 1 branch
BranchTrueFalseTotal
if defined $name and not @n 0 2 2
Condition66%2/3
defined $name and not @n
!ll&&!rl&&r
110
MC/DC0%0/2
defined $name and not @n
defined $name not @n
Truth table66%2/3
A and not(B)
A= defined $nameB= not @n
ABresult
0X0
100
111
413 0 ▶ return _structured( $o, 'pvcs', { map { $_ => $p->{$_} } @n } ) if $o->{out} && $o->{out} =~ /\A(?:yaml|json)/;
Branch: 1 branch
BranchTrueFalseTotal
if $$o{"out"} and $$o{"out"} =~ /\A(?:yaml|json)/ 0 2 2
Condition33%1/3
$$o{"out"} and $$o{"out"} =~ /\A(?:yaml|json)/
!ll&&!rl&&r
200
MC/DC0%0/2
$$o{"out"} and $$o{"out"} =~ /\A(?:yaml|json)/
$$o{"out"} $$o{"out"} =~ /\A(?:yaml|json)/
Truth table33%1/3
A and B
A= $$o{"out"}B= $$o{"out"} =~ /\A(?:yaml|json)/
ABresult
0X0
100
111
414 push @rows, map {
415 2 my $ph = _pvc_phase( $k, $ns, $_ );
416 0 ▶ my $sc = $p->{$_}{storage_class} // ( grep { $k->{storageclasses}{$_}{default} } sort keys %{ $k->{storageclasses} || {} } )[0] // '';
Condition28%2/7
($$p{$_}{"storage_class"} // (grep {$$k{"storageclasses"}{$_}{"default"};} sort(keys %{$$k{"storageclasses"} or {};}))[0]) // ""
l!l
20
$$p{$_}{"storage_class"} // (grep {$$k{"storageclasses"}{$_}{"default"};} sort(keys %{$$k{"storageclasses"} or {};}))[0]
l!l&&r!l&&!r
200
$$k{'storageclasses'} || {}
l!l
00
MC/DC0%0/2
($$p{$_}{"storage_class"} // (grep {$$k{"storageclasses"}{$_}{"default"};} sort(keys %{$$k{"storageclasses"} or {};}))[0]) // ""
$$p{$_}{"storage_class"} (grep {$$k{"storageclasses"}{$_}{"default"};} sort(keys %{$$k{"storageclasses"} or {};}))[0]
MC/DC0%0/1
$$k{'storageclasses'} || {}
$$k{'storageclasses'}
Truth table33%1/3
A // B
A= $$p{$_}{"storage_class"}B= (grep {$$k{"storageclasses"}{$_}{"default"};} sort(keys %{$$k{"storageclasses"} or {};}))[0]
ABresult
1X1
011
000
Truth table0%0/2
A
A= $$k{'storageclasses'}
Aresult
11
00
417 2 ▶ [ ( $multi ? $ns : () ), $_, $ph, $ph eq 'Bound' ? 'pvc-' . substr( _hash( [ $ns, $_ ] ), 0, 8 ) : '', $ph eq 'Bound' ? $p->{$_}{size} : '', $ph eq 'Bound' ? 'RWO' : '', $sc, '<unset>', '2d' ];
Branch: 4 branches
BranchTrueFalseTotal
$multi ? : 0 2 2
$ph eq 'Bound' ? : 1 1 2
$ph eq 'Bound' ? : 1 1 2
$ph eq 'Bound' ? : 1 1 2
418 } @n;
419 2 ▶ unshift @rows, [ ( $multi ? 'NAMESPACE' : () ), qw( NAME STATUS VOLUME CAPACITY ACCESS MODES STORAGECLASS VOLUMEATTRIBUTESCLASS AGE ) ] if @rows;
Branch: 2 branches
BranchTrueFalseTotal
if @rows 2 0 2
$multi ? : 0 2 2
420 2 ▶ $_ = [ @$_[ 0 .. ( $multi ? 4 : 3 ) ], 'ACCESS MODES', @$_[ ( $multi ? 7 : 6 ) .. $#$_ ] ] for grep { $_->[ $multi ? 5 : 4 ] eq 'ACCESS' } @rows;
Branch: 3 branches
BranchTrueFalseTotal
$multi ? : 0 4 4
$multi ? : 0 2 2
$multi ? : 0 2 2
421 }
422 elsif ( $kind eq 'networkpolicies' ) {
423 0 ▶ my $p = $obj->{networkpolicies} || {};
Condition0%0/2
$$obj{'networkpolicies'} || {}
l!l
00
MC/DC0%0/1
$$obj{'networkpolicies'} || {}
$$obj{'networkpolicies'}
Truth table0%0/2
A
A= $$obj{'networkpolicies'}
Aresult
11
00
424 0 ▶ my @n = grep { !defined $name || $_ eq $name } sort keys %$p;
Condition0%0/3
!defined($name) || $_ eq $name
l!l&&r!l&&!r
000
MC/DC0%0/2
!defined($name) || $_ eq $name
!defined($name) $_ eq $name
Truth table0%0/3
not(A) || B
A= !defined($name)B= $_ eq $name
ABresult
1X1
011
000
425 0 ▶ return ( qq{Error from server (NotFound): networkpolicies.networking.k8s.io "$name" not found}, 0 ) if defined $name && !@n;
Branch: 1 branch
BranchTrueFalseTotal
if defined $name and not @n 0 0 0
Condition0%0/3
defined $name and not @n
!ll&&!rl&&r
000
MC/DC0%0/2
defined $name and not @n
defined $name not @n
Truth table0%0/3
A and not(B)
A= defined $nameB= not @n
ABresult
0X0
100
111
426 0 ▶ return _structured( $o, 'networkpolicies', { map { $_ => $p->{$_} } @n } ) if $o->{out} && $o->{out} =~ /\A(?:yaml|json)/;
Branch: 1 branch
BranchTrueFalseTotal
if $$o{"out"} and $$o{"out"} =~ /\A(?:yaml|json)/ 0 0 0
Condition0%0/3
$$o{"out"} and $$o{"out"} =~ /\A(?:yaml|json)/
!ll&&!rl&&r
000
MC/DC0%0/2
$$o{"out"} and $$o{"out"} =~ /\A(?:yaml|json)/
$$o{"out"} $$o{"out"} =~ /\A(?:yaml|json)/
Truth table0%0/3
A and B
A= $$o{"out"}B= $$o{"out"} =~ /\A(?:yaml|json)/
ABresult
0X0
100
111
427 0 ▶ push @rows, map { [ ( $multi ? $ns : () ), $_, _labels_text( $p->{$_}{pod_selector} ) =~ s/\A<none>\z/<none>/r, '41d' ] } @n;
Branch: 1 branch
BranchTrueFalseTotal
$multi ? : 0 0 0
428 0 ▶ unshift @rows, [ ( $multi ? 'NAMESPACE' : () ), qw( NAME POD-SELECTOR AGE ) ] if @rows;
Branch: 2 branches
BranchTrueFalseTotal
if @rows 0 0 0
$multi ? : 0 0 0
429 }
430 ▶ elsif ( $kind eq 'secrets' || $kind eq 'configmaps' ) {
Condition66%2/3
$kind eq "secrets" or $kind eq "configmaps"
l!l&&r!l&&!r
605
MC/DC50%1/2
$kind eq "secrets" or $kind eq "configmaps"
$kind eq "secrets" $kind eq "configmaps"
Truth table66%2/3
A or B
A= $kind eq "secrets"B= $kind eq "configmaps"
ABresult
1X1
011
000
431 6 ▶ my $p = $kind eq 'secrets' ? _secrets_all( $k, $ns ) : $obj->{$kind} || {};
Branch: 1 branch
BranchTrueFalseTotal
$kind eq 'secrets' ? : 6 0 6
Condition0%0/2
$$obj{$kind} or {}
l!l
00
MC/DC0%0/1
$$obj{$kind} or {}
$$obj{$kind}
Truth table0%0/2
A
A= $$obj{$kind}
Aresult
11
00
432 6 ▶ my @n = grep { !defined $name || $_ eq $name } sort keys %$p;
Condition100%3/3
!defined($name) || $_ eq $name
l!l&&r!l&&!r
4516
MC/DC100%2/2
!defined($name) || $_ eq $name
!defined($name) $_ eq $name
Truth table100%3/3
not(A) || B
A= !defined($name)B= $_ eq $name
ABresult
1X1
011
000
433 6 ▶ return ( qq{Error from server (NotFound): $kind "$name" not found}, 0 ) if defined $name && !@n;
Branch: 1 branch
BranchTrueFalseTotal
if defined $name and not @n 0 6 6
Condition66%2/3
defined $name and not @n
!ll&&!rl&&r
150
MC/DC0%0/2
defined $name and not @n
defined $name not @n
Truth table66%2/3
A and not(B)
A= defined $nameB= not @n
ABresult
0X0
100
111
434 6 ▶ return _structured( $o, $kind, { map { $_ => $p->{$_} } @n } ) if $o->{out} && $o->{out} =~ /\A(?:yaml|json)/;
Branch: 1 branch
BranchTrueFalseTotal
if $$o{"out"} and $$o{"out"} =~ /\A(?:yaml|json)/ 4 2 6
Condition66%2/3
$$o{"out"} and $$o{"out"} =~ /\A(?:yaml|json)/
!ll&&!rl&&r
204
MC/DC50%1/2
$$o{"out"} and $$o{"out"} =~ /\A(?:yaml|json)/
$$o{"out"} $$o{"out"} =~ /\A(?:yaml|json)/
Truth table66%2/3
A and B
A= $$o{"out"}B= $$o{"out"} =~ /\A(?:yaml|json)/
ABresult
0X0
100
111
435 2 ▶ push @rows, map { [ ( $multi ? $ns : () ), $_, ( $kind eq 'secrets' ? _secret_type( $p->{$_} ) : () ), scalar( grep { !/\A_/ } keys %{ $p->{$_} } ), '41d' ] } @n;
Branch: 2 branches
BranchTrueFalseTotal
$multi ? : 0 5 5
$kind eq 'secrets' ? : 5 0 5
436 2 ▶ unshift @rows, [ ( $multi ? 'NAMESPACE' : () ), 'NAME', ( $kind eq 'secrets' ? 'TYPE' : () ), 'DATA', 'AGE' ] if @rows;
Branch: 3 branches
BranchTrueFalseTotal
if @rows 2 0 2
$multi ? : 0 2 2
$kind eq 'secrets' ? : 2 0 2
437 }
438 elsif ( $kind eq 'events' ) {
439 4 my @e = map { my $p = $_; $p->{reason} ? [ '2m', $p->{reason} eq 'NotReady' || $p->{reason} eq 'CrashLoopBackOff' || $p->{reason} eq 'ImagePullBackOff' || $p->{reason} eq 'Unschedulable' ? 'Warning' : 'Normal',
440 { NotReady => 'Unhealthy', CrashLoopBackOff => 'BackOff', ImagePullBackOff => 'Failed', Unschedulable => 'FailedScheduling', CreateContainerConfigError => 'Failed' }->{ $p->{reason} } // $p->{reason},
441 14 ▶ "pod/$p->{name}", $p->{reason} eq 'ImagePullBackOff' ? qq{Failed to pull image "$p->{container}{image}": rpc error: code = NotFound desc = failed to pull and unpack image "$p->{container}{image}": failed to resolve reference "$p->{container}{image}": $p->{container}{image}: not found} : $p->{message} ] : () } _pods( $k, $ns );
Branch: 3 branches
BranchTrueFalseTotal
$$p{'reason'} ? : 0 14 14
$$p{'reason'} eq 'NotReady' || $$p{'reason'} eq 'CrashLoopBackOff' || $$p{'reason'} eq 'ImagePullBackOff' || $$p{'reason'} eq 'Unschedulable' ? : 0 0 0
$$p{'reason'} eq 'ImagePullBackOff' ? : 0 0 0
Condition0%0/12
$$p{"reason"} eq "NotReady" or $$p{"reason"} eq "CrashLoopBackOff" or $$p{"reason"} eq "ImagePullBackOff" or $$p{"reason"} eq "Unschedulable"
l!l&&r!l&&!r
000
$$p{"reason"} eq "NotReady" or $$p{"reason"} eq "CrashLoopBackOff" or $$p{"reason"} eq "ImagePullBackOff"
l!l&&r!l&&!r
000
$$p{"reason"} eq "NotReady" or $$p{"reason"} eq "CrashLoopBackOff"
l!l&&r!l&&!r
000
{"NotReady", "Unhealthy", "CrashLoopBackOff", "BackOff", "ImagePullBackOff", "Failed", "Unschedulable", "FailedScheduling", "CreateContainerConfigError", "Failed"}->{$$p{"reason"}} // $$p{"reason"}
l!l&&r!l&&!r
000
MC/DC0%0/4
$$p{"reason"} eq "NotReady" or $$p{"reason"} eq "CrashLoopBackOff" or $$p{"reason"} eq "ImagePullBackOff" or $$p{"reason"} eq "Unschedulable"
$$p{"reason"} eq "NotReady" $$p{"reason"} eq "CrashLoopBackOff" $$p{"reason"} eq "ImagePullBackOff" $$p{"reason"} eq "Unschedulable"
MC/DC0%0/2
{"NotReady", "Unhealthy", "CrashLoopBackOff", "BackOff", "ImagePullBackOff", "Failed", "Unschedulable", "FailedScheduling", "CreateContainerConfigError", "Failed"}->{$$p{"reason"}} // $$p{"reason"}
{"NotReady", "Unhealthy", "CrashLoopBackOff", "BackOff", "ImagePullBackOff", "Failed", "Unschedulable", "FailedScheduling", "CreateContainerConfigError", "Failed"}->{$$p{"reason"}} $$p{"reason"}
Truth table0%0/5
A or B or C or D
A= $$p{"reason"} eq "NotReady"B= $$p{"reason"} eq "CrashLoopBackOff"C= $$p{"reason"} eq "ImagePullBackOff"D= $$p{"reason"} eq "Unschedulable"
ABCDresult
1XXX1
01XX1
001X1
00011
00000
Truth table0%0/3
A // B
A= {"NotReady", "Unhealthy", "CrashLoopBackOff", "BackOff", "ImagePullBackOff", "Failed", "Unschedulable", "FailedScheduling", "CreateContainerConfigError", "Failed"}->{$$p{"reason"}}B= $$p{"reason"}
ABresult
1X1
011
000
442 10 push @e, map { my $t = $obj->{deployments}{$_}{template}; _sa_exists( $k, $ns, $t->{service_account} ) ? ()
443 : [ '2m', 'Warning', 'FailedCreate', "replicaset/$_-" . _hash( [ $t, $obj->{deployments}{$_}{restarted_at} // '' ] ),
444 10 ▶ qq{Error creating: pods "$_-} . _hash( [ $t, $obj->{deployments}{$_}{restarted_at} // '' ] ) . qq{-" is forbidden: error looking up service account $ns/$t->{service_account}: serviceaccount "$t->{service_account}" not found} ] }
Branch: 1 branch
BranchTrueFalseTotal
_sa_exists($k, $ns, $$t{'service_account'}) ? : 9 1 10
Condition50%2/4
$$obj{"deployments"}{$_}{"restarted_at"} // ""
l!l
01
$$obj{"deployments"}{$_}{"restarted_at"} // ""
l!l
01
MC/DC0%0/1
$$obj{"deployments"}{$_}{"restarted_at"} // ""
$$obj{"deployments"}{$_}{"restarted_at"}
MC/DC0%0/1
$$obj{"deployments"}{$_}{"restarted_at"} // ""
$$obj{"deployments"}{$_}{"restarted_at"}
Truth table50%1/2
A
A= $$obj{"deployments"}{$_}{"restarted_at"}
Aresult
11
00
Truth table50%1/2
A
A= $$obj{"deployments"}{$_}{"restarted_at"}
Aresult
11
00
445 4 ▶ sort keys %{ $obj->{deployments} || {} };
Condition50%1/2
$$obj{'deployments'} || {}
l!l
40
MC/DC0%0/1
$$obj{'deployments'} || {}
$$obj{'deployments'}
Truth table50%1/2
A
A= $$obj{'deployments'}
Aresult
11
00
446 4 ▶ push @e, map { _pvc_phase( $k, $ns, $_ ) eq 'Pending' ? [ '2m', 'Warning', 'ProvisioningFailed', "persistentvolumeclaim/$_", 'storageclass.storage.k8s.io "' . ( $obj->{pvcs}{$_}{storage_class} // '' ) . '" not found' ] : () } sort keys %{ $obj->{pvcs} || {} };
Branch: 1 branch
BranchTrueFalseTotal
_pvc_phase($k, $ns, $_) eq 'Pending' ? : 3 0 3
Condition75%3/4
$$obj{"pvcs"}{$_}{"storage_class"} // ""
l!l
30
$$obj{'pvcs'} || {}
l!l
31
MC/DC0%0/1
$$obj{"pvcs"}{$_}{"storage_class"} // ""
$$obj{"pvcs"}{$_}{"storage_class"}
MC/DC100%1/1
$$obj{'pvcs'} || {}
$$obj{'pvcs'}
Truth table50%1/2
A
A= $$obj{"pvcs"}{$_}{"storage_class"}
Aresult
11
00
Truth table100%2/2
A
A= $$obj{'pvcs'}
Aresult
11
00
447 4 ▶ push @rows, map { [ ( $multi ? $ns : () ), @$_ ] } @e;
Branch: 1 branch
BranchTrueFalseTotal
$multi ? : 0 4 4
448 4 ▶ unshift @rows, [ ( $multi ? 'NAMESPACE' : () ), qw( LAST SEEN TYPE REASON OBJECT MESSAGE ) ] if @rows;
Branch: 2 branches
BranchTrueFalseTotal
if @rows 4 0 4
$multi ? : 0 4 4
449 4 ▶ $_ = [ @$_[ 0 .. ( $multi ? 0 : -1 ) ], 'LAST SEEN', @$_[ ( $multi ? 3 : 2 ) .. $#$_ ] ] for grep { $_->[ $multi ? 1 : 0 ] eq 'LAST' } @rows;
Branch: 3 branches
BranchTrueFalseTotal
$multi ? : 0 8 8
$multi ? : 0 4 4
$multi ? : 0 4 4
450 }
451 elsif ( $kind eq 'replicasets' ) {
452 1 my @rs = _replicasets( $k, $ns );
453 0 ▶ @rs = grep { $_->{name} eq $name } @rs if defined $name;
Branch: 1 branch
BranchTrueFalseTotal
if defined $name 0 1 1
454 1 ▶ return ( qq{Error from server (NotFound): replicasets.apps "$name" not found}, 0 ) if defined $name && !@rs;
Branch: 1 branch
BranchTrueFalseTotal
if defined $name and not @rs 0 1 1
Condition33%1/3
defined $name and not @rs
!ll&&!rl&&r
100
MC/DC0%0/2
defined $name and not @rs
defined $name not @rs
Truth table33%1/3
A and not(B)
A= defined $nameB= not @rs
ABresult
0X0
100
111
455 1 ▶ push @rows, map { [ ( $multi ? $ns : () ), $_->{name}, $_->{desired}, $_->{current}, $_->{ready}, '12m' ] } @rs;
Branch: 1 branch
BranchTrueFalseTotal
$multi ? : 0 4 4
456 1 ▶ unshift @rows, [ ( $multi ? 'NAMESPACE' : () ), qw( NAME DESIRED CURRENT READY AGE ) ] if @rows;
Branch: 2 branches
BranchTrueFalseTotal
if @rows 1 0 1
$multi ? : 0 1 1
457 }
458 25 ▶ if (@rows) { shift @rows if @all; push @all, @rows } # -A: eine Tabelle, ein Kopf
Branch: 2 branches
BranchTrueFalseTotal
if (@rows) 24 1 25
if @all 1 23 24
459 }
460 24 ▶ push @out, _cols(@all) if @all;
Branch: 1 branch
BranchTrueFalseTotal
if @all 23 1 24
461 24 ▶ return ( @out ? join( "\n", @out ) : ( $o->{all} ? 'No resources found' : "No resources found in $o->{ns} namespace." ), 1 );
Branch: 2 branches
BranchTrueFalseTotal
@out ? : 23 1 24
$$o{'all'} ? : 0 1 1
462 }
463  
464 64 ▶sub _label_sel {
Subroutine _label_sel: called CC=6 SCAR=18.0
465 64 my ( $sel, $l ) = @_;
466 64 ▶ return 1 unless defined $sel;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $sel 43 21 64
467 21 for my $part ( split /,/, $sel ) {
468 21 my ( $k, $v ) = split /=/, $part, 2;
469 21 ▶ return 0 unless defined $l->{$k} && ( !defined $v || $l->{$k} eq $v );
Branch: 1 branch
BranchTrueFalseTotal
unless defined $$l{$k} and !defined($v) || $$l{$k} eq $v 11 10 21
Condition66%4/6
defined $$l{$k} and !defined($v) || $$l{$k} eq $v
!ll&&!rl&&r
01110
not defined $v or $$l{$k} eq $v
l!l&&r!l&&!r
01011
MC/DC33%1/3
defined $$l{$k} and !defined($v) || $$l{$k} eq $v
defined $$l{$k} not defined $v $$l{$k} eq $v
Truth table50%2/4
A and not(B) or C
A= defined $$l{$k}B= not defined $vC= $$l{$k} eq $v
ABCresult
0XX0
1000
11X1
1011
470 }
471 10 return 1;
472 }
473  
474 0 ▶sub _pod_obj {
Subroutine _pod_obj: not called CC=3 SCAR=24.8
475 0 my ($p) = @_;
476 return { labels => $p->{labels}, containers => $p->{template}{containers},
477 0 ▶ status => { phase => $p->{phase}, ready => $p->{ready} ? JSON::MaybeXS::true() : JSON::MaybeXS::false(), ( $p->{reason} ? ( reason => $p->{reason} ) : () ) } };
Branch: 2 branches
BranchTrueFalseTotal
$$p{'ready'} ? : 0 0 0
$$p{'reason'} ? : 0 0 0
478 }
479  
480 17 ▶sub _structured {
Subroutine _structured: called CC=3 SCAR=11.0
481 17 my ( $o, $kind, $objs ) = @_;
482 17 my @items = map { _api_obj( $kind, $_, $objs->{$_}, $o->{ns} ) } sort keys %$objs;
483 17 ▶ my $data = @items == 1 ? $items[0] : { apiVersion => 'v1', kind => 'List', items => \@items };
Branch: 1 branch
BranchTrueFalseTotal
@items == 1 ? : 13 4 17
484 17 ▶ return ( $o->{out} =~ /\Ajson/ ? $OUT_JSON->encode($data) =~ s/\s+\z//r : do { local $YAML::XS::Boolean = q{JSON::PP}; YAML::XS::Dump($data) } =~ s/\A---\n//r =~ s/\s+\z//r, 1 );
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Branch: 1 branch
BranchTrueFalseTotal
$$o{'out'} =~ /\Ajson/ ? : 12 5 17
485 }
486  
487 # Objekt des Zustands -> Form der API (fuer -o yaml|json); vereinfacht
488 51 ▶sub _api_obj {
Subroutine _api_obj: called CC=28 SCAR=40.9
489 51 my ( $kind, $name, $x, $ns ) = @_;
490 51 ▶ my $meta = { name => $name, ( !$CLUSTER{$kind} ? ( namespace => $ns ) : () ) };
Branch: 1 branch
BranchTrueFalseTotal
!$Langertha::Holmgang::Sim::Linux::Kubernetes::CLUSTER{$kind} ? : 51 0 51
491 51 ▶ if ( $GEN{$kind} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($Langertha::Holmgang::Sim::Linux::Kubernetes::GEN{$kind}) 7 44 51
492 # tiefe Kopie: ein JSON-Patch aendert das Ergebnis an Ort und Stelle
493 7 my %x = %{ JSON::MaybeXS->new( canonical => 1 )->decode( JSON::MaybeXS->new( canonical => 1 )->encode($x) ) };
494 7 ▶ my $m = delete $x{metadata} || {};
Condition100%2/2
delete $x{'metadata'} || {}
l!l
43
MC/DC100%1/1
delete $x{'metadata'} || {}
delete $x{'metadata'}
Truth table100%2/2
A
A= delete $x{'metadata'}
Aresult
11
00
495 7 my $st = delete $x{_status};
496 7 delete @x{ grep {/\A_/} keys %x }; # nur fuer die Simulation
497 7 ▶ return { apiVersion => $GEN{$kind}[0], kind => $GEN{$kind}[1], metadata => { %$meta, %$m }, %x, ( $st ? ( status => $st ) : () ) };
Branch: 1 branch
BranchTrueFalseTotal
$st ? : 2 5 7
498 }
499 44 ▶ if ( $kind eq 'deployments' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($kind eq "deployments") 31 13 44
500 return { apiVersion => 'apps/v1', kind => 'Deployment', metadata => { %$meta, generation => $x->{generation} // 1 },
501 spec => { replicas => $x->{replicas}, selector => { matchLabels => $x->{selector} },
502 template => { metadata => { labels => $x->{template}{labels}, ( $x->{template}{annotations} ? ( annotations => $x->{template}{annotations} ) : () ) },
503 31 ▶ spec => { ( defined $x->{template}{service_account} ? ( serviceAccountName => $x->{template}{service_account} ) : () ), containers => [ map { _api_container($_) } @{ $x->{template}{containers} } ],
Branch: 1 branch
BranchTrueFalseTotal
grep({@{$$_{'volumes'} or [];};} @{$$x{'template'}{'containers'};}) ? : 0 31 31
504 31 ▶ ( grep { @{ $_->{volumes} || [] } } @{ $x->{template}{containers} } )
Condition50%1/2
$$_{'volumes'} || []
l!l
031
MC/DC0%0/1
$$_{'volumes'} || []
$$_{'volumes'}
Truth table50%1/2
A
A= $$_{'volumes'}
Aresult
11
00
505 0 ▶ ? ( volumes => [ map { { name => $_->{claim}, persistentVolumeClaim => { claimName => $_->{claim} } } } map { @{ $_->{volumes} || [] } } @{ $x->{template}{containers} } ] ) : () } } } };
Branch: 2 branches
BranchTrueFalseTotal
$$x{'template'}{'annotations'} ? : 1 30 31
defined $$x{'template'}{'service_account'} ? : 1 30 31
Condition50%2/4
$$x{"generation"} // 1
l!l
1516
$$_{'volumes'} || []
l!l
00
MC/DC100%1/1
$$x{"generation"} // 1
$$x{"generation"}
MC/DC0%0/1
$$_{'volumes'} || []
$$_{'volumes'}
Truth table100%2/2
A
A= $$x{"generation"}
Aresult
11
00
Truth table0%0/2
A
A= $$_{'volumes'}
Aresult
11
00
506 }
507 13 ▶ if ( $kind eq 'services' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($kind eq "services") 4 9 13
508 return { apiVersion => 'v1', kind => 'Service', metadata => $meta,
509 4 ▶ spec => { type => $x->{type} // 'ClusterIP', selector => $x->{selector}, ports => [ map { { port => $_->{port}, targetPort => $_->{target}, protocol => 'TCP', ( $_->{name} ? ( name => $_->{name} ) : () ) } } @{ $x->{ports} || [] } ] } };
Branch: 1 branch
BranchTrueFalseTotal
$$_{'name'} ? : 6 0 6
Condition50%2/4
$$x{"type"} // "ClusterIP"
l!l
04
$$x{'ports'} || []
l!l
40
MC/DC0%0/1
$$x{"type"} // "ClusterIP"
$$x{"type"}
MC/DC0%0/1
$$x{'ports'} || []
$$x{'ports'}
Truth table50%1/2
A
A= $$x{"type"}
Aresult
11
00
Truth table50%1/2
A
A= $$x{'ports'}
Aresult
11
00
510 }
511 9 ▶ if ( $kind eq 'secrets' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($kind eq "secrets") 8 1 9
512 8 return { apiVersion => 'v1', kind => 'Secret', metadata => $meta, type => _secret_type($x), data => { map { $_ => MIME::Base64::encode_base64( $x->{$_}, '' ) } grep { !/\A_/ } keys %$x } };
513 }
514 1 ▶ return { apiVersion => 'v1', kind => 'ConfigMap', metadata => $meta, data => $x } if $kind eq 'configmaps';
Branch: 1 branch
BranchTrueFalseTotal
if $kind eq "configmaps" 0 1 1
515 1 ▶ if ( $kind eq 'pvcs' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($kind eq "pvcs") 0 1 1
516 return { apiVersion => 'v1', kind => 'PersistentVolumeClaim', metadata => $meta,
517 0 ▶ spec => { accessModes => ['ReadWriteOnce'], resources => { requests => { storage => $x->{size} } }, ( defined $x->{storage_class} ? ( storageClassName => $x->{storage_class} ) : () ) } };
Branch: 1 branch
BranchTrueFalseTotal
defined $$x{'storage_class'} ? : 0 0 0
518 }
519 1 ▶ if ( $kind eq 'networkpolicies' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($kind eq "networkpolicies") 1 0 1
520 return { apiVersion => 'networking.k8s.io/v1', kind => 'NetworkPolicy', metadata => $meta,
521 spec => { podSelector => { matchLabels => $x->{pod_selector} || {} }, policyTypes => ['Ingress'],
522 1 ▶ ingress => [ map { my $r = $_; +{ ( $r->{from} ? ( from => [ map { { podSelector => { matchLabels => $_ } } } @{ $r->{from} } ] ) : () ),
Branch: 1 branch
BranchTrueFalseTotal
$$r{'ports'} ? : 1 0 1
523 1 ▶ ( $r->{ports} ? ( ports => [ map { { protocol => 'TCP', port => $_ } } @{ $r->{ports} } ] ) : () ) } } @{ $x->{ingress} || [] } ] } };
Branch: 1 branch
BranchTrueFalseTotal
$$r{'from'} ? : 1 0 1
Condition50%2/4
$$x{'pod_selector'} || {}
l!l
10
$$x{'ingress'} || []
l!l
10
MC/DC0%0/1
$$x{'pod_selector'} || {}
$$x{'pod_selector'}
MC/DC0%0/1
$$x{'ingress'} || []
$$x{'ingress'}
Truth table50%1/2
A
A= $$x{'pod_selector'}
Aresult
11
00
Truth table50%1/2
A
A= $$x{'ingress'}
Aresult
11
00
524 }
525 0 ▶ if ( $kind eq 'storageclasses' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($kind eq "storageclasses") 0 0 0
526 return { apiVersion => 'storage.k8s.io/v1', kind => 'StorageClass', metadata => { %$meta, ( $x->{default} ? ( annotations => { 'storageclass.kubernetes.io/is-default-class' => 'true' } ) : () ) },
527 0 ▶ provisioner => $x->{provisioner}, reclaimPolicy => 'Delete', volumeBindingMode => 'Immediate' };
Branch: 1 branch
BranchTrueFalseTotal
$$x{'default'} ? : 0 0 0
528 }
529 0 ▶ if ( $kind eq 'pods' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($kind eq "pods") 0 0 0
530 0 return { apiVersion => 'v1', kind => 'Pod', metadata => { %$meta, labels => $x->{labels} }, spec => { containers => [ map { _api_container($_) } @{ $x->{containers} } ] }, status => $x->{status} };
531 }
532 0 return $x;
533 }
534  
535 31 ▶sub _api_container {
Subroutine _api_container: called CC=11 SCAR=28.0
536 31 my ($c) = @_;
537 return {
538 name => $c->{name},
539 image => $c->{image},
540 31 ▶ ( $c->{ports} ? ( ports => [ map { { containerPort => $_, protocol => 'TCP' } } @{ $c->{ports} } ] ) : () ),
Branch: 1 branch
BranchTrueFalseTotal
$$c{'env'} ? : 25 6 31
541 ( $c->{env} ? ( env => [ map {
542 defined $_->{secret} ? { name => $_->{name}, valueFrom => { secretKeyRef => { name => $_->{secret}, key => $_->{key}, ( $_->{optional} ? ( optional => JSON::MaybeXS::true() ) : () ) } } }
543 : defined $_->{configmap} ? { name => $_->{name}, valueFrom => { configMapKeyRef => { name => $_->{configmap}, key => $_->{key} } } }
544 17 ▶ : { name => $_->{name}, value => $_->{value} } } @{ $c->{env} } ] ) : () ),
Branch: 5 branches
BranchTrueFalseTotal
defined $$_{'secret'} ? : 8 9 17
$$_{'optional'} ? : 8 0 8
defined $$_{'configmap'} ? : 0 9 9
$$c{'readiness'} ? : 8 23 31
$$c{'volumes'} ? : 0 31 31
Condition50%1/2
$$c{"readiness"}{"path"} // "/"
l!l
80
MC/DC0%0/1
$$c{"readiness"}{"path"} // "/"
$$c{"readiness"}{"path"}
Truth table50%1/2
A
A= $$c{"readiness"}{"path"}
Aresult
11
00
545 ( $c->{readiness} ? ( readinessProbe => { httpGet => { path => $c->{readiness}{path} // '/', port => $c->{readiness}{port} }, periodSeconds => 10 } ) : () ),
546 0 ▶ ( $c->{volumes} ? ( volumeMounts => [ map { { name => $_->{claim}, mountPath => $_->{mount} // '/data' } } @{ $c->{volumes} } ] ) : () ),
Branch: 1 branch
BranchTrueFalseTotal
$$c{'privileged'} ? : 0 31 31
Condition0%0/2
$$_{"mount"} // "/data"
l!l
00
MC/DC0%0/1
$$_{"mount"} // "/data"
$$_{"mount"}
Truth table0%0/2
A
A= $$_{"mount"}
Aresult
11
00
547 31 ▶ ( $c->{privileged} ? ( securityContext => { privileged => JSON::MaybeXS::true() } ) : () ),
Branch: 1 branch
BranchTrueFalseTotal
$$c{'ports'} ? : 31 0 31
548 };
549 }
550  
551 # API-Form -> Zustand (fuer apply/create/patch)
552 17 ▶sub _from_api {
Subroutine _from_api: called CC=58 SCAR=52.7
553 17 my ( $kind, $doc, $old ) = @_;
554 17 ▶ my $s = $doc->{spec} || {};
Condition100%2/2
$$doc{'spec'} || {}
l!l
116
MC/DC100%1/1
$$doc{'spec'} || {}
$$doc{'spec'}
Truth table100%2/2
A
A= $$doc{'spec'}
Aresult
11
00
555 17 ▶ if ( $GEN{$kind} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($Langertha::Holmgang::Sim::Linux::Kubernetes::GEN{$kind}) 5 12 17
556 5 my %d = %$doc;
557 5 delete @d{qw( apiVersion kind status )};
558 5 ▶ my $m = delete $d{metadata} || {};
Condition50%1/2
delete $d{'metadata'} || {}
l!l
50
MC/DC0%0/1
delete $d{'metadata'} || {}
delete $d{'metadata'}
Truth table50%1/2
A
A= delete $d{'metadata'}
Aresult
11
00
559 5 ▶ my %m = map { $_ => { %{ $m->{$_} } } } grep { ref $m->{$_} eq 'HASH' && %{ $m->{$_} } } qw( labels annotations );
Condition66%2/3
ref $$m{$_} eq 'HASH' && %{$$m{$_};}
!ll&&!rl&&r
802
MC/DC50%1/2
ref $$m{$_} eq 'HASH' && %{$$m{$_};}
ref $$m{$_} eq 'HASH' %{$$m{$_};}
Truth table66%2/3
A && B
A= ref $$m{$_} eq 'HASH'B= %{$$m{$_};}
ABresult
0X0
100
111
560 5 ▶ delete $m{annotations}{'kubectl.kubernetes.io/last-applied-configuration'} if $m{annotations};
Branch: 1 branch
BranchTrueFalseTotal
if $m{"annotations"} 2 3 5
561 5 ▶ delete $m{annotations} if $m{annotations} && !%{ $m{annotations} };
Branch: 1 branch
BranchTrueFalseTotal
if $m{"annotations"} and not %{$m{"annotations"};} 0 5 5
Condition66%2/3
$m{"annotations"} and not %{$m{"annotations"};}
!ll&&!rl&&r
320
MC/DC0%0/2
$m{"annotations"} and not %{$m{"annotations"};}
$m{"annotations"} not %{$m{"annotations"};}
Truth table66%2/3
A and not(B)
A= $m{"annotations"}B= not %{$m{"annotations"};}
ABresult
0X0
100
111
562 5 ▶ $d{metadata} = \%m if %m;
Branch: 1 branch
BranchTrueFalseTotal
if %m 2 3 5
563 5 return \%d;
564 }
565 12 ▶ if ( $kind eq 'deployments' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($kind eq "deployments") 3 9 12
566 3 ▶ my $t = $s->{template} || {};
Condition50%1/2
$$s{'template'} || {}
l!l
30
MC/DC0%0/1
$$s{'template'} || {}
$$s{'template'}
Truth table50%1/2
A
A= $$s{'template'}
Aresult
11
00
567 3 ▶ my %olds = map { $_->{name} => $_ } @{ ( $old || {} )->{template}{containers} || [] };
Condition50%2/4
($old || {})->{'template'}{'containers'} || []
l!l
30
$old || {}
l!l
30
MC/DC0%0/1
($old || {})->{'template'}{'containers'} || []
$old
Truth table50%1/2
A
A= $old
Aresult
11
00
568 return {
569 3 ▶ %{ $old || {} },
Branch: 1 branch
BranchTrueFalseTotal
%{($$t{'metadata'} || {})->{'annotations'} or {};} ? : 1 2 3
Condition50%6/12
$old || {}
l!l
30
$$s{"replicas"} // 1
l!l
30
($$s{"selector"} || {})->{"matchLabels"} // {}
l!l
30
$$s{'selector'} || {}
l!l
30
($$t{"metadata"} || {})->{"labels"} // {}
l!l
30
$$t{'metadata'} || {}
l!l
30
MC/DC0%0/1
$old || {}
$old
MC/DC0%0/1
$$s{"replicas"} // 1
$$s{"replicas"}
MC/DC0%0/1
($$s{"selector"} || {})->{"matchLabels"} // {}
$$s{'selector'}
MC/DC0%0/1
($$t{"metadata"} || {})->{"labels"} // {}
$$t{'metadata'}
Truth table50%1/2
A
A= $old
Aresult
11
00
Truth table50%1/2
A
A= $$s{"replicas"}
Aresult
11
00
Truth table50%1/2
A
A= $$s{'selector'}
Aresult
11
00
Truth table50%1/2
A
A= $$t{'metadata'}
Aresult
11
00
570 replicas => $s->{replicas} // 1,
571 selector => ( $s->{selector} || {} )->{matchLabels} // {},
572 template => { labels => ( $t->{metadata} || {} )->{labels} // {},
573 3 ▶ ( %{ ( $t->{metadata} || {} )->{annotations} || {} } ? ( annotations => $t->{metadata}{annotations} ) : () ),
Branch: 1 branch
BranchTrueFalseTotal
defined(($$t{'spec'} || {})->{'serviceAccountName'}) ? : 0 3 3
Condition66%4/6
($$t{'metadata'} || {})->{'annotations'} || {}
l!l
12
$$t{'metadata'} || {}
l!l
30
$$t{'spec'} || {}
l!l
30
MC/DC0%0/1
($$t{'metadata'} || {})->{'annotations'} || {}
$$t{'metadata'}
MC/DC0%0/1
$$t{'spec'} || {}
$$t{'spec'}
Truth table50%1/2
A
A= $$t{'metadata'}
Aresult
11
00
Truth table50%1/2
A
A= $$t{'spec'}
Aresult
11
00
574 ( defined( ( $t->{spec} || {} )->{serviceAccountName} ) ? ( service_account => $t->{spec}{serviceAccountName} ) : () ),
575 3 ▶ containers => [ map { _container_from_api( $_, $olds{ $_->{name} }, $t->{spec}{volumes} ) } @{ ( $t->{spec} || {} )->{containers} || [] } ] },
Condition50%2/4
($$t{'spec'} || {})->{'containers'} || []
l!l
30
$$t{'spec'} || {}
l!l
30
MC/DC0%0/1
($$t{'spec'} || {})->{'containers'} || []
$$t{'spec'}
Truth table50%1/2
A
A= $$t{'spec'}
Aresult
11
00
576 };
577 }
578 9 ▶ if ( $kind eq 'services' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($kind eq "services") 2 7 9
579 2 ▶ return { %{ $old || {} }, selector => $s->{selector} // {}, ( $s->{type} && ( $s->{type} ne 'ClusterIP' || ( $old || {} )->{type} ) ? ( type => $s->{type} ) : () ),
Branch: 1 branch
BranchTrueFalseTotal
$$s{'type'} && ($$s{'type'} ne 'ClusterIP' || ($old || {})->{'type'}) ? : 0 2 2
Condition41%5/12
$old || {}
l!l
20
$$s{"selector"} // {}
l!l
20
$$s{"type"} and $$s{"type"} ne "ClusterIP" || ($old || {})->{"type"}
!ll&&!rl&&r
020
$$s{"type"} ne "ClusterIP" or ($old || {})->{"type"}
l!l&&r!l&&!r
002
$old || {}
l!l
20
MC/DC0%0/1
$$s{"selector"} // {}
$$s{"selector"}
MC/DC0%0/3
$$s{"type"} and $$s{"type"} ne "ClusterIP" || ($old || {})->{"type"}
$$s{"type"} $$s{"type"} ne "ClusterIP" $old
Truth table50%1/2
A
A= $$s{"selector"}
Aresult
11
00
Truth table25%1/4
A and B or C
A= $$s{"type"}B= $$s{"type"} ne "ClusterIP"C= $old
ABCresult
0XX0
1000
11X1
1011
580 2 ▶ ports => [ map { { port => $_->{port}, target => $_->{targetPort} // $_->{port}, ( $_->{name} ? ( name => $_->{name} ) : () ) } } @{ $s->{ports} || [] } ] };
Branch: 1 branch
BranchTrueFalseTotal
$$_{'name'} ? : 2 1 3
Condition40%2/5
$$_{"targetPort"} // $$_{"port"}
l!l&&r!l&&!r
300
$$s{'ports'} || []
l!l
20
MC/DC0%0/2
$$_{"targetPort"} // $$_{"port"}
$$_{"targetPort"} $$_{"port"}
MC/DC0%0/1
$$s{'ports'} || []
$$s{'ports'}
Truth table33%1/3
A // B
A= $$_{"targetPort"}B= $$_{"port"}
ABresult
1X1
011
000
Truth table50%1/2
A
A= $$s{'ports'}
Aresult
11
00
581 }
582 7 ▶ if ( $kind eq 'secrets' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($kind eq "secrets") 3 4 7
583 3 ▶ return { ( map { $_ => MIME::Base64::decode_base64( $doc->{data}{$_} ) } keys %{ $doc->{data} || {} } ), %{ $doc->{stringData} || {} } };
Condition75%3/4
$$doc{'data'} || {}
l!l
30
$$doc{'stringData'} || {}
l!l
12
MC/DC0%0/1
$$doc{'data'} || {}
$$doc{'data'}
MC/DC100%1/1
$$doc{'stringData'} || {}
$$doc{'stringData'}
Truth table50%1/2
A
A= $$doc{'data'}
Aresult
11
00
Truth table100%2/2
A
A= $$doc{'stringData'}
Aresult
11
00
584 }
585 0 ▶ return { %{ $doc->{data} || {} } } if $kind eq 'configmaps';
Branch: 1 branch
BranchTrueFalseTotal
if $kind eq "configmaps" 0 4 4
Condition0%0/2
$$doc{'data'} || {}
l!l
00
MC/DC0%0/1
$$doc{'data'} || {}
$$doc{'data'}
Truth table0%0/2
A
A= $$doc{'data'}
Aresult
11
00
586 4 ▶ if ( $kind eq 'pvcs' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($kind eq "pvcs") 3 1 4
587 3 ▶ return { size => ( ( $s->{resources} || {} )->{requests} || {} )->{storage}, ( defined $s->{storageClassName} ? ( storage_class => $s->{storageClassName} ) : () ) };
Branch: 1 branch
BranchTrueFalseTotal
defined $$s{'storageClassName'} ? : 3 0 3
Condition50%2/4
($$s{'resources'} || {})->{'requests'} || {}
l!l
30
$$s{'resources'} || {}
l!l
30
MC/DC0%0/1
($$s{'resources'} || {})->{'requests'} || {}
$$s{'resources'}
Truth table50%1/2
A
A= $$s{'resources'}
Aresult
11
00
588 }
589 1 ▶ if ( $kind eq 'networkpolicies' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($kind eq "networkpolicies") 1 0 1
590 return { pod_selector => ( $s->{podSelector} || {} )->{matchLabels} // {},
591 1 ▶ ingress => [ map { my $r = $_; +{ ( $r->{from} ? ( from => [ map { ( $_->{podSelector} || {} )->{matchLabels} // {} } @{ $r->{from} } ] ) : () ),
Branch: 1 branch
BranchTrueFalseTotal
$$r{'ports'} ? : 1 0 1
Condition50%2/4
($$_{"podSelector"} || {})->{"matchLabels"} // {}
l!l
10
$$_{'podSelector'} || {}
l!l
10
MC/DC0%0/1
($$_{"podSelector"} || {})->{"matchLabels"} // {}
$$_{'podSelector'}
Truth table50%1/2
A
A= $$_{'podSelector'}
Aresult
11
00
592 1 ▶ ( $r->{ports} ? ( ports => [ map { $_->{port} } @{ $r->{ports} } ] ) : () ) } } @{ $s->{ingress} || [] } ] };
Branch: 1 branch
BranchTrueFalseTotal
$$r{'from'} ? : 1 0 1
Condition50%3/6
($$s{"podSelector"} || {})->{"matchLabels"} // {}
l!l
10
$$s{'podSelector'} || {}
l!l
10
$$s{'ingress'} || []
l!l
10
MC/DC0%0/1
($$s{"podSelector"} || {})->{"matchLabels"} // {}
$$s{'podSelector'}
MC/DC0%0/1
$$s{'ingress'} || []
$$s{'ingress'}
Truth table50%1/2
A
A= $$s{'podSelector'}
Aresult
11
00
Truth table50%1/2
A
A= $$s{'ingress'}
Aresult
11
00
593 }
594 0 ▶ if ( $kind eq 'storageclasses' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($kind eq "storageclasses") 0 0 0
595 0 ▶ my $a = ( $doc->{metadata} || {} )->{annotations} || {};
Condition0%0/4
($$doc{'metadata'} || {})->{'annotations'} || {}
l!l
00
$$doc{'metadata'} || {}
l!l
00
MC/DC0%0/1
($$doc{'metadata'} || {})->{'annotations'} || {}
$$doc{'metadata'}
Truth table0%0/2
A
A= $$doc{'metadata'}
Aresult
11
00
596 0 ▶ return { provisioner => $doc->{provisioner}, ( ( $a->{'storageclass.kubernetes.io/is-default-class'} // '' ) eq 'true' ? ( default => JSON::MaybeXS::true() ) : () ) };
Branch: 1 branch
BranchTrueFalseTotal
($$a{'storageclass.kubernetes.io/is-default-class'} // '') eq 'true' ? : 0 0 0
Condition0%0/2
$$a{"storageclass.kubernetes.io/is-default-class"} // ""
l!l
00
MC/DC0%0/1
$$a{"storageclass.kubernetes.io/is-default-class"} // ""
$$a{"storageclass.kubernetes.io/is-default-class"}
Truth table0%0/2
A
A= $$a{"storageclass.kubernetes.io/is-default-class"}
Aresult
11
00
597 }
598 0 return {};
599 }
600  
601 3 ▶sub _container_from_api {
Subroutine _container_from_api: called CC=17 SCAR=36.7
602 3 my ( $c, $old, $vols ) = @_;
603 3 ▶ $old ||= {};
Condition50%1/2
$old ||= {}
l!l
30
MC/DC0%0/1
$old ||= {}
$old
Truth table50%1/2
A
A= $old
Aresult
11
00
604 0 ▶ my %claim = map { $_->{name} => ( $_->{persistentVolumeClaim} || {} )->{claimName} } @{ $vols || [] };
Condition25%1/4
$$_{'persistentVolumeClaim'} || {}
l!l
00
$vols || []
l!l
03
MC/DC0%0/1
$$_{'persistentVolumeClaim'} || {}
$$_{'persistentVolumeClaim'}
MC/DC0%0/1
$vols || []
$vols
Truth table0%0/2
A
A= $$_{'persistentVolumeClaim'}
Aresult
11
00
Truth table50%1/2
A
A= $vols
Aresult
11
00
605 3 ▶ my $rp = ( $c->{readinessProbe} || {} )->{httpGet};
Condition50%1/2
$$c{'readinessProbe'} || {}
l!l
30
MC/DC0%0/1
$$c{'readinessProbe'} || {}
$$c{'readinessProbe'}
Truth table50%1/2
A
A= $$c{'readinessProbe'}
Aresult
11
00
606 my %n = (
607 %$old,
608 name => $c->{name},
609 image => $c->{image},
610 3 );
611 3 delete @n{qw( ports env readiness volumes privileged )};
612 3 ▶ $n{ports} = [ map { $_->{containerPort} } @{ $c->{ports} } ] if $c->{ports};
Branch: 1 branch
BranchTrueFalseTotal
if $$c{"ports"} 3 0 3
613 $n{env} = [ map {
614 3 ▶ my $v = $_->{valueFrom} || {};
Condition50%1/2
$$_{'valueFrom'} || {}
l!l
30
MC/DC0%0/1
$$_{'valueFrom'} || {}
$$_{'valueFrom'}
Truth table50%1/2
A
A= $$_{'valueFrom'}
Aresult
11
00
615 $v->{secretKeyRef} ? { name => $_->{name}, secret => $v->{secretKeyRef}{name}, key => $v->{secretKeyRef}{key}, ( $v->{secretKeyRef}{optional} ? ( optional => JSON::MaybeXS::true() ) : () ) }
616 : $v->{configMapKeyRef} ? { name => $_->{name}, configmap => $v->{configMapKeyRef}{name}, key => $v->{configMapKeyRef}{key} }
617 3 ▶ : { name => $_->{name}, value => $_->{value} };
Branch: 3 branches
BranchTrueFalseTotal
$$v{'secretKeyRef'} ? : 3 0 3
$$v{'secretKeyRef'}{'optional'} ? : 3 0 3
$$v{'configMapKeyRef'} ? : 0 0 0
618 3 ▶ } @{ $c->{env} } ] if $c->{env};
Branch: 1 branch
BranchTrueFalseTotal
if $$c{"env"} 3 0 3
619 3 ▶ $n{readiness} = { port => $rp->{port}, path => $rp->{path} // '/' } if $rp;
Branch: 1 branch
BranchTrueFalseTotal
if $rp 3 0 3
Condition50%1/2
$$rp{"path"} // "/"
l!l
30
MC/DC0%0/1
$$rp{"path"} // "/"
$$rp{"path"}
Truth table50%1/2
A
A= $$rp{"path"}
Aresult
11
00
620 0 ▶ $n{volumes} = [ map { { claim => $claim{ $_->{name} } // $_->{name}, mount => $_->{mountPath} } } @{ $c->{volumeMounts} } ] if $c->{volumeMounts};
Branch: 1 branch
BranchTrueFalseTotal
if $$c{"volumeMounts"} 0 3 3
Condition0%0/3
$claim{$$_{"name"}} // $$_{"name"}
l!l&&r!l&&!r
000
MC/DC0%0/2
$claim{$$_{"name"}} // $$_{"name"}
$claim{$$_{"name"}} $$_{"name"}
Truth table0%0/3
A // B
A= $claim{$$_{"name"}}B= $$_{"name"}
ABresult
1X1
011
000
621 3 ▶ $n{privileged} = JSON::MaybeXS::true() if ( $c->{securityContext} || {} )->{privileged};
Branch: 1 branch
BranchTrueFalseTotal
if ($$c{"securityContext"} || {})->{"privileged"} 0 3 3
Condition50%1/2
$$c{'securityContext'} || {}
l!l
03
MC/DC0%0/1
$$c{'securityContext'} || {}
$$c{'securityContext'}
Truth table50%1/2
A
A= $$c{'securityContext'}
Aresult
11
00
622 3 return \%n;
623 }
624  
625 18 ▶sub _bump {
Subroutine _bump: called CC=2 SCAR=7.1
626 18 my ($d) = @_;
627 18 ▶ $d->{generation} = ( $d->{generation} // 1 ) + 1;
Condition50%1/2
$$d{"generation"} // 1
l!l
180
MC/DC0%0/1
$$d{"generation"} // 1
$$d{"generation"}
Truth table50%1/2
A
A= $$d{"generation"}
Aresult
11
00
628 18 return;
629 }
630  
631 23 ▶sub _store {
Subroutine _store: called CC=28 SCAR=37.9
632 23 my ( $k, $kind, $ns, $name, $new ) = @_;
633 0 ▶ if ( $kind eq 'storageclasses' ) { $k->{storageclasses}{$name} = $new; return 'created' }
Branch: 1 branch
BranchTrueFalseTotal
if ($kind eq "storageclasses") 0 23 23
634 0 ▶ if ( $kind eq 'namespaces' ) { $k->{namespaces}{$name} //= {}; return 'created' }
Branch: 1 branch
BranchTrueFalseTotal
if ($kind eq "namespaces") 0 23 23
Condition0%0/2
$$k{"namespaces"}{$name} //= {}
l!l
00
MC/DC0%0/1
$$k{"namespaces"}{$name} //= {}
$$k{"namespaces"}{$name}
Truth table0%0/2
A
A= $$k{"namespaces"}{$name}
Aresult
11
00
635 23 ▶ die qq{error: $kind are derived by the controller and cannot be applied\n} if $DERIVED{$kind};
Branch: 1 branch
BranchTrueFalseTotal
if $Langertha::Holmgang::Sim::Linux::Kubernetes::DERIVED{$kind} 0 23 23
636 23 ▶ my $o = $CLUSTER{$kind} ? $k : $k->{namespaces}{$ns} or die qq{Error from server (NotFound): namespaces "$ns" not found\n};
Branch: 2 branches
BranchTrueFalseTotal
my $o = $Langertha::Holmgang::Sim::Linux::Kubernetes::CLUSTER{$kind} ? $k : $$k{"namespaces"}{$ns} or die qq[Error from server (NotFound): namespaces "$ns" not found\n] 23 0 23
$Langertha::Holmgang::Sim::Linux::Kubernetes::CLUSTER{$kind} ? : 0 23 23
637 23 my $old = $o->{$kind}{$name};
638 23 ▶ if ( $kind =~ /\A(?:cluster)?rolebindings\z/ && $old && $J->encode( $old->{roleRef} // {} ) ne $J->encode( $new->{roleRef} // {} ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($kind =~ /\A(?:cluster)?rolebindings\z/ and $old and $J->encode($$old{"roleRef"} // {}) ne $J->encode($$new{"roleRef"} // {})) 2 21 23
Condition70%7/10
$kind =~ /\A(?:cluster)?rolebindings\z/ and $old and $J->encode($$old{"roleRef"} // {}) ne $J->encode($$new{"roleRef"} // {})
!ll&&!rl&&r
2012
$kind =~ /\A(?:cluster)?rolebindings\z/ and $old
!ll&&!rl&&r
2003
$$old{"roleRef"} // {}
l!l
30
$$new{"roleRef"} // {}
l!l
30
MC/DC66%2/3
$kind =~ /\A(?:cluster)?rolebindings\z/ and $old and $J->encode($$old{"roleRef"} // {}) ne $J->encode($$new{"roleRef"} // {})
$kind =~ /\A(?:cluster)?rolebindings\z/ $old $J->encode($$old{"roleRef"} // {}) ne $J->encode($$new{"roleRef"} // {})
MC/DC0%0/1
$$old{"roleRef"} // {}
$$old{"roleRef"}
MC/DC0%0/1
$$new{"roleRef"} // {}
$$new{"roleRef"}
Truth table75%3/4
A and B and C
A= $kind =~ /\A(?:cluster)?rolebindings\z/B= $oldC= $J->encode($$old{"roleRef"} // {}) ne $J->encode($$new{"roleRef"} // {})
ABCresult
0XX0
10X0
1100
1111
Truth table50%1/2
A
A= $$old{"roleRef"}
Aresult
11
00
Truth table50%1/2
A
A= $$new{"roleRef"}
Aresult
11
00
639 2 ▶ die qq{The $GEN{$kind}[1] "$name" is invalid: roleRef: Invalid value: } . $J->encode( $new->{roleRef} // {} ) =~ s/\s+/ /gr . qq{: cannot change roleRef\n};
Condition50%1/2
$$new{"roleRef"} // {}
l!l
20
MC/DC0%0/1
$$new{"roleRef"} // {}
$$new{"roleRef"}
Truth table50%1/2
A
A= $$new{"roleRef"}
Aresult
11
00
640 }
641 21 ▶ if ( $kind eq 'pvcs' && $old && $J->encode( { %$old, size => undef } ) ne $J->encode( { %$new, size => undef } ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($kind eq "pvcs" and $old and $J->encode({%$old, "size", undef}) ne $J->encode({%$new, "size", undef})) 1 20 21
Condition100%6/6
$kind eq "pvcs" and $old and $J->encode({%$old, "size", undef}) ne $J->encode({%$new, "size", undef})
!ll&&!rl&&r
1911
$kind eq "pvcs" and $old
!ll&&!rl&&r
1812
MC/DC100%3/3
$kind eq "pvcs" and $old and $J->encode({%$old, "size", undef}) ne $J->encode({%$new, "size", undef})
$kind eq "pvcs" $old $J->encode({%$old, "size", undef}) ne $J->encode({%$new, "size", undef})
Truth table100%4/4
A and B and C
A= $kind eq "pvcs"B= $oldC= $J->encode({%$old, "size", undef}) ne $J->encode({%$new, "size", undef})
ABCresult
0XX0
10X0
1100
1111
642 1 die qq{The PersistentVolumeClaim "$name" is invalid: spec: Forbidden: spec is immutable after creation except resources.requests and volumeAttributesClassName for bound claims\n};
643 }
644 20 ▶ if ( $kind eq 'deployments' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($kind eq "deployments") 9 11 20
645 die qq{The Deployment "$name" is invalid: spec.selector: Invalid value: field is immutable\n}
646 9 ▶ if $old && $J->encode( $old->{selector} ) ne $J->encode( $new->{selector} );
Branch: 1 branch
BranchTrueFalseTotal
if $old and $J->encode($$old{"selector"}) ne $J->encode($$new{"selector"}) 0 9 9
Condition33%1/3
$old and $J->encode($$old{"selector"}) ne $J->encode($$new{"selector"})
!ll&&!rl&&r
090
MC/DC0%0/2
$old and $J->encode($$old{"selector"}) ne $J->encode($$new{"selector"})
$old $J->encode($$old{"selector"}) ne $J->encode($$new{"selector"})
Truth table33%1/3
A and B
A= $oldB= $J->encode($$old{"selector"}) ne $J->encode($$new{"selector"})
ABresult
0X0
100
111
647 die qq{The Deployment "$name" is invalid: spec.template.metadata.labels: Invalid value: map[string]string{} : `selector` does not match template `labels`\n}
648 9 ▶ unless _sel_match( $new->{selector}, $new->{template}{labels} );
Branch: 1 branch
BranchTrueFalseTotal
unless _sel_match($$new{"selector"}, $$new{"template"}{"labels"}) 0 9 9
649 9 ▶ $new->{generation} = $old->{generation} // 1 if $old;
Branch: 1 branch
BranchTrueFalseTotal
if $old 9 0 9
Condition50%1/2
$$old{"generation"} // 1
l!l
90
MC/DC0%0/1
$$old{"generation"} // 1
$$old{"generation"}
Truth table50%1/2
A
A= $$old{"generation"}
Aresult
11
00
650 9 ▶ _bump($new) if $old && $J->encode( $old->{template} ) ne $J->encode( $new->{template} );
Branch: 1 branch
BranchTrueFalseTotal
if $old and $J->encode($$old{"template"}) ne $J->encode($$new{"template"}) 7 2 9
Condition66%2/3
$old and $J->encode($$old{"template"}) ne $J->encode($$new{"template"})
!ll&&!rl&&r
027
MC/DC50%1/2
$old and $J->encode($$old{"template"}) ne $J->encode($$new{"template"})
$old $J->encode($$old{"template"}) ne $J->encode($$new{"template"})
Truth table66%2/3
A and B
A= $oldB= $J->encode($$old{"template"}) ne $J->encode($$new{"template"})
ABresult
0X0
100
111
651 9 ▶ $new->{generation} //= 1;
Condition50%1/2
$$new{"generation"} //= 1
l!l
90
MC/DC0%0/1
$$new{"generation"} //= 1
$$new{"generation"}
Truth table50%1/2
A
A= $$new{"generation"}
Aresult
11
00
652 }
653 20 ▶ my $same = $old && $J->encode($old) eq $J->encode($new);
Condition100%3/3
$old && $J->encode($old) eq $J->encode($new)
!ll&&!rl&&r
1163
MC/DC100%2/2
$old && $J->encode($old) eq $J->encode($new)
$old $J->encode($old) eq $J->encode($new)
Truth table100%3/3
A && B
A= $oldB= $J->encode($old) eq $J->encode($new)
ABresult
0X0
100
111
654 20 $o->{$kind}{$name} = $new;
655 20 ▶ return $same ? 'unchanged' : $old ? 'configured' : 'created';
Branch: 2 branches
BranchTrueFalseTotal
$same ? : 3 17 20
$old ? : 16 1 17
656 }
657  
658 5 ▶sub _docs_from_file {
Subroutine _docs_from_file: called CC=10 SCAR=26.9
659 5 my ( $dev, $file, $stdin ) = @_;
660 5 my $text;
661 5 ▶ if ( $file eq '-' ) { $text = $stdin // '' }
Branch: 1 branch
BranchTrueFalseTotal
if ($file eq '-') { } 2 3 5
Condition50%1/2
$stdin // ""
l!l
20
MC/DC0%0/1
$stdin // ""
$stdin
Truth table50%1/2
A
A= $stdin
Aresult
11
00
662 else {
663 3 ▶ my $f = ( $dev->{files} || {} )->{$file};
Condition50%1/2
$$dev{'files'} || {}
l!l
30
MC/DC0%0/1
$$dev{'files'} || {}
$$dev{'files'}
Truth table50%1/2
A
A= $$dev{'files'}
Aresult
11
00
664 3 ▶ $f = $f->{content} if ref $f eq 'HASH';
Branch: 1 branch
BranchTrueFalseTotal
if ref $f eq "HASH" 0 3 3
665 3 ▶ die "error: the path \"$file\" does not exist\n" unless defined $f;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $f 0 3 3
666 3 $text = $f;
667 }
668 5 my @d = eval { YAML::XS::Load( Encode::encode( 'UTF-8', $text ) ) };
669 0 ▶ if ( my $e = $@ ) { $e =~ s/\s+\z//; $e =~ s/\n.*//s; die "error: error parsing $file: error converting YAML to JSON: yaml: $e\n" }
Branch: 1 branch
BranchTrueFalseTotal
if (my $e = $@) 0 5 5
670 0 ▶ return map { ( $_->{kind} // '' ) eq 'List' ? @{ $_->{items} || [] } : $_ } grep { ref $_ eq 'HASH' } @d;
Branch: 1 branch
BranchTrueFalseTotal
($$_{'kind'} // '') eq 'List' ? : 0 5 5
Condition25%1/4
$$_{"kind"} // ""
l!l
50
$$_{'items'} || []
l!l
00
MC/DC0%0/1
$$_{"kind"} // ""
$$_{"kind"}
MC/DC0%0/1
$$_{'items'} || []
$$_{'items'}
Truth table50%1/2
A
A= $$_{"kind"}
Aresult
11
00
Truth table0%0/2
A
A= $$_{'items'}
Aresult
11
00
671 }
672  
673 5 ▶sub _v_apply {
Subroutine _v_apply: called CC=15 SCAR=31.3
674 5 my ( $k, $a, $o, $dev, $stdin ) = @_;
675 5 ▶ return ( 'error: must specify one of -f and -k', 0 ) unless $o->{files};
Branch: 1 branch
BranchTrueFalseTotal
unless $$o{"files"} 0 5 5
676 5 my @out;
677 5 for my $f ( @{ $o->{files} } ) {
678 5 my @docs = eval { _docs_from_file( $dev, $f, $stdin ) };
679 5 ▶ return ( $@ =~ s/\s+\z//r, 0 ) if $@;
Branch: 1 branch
BranchTrueFalseTotal
if $@ 0 5 5
680 5 for my $d (@docs) {
681 5 ▶ my $kind = $FROM_APIKIND{ $d->{kind} // '' } or return ( qq{error: resource mapping not found for name: "} . ( $d->{metadata}{name} // '' ) . qq{" namespace: "" from "$f": no matches for kind "$d->{kind}"}, 0 );
Branch: 1 branch
BranchTrueFalseTotal
my $kind = $FROM_APIKIND{$$d{"kind"} // ""} or return 'error: resource mapping not found for name: "' . ($$d{"metadata"}{"name"} // "") . qq[" namespace: "" from "$f": no matches for kind "$$d{"kind"}"], 0 5 0 5
Condition25%1/4
$$d{"kind"} // ""
l!l
50
$$d{"metadata"}{"name"} // ""
l!l
00
MC/DC0%0/1
$$d{"kind"} // ""
$$d{"kind"}
MC/DC0%0/1
$$d{"metadata"}{"name"} // ""
$$d{"metadata"}{"name"}
Truth table50%1/2
A
A= $$d{"kind"}
Aresult
11
00
Truth table0%0/2
A
A= $$d{"metadata"}{"name"}
Aresult
11
00
682 5 ▶ my $name = ( $d->{metadata} || {} )->{name} or return ( 'error: error validating data: metadata.name missing', 0 );
Branch: 1 branch
BranchTrueFalseTotal
my $name = ($$d{"metadata"} || {})->{"name"} or return "error: error validating data: metadata.name missing", 0 5 0 5
Condition50%1/2
$$d{'metadata'} || {}
l!l
50
MC/DC0%0/1
$$d{'metadata'} || {}
$$d{'metadata'}
Truth table50%1/2
A
A= $$d{'metadata'}
Aresult
11
00
683 5 ▶ my $ns = $d->{metadata}{namespace} // $o->{ns};
Condition33%1/3
$$d{"metadata"}{"namespace"} // $$o{"ns"}
l!l&&r!l&&!r
500
MC/DC0%0/2
$$d{"metadata"}{"namespace"} // $$o{"ns"}
$$d{"metadata"}{"namespace"} $$o{"ns"}
Truth table33%1/3
A // B
A= $$d{"metadata"}{"namespace"}B= $$o{"ns"}
ABresult
1X1
011
000
684 5 ▶ my $old = $CLUSTER{$kind} ? ( $k->{$kind} || {} )->{$name} : ( $k->{namespaces}{$ns} || {} )->{$kind}{$name};
Branch: 1 branch
BranchTrueFalseTotal
$Langertha::Holmgang::Sim::Linux::Kubernetes::CLUSTER{$kind} ? : 0 5 5
Condition25%1/4
$$k{$kind} || {}
l!l
00
$$k{'namespaces'}{$ns} || {}
l!l
50
MC/DC0%0/1
$$k{$kind} || {}
$$k{$kind}
MC/DC0%0/1
$$k{'namespaces'}{$ns} || {}
$$k{'namespaces'}{$ns}
Truth table0%0/2
A
A= $$k{$kind}
Aresult
11
00
Truth table50%1/2
A
A= $$k{'namespaces'}{$ns}
Aresult
11
00
685 5 my $r = eval { _store( $k, $kind, $ns, $name, _from_api( $kind, $d, $old ) ) };
686 5 ▶ return ( join( "\n", @out, $@ =~ s/\s+\z//r ), 0 ) if $@;
Branch: 1 branch
BranchTrueFalseTotal
if $@ 1 4 5
687 4 push @out, "$SINGULAR{$kind}/$name $r";
688 }
689 }
690 4 return ( join( "\n", @out ), 1 );
691 }
692  
693 11 ▶sub _v_create {
Subroutine _v_create: called CC=24 SCAR=40.0
694 11 my ( $k, $a, $o, $dev, $stdin ) = @_;
695 11 ▶ if ( ( $a->[0] // '' ) eq 'secret' && ( $a->[1] // '' ) eq 'generic' ) {
Branch: 1 branch
BranchTrueFalseTotal
if (($$a[0] // "") eq "secret" and ($$a[1] // "") eq "generic") 4 7 11
Condition71%5/7
($$a[0] // "") eq "secret" and ($$a[1] // "") eq "generic"
!ll&&!rl&&r
614
$$a[0] // ""
l!l
110
$$a[1] // ""
l!l
50
MC/DC0%0/2
($$a[0] // "") eq "secret" and ($$a[1] // "") eq "generic"
$$a[0] $$a[1]
Truth table33%1/3
A and B
A= $$a[0]B= $$a[1]
ABresult
0X0
100
111
696 4 ▶ my $name = $a->[2] // return ( 'error: exactly one NAME is required, got 0', 0 );
Condition50%1/2
$$a[2] // (return "error: exactly one NAME is required, got 0", 0)
l!l
40
MC/DC0%0/1
$$a[2] // (return "error: exactly one NAME is required, got 0", 0)
$$a[2]
Truth table50%1/2
A
A= $$a[2]
Aresult
11
00
697 4 ▶ my %lit = map { $_->[0] => $_->[1] } @{ $o->{literal} || [] };
Condition100%2/2
$$o{'literal'} || []
l!l
22
MC/DC100%1/1
$$o{'literal'} || []
$$o{'literal'}
Truth table100%2/2
A
A= $$o{'literal'}
Aresult
11
00
698 4 ▶ for my $ff ( @{ $o->{from_file} || [] } ) { # Inhalt genau wie in der Datei (mit Zeilenende, wie echt)
Condition100%2/2
$$o{'from_file'} || []
l!l
22
MC/DC100%1/1
$$o{'from_file'} || []
$$o{'from_file'}
Truth table100%2/2
A
A= $$o{'from_file'}
Aresult
11
00
699 2 my ( $key, $path ) = @$ff;
700 2 ▶ my $f = ( $dev->{files} || {} )->{$path};
Condition50%1/2
$$dev{'files'} || {}
l!l
20
MC/DC0%0/1
$$dev{'files'} || {}
$$dev{'files'}
Truth table50%1/2
A
A= $$dev{'files'}
Aresult
11
00
701 2 ▶ $f = $f->{content} if ref $f eq 'HASH';
Branch: 1 branch
BranchTrueFalseTotal
if ref $f eq "HASH" 0 2 2
702 2 ▶ return ( "error: error reading $path: no such file or directory", 0 ) unless defined $f;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $f 1 1 2
703 1 ▶ $lit{ $key // ( $path =~ s{.*/}{}r ) } = $f;
Condition33%1/3
$key // $path =~ s[.*/][]r
l!l&&r!l&&!r
100
MC/DC0%0/2
$key // $path =~ s[.*/][]r
$key $path =~ s[.*/][]r
Truth table33%1/3
A // B
A= $keyB= $path =~ s[.*/][]r
ABresult
1X1
011
000
704 }
705 3 ▶ if ( grep {/\A--dry-run=(?:client|server)\z/} keys %{ $o->{flags} || {} } ) {
Branch: 1 branch
BranchTrueFalseTotal
if (grep {/\A--dry-run=(?:client|server)\z/;} keys %{$$o{"flags"} or {};}) 3 0 3
Condition50%1/2
$$o{'flags'} || {}
l!l
30
MC/DC0%0/1
$$o{'flags'} || {}
$$o{'flags'}
Truth table50%1/2
A
A= $$o{'flags'}
Aresult
11
00
706 # nur das Manifest, nichts anlegen (fuer … | kubectl apply -f -)
707 3 ▶ return ( "secret/$name created (dry run)", 1 ) unless ( $o->{out} // '' ) =~ /\A(?:yaml|json)\z/;
Branch: 1 branch
BranchTrueFalseTotal
unless ($$o{"out"} // "") =~ /\A(?:yaml|json)\z/ 0 3 3
Condition50%1/2
$$o{"out"} // ""
l!l
30
MC/DC0%0/1
$$o{"out"} // ""
$$o{"out"}
Truth table50%1/2
A
A= $$o{"out"}
Aresult
11
00
708 3 return _structured( $o, 'secrets', { $name => \%lit } );
709 }
710 0 ▶ return ( qq{error: failed to create secret secrets "$name" already exists}, 0 ) if $k->{namespaces}{ $o->{ns} }{secrets}{$name};
Branch: 1 branch
BranchTrueFalseTotal
if $$k{"namespaces"}{$$o{"ns"}}{"secrets"}{$name} 0 0 0
711 0 $k->{namespaces}{ $o->{ns} }{secrets}{$name} = \%lit;
712 0 return ( "secret/$name created", 1 );
713 }
714 0 ▶ if ( ( $a->[0] // '' ) =~ /\A(?:namespace|ns)\z/ ) { push @GAPS, 'kubectl create namespace'; return ( '', 0 ) }
Branch: 1 branch
BranchTrueFalseTotal
if (($$a[0] // "") =~ /\A(?:namespace|ns)\z/) 0 7 7
Condition50%1/2
$$a[0] // ""
l!l
70
MC/DC0%0/1
$$a[0] // ""
$$a[0]
Truth table50%1/2
A
A= $$a[0]
Aresult
11
00
715 7 ▶ if ( defined $a->[0] && !$o->{files} ) { my @r = _create_more( $k, $a, $o, $dev ); return @r if @r }
Branch: 2 branches
BranchTrueFalseTotal
if (defined $$a[0] and not $$o{"files"}) 7 0 7
if @r 7 0 7
Condition33%1/3
defined $$a[0] and not $$o{"files"}
!ll&&!rl&&r
007
MC/DC0%0/2
defined $$a[0] and not $$o{"files"}
defined $$a[0] not $$o{"files"}
Truth table33%1/3
A and not(B)
A= defined $$a[0]B= not $$o{"files"}
ABresult
0X0
100
111
716 0 ▶ return _v_apply( $k, $a, $o, $dev, $stdin ) if $o->{files};
Branch: 1 branch
BranchTrueFalseTotal
if $$o{"files"} 0 0 0
717 0 push @GAPS, "kubectl create @$a";
718 0 return ( '', 0 );
719 }
720  
721 19 ▶sub _target {
Subroutine _target: called CC=5 SCAR=19.2
722 19 my ( $k, $o, $kind, $name ) = @_;
723 19 ▶ return ( $k->{$kind} ||= {} ) if $CLUSTER{$kind} && $kind ne 'namespaces';
Branch: 1 branch
BranchTrueFalseTotal
if $Langertha::Holmgang::Sim::Linux::Kubernetes::CLUSTER{$kind} and $kind ne "namespaces" 0 19 19
Condition20%1/5
$Langertha::Holmgang::Sim::Linux::Kubernetes::CLUSTER{$kind} and $kind ne "namespaces"
!ll&&!rl&&r
1900
$$k{$kind} ||= {}
l!l
00
MC/DC0%0/2
$Langertha::Holmgang::Sim::Linux::Kubernetes::CLUSTER{$kind} and $kind ne "namespaces"
$Langertha::Holmgang::Sim::Linux::Kubernetes::CLUSTER{$kind} $kind ne "namespaces"
MC/DC0%0/1
$$k{$kind} ||= {}
$$k{$kind}
Truth table33%1/3
A and B
A= $Langertha::Holmgang::Sim::Linux::Kubernetes::CLUSTER{$kind}B= $kind ne "namespaces"
ABresult
0X0
100
111
Truth table0%0/2
A
A= $$k{$kind}
Aresult
11
00
724 19 ▶ return ( $k->{namespaces}{ $o->{ns} }{$kind} ||= {} );
Condition100%2/2
$$k{"namespaces"}{$$o{"ns"}}{$kind} ||= {}
l!l
172
MC/DC100%1/1
$$k{"namespaces"}{$$o{"ns"}}{$kind} ||= {}
$$k{"namespaces"}{$$o{"ns"}}{$kind}
Truth table100%2/2
A
A= $$k{"namespaces"}{$$o{"ns"}}{$kind}
Aresult
11
00
725 }
726  
727 3 ▶sub _v_delete {
Subroutine _v_delete: called CC=14 SCAR=30.4
728 3 my ( $k, $a, $o, $dev ) = @_;
729 3 my ( $kind, $name ) = _kind_name($a);
730 3 ▶ my @names = defined $name ? ( $name, @$a[ 2 .. $#$a ] ) : ();
Branch: 1 branch
BranchTrueFalseTotal
defined $name ? : 3 0 3
731 3 ▶ return ( 'error: resource(s) were provided, but no name was specified', 0 ) unless $kind && @names;
Branch: 1 branch
BranchTrueFalseTotal
unless $kind and @names 0 3 3
Condition33%1/3
$kind and @names
!ll&&!rl&&r
003
MC/DC0%0/2
$kind and @names
$kind @names
Truth table33%1/3
A and B
A= $kindB= @names
ABresult
0X0
100
111
732 3 my @out;
733 3 for my $n (@names) {
734 3 ▶ if ( $kind eq 'namespaces' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($kind eq "namespaces") 1 2 3
735 1 ▶ delete $k->{namespaces}{$n} or return ( qq{Error from server (NotFound): namespaces "$n" not found}, 0 );
Branch: 1 branch
BranchTrueFalseTotal
delete $$k{"namespaces"}{$n} or return qq[Error from server (NotFound): namespaces "$n" not found], 0 1 0 1
736 1 push @out, qq{namespace "$n" deleted};
737 1 next;
738 }
739 2 ▶ if ( $kind eq 'pods' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($kind eq "pods") 0 2 2
740 # Pods eines Deployments kommen neu (gleicher Status); nur die Neuerstellung zaehlt
741 0 my ($p) = grep { $_->{name} eq $n } _pods( $k, $o->{ns} );
742 0 ▶ return ( qq{Error from server (NotFound): pods "$n" not found}, 0 ) unless $p;
Branch: 1 branch
BranchTrueFalseTotal
unless $p 0 0 0
743 0 push @out, qq{pod "$n" deleted};
744 0 next;
745 }
746 2 ▶ if ( $kind eq 'secrets' && $n =~ /\Ash\.helm\.release\.v1\.(.+)\.v(\d+)\z/ ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($kind eq "secrets" and $n =~ /\Ash\.helm\.release\.v1\.(.+)\.v(\d+)\z/) 1 1 2
Condition66%2/3
$kind eq "secrets" and $n =~ /\Ash\.helm\.release\.v1\.(.+)\.v(\d+)\z/
!ll&&!rl&&r
101
MC/DC50%1/2
$kind eq "secrets" and $n =~ /\Ash\.helm\.release\.v1\.(.+)\.v(\d+)\z/
$kind eq "secrets" $n =~ /\Ash\.helm\.release\.v1\.(.+)\.v(\d+)\z/
Truth table66%2/3
A and B
A= $kind eq "secrets"B= $n =~ /\Ash\.helm\.release\.v1\.(.+)\.v(\d+)\z/
ABresult
0X0
100
111
747 1 Langertha::Holmgang::Sim::Linux::_part('Helm');
748 1 ▶ Langertha::Holmgang::Sim::Linux::Helm::drop_revision( $k, $o->{ns}, $1, $2 ) or return ( qq{Error from server (NotFound): secrets "$n" not found}, 0 );
Branch: 1 branch
BranchTrueFalseTotal
Langertha::Holmgang::Sim::Linux::Helm::drop_revision($k, $$o{"ns"}, $1, $2) or return qq[Error from server (NotFound): secrets "$n" not found], 0 1 0 1
749 1 push @out, qq{secret "$n" deleted};
750 1 next;
751 }
752 1 ▶ return ( qq{Error from server (MethodNotAllowed): the server does not allow this method on the requested resource}, 0 ) if $DERIVED{$kind};
Branch: 1 branch
BranchTrueFalseTotal
if $Langertha::Holmgang::Sim::Linux::Kubernetes::DERIVED{$kind} 0 1 1
753 1 my $t = _target( $k, $o, $kind );
754 1 ▶ delete $t->{$n} or return ( qq{Error from server (NotFound): } . ( $SINGULAR{$kind} =~ s/\..*//r ) . qq{s "$n" not found}, 0 );
Branch: 1 branch
BranchTrueFalseTotal
delete $$t{$n} or return 'Error from server (NotFound): ' . $Langertha::Holmgang::Sim::Linux::Kubernetes::SINGULAR{$kind} =~ s/\..*//r . qq[s "$n" not found], 0 1 0 1
755 1 push @out, ( $SINGULAR{$kind} =~ s/\..*//r ) . qq{ "$n" deleted};
756 }
757 3 return ( join( "\n", @out ), 1 );
758 }
759  
760 15 ▶sub _dep {
Subroutine _dep: called CC=6 SCAR=19.9
761 15 my ( $k, $o, $ref ) = @_;
762 15 ▶ my ( $kind, $name ) = _kind_name( [ split( m{/}, $ref // '', 2 ) ] );
Condition50%1/2
$ref // ""
l!l
150
MC/DC0%0/1
$ref // ""
$ref
Truth table50%1/2
A
A= $ref
Aresult
11
00
763 15 ▶ die qq{error: the server doesn't have a resource type "$ref"\n} unless ( $kind // '' ) eq 'deployments';
Branch: 1 branch
BranchTrueFalseTotal
unless ($kind // "") eq "deployments" 0 15 15
Condition50%1/2
$kind // ""
l!l
150
MC/DC0%0/1
$kind // ""
$kind
Truth table50%1/2
A
A= $kind
Aresult
11
00
764 15 ▶ my $d = $k->{namespaces}{ $o->{ns} }{deployments}{ $name // '' } or die qq{Error from server (NotFound): deployments.apps "$name" not found\n};
Branch: 1 branch
BranchTrueFalseTotal
my $d = $$k{"namespaces"}{$$o{"ns"}}{"deployments"}{$name // ""} or die qq[Error from server (NotFound): deployments.apps "$name" not found\n] 15 0 15
Condition50%1/2
$name // ""
l!l
150
MC/DC0%0/1
$name // ""
$name
Truth table50%1/2
A
A= $name
Aresult
11
00
765 15 return ( $d, $name );
766 }
767  
768 14 ▶sub _v_set {
Subroutine _v_set: called CC=42 SCAR=41.2
769 14 my ( $k, $a, $o ) = @_;
770 14 my ( $what, $ref, @assign ) = @$a;
771 14 my ( $d, $name ) = eval { _dep( $k, $o, $ref ) };
772 14 ▶ return ( $@ =~ s/\s+\z//r, 0 ) unless $d;
Branch: 1 branch
BranchTrueFalseTotal
unless $d 0 14 14
773 14 my $before = $J->encode( $d->{template} );
774 14 ▶ if ( ( $what // '' ) eq 'image' ) {
Branch: 3 branches
BranchTrueFalseTotal
if (($what // '') eq 'image') { } 1 13 14
elsif (($what // '') eq 'env') { } 13 0 13
elsif (($what // '') =~ /\A(?:serviceaccount|sa)\z/) { } 0 0 0
Condition50%1/2
$what // ""
l!l
140
MC/DC0%0/1
$what // ""
$what
Truth table50%1/2
A
A= $what
Aresult
11
00
775 1 for my $x (@assign) {
776 1 my ( $c, $img ) = split /=/, $x, 2;
777 1 ▶ my @cs = grep { $c eq '*' || $_->{name} eq $c } @{ $d->{template}{containers} };
Condition33%1/3
$c eq '*' || $$_{'name'} eq $c
l!l&&r!l&&!r
010
MC/DC0%0/2
$c eq '*' || $$_{'name'} eq $c
$c eq '*' $$_{'name'} eq $c
Truth table33%1/3
A || B
A= $c eq '*'B= $$_{'name'} eq $c
ABresult
1X1
011
000
778 1 ▶ return ( qq{error: unable to find container named "$c"}, 0 ) unless @cs;
Branch: 1 branch
BranchTrueFalseTotal
unless @cs 0 1 1
779 1 $_->{image} = $img for @cs;
780 }
781 }
782 ▶ elsif ( ( $what // '' ) eq 'env' ) {
Condition50%1/2
$what // ""
l!l
130
MC/DC0%0/1
$what // ""
$what
Truth table50%1/2
A
A= $what
Aresult
11
00
783 # -c/--containers waehlt Container (Komma-Liste, *); ohne: alle (wie kubectl)
784 13 ▶ my $want = $o->{container} // '*';
Condition100%2/2
$$o{"container"} // "*"
l!l
94
MC/DC100%1/1
$$o{"container"} // "*"
$$o{"container"}
Truth table100%2/2
A
A= $$o{"container"}
Aresult
11
00
785 13 my %want = map { $_ => 1 } split /,/, $want;
786 13 ▶ my @cs = grep { $want{'*'} || $want{ $_->{name} } } @{ $d->{template}{containers} };
Condition100%3/3
$want{'*'} || $want{$$_{'name'}}
l!l&&r!l&&!r
8810
MC/DC100%2/2
$want{'*'} || $want{$$_{'name'}}
$want{'*'} $want{$$_{'name'}}
Truth table100%3/3
A || B
A= $want{'*'}B= $want{$$_{'name'}}
ABresult
1X1
011
000
787 13 ▶ return ( qq{error: unable to find container named "$want"}, 0 ) unless @cs;
Branch: 1 branch
BranchTrueFalseTotal
unless @cs 1 12 13
788 12 ▶ if ( $o->{env_list} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($$o{"env_list"}) 1 11 12
789 return ( join( "\n", map {
790 1 my $c = $_;
791 ( "# deployments/$name, container $c->{name}",
792 map { defined $_->{secret} ? "# $_->{name} from secret $_->{secret}, key $_->{key}"
793 : defined $_->{configmap} ? "# $_->{name} from configmap $_->{configmap}, key $_->{key}"
794 2 ▶ : "$_->{name}=" . ( $_->{value} // '' ) } @{ $c->{env} || [] } );
Branch: 2 branches
BranchTrueFalseTotal
defined $$_{'secret'} ? : 1 1 2
defined $$_{'configmap'} ? : 0 1 1
Condition75%3/4
$$_{"value"} // ""
l!l
10
$$c{'env'} || []
l!l
11
MC/DC0%0/1
$$_{"value"} // ""
$$_{"value"}
MC/DC100%1/1
$$c{'env'} || []
$$c{'env'}
Truth table50%1/2
A
A= $$_{"value"}
Aresult
11
00
Truth table100%2/2
A
A= $$c{'env'}
Aresult
11
00
795 } @cs ), 1 );
796 }
797 11 my @set;
798 11 ▶ if ( defined $o->{env_from} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $$o{"env_from"}) 5 6 11
799 5 ▶ my ( $kind, $sname ) = $o->{env_from} =~ m{\A(secret|configmap)/(.+)\z}
Branch: 1 branch
BranchTrueFalseTotal
() = $$o{"env_from"} =~ m[\A(secret|configmap)/(.+)\z] or return qq[error: unknown resource for --from: $$o{"env_from"}], 0 5 0 5
800 or return ( "error: unknown resource for --from: $o->{env_from}", 0 );
801 0 ▶ if ( $kind eq 'configmap' ) { push @GAPS, 'kubectl set env --from=configmap'; return ( '', 0 ) }
Branch: 1 branch
BranchTrueFalseTotal
if ($kind eq "configmap") 0 5 5
802 5 ▶ my $sec = $k->{namespaces}{ $o->{ns} }{secrets}{$sname}
Branch: 1 branch
BranchTrueFalseTotal
my $sec = $$k{"namespaces"}{$$o{"ns"}}{"secrets"}{$sname} or return qq[Error from server (NotFound): secrets "$sname" not found], 0 4 1 5
803 or return ( qq{Error from server (NotFound): secrets "$sname" not found}, 0 );
804 4 ▶ my @keys = defined $o->{env_keys} ? split( /,/, $o->{env_keys} ) : sort keys %$sec;
Branch: 1 branch
BranchTrueFalseTotal
defined $$o{'env_keys'} ? : 3 1 4
805 4 for my $key (@keys) {
806 5 ▶ return ( qq{error: key "$key" not found in secret "$sname"}, 0 ) unless exists $sec->{$key};
Branch: 1 branch
BranchTrueFalseTotal
unless exists $$sec{$key} 1 4 5
807 4 ▶ ( my $n = uc( ( $o->{env_prefix} // '' ) . $key ) ) =~ s/[^A-Z0-9_]/_/g;
Condition100%2/2
$$o{"env_prefix"} // ""
l!l
22
MC/DC100%1/1
$$o{"env_prefix"} // ""
$$o{"env_prefix"}
Truth table100%2/2
A
A= $$o{"env_prefix"}
Aresult
11
00
808 4 push @set, [ $n, { name => $n, secret => $sname, key => $key } ];
809 }
810 }
811 9 for my $x (@assign) {
812 6 ▶ if ( $x =~ /\A([A-Za-z_][A-Za-z0-9_.-]*)-\z/ ) { push @set, [ $1, undef ]; next }
Branch: 1 branch
BranchTrueFalseTotal
if ($x =~ /\A([A-Za-z_][A-Za-z0-9_.-]*)-\z/) 1 5 6
813 5 ▶ my ( $n, $v ) = $x =~ /\A([^=]+)=(.*)\z/s or return ( "error: invalid env: $x", 0 );
Branch: 1 branch
BranchTrueFalseTotal
() = $x =~ /\A([^=]+)=(.*)\z/s or return "error: invalid env: $x", 0 5 0 5
814 5 push @set, [ $n, { name => $n, value => $v } ];
815 }
816 9 for my $c (@cs) {
817 10 for my $s (@set) {
818 11 my ( $n, $e ) = @$s;
819 11 ▶ my $had = grep { $_->{name} eq $n } @{ $c->{env} || [] };
Condition100%2/2
$$c{'env'} || []
l!l
101
MC/DC100%1/1
$$c{'env'} || []
$$c{'env'}
Truth table100%2/2
A
A= $$c{'env'}
Aresult
11
00
820 11 ▶ next if !$e && !$had;
Branch: 1 branch
BranchTrueFalseTotal
unless $e or $had 0 11 11
Condition66%2/3
$e or $had
l!l&&r!l&&!r
1010
MC/DC0%0/2
$e or $had
$e $had
Truth table66%2/3
A or B
A= $eB= $had
ABresult
1X1
011
000
821 11 ▶ $c->{env} = [ grep { $_->{name} ne $n } @{ $c->{env} || [] } ];
Condition100%2/2
$$c{'env'} || []
l!l
101
MC/DC100%1/1
$$c{'env'} || []
$$c{'env'}
Truth table100%2/2
A
A= $$c{'env'}
Aresult
11
00
822 11 ▶ push @{ $c->{env} }, $e if $e;
Branch: 1 branch
BranchTrueFalseTotal
if $e 10 1 11
823 }
824 }
825 }
826 ▶ elsif ( ( $what // '' ) =~ /\A(?:serviceaccount|sa)\z/ ) {
Condition0%0/2
$what // ""
l!l
00
MC/DC0%0/1
$what // ""
$what
Truth table0%0/2
A
A= $what
Aresult
11
00
827 0 ▶ return ( 'error: serviceaccount is required', 0 ) unless defined $assign[0];
Branch: 1 branch
BranchTrueFalseTotal
unless defined $assign[0] 0 0 0
828 0 $d->{template}{service_account} = $assign[0];
829 0 ▶ _bump($d) if $J->encode( $d->{template} ) ne $before;
Branch: 1 branch
BranchTrueFalseTotal
if $J->encode($$d{"template"}) ne $before 0 0 0
830 0 return ( "deployment.apps/$name serviceaccount updated", 1 );
831 }
832 0 else { push @GAPS, "kubectl set $what"; return ( '', 0 ) }
833 10 return ( "deployment.apps/$name " . ( $what eq 'image' ? 'image updated' : 'env updated' ), 1 ) if 0;
834 10 ▶ _bump($d) if $J->encode( $d->{template} ) ne $before;
Branch: 1 branch
BranchTrueFalseTotal
if $J->encode($$d{"template"}) ne $before 10 0 10
835 10 ▶ return ( "deployment.apps/$name " . ( $what eq 'image' ? 'image updated' : 'env updated' ), 1 );
Branch: 1 branch
BranchTrueFalseTotal
$what eq 'image' ? : 1 9 10
836 }
837  
838 13 ▶sub _merge {
Subroutine _merge: called CC=5 SCAR=16.8
839 13 my ( $a, $b ) = @_;
840 13 ▶ return $b unless ref $a eq 'HASH' && ref $b eq 'HASH';
Branch: 1 branch
BranchTrueFalseTotal
unless ref $a eq "HASH" and ref $b eq "HASH" 5 8 13
Condition66%2/3
ref $a eq "HASH" and ref $b eq "HASH"
!ll&&!rl&&r
508
MC/DC50%1/2
ref $a eq "HASH" and ref $b eq "HASH"
ref $a eq "HASH" ref $b eq "HASH"
Truth table66%2/3
A and B
A= ref $a eq "HASH"B= ref $b eq "HASH"
ABresult
0X0
100
111
841 8 my %r = %$a;
842 8 for my $k ( keys %$b ) {
843 0 ▶ if ( !defined $b->{$k} ) { delete $r{$k}; next }
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $$b{$k}) 0 9 9
844 9 $r{$k} = _merge( $a->{$k}, $b->{$k} );
845 }
846 8 return \%r;
847 }
848  
849 # strategic merge: Listen von Containern (name) bzw. Ports (port) werden zusammengefuehrt
850 24 ▶sub _smerge {
Subroutine _smerge: called CC=17 SCAR=32.1
851 24 my ( $a, $b, $key ) = @_;
852 24 ▶ if ( ref $a eq 'ARRAY' && ref $b eq 'ARRAY' && $key ) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $a eq "ARRAY" and ref $b eq "ARRAY" and $key) 2 22 24
Condition66%4/6
ref $a eq "ARRAY" and ref $b eq "ARRAY" and $key
!ll&&!rl&&r
2202
ref $a eq "ARRAY" and ref $b eq "ARRAY"
!ll&&!rl&&r
2202
MC/DC33%1/3
ref $a eq "ARRAY" and ref $b eq "ARRAY" and $key
ref $a eq "ARRAY" ref $b eq "ARRAY" $key
Truth table50%2/4
A and B and C
A= ref $a eq "ARRAY"B= ref $b eq "ARRAY"C= $key
ABCresult
0XX0
10X0
1100
1111
853 # Ports eines Service fuehrt die API ueber port zusammen, die eines Containers ueber containerPort
854 2 ▶ $key = 'port' if $key eq 'containerPort' && !grep { ref $_ eq 'HASH' && exists $_->{containerPort} } @$a, @$b;
Branch: 1 branch
BranchTrueFalseTotal
if $key eq "containerPort" and not grep({ref $_ eq "HASH" and exists $$_{"containerPort"};} @$a, @$b) 1 1 2
Condition50%3/6
$key eq "containerPort" and not grep({ref $_ eq "HASH" and exists $$_{"containerPort"};} @$a, @$b)
!ll&&!rl&&r
101
ref $_ eq 'HASH' && exists $$_{'containerPort'}
!ll&&!rl&&r
030
MC/DC50%1/2
$key eq "containerPort" and not grep({ref $_ eq "HASH" and exists $$_{"containerPort"};} @$a, @$b)
$key eq "containerPort" not grep({ref $_ eq "HASH" and exists $$_{"containerPort"};} @$a, @$b)
MC/DC0%0/2
ref $_ eq 'HASH' && exists $$_{'containerPort'}
ref $_ eq 'HASH' exists $$_{'containerPort'}
Truth table66%2/3
A and not(B)
A= $key eq "containerPort"B= not grep({ref $_ eq "HASH" and exists $$_{"containerPort"};} @$a, @$b)
ABresult
0X0
100
111
Truth table33%1/3
A && B
A= ref $_ eq 'HASH'B= exists $$_{'containerPort'}
ABresult
0X0
100
111
855 2 my @r = @$a;
856 2 for my $x (@$b) {
857 2 ▶ my ($i) = grep { ref $r[$_] eq 'HASH' && ref $x eq 'HASH' && defined $x->{$key} && ( $r[$_]{$key} // '' ) eq $x->{$key} } 0 .. $#r;
Condition45%5/11
ref $r[$_] eq 'HASH' && ref $x eq 'HASH' && defined $$x{$key} && ($r[$_]{$key} // '') eq $$x{$key}
!ll&&!rl&&r
012
ref $r[$_] eq "HASH" and ref $x eq "HASH" and defined $$x{$key}
!ll&&!rl&&r
003
ref $r[$_] eq "HASH" and ref $x eq "HASH"
!ll&&!rl&&r
003
$r[$_]{$key} // ""
l!l
30
MC/DC0%0/4
ref $r[$_] eq 'HASH' && ref $x eq 'HASH' && defined $$x{$key} && ($r[$_]{$key} // '') eq $$x{$key}
ref $r[$_] eq "HASH" ref $x eq "HASH" defined $$x{$key} $r[$_]{$key}
Truth table20%1/5
A and B and C && D
A= ref $r[$_] eq "HASH"B= ref $x eq "HASH"C= defined $$x{$key}D= $r[$_]{$key}
ABCDresult
0XXX0
10XX0
110X0
11100
11111
858 0 ▶ if ( defined $i ) { $r[$i] = _smerge( $r[$i], $x ) } else { push @r, $x }
Branch: 1 branch
BranchTrueFalseTotal
if (defined $i) { } 2 0 2
859 }
860 2 return \@r;
861 }
862 22 ▶ return $b unless ref $a eq 'HASH' && ref $b eq 'HASH';
Branch: 1 branch
BranchTrueFalseTotal
unless ref $a eq "HASH" and ref $b eq "HASH" 7 15 22
Condition66%2/3
ref $a eq "HASH" and ref $b eq "HASH"
!ll&&!rl&&r
7015
MC/DC50%1/2
ref $a eq "HASH" and ref $b eq "HASH"
ref $a eq "HASH" ref $b eq "HASH"
Truth table66%2/3
A and B
A= ref $a eq "HASH"B= ref $b eq "HASH"
ABresult
0X0
100
111
863 15 my %r = %$a;
864 15 my %mk = ( containers => 'name', env => 'name', ports => 'containerPort', volumes => 'name', volumeMounts => 'mountPath' );
865 15 for my $k ( keys %$b ) {
866 0 ▶ if ( !defined $b->{$k} ) { delete $r{$k}; next }
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $$b{$k}) 0 18 18
867 18 $r{$k} = _smerge( $a->{$k}, $b->{$k}, $mk{$k} );
868 }
869 15 return \%r;
870 }
871  
872 4 ▶sub _jsonpatch {
Subroutine _jsonpatch: called CC=16 SCAR=34.9
873 4 my ( $doc, $ops ) = @_;
874 4 for my $op (@$ops) {
875 4 ▶ my @p = map { s/~1/\//gr =~ s/~0/~/gr } grep { length } split m{/}, $op->{path} // '';
Condition50%1/2
$$op{"path"} // ""
l!l
40
MC/DC0%0/1
$$op{"path"} // ""
$$op{"path"}
Truth table50%1/2
A
A= $$op{"path"}
Aresult
11
00
876 4 my $last = pop @p;
877 4 my $t = $doc;
878 4 ▶ for my $s (@p) { $t = ref $t eq 'ARRAY' ? $t->[$s] : $t->{$s}; die "error: unable to find path $op->{path}\n" unless ref $t }
Branch: 2 branches
BranchTrueFalseTotal
ref $t eq 'ARRAY' ? : 4 15 19
unless ref $t 0 19 19
879 4 ▶ my $o = $op->{op} // '';
Condition50%1/2
$$op{"op"} // ""
l!l
40
MC/DC0%0/1
$$op{"op"} // ""
$$op{"op"}
Truth table50%1/2
A
A= $$op{"op"}
Aresult
11
00
880 4 ▶ if ( $o eq 'replace' || $o eq 'add' ) {
Branch: 2 branches
BranchTrueFalseTotal
if ($o eq 'replace' or $o eq 'add') { } 4 0 4
elsif ($o eq 'remove') { } 0 0 0
Condition66%2/3
$o eq "replace" or $o eq "add"
l!l&&r!l&&!r
310
MC/DC0%0/2
$o eq "replace" or $o eq "add"
$o eq "replace" $o eq "add"
Truth table66%2/3
A or B
A= $o eq "replace"B= $o eq "add"
ABresult
1X1
011
000
881 0 ▶ if ( ref $t eq 'ARRAY' ) { if ( $last eq '-' ) { push @$t, $op->{value} } elsif ( $o eq 'add' ) { splice @$t, $last, 0, $op->{value} } else { $t->[$last] = $op->{value} } }
Branch: 3 branches
BranchTrueFalseTotal
if (ref $t eq 'ARRAY') { } 1 3 4
if ($last eq '-') { } 1 0 1
elsif ($o eq 'add') { } 0 0 0
882 3 ▶ else { die "error: replace operation does not apply: doc is missing path: $op->{path}\n" if $o eq 'replace' && !exists $t->{$last}; $t->{$last} = $op->{value} }
Branch: 1 branch
BranchTrueFalseTotal
if $o eq "replace" and not exists $$t{$last} 0 3 3
Condition33%1/3
$o eq "replace" and not exists $$t{$last}
!ll&&!rl&&r
030
MC/DC0%0/2
$o eq "replace" and not exists $$t{$last}
$o eq "replace" not exists $$t{$last}
Truth table33%1/3
A and not(B)
A= $o eq "replace"B= not exists $$t{$last}
ABresult
0X0
100
111
883 }
884 0 ▶ elsif ( $o eq 'remove' ) { if ( ref $t eq 'ARRAY' ) { splice @$t, $last, 1 } else { delete $t->{$last} } }
Branch: 1 branch
BranchTrueFalseTotal
if (ref $t eq 'ARRAY') { } 0 0 0
885 0 else { die "error: unsupported json patch operation $o\n" }
886 }
887 4 return $doc;
888 }
889  
890 12 ▶sub _v_patch {
Subroutine _v_patch: called CC=15 SCAR=30.8
891 12 my ( $k, $a, $o ) = @_;
892 12 my ( $kind, $name ) = _kind_name($a);
893 12 ▶ return ( 'error: you must specify the type of resource to patch', 0 ) unless $kind && defined $name;
Branch: 1 branch
BranchTrueFalseTotal
unless $kind and defined $name 0 12 12
Condition33%1/3
$kind and defined $name
!ll&&!rl&&r
0012
MC/DC0%0/2
$kind and defined $name
$kind defined $name
Truth table33%1/3
A and B
A= $kindB= defined $name
ABresult
0X0
100
111
894 0 ▶ my $p = eval { JSON::MaybeXS->new->decode( $o->{patch} // '' ) } // eval { YAML::XS::Load( $o->{patch} // '' ) };
Condition28%2/7
eval { do { "JSON::MaybeXS"->new->decode($$o{"patch"} // "") } } // eval { do { YAML::XS::Load($$o{"patch"} // "") } }
l!l&&r!l&&!r
1200
$$o{"patch"} // ""
l!l
120
$$o{"patch"} // ""
l!l
00
MC/DC0%0/2
eval { do { "JSON::MaybeXS"->new->decode($$o{"patch"} // "") } } // eval { do { YAML::XS::Load($$o{"patch"} // "") } }
eval { do { "JSON::MaybeXS"->new->decode($$o{"patch"} // "") } } eval { do { YAML::XS::Load($$o{"patch"} // "") } }
MC/DC0%0/1
$$o{"patch"} // ""
$$o{"patch"}
MC/DC0%0/1
$$o{"patch"} // ""
$$o{"patch"}
Truth table33%1/3
A // B
A= eval { do { "JSON::MaybeXS"->new->decode($$o{"patch"} // "") } }B= eval { do { YAML::XS::Load($$o{"patch"} // "") } }
ABresult
1X1
011
000
Truth table50%1/2
A
A= $$o{"patch"}
Aresult
11
00
Truth table0%0/2
A
A= $$o{"patch"}
Aresult
11
00
895 12 ▶ return ( 'error: unable to parse "' . ( $o->{patch} // '' ) . '": yaml: did not find expected node content', 0 ) unless ref $p;
Branch: 1 branch
BranchTrueFalseTotal
unless ref $p 0 12 12
Condition0%0/2
$$o{"patch"} // ""
l!l
00
MC/DC0%0/1
$$o{"patch"} // ""
$$o{"patch"}
Truth table0%0/2
A
A= $$o{"patch"}
Aresult
11
00
896 12 my $t = _target( $k, $o, $kind );
897 12 ▶ my $old = $t->{$name} or return ( qq{Error from server (NotFound): } . ( $SINGULAR{$kind} =~ s/\..*//r ) . qq{s "$name" not found}, 0 );
Branch: 1 branch
BranchTrueFalseTotal
my $old = $$t{$name} or return 'Error from server (NotFound): ' . $Langertha::Holmgang::Sim::Linux::Kubernetes::SINGULAR{$kind} =~ s/\..*//r . qq[s "$name" not found], 0 12 0 12
898 12 my $api = _api_obj( $kind, $name, $old, $o->{ns} );
899 12 ▶ my $type = $o->{type} // 'strategic';
Condition100%2/2
$$o{"type"} // "strategic"
l!l
84
MC/DC100%1/1
$$o{"type"} // "strategic"
$$o{"type"}
Truth table100%2/2
A
A= $$o{"type"}
Aresult
11
00
900 12 my $new = eval {
901 12 ▶ $type eq 'json' ? _jsonpatch( $api, $p ) : $type eq 'merge' ? _merge( $api, $p ) : _smerge( $api, $p );
Branch: 2 branches
BranchTrueFalseTotal
$type eq 'json' ? : 4 8 12
$type eq 'merge' ? : 4 4 8
902 };
903 12 ▶ return ( $@ =~ s/\s+\z//r, 0 ) unless $new;
Branch: 1 branch
BranchTrueFalseTotal
unless $new 0 12 12
904 12 my $r = eval { _store( $k, $kind, $o->{ns}, $name, _from_api( $kind, $new, $old ) ) };
905 12 ▶ return ( $@ =~ s/\s+\z//r, 0 ) if $@;
Branch: 1 branch
BranchTrueFalseTotal
if $@ 2 10 12
906 10 ▶ return ( "$SINGULAR{$kind}/$name " . ( $r eq 'unchanged' ? 'patched (no change)' : 'patched' ), 1 );
Branch: 1 branch
BranchTrueFalseTotal
$r eq 'unchanged' ? : 0 10 10
907 }
908  
909 0 ▶sub _v_scale {
Subroutine _v_scale: not called CC=4 SCAR=30.0
910 0 my ( $k, $a, $o ) = @_;
911 0 ▶ my $ref = @$a == 2 ? "$a->[0]/$a->[1]" : $a->[0];
Branch: 1 branch
BranchTrueFalseTotal
@$a == 2 ? : 0 0 0
912 0 my ( $d, $name ) = eval { _dep( $k, $o, $ref ) };
913 0 ▶ return ( $@ =~ s/\s+\z//r, 0 ) unless $d;
Branch: 1 branch
BranchTrueFalseTotal
unless $d 0 0 0
914 0 ▶ return ( 'error: required flag(s) "replicas" not set', 0 ) unless defined $o->{replicas};
Branch: 1 branch
BranchTrueFalseTotal
unless defined $$o{"replicas"} 0 0 0
915 0 $d->{replicas} = 0 + $o->{replicas};
916 0 return ( "deployment.apps/$name scaled", 1 );
917 }
918  
919 0 ▶sub _v_label { return _meta_edit( 'labels', @_ ) }
Subroutine _v_label: not called CC=1 SCAR=6.9
920 1 ▶sub _v_annotate { return _meta_edit( 'annotations', @_ ) }
Subroutine _v_annotate: called CC=1 SCAR=0.0
921  
922 # kubectl label|annotate KIND NAME k=v k2- [--overwrite]: nur Arten in API-Form
923 1 ▶sub _meta_edit {
Subroutine _meta_edit: called CC=19 SCAR=38.4
924 1 my ( $what, $k, $a, $o ) = @_;
925 1 my ( $kind, $name ) = _kind_name($a);
926 1 ▶ my $verb = $what eq 'labels' ? 'label' : 'annotate';
Branch: 1 branch
BranchTrueFalseTotal
$what eq 'labels' ? : 0 1 1
927 0 ▶ unless ( $kind && $GEN{$kind} ) { push @GAPS, "kubectl $verb @$a"; return ( '', 0 ) }
Branch: 1 branch
BranchTrueFalseTotal
unless ($kind and $Langertha::Holmgang::Sim::Linux::Kubernetes::GEN{$kind}) 0 1 1
Condition33%1/3
$kind and $Langertha::Holmgang::Sim::Linux::Kubernetes::GEN{$kind}
!ll&&!rl&&r
001
MC/DC0%0/2
$kind and $Langertha::Holmgang::Sim::Linux::Kubernetes::GEN{$kind}
$kind $Langertha::Holmgang::Sim::Linux::Kubernetes::GEN{$kind}
Truth table33%1/3
A and B
A= $kindB= $Langertha::Holmgang::Sim::Linux::Kubernetes::GEN{$kind}
ABresult
0X0
100
111
928 1 ▶ my @kv = @$a[ ( $a->[0] =~ m{/} ? 1 : 2 ) .. $#$a ];
Branch: 1 branch
BranchTrueFalseTotal
$$a[0] =~ m[/] ? : 0 1 1
929 1 ▶ return ( "error: at least one $what update is required", 0 ) unless @kv;
Branch: 1 branch
BranchTrueFalseTotal
unless @kv 0 1 1
930 1 my $t = _target( $k, $o, $kind );
931 1 ▶ my $x = $t->{ $name // '' } or return ( qq{Error from server (NotFound): $GEN{$kind}[3] "} . ( $name // '' ) . '" not found', 0 );
Branch: 1 branch
BranchTrueFalseTotal
my $x = $$t{$name // ""} or return qq[Error from server (NotFound): $Langertha::Holmgang::Sim::Linux::Kubernetes::GEN{$kind}[3] "] . ($name // "") . '" not found', 0 1 0 1
Condition25%1/4
$name // ""
l!l
10
$name // ""
l!l
00
MC/DC0%0/1
$name // ""
$name
MC/DC0%0/1
$name // ""
$name
Truth table50%1/2
A
A= $name
Aresult
11
00
Truth table0%0/2
A
A= $name
Aresult
11
00
932 1 ▶ my $m = $x->{metadata}{$what} ||= {};
Condition50%1/2
$$x{"metadata"}{$what} ||= {}
l!l
10
MC/DC0%0/1
$$x{"metadata"}{$what} ||= {}
$$x{"metadata"}{$what}
Truth table50%1/2
A
A= $$x{"metadata"}{$what}
Aresult
11
00
933 1 for my $e (@kv) {
934 0 ▶ if ( $e =~ /\A([^=]+)-\z/ ) { delete $m->{$1}; next }
Branch: 1 branch
BranchTrueFalseTotal
if ($e =~ /\A([^=]+)-\z/) 0 1 1
935 1 ▶ my ( $kk, $v ) = $e =~ /\A([^=]+)=(.*)\z/s or return ( "error: invalid $what format: $e", 0 );
Branch: 1 branch
BranchTrueFalseTotal
() = $e =~ /\A([^=]+)=(.*)\z/s or return "error: invalid $what format: $e", 0 1 0 1
936 return ( "error: --overwrite is false but found the following declared $what(s): '$kk' already has a value ($m->{$kk})", 0 )
937 1 ▶ if defined $m->{$kk} && $m->{$kk} ne $v && !$o->{flags}{'--overwrite'};
Branch: 1 branch
BranchTrueFalseTotal
if defined $$m{$kk} and $$m{$kk} ne $v and not $$o{"flags"}{"--overwrite"} 0 1 1
Condition33%2/6
defined $$m{$kk} and $$m{$kk} ne $v and not $$o{"flags"}{"--overwrite"}
!ll&&!rl&&r
010
defined $$m{$kk} and $$m{$kk} ne $v
!ll&&!rl&&r
001
MC/DC0%0/3
defined $$m{$kk} and $$m{$kk} ne $v and not $$o{"flags"}{"--overwrite"}
defined $$m{$kk} $$m{$kk} ne $v not $$o{"flags"}{"--overwrite"}
Truth table25%1/4
A and B and not(C)
A= defined $$m{$kk}B= $$m{$kk} ne $vC= not $$o{"flags"}{"--overwrite"}
ABCresult
0XX0
10X0
1100
1111
938 1 $m->{$kk} = $v;
939 }
940 1 ▶ delete $x->{metadata}{$what} unless %$m;
Branch: 1 branch
BranchTrueFalseTotal
unless %$m 0 1 1
941 1 ▶ delete $x->{metadata} unless %{ $x->{metadata} };
Branch: 1 branch
BranchTrueFalseTotal
unless %{$$x{"metadata"};} 0 1 1
942 1 ▶ return ( "$GEN{$kind}[3]/$name " . ( $what eq 'labels' ? 'labeled' : 'annotated' ), 1 );
Branch: 1 branch
BranchTrueFalseTotal
$what eq 'labels' ? : 0 1 1
943 }
944  
945 1 ▶sub _v_rollout {
Subroutine _v_rollout: called CC=14 SCAR=42.5
946 1 my ( $k, $a, $o ) = @_;
947 1 my ( $what, @refs ) = @$a;
948 1 ▶ @refs = ( "$refs[0]/$refs[1]" ) if @refs == 2 && $refs[0] !~ m{/};
Branch: 1 branch
BranchTrueFalseTotal
if @refs == 2 and not $refs[0] =~ m[/] 0 1 1
Condition33%1/3
@refs == 2 and not $refs[0] =~ m[/]
!ll&&!rl&&r
100
MC/DC0%0/2
@refs == 2 and not $refs[0] =~ m[/]
@refs == 2 not $refs[0] =~ m[/]
Truth table33%1/3
A and not(B)
A= @refs == 2B= not $refs[0] =~ m[/]
ABresult
0X0
100
111
949 1 my @out;
950 1 for my $ref (@refs) {
951 1 my ( $d, $name ) = eval { _dep( $k, $o, $ref ) };
952 1 ▶ return ( $@ =~ s/\s+\z//r, 0 ) unless $d;
Branch: 1 branch
BranchTrueFalseTotal
unless $d 0 1 1
953 1 ▶ if ( $what eq 'restart' ) {
Branch: 4 branches
BranchTrueFalseTotal
if ($what eq 'restart') { } 1 0 1
elsif ($what eq 'status') { } 0 0 0
elsif ($what eq 'undo') { } 0 0 0
elsif ($what eq 'history') { } 0 0 0
954 1 ▶ $d->{restarted_at} = '2026-10-21T12:' . sprintf( '%02d', ( $d->{generation} // 1 ) % 60 ) . ':00Z';
Condition50%1/2
$$d{"generation"} // 1
l!l
10
MC/DC0%0/1
$$d{"generation"} // 1
$$d{"generation"}
Truth table50%1/2
A
A= $$d{"generation"}
Aresult
11
00
955 1 _bump($d);
956 1 push @out, "deployment.apps/$name restarted";
957 }
958 elsif ( $what eq 'status' ) {
959 0 my @p = grep { $_->{deployment} eq $name } _pods( $k, $o->{ns} );
960 0 my $r = grep { $_->{ready} } @p;
961 0 ▶ push @out, $r == @p ? qq{deployment "$name" successfully rolled out}
Branch: 1 branch
BranchTrueFalseTotal
$r == @p ? : 0 0 0
962 : qq{Waiting for deployment "$name" rollout to finish: $r of } . scalar(@p) . " updated replicas are available...\nerror: timed out waiting for the condition";
963 0 ▶ return ( join( "\n", @out ), 0 ) if $r != @p;
Branch: 1 branch
BranchTrueFalseTotal
if $r != @p 0 0 0
964 }
965 elsif ( $what eq 'undo' ) {
966 0 ▶ my $prev = $d->{previous} or return ( qq{error: no rollout history found for deployment "$name"}, 0 );
Branch: 1 branch
BranchTrueFalseTotal
my $prev = $$d{"previous"} or return qq[error: no rollout history found for deployment "$name"], 0 0 0 0
967 0 $d->{template} = $prev;
968 0 delete $d->{previous};
969 0 _bump($d);
970 0 push @out, "deployment.apps/$name rolled back";
971 }
972 elsif ( $what eq 'history' ) {
973 0 ▶ push @out, "deployment.apps/$name \nREVISION CHANGE-CAUSE\n" . join( "\n", map {"$_ <none>"} 1 .. ( $d->{generation} // 1 ) );
Condition0%0/2
$$d{"generation"} // 1
l!l
00
MC/DC0%0/1
$$d{"generation"} // 1
$$d{"generation"}
Truth table0%0/2
A
A= $$d{"generation"}
Aresult
11
00
974 }
975 0 else { push @GAPS, "kubectl rollout $what"; return ( '', 0 ) }
976 }
977 1 return ( join( "\n", @out ), 1 );
978 }
979  
980 5 ▶sub _v_logs {
Subroutine _v_logs: called CC=20 SCAR=35.5
981 5 my ( $k, $a, $o ) = @_;
982 5 ▶ my $ref = $a->[0] // return ( 'error: expected \'logs [-f] [-p] (POD | TYPE/NAME) [-c CONTAINER]\'.', 0 );
Condition50%1/2
$$a[0] // (return "error: expected 'logs [-f] [-p] (POD | TYPE/NAME) [-c CONTAINER]'.", 0)
l!l
50
MC/DC0%0/1
$$a[0] // (return "error: expected 'logs [-f] [-p] (POD | TYPE/NAME) [-c CONTAINER]'.", 0)
$$a[0]
Truth table50%1/2
A
A= $$a[0]
Aresult
11
00
983 5 my @p = _pods( $k, $o->{ns} );
984 5 ▶ my ($p) = $ref =~ m{\A(?:deploy(?:ment)?(?:\.apps)?)/(.+)\z} ? grep { $_->{deployment} eq $1 } @p : grep { $_->{name} eq $ref || "pod/$_->{name}" eq $ref } @p;
Branch: 1 branch
BranchTrueFalseTotal
$ref =~ m[\A(?:deploy(?:ment)?(?:\.apps)?)/(.+)\z] ? : 4 1 5
Condition66%2/3
$$_{'name'} eq $ref || "pod/$$_{'name'}" eq $ref
l!l&&r!l&&!r
015
MC/DC50%1/2
$$_{'name'} eq $ref || "pod/$$_{'name'}" eq $ref
$$_{'name'} eq $ref "pod/$$_{'name'}" eq $ref
Truth table66%2/3
A || B
A= $$_{'name'} eq $refB= "pod/$$_{'name'}" eq $ref
ABresult
1X1
011
000
985 5 ▶ return ( qq{Error from server (NotFound): pods "$ref" not found}, 0 ) unless $p;
Branch: 1 branch
BranchTrueFalseTotal
unless $p 0 5 5
986 5 my ($c) = @{ $p->{template}{containers} };
987 5 ▶ if ( $p->{reason} eq 'ImagePullBackOff' || $p->{reason} eq 'CreateContainerConfigError' || $p->{phase} eq 'Pending' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($$p{"reason"} eq "ImagePullBackOff" or $$p{"reason"} eq "CreateContainerConfigError" or $$p{"phase"} eq "Pending") 0 5 5
Condition33%2/6
$$p{"reason"} eq "ImagePullBackOff" or $$p{"reason"} eq "CreateContainerConfigError" or $$p{"phase"} eq "Pending"
l!l&&r!l&&!r
005
$$p{"reason"} eq "ImagePullBackOff" or $$p{"reason"} eq "CreateContainerConfigError"
l!l&&r!l&&!r
005
MC/DC0%0/3
$$p{"reason"} eq "ImagePullBackOff" or $$p{"reason"} eq "CreateContainerConfigError" or $$p{"phase"} eq "Pending"
$$p{"reason"} eq "ImagePullBackOff" $$p{"reason"} eq "CreateContainerConfigError" $$p{"phase"} eq "Pending"
Truth table25%1/4
A or B or C
A= $$p{"reason"} eq "ImagePullBackOff"B= $$p{"reason"} eq "CreateContainerConfigError"C= $$p{"phase"} eq "Pending"
ABCresult
1XX1
01X1
0011
0000
988 0 ▶ return ( qq{Error from server (BadRequest): container "$c->{name}" in pod "$p->{name}" is waiting to start: } . ( $p->{reason} eq 'ImagePullBackOff' ? 'trying and failing to pull image' : $p->{reason} eq 'CreateContainerConfigError' ? 'CreateContainerConfigError' : 'ContainerCreating' ), 0 );
Branch: 2 branches
BranchTrueFalseTotal
$$p{'reason'} eq 'ImagePullBackOff' ? : 0 0 0
$$p{'reason'} eq 'CreateContainerConfigError' ? : 0 0 0
989 }
990 5 ▶ my @l = $p->{reason} eq 'CrashLoopBackOff' ? @{ $p->{container}{crash_log} || ['error: missing configuration'] } : @{ $c->{logs} || [] };
Branch: 1 branch
BranchTrueFalseTotal
$$p{'reason'} eq 'CrashLoopBackOff' ? : 2 3 5
Condition75%3/4
$$p{'container'}{'crash_log'} || ['error: missing configuration']
l!l
20
$$c{'logs'} || []
l!l
21
MC/DC0%0/1
$$p{'container'}{'crash_log'} || ['error: missing configuration']
$$p{'container'}{'crash_log'}
MC/DC100%1/1
$$c{'logs'} || []
$$c{'logs'}
Truth table50%1/2
A
A= $$p{'container'}{'crash_log'}
Aresult
11
00
Truth table100%2/2
A
A= $$c{'logs'}
Aresult
11
00
991 # Controller, deren Log aus dem Zustand folgt
992 5 ▶ push @l, _ingress_log($k) if ( $c->{derive_logs} // '' ) eq 'ingress-nginx';
Branch: 1 branch
BranchTrueFalseTotal
if ($$c{"derive_logs"} // "") eq "ingress-nginx" 2 3 5
Condition100%2/2
$$c{"derive_logs"} // ""
l!l
23
MC/DC100%1/1
$$c{"derive_logs"} // ""
$$c{"derive_logs"}
Truth table100%2/2
A
A= $$c{"derive_logs"}
Aresult
11
00
993 5 ▶ push @l, _cm_log($k) if ( $c->{derive_logs} // '' ) eq 'cert-manager';
Branch: 1 branch
BranchTrueFalseTotal
if ($$c{"derive_logs"} // "") eq "cert-manager" 0 5 5
Condition100%2/2
$$c{"derive_logs"} // ""
l!l
23
MC/DC100%1/1
$$c{"derive_logs"} // ""
$$c{"derive_logs"}
Truth table100%2/2
A
A= $$c{"derive_logs"}
Aresult
11
00
994 5 ▶ @l = @l[ ( @l > $o->{tail} ? @l - $o->{tail} : 0 ) .. $#l ] if defined $o->{tail} && $o->{tail} =~ /\A\d+\z/;
Branch: 2 branches
BranchTrueFalseTotal
if defined $$o{"tail"} and $$o{"tail"} =~ /\A\d+\z/ 0 5 5
@l > $$o{'tail'} ? : 0 0 0
Condition33%1/3
defined $$o{"tail"} and $$o{"tail"} =~ /\A\d+\z/
!ll&&!rl&&r
500
MC/DC0%0/2
defined $$o{"tail"} and $$o{"tail"} =~ /\A\d+\z/
defined $$o{"tail"} $$o{"tail"} =~ /\A\d+\z/
Truth table33%1/3
A and B
A= defined $$o{"tail"}B= $$o{"tail"} =~ /\A\d+\z/
ABresult
0X0
100
111
995 5 return ( join( "\n", @l ), 1 );
996 }
997  
998 5 ▶sub _v_describe {
Subroutine _v_describe: called CC=54 SCAR=70.1
999 5 my ( $k, $a, $o ) = @_;
1000 5 my ( $kind, $name ) = _kind_name($a);
1001 5 ▶ return ( 'error: You must specify the type of resource to describe.', 0 ) unless $kind;
Branch: 1 branch
BranchTrueFalseTotal
unless $kind 0 5 5
1002 5 my $ns = $o->{ns};
1003 5 ▶ if ( $GEN{$kind} || $DERIVED{$kind} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($Langertha::Holmgang::Sim::Linux::Kubernetes::GEN{$kind} or $Langertha::Holmgang::Sim::Linux::Kubernetes::DERIVED{$kind}) 3 2 5
Condition100%3/3
$Langertha::Holmgang::Sim::Linux::Kubernetes::GEN{$kind} or $Langertha::Holmgang::Sim::Linux::Kubernetes::DERIVED{$kind}
l!l&&r!l&&!r
212
MC/DC100%2/2
$Langertha::Holmgang::Sim::Linux::Kubernetes::GEN{$kind} or $Langertha::Holmgang::Sim::Linux::Kubernetes::DERIVED{$kind}
$Langertha::Holmgang::Sim::Linux::Kubernetes::GEN{$kind} $Langertha::Holmgang::Sim::Linux::Kubernetes::DERIVED{$kind}
Truth table100%3/3
A or B
A= $Langertha::Holmgang::Sim::Linux::Kubernetes::GEN{$kind}B= $Langertha::Holmgang::Sim::Linux::Kubernetes::DERIVED{$kind}
ABresult
1X1
011
000
1004 3 ▶ return _describe_gen( $k, $kind, $ns, $name ) if defined $name || $DERIVED{$kind};
Branch: 1 branch
BranchTrueFalseTotal
if defined $name or $Langertha::Holmgang::Sim::Linux::Kubernetes::DERIVED{$kind} 3 0 3
Condition66%2/3
defined $name or $Langertha::Holmgang::Sim::Linux::Kubernetes::DERIVED{$kind}
l!l&&r!l&&!r
210
MC/DC0%0/2
defined $name or $Langertha::Holmgang::Sim::Linux::Kubernetes::DERIVED{$kind}
defined $name $Langertha::Holmgang::Sim::Linux::Kubernetes::DERIVED{$kind}
Truth table66%2/3
A or B
A= defined $nameB= $Langertha::Holmgang::Sim::Linux::Kubernetes::DERIVED{$kind}
ABresult
1X1
011
000
1005 0 ▶ my @n = sort keys %{ $kind eq 'certificates' ? _certs( $k, $ns ) : _gen_objs( $k, $kind, $ns ) };
Branch: 1 branch
BranchTrueFalseTotal
$kind eq 'certificates' ? : 0 0 0
1006 0 ▶ return ( "No resources found in $ns namespace.", 1 ) unless @n;
Branch: 1 branch
BranchTrueFalseTotal
unless @n 0 0 0
1007 0 return ( join( "\n\n\n", map { ( _describe_gen( $k, $kind, $ns, $_ ) )[0] } @n ), 1 );
1008 }
1009 2 ▶ if ( $kind eq 'pods' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($kind eq "pods") 1 1 2
1010 1 ▶ my @p = grep { !defined $name || $_->{name} eq $name || index( $_->{name}, $name ) == 0 } _pods( $k, $ns );
Condition66%4/6
!defined($name) || $$_{'name'} eq $name || index($$_{'name'}, $name) == 0
l!l&&r!l&&!r
102
not defined $name or $$_{"name"} eq $name
l!l&&r!l&&!r
012
MC/DC33%1/3
!defined($name) || $$_{'name'} eq $name || index($$_{'name'}, $name) == 0
not defined $name $$_{"name"} eq $name index($$_{'name'}, $name) == 0
Truth table50%2/4
not(A) or B || C
A= not defined $nameB= $$_{"name"} eq $nameC= index($$_{'name'}, $name) == 0
ABCresult
1XX1
01X1
0011
0000
1011 1 ▶ return ( qq{Error from server (NotFound): pods "$name" not found}, 0 ) unless @p;
Branch: 1 branch
BranchTrueFalseTotal
unless @p 0 1 1
1012 1 return ( join( "\n\n", map { _describe_pod( $k, $ns, $_ ) } @p ), 1 );
1013 }
1014 1 ▶ if ( $kind eq 'deployments' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($kind eq "deployments") 0 1 1
1015 0 ▶ my $d = $k->{namespaces}{$ns}{deployments}{ $name // '' } or return ( qq{Error from server (NotFound): deployments.apps "$name" not found}, 0 );
Branch: 1 branch
BranchTrueFalseTotal
my $d = $$k{"namespaces"}{$ns}{"deployments"}{$name // ""} or return qq[Error from server (NotFound): deployments.apps "$name" not found], 0 0 0 0
Condition0%0/2
$name // ""
l!l
00
MC/DC0%0/1
$name // ""
$name
Truth table0%0/2
A
A= $name
Aresult
11
00
1016 0 my @p = grep { $_->{deployment} eq $name } _pods( $k, $ns );
1017 0 my $r = grep { $_->{ready} } @p;
1018 return ( join( "\n", "Name: $name", "Namespace: $ns", 'Selector: ' . _labels_text( $d->{selector} ),
1019 "Replicas: $d->{replicas} desired | " . scalar(@p) . ' updated | ' . scalar(@p) . " total | $r available | " . ( @p - $r ) . ' unavailable',
1020 'StrategyType: RollingUpdate', 'Pod Template:', ' Labels: ' . _labels_text( $d->{template}{labels} ), ' Containers:',
1021 0 ▶ ( map { _describe_container( $_, ' ' ) } @{ $d->{template}{containers} } ),
Branch: 1 branch
BranchTrueFalseTotal
$r == @p ? : 0 0 0
1022 'Conditions:', ' Type Status Reason', ' ---- ------ ------',
1023 ' Available ' . ( $r == @p ? 'True MinimumReplicasAvailable' : 'False MinimumReplicasUnavailable' ),
1024 ' Progressing True NewReplicaSetAvailable' ), 1 );
1025 }
1026 1 ▶ if ( $kind eq 'services' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($kind eq "services") 0 1 1
1027 0 ▶ my $s = $k->{namespaces}{$ns}{services}{ $name // '' } or return ( qq{Error from server (NotFound): services "$name" not found}, 0 );
Branch: 1 branch
BranchTrueFalseTotal
my $s = $$k{"namespaces"}{$ns}{"services"}{$name // ""} or return qq[Error from server (NotFound): services "$name" not found], 0 0 0 0
Condition0%0/2
$name // ""
l!l
00
MC/DC0%0/1
$name // ""
$name
Truth table0%0/2
A
A= $name
Aresult
11
00
1028 0 my @e = _endpoints( $k, $ns, $name );
1029 return ( join( "\n", "Name: $name", "Namespace: $ns", 'Selector: ' . _labels_text( $s->{selector} ), 'Type: ' . ( $s->{type} // 'ClusterIP' ),
1030 ( map { ( "Port: " . ( $_->{name} // '<unset>' ) . " $_->{port}/TCP", "TargetPort: $_->{target}/TCP",
1031 0 ▶ 'Endpoints: ' . ( @e ? join( ',', map { my $p = $_; "$p->{ip}:" } @e ) =~ s/:(,|\z)/:$_->{target}$1/gr : '<none>' ) ) } @{ $s->{ports} || [] } ),
Branch: 1 branch
BranchTrueFalseTotal
@e ? : 0 0 0
Condition0%0/6
$$s{"type"} // "ClusterIP"
l!l
00
$$_{"name"} // "<unset>"
l!l
00
$$s{'ports'} || []
l!l
00
MC/DC0%0/1
$$s{"type"} // "ClusterIP"
$$s{"type"}
MC/DC0%0/1
$$_{"name"} // "<unset>"
$$_{"name"}
MC/DC0%0/1
$$s{'ports'} || []
$$s{'ports'}
Truth table0%0/2
A
A= $$s{"type"}
Aresult
11
00
Truth table0%0/2
A
A= $$_{"name"}
Aresult
11
00
Truth table0%0/2
A
A= $$s{'ports'}
Aresult
11
00
1032 'Session Affinity: None', 'Events: <none>' ), 1 );
1033 }
1034 1 ▶ if ( $kind eq 'pvcs' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($kind eq "pvcs") 0 1 1
1035 0 ▶ my $p = $k->{namespaces}{$ns}{pvcs}{ $name // '' } or return ( qq{Error from server (NotFound): persistentvolumeclaims "$name" not found}, 0 );
Branch: 1 branch
BranchTrueFalseTotal
my $p = $$k{"namespaces"}{$ns}{"pvcs"}{$name // ""} or return qq[Error from server (NotFound): persistentvolumeclaims "$name" not found], 0 0 0 0
Condition0%0/2
$name // ""
l!l
00
MC/DC0%0/1
$name // ""
$name
Truth table0%0/2
A
A= $name
Aresult
11
00
1036 0 my $ph = _pvc_phase( $k, $ns, $name );
1037 return ( join( "\n", "Name: $name", "Namespace: $ns", 'StorageClass: ' . ( $p->{storage_class} // '' ), "Status: $ph",
1038 'Capacity: ' . ( $ph eq 'Bound' ? $p->{size} : '' ), 'Access Modes: ' . ( $ph eq 'Bound' ? 'RWO' : '' ),
1039 'Events:', ' Type Reason Age From Message', ' ---- ------ ---- ---- -------',
1040 0 ▶ ( $ph eq 'Pending' ? ' Warning ProvisioningFailed 2m (x41 over 12m) persistentvolume-controller storageclass.storage.k8s.io "' . ( $p->{storage_class} // '' ) . '" not found' : () ) ), 1 );
Branch: 3 branches
BranchTrueFalseTotal
$ph eq 'Bound' ? : 0 0 0
$ph eq 'Bound' ? : 0 0 0
$ph eq 'Pending' ? : 0 0 0
Condition0%0/4
$$p{"storage_class"} // ""
l!l
00
$$p{"storage_class"} // ""
l!l
00
MC/DC0%0/1
$$p{"storage_class"} // ""
$$p{"storage_class"}
MC/DC0%0/1
$$p{"storage_class"} // ""
$$p{"storage_class"}
Truth table0%0/2
A
A= $$p{"storage_class"}
Aresult
11
00
Truth table0%0/2
A
A= $$p{"storage_class"}
Aresult
11
00
1041 }
1042 1 ▶ if ( $kind eq 'networkpolicies' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($kind eq "networkpolicies") 0 1 1
1043 0 ▶ my $p = $k->{namespaces}{$ns}{networkpolicies}{ $name // '' } or return ( qq{Error from server (NotFound): networkpolicies.networking.k8s.io "$name" not found}, 0 );
Branch: 1 branch
BranchTrueFalseTotal
my $p = $$k{"namespaces"}{$ns}{"networkpolicies"}{$name // ""} or return qq[Error from server (NotFound): networkpolicies.networking.k8s.io "$name" not found], 0 0 0 0
Condition0%0/2
$name // ""
l!l
00
MC/DC0%0/1
$name // ""
$name
Truth table0%0/2
A
A= $name
Aresult
11
00
1044 0 ▶ my @l = ( "Name: $name", "Namespace: $ns", 'Spec:', ' PodSelector: ' . ( %{ $p->{pod_selector} || {} } ? _labels_text( $p->{pod_selector} ) : '<none> (Allowing the specific traffic to all pods in this namespace)' ),
Branch: 1 branch
BranchTrueFalseTotal
%{$$p{'pod_selector'} or {};} ? : 0 0 0
Condition0%0/2
$$p{'pod_selector'} || {}
l!l
00
MC/DC0%0/1
$$p{'pod_selector'} || {}
$$p{'pod_selector'}
Truth table0%0/2
A
A= $$p{'pod_selector'}
Aresult
11
00
1045 ' Allowing ingress traffic:' );
1046 0 ▶ if ( !@{ $p->{ingress} || [] } ) { push @l, ' <none> (Selected pods are isolated for ingress connectivity)' }
Branch: 1 branch
BranchTrueFalseTotal
unless (@{$$p{"ingress"} or [];}) 0 0 0
Condition0%0/2
$$p{'ingress'} || []
l!l
00
MC/DC0%0/1
$$p{'ingress'} || []
$$p{'ingress'}
Truth table0%0/2
A
A= $$p{'ingress'}
Aresult
11
00
1047 0 ▶ for my $r ( @{ $p->{ingress} || [] } ) {
Condition0%0/2
$$p{'ingress'} || []
l!l
00
MC/DC0%0/1
$$p{'ingress'} || []
$$p{'ingress'}
Truth table0%0/2
A
A= $$p{'ingress'}
Aresult
11
00
1048 0 ▶ push @l, ' To Port: ' . ( $r->{ports} ? join( ', ', map {"$_/TCP"} @{ $r->{ports} } ) : '<any> (traffic allowed to all ports)' ), ' From:';
Branch: 1 branch
BranchTrueFalseTotal
$$r{'ports'} ? : 0 0 0
1049 0 ▶ push @l, $r->{from} ? map { ' PodSelector: ' . _labels_text($_) } @{ $r->{from} } : ' <any> (traffic not restricted by source)';
Branch: 1 branch
BranchTrueFalseTotal
$$r{'from'} ? : 0 0 0
1050 }
1051 0 push @l, ' Not affecting egress traffic', ' Policy Types: Ingress';
1052 0 return ( join( "\n", @l ), 1 );
1053 }
1054 1 ▶ if ( $kind eq 'secrets' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($kind eq "secrets") 0 1 1
1055 0 ▶ my $s = _secrets_all( $k, $ns )->{ $name // '' } or return ( qq{Error from server (NotFound): secrets "$name" not found}, 0 );
Branch: 1 branch
BranchTrueFalseTotal
my $s = _secrets_all($k, $ns)->{$name // ""} or return qq[Error from server (NotFound): secrets "$name" not found], 0 0 0 0
Condition0%0/2
$name // ""
l!l
00
MC/DC0%0/1
$name // ""
$name
Truth table0%0/2
A
A= $name
Aresult
11
00
1056 0 return ( join( "\n", "Name: $name", "Namespace: $ns", '', 'Type: ' . _secret_type($s), '', 'Data', '====', map { "$_: " . length( $s->{$_} ) . ' bytes' } sort grep { !/\A_/ } keys %$s ), 1 );
1057 }
1058 1 ▶ if ( $kind eq 'storageclasses' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($kind eq "storageclasses") 0 1 1
1059 0 ▶ my $s = ( $k->{storageclasses} || {} )->{ $name // '' } or return ( qq{Error from server (NotFound): storageclasses.storage.k8s.io "$name" not found}, 0 );
Branch: 1 branch
BranchTrueFalseTotal
my $s = ($$k{"storageclasses"} || {})->{$name // ""} or return qq[Error from server (NotFound): storageclasses.storage.k8s.io "$name" not found], 0 0 0 0
Condition0%0/4
$$k{'storageclasses'} || {}
l!l
00
$name // ""
l!l
00
MC/DC0%0/1
$$k{'storageclasses'} || {}
$$k{'storageclasses'}
MC/DC0%0/1
$name // ""
$name
Truth table0%0/2
A
A= $$k{'storageclasses'}
Aresult
11
00
Truth table0%0/2
A
A= $name
Aresult
11
00
1060 0 ▶ return ( join( "\n", "Name: $name", 'IsDefaultClass: ' . ( $s->{default} ? 'Yes' : 'No' ), "Provisioner: $s->{provisioner}", 'ReclaimPolicy: Delete', 'VolumeBindingMode: Immediate' ), 1 );
Branch: 1 branch
BranchTrueFalseTotal
$$s{'default'} ? : 0 0 0
1061 }
1062 1 ▶ if ( $kind eq 'replicasets' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($kind eq "replicasets") 1 0 1
1063 1 ▶ my @rs = grep { !defined $name || index( $_->{name}, $name ) == 0 } _replicasets( $k, $ns );
Condition66%2/3
!defined($name) || index($$_{'name'}, $name) == 0
l!l&&r!l&&!r
013
MC/DC50%1/2
!defined($name) || index($$_{'name'}, $name) == 0
!defined($name) index($$_{'name'}, $name) == 0
Truth table66%2/3
not(A) || B
A= !defined($name)B= index($$_{'name'}, $name) == 0
ABresult
1X1
011
000
1064 1 ▶ return ( qq{Error from server (NotFound): replicasets.apps "$name" not found}, 0 ) unless @rs;
Branch: 1 branch
BranchTrueFalseTotal
unless @rs 0 1 1
1065 return ( join( "\n\n", map {
1066 1 my $r = $_;
1067 join "\n", "Name: $r->{name}", "Namespace: $ns", "Controlled By: Deployment/$r->{deployment}",
1068 "Replicas: $r->{current} current / $r->{desired} desired", "Pods Status: $r->{ready} Running / 0 Waiting / 0 Succeeded / 0 Failed",
1069 1 ▶ ( $r->{failed} ? ( 'Conditions:', ' Type Status Reason', ' ---- ------ ------', ' ReplicaFailure True FailedCreate',
Branch: 1 branch
BranchTrueFalseTotal
$$r{'failed'} ? : 1 0 1
1070 'Events:', ' Type Reason Age From Message', ' ---- ------ ---- ---- -------',
1071 " Warning FailedCreate 2m (x18 over 12m) replicaset-controller $r->{failed}" ) : ('Events: <none>') );
1072 } @rs ), 1 );
1073 }
1074 0 push @GAPS, "kubectl describe @$a";
1075 0 return ( '', 0 );
1076 }
1077  
1078 1 ▶sub _describe_container {
Subroutine _describe_container: called CC=16 SCAR=37.7
1079 1 my ( $c, $ind ) = @_;
1080 return ( "$ind$c->{name}:", "$ind Image: $c->{image}",
1081 1 ▶ ( $c->{ports} ? "$ind Port: " . join( ', ', map {"$_/TCP"} @{ $c->{ports} } ) : () ),
Branch: 1 branch
BranchTrueFalseTotal
$$c{'readiness'} ? : 1 0 1
Condition50%1/2
$$c{"readiness"}{"path"} // "/"
l!l
10
MC/DC0%0/1
$$c{"readiness"}{"path"} // "/"
$$c{"readiness"}{"path"}
Truth table50%1/2
A
A= $$c{"readiness"}{"path"}
Aresult
11
00
1082 ( $c->{readiness} ? "$ind Readiness: http-get http://:$c->{readiness}{port}" . ( $c->{readiness}{path} // '/' ) . ' delay=0s timeout=1s period=10s #success=1 #failure=3' : () ),
1083 1 ▶ "$ind Environment:", ( map { "$ind $_->{name}: " . ( defined $_->{secret} ? "<set to the key '$_->{key}' in secret '$_->{secret}'>" . ( $_->{optional} ? ' Optional: true' : ' Optional: false' ) : defined $_->{configmap} ? "<set to the key '$_->{key}' of config map '$_->{configmap}'>" : $_->{value} // '' ) } @{ $c->{env} || [] } ),
Branch: 4 branches
BranchTrueFalseTotal
defined $$_{'secret'} ? : 1 0 1
$$_{'optional'} ? : 1 0 1
defined $$_{'configmap'} ? : 0 0 0
!@{$$c{'env'} or [];} ? : 0 1 1
Condition25%1/4
$$_{"value"} // ""
l!l
00
$$c{'env'} || []
l!l
10
MC/DC0%0/1
$$_{"value"} // ""
$$_{"value"}
MC/DC0%0/1
$$c{'env'} || []
$$c{'env'}
Truth table0%0/2
A
A= $$_{"value"}
Aresult
11
00
Truth table50%1/2
A
A= $$c{'env'}
Aresult
11
00
1084 1 ▶ ( !@{ $c->{env} || [] } ? "$ind <none>" : () ),
Condition50%1/2
$$c{'env'} || []
l!l
10
MC/DC0%0/1
$$c{'env'} || []
$$c{'env'}
Truth table50%1/2
A
A= $$c{'env'}
Aresult
11
00
1085 0 ▶ "$ind Mounts:", ( map { "$ind " . ( $_->{mount} // '/data' ) . " from $_->{claim} (rw)" } @{ $c->{volumes} || [] } ), ( !@{ $c->{volumes} || [] } ? "$ind <none>" : () ),
Branch: 2 branches
BranchTrueFalseTotal
!@{$$c{'volumes'} or [];} ? : 1 0 1
$$c{'privileged'} ? : 0 1 1
Condition33%2/6
$$_{"mount"} // "/data"
l!l
00
$$c{'volumes'} || []
l!l
01
$$c{'volumes'} || []
l!l
01
MC/DC0%0/1
$$_{"mount"} // "/data"
$$_{"mount"}
MC/DC0%0/1
$$c{'volumes'} || []
$$c{'volumes'}
MC/DC0%0/1
$$c{'volumes'} || []
$$c{'volumes'}
Truth table0%0/2
A
A= $$_{"mount"}
Aresult
11
00
Truth table50%1/2
A
A= $$c{'volumes'}
Aresult
11
00
Truth table50%1/2
A
A= $$c{'volumes'}
Aresult
11
00
1086 1 ▶ ( $c->{privileged} ? "$ind Security Context: privileged" : () ) );
Branch: 1 branch
BranchTrueFalseTotal
$$c{'ports'} ? : 1 0 1
1087 }
1088  
1089 1 ▶sub _describe_pod {
Subroutine _describe_pod: called CC=14 SCAR=33.8
1090 1 my ( $k, $ns, $p ) = @_;
1091 my @state = $p->{reason} eq 'CrashLoopBackOff' ? ( ' State: Waiting', ' Reason: CrashLoopBackOff', ' Last State: Terminated', ' Reason: Error', ' Exit Code: 1' )
1092 : $p->{reason} =~ /\A(?:ImagePullBackOff|CreateContainerConfigError)\z/ ? ( ' State: Waiting', " Reason: $p->{reason}" )
1093 1 ▶ : $p->{phase} eq 'Pending' ? (' State: Waiting', ' Reason: ContainerCreating') : ( ' State: Running', ' Started: Tue, 21 Oct 2026 11:48:02 +0200' );
Branch: 3 branches
BranchTrueFalseTotal
$$p{'reason'} eq 'CrashLoopBackOff' ? : 0 1 1
$$p{'reason'} =~ /\A(?:ImagePullBackOff|CreateContainerConfigError)\z/ ? : 1 0 1
$$p{'phase'} eq 'Pending' ? : 0 0 0
1094 1 my @ev;
1095 1 ▶ if ( $p->{reason} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($$p{'reason'}) { } 1 0 1
1096 1 my %r = ( NotReady => [ 'Warning', 'Unhealthy', 'kubelet' ], CrashLoopBackOff => [ 'Warning', 'BackOff', 'kubelet' ], ImagePullBackOff => [ 'Warning', 'Failed', 'kubelet' ],
1097 Unschedulable => [ 'Warning', 'FailedScheduling', 'default-scheduler' ], CreateContainerConfigError => [ 'Warning', 'Failed', 'kubelet' ] );
1098 1 ▶ my $r = $r{ $p->{reason} } // [ 'Normal', $p->{reason}, 'kubelet' ];
Condition50%1/2
$r{$$p{"reason"}} // ["Normal", $$p{"reason"}, "kubelet"]
l!l
10
MC/DC0%0/1
$r{$$p{"reason"}} // ["Normal", $$p{"reason"}, "kubelet"]
$r{$$p{"reason"}}
Truth table50%1/2
A
A= $r{$$p{"reason"}}
Aresult
11
00
1099 my $msg = $p->{reason} eq 'ImagePullBackOff' ? qq{Failed to pull image "$p->{container}{image}": rpc error: code = NotFound desc = failed to pull and unpack image "$p->{container}{image}": failed to resolve reference "$p->{container}{image}": $p->{container}{image}: not found}
1100 1 ▶ : $p->{reason} eq 'CreateContainerConfigError' ? "Error: $p->{message}" : $p->{message};
Branch: 2 branches
BranchTrueFalseTotal
$$p{'reason'} eq 'ImagePullBackOff' ? : 1 0 1
$$p{'reason'} eq 'CreateContainerConfigError' ? : 0 0 0
1101 1 @ev = ( 'Events:', ' Type Reason Age From Message', ' ---- ------ ---- ---- -------',
1102 sprintf( ' %-8s %-10s %-19s %-18s %s', @$r[ 0, 1 ], '2m (x41 over 12m)', $r->[2], $msg ) );
1103 }
1104 0 else { @ev = ('Events: <none>') }
1105 1 my ($c) = @{ $p->{template}{containers} };
1106 return join "\n", "Name: $p->{name}", "Namespace: $ns", 'Node: ' . ( $p->{phase} eq 'Pending' && $p->{reason} eq 'Unschedulable' ? '<none>' : 'node1/10.30.0.21' ),
1107 2 ▶ 'Labels: ' . join( "\n ", map {"$_=$p->{labels}{$_}"} sort keys %{ $p->{labels} } ), "Status: $p->{phase}",
Branch: 3 branches
BranchTrueFalseTotal
$$p{'phase'} eq 'Pending' && $$p{'reason'} eq 'Unschedulable' ? : 0 1 1
$$p{'ready'} ? : 0 1 1
$$p{'ready'} ? : 0 1 1
Condition33%1/3
$$p{"phase"} eq "Pending" and $$p{"reason"} eq "Unschedulable"
!ll&&!rl&&r
010
MC/DC0%0/2
$$p{"phase"} eq "Pending" and $$p{"reason"} eq "Unschedulable"
$$p{"phase"} eq "Pending" $$p{"reason"} eq "Unschedulable"
Truth table33%1/3
A and B
A= $$p{"phase"} eq "Pending"B= $$p{"reason"} eq "Unschedulable"
ABresult
0X0
100
111
1108 "IP: " . ( $p->{phase} eq 'Pending' && $p->{reason} eq 'Unschedulable' ? '' : $p->{ip} ), 'Containers:', _describe_container( $c, ' ' ), @state,
1109 1 ▶ " Ready: " . ( $p->{ready} ? 'True' : 'False' ), " Restart Count: $p->{restarts}", 'Conditions:', ' Type Status', ' Ready ' . ( $p->{ready} ? 'True' : 'False' ), @ev;
Branch: 1 branch
BranchTrueFalseTotal
$$p{'phase'} eq 'Pending' && $$p{'reason'} eq 'Unschedulable' ? : 0 1 1
Condition33%1/3
$$p{"phase"} eq "Pending" and $$p{"reason"} eq "Unschedulable"
!ll&&!rl&&r
010
MC/DC0%0/2
$$p{"phase"} eq "Pending" and $$p{"reason"} eq "Unschedulable"
$$p{"phase"} eq "Pending" $$p{"reason"} eq "Unschedulable"
Truth table33%1/3
A and B
A= $$p{"phase"} eq "Pending"B= $$p{"reason"} eq "Unschedulable"
ABresult
0X0
100
111
1110 }
1111  
1112 # kubectl exec POD -- curl|wget URL : Erreichbarkeit von Pod zu Service
1113 18 ▶sub _v_exec {
Subroutine _v_exec: called CC=31 SCAR=42.2
1114 18 my ( $k, $a, $o ) = @_;
1115 18 ▶ my $ref = $a->[0] // return ( 'error: expected \'exec (POD | TYPE/NAME) [-c CONTAINER] [flags] -- COMMAND [args...]\'.', 0 );
Condition50%1/2
$$a[0] // (return "error: expected 'exec (POD | TYPE/NAME) [-c CONTAINER] [flags] -- COMMAND [args...]'.", 0)
l!l
180
MC/DC0%0/1
$$a[0] // (return "error: expected 'exec (POD | TYPE/NAME) [-c CONTAINER] [flags] -- COMMAND [args...]'.", 0)
$$a[0]
Truth table50%1/2
A
A= $$a[0]
Aresult
11
00
1116 18 my @p = _pods( $k, $o->{ns} );
1117 18 ▶ my ($src) = $ref =~ m{\Adeploy(?:ment)?/(.+)\z} ? grep { $_->{deployment} eq $1 } @p : grep { $_->{name} eq $ref } @p;
Branch: 1 branch
BranchTrueFalseTotal
$ref =~ m[\Adeploy(?:ment)?/(.+)\z] ? : 13 5 18
1118 18 ▶ return ( qq{Error from server (NotFound): pods "$ref" not found}, 0 ) unless $src;
Branch: 1 branch
BranchTrueFalseTotal
unless $src 0 18 18
1119 18 ▶ my @cmd = @{ $o->{rest} || [] };
Condition50%1/2
$$o{'rest'} || []
l!l
180
MC/DC0%0/1
$$o{'rest'} || []
$$o{'rest'}
Truth table50%1/2
A
A= $$o{'rest'}
Aresult
11
00
1120 18 ▶ return ( qq{error: unable to upgrade connection: container not found ("$src->{template}{containers}[0]{name}")}, 0 ) unless $src->{phase} eq 'Running' && $src->{reason} ne 'CrashLoopBackOff';
Branch: 1 branch
BranchTrueFalseTotal
unless $$src{"phase"} eq "Running" and $$src{"reason"} ne "CrashLoopBackOff" 0 18 18
Condition33%1/3
$$src{"phase"} eq "Running" and $$src{"reason"} ne "CrashLoopBackOff"
!ll&&!rl&&r
0018
MC/DC0%0/2
$$src{"phase"} eq "Running" and $$src{"reason"} ne "CrashLoopBackOff"
$$src{"phase"} eq "Running" $$src{"reason"} ne "CrashLoopBackOff"
Truth table33%1/3
A and B
A= $$src{"phase"} eq "Running"B= $$src{"reason"} ne "CrashLoopBackOff"
ABresult
0X0
100
111
1121 18 ▶ if ( $o->{interactive} && !@cmd || ( $cmd[0] // '' ) =~ /\A(?:sh|bash|ash)\z/ && @cmd == 1 ) { push @GAPS, "kubectl exec -it"; return ( '', 0 ) }
Branch: 1 branch
BranchTrueFalseTotal
if ($$o{"interactive"} and not @cmd or ($cmd[0] // "") =~ /\A(?:sh|bash|ash)\z/ and @cmd == 1) 1 17 18
Condition72%8/11
$$o{"interactive"} and not @cmd or ($cmd[0] // "") =~ /\A(?:sh|bash|ash)\z/ and @cmd == 1
l!l&&r!l&&!r
0117
$$o{"interactive"} and not @cmd
!ll&&!rl&&r
1710
($cmd[0] // "") =~ /\A(?:sh|bash|ash)\z/ and @cmd == 1
!ll&&!rl&&r
1521
$cmd[0] // ""
l!l
180
MC/DC0%0/4
$$o{"interactive"} and not @cmd or ($cmd[0] // "") =~ /\A(?:sh|bash|ash)\z/ and @cmd == 1
$$o{"interactive"} not @cmd $cmd[0] @cmd == 1
Truth table28%2/7
A and not(B) or C and D
A= $$o{"interactive"}B= not @cmdC= $cmd[0]D= @cmd == 1
ABCDresult
11XX1
0X111
10111
0X0X0
0X100
100X0
10100
1122 17 ▶ return pod_tool( $k, $o->{ns}, $src, \@cmd ) if ( $cmd[0] // '' ) =~ /\A(?:curl|wget)\z/ || ( $cmd[0] // '' ) eq 'openssl' && ( $cmd[1] // '' ) eq 's_client';
Branch: 1 branch
BranchTrueFalseTotal
if ($cmd[0] // "") =~ /\A(?:curl|wget)\z/ or ($cmd[0] // "") eq "openssl" and ($cmd[1] // "") eq "s_client" 14 3 17
Condition66%8/12
($cmd[0] // "") =~ /\A(?:curl|wget)\z/ or ($cmd[0] // "") eq "openssl" and ($cmd[1] // "") eq "s_client"
l!l&&r!l&&!r
1313
$cmd[0] // ""
l!l
170
($cmd[0] // "") eq "openssl" and ($cmd[1] // "") eq "s_client"
!ll&&!rl&&r
301
$cmd[0] // ""
l!l
40
$cmd[1] // ""
l!l
10
MC/DC0%0/3
($cmd[0] // "") =~ /\A(?:curl|wget)\z/ or ($cmd[0] // "") eq "openssl" and ($cmd[1] // "") eq "s_client"
$cmd[0] $cmd[0] $cmd[1]
Truth table25%1/4
A or B and C
A= $cmd[0]B= $cmd[0]C= $cmd[1]
ABCresult
1XX1
0111
00X0
0100
1123 # alles andere in einer Shell des Pods (curl, wget, openssl darin wieder ueber den Cluster)
1124 3 require Langertha::Holmgang::Sim::Linux;
1125 3 ▶ my $line = ( $cmd[0] // '' ) =~ /\A(?:sh|bash|ash)\z/ && ( $cmd[1] // '' ) eq '-c' ? $cmd[2] // '' : join ' ', map { /\A[\w\/.:=,@%+-]+\z/ ? $_ : "'" . s/'/'\\''/gr . "'" } @cmd;
Branch: 2 branches
BranchTrueFalseTotal
($cmd[0] // '') =~ /\A(?:sh|bash|ash)\z/ && ($cmd[1] // '') eq '-c' ? : 2 1 3
m[\A[\w/.:=,\@%+-]+\z] ? : 2 0 2
Condition55%5/9
($cmd[0] // "") =~ /\A(?:sh|bash|ash)\z/ and ($cmd[1] // "") eq "-c"
!ll&&!rl&&r
102
$cmd[0] // ""
l!l
30
$cmd[1] // ""
l!l
20
$cmd[2] // ""
l!l
20
MC/DC0%0/2
($cmd[0] // "") =~ /\A(?:sh|bash|ash)\z/ and ($cmd[1] // "") eq "-c"
$cmd[0] $cmd[1]
MC/DC0%0/1
$cmd[2] // ""
$cmd[2]
Truth table33%1/3
A and B
A= $cmd[0]B= $cmd[1]
ABresult
0X0
100
111
Truth table50%1/2
A
A= $cmd[2]
Aresult
11
00
1126 3 my ($c) = @{ $src->{template}{containers} };
1127 0 ▶ my %env = map { $_->{name} => ( defined $_->{value} ? $_->{value} : defined $_->{secret} ? ( ( ( $k->{namespaces}{ $o->{ns} }{secrets} || {} )->{ $_->{secret} } || {} )->{ $_->{key} } // '' ) : '' ) } @{ $c->{env} || [] };
Branch: 2 branches
BranchTrueFalseTotal
defined $$_{'value'} ? : 0 0 0
defined $$_{'secret'} ? : 0 0 0
Condition12%1/8
(($$k{"namespaces"}{$$o{"ns"}}{"secrets"} || {})->{$$_{"secret"}} || {})->{$$_{"key"}} // ""
l!l
00
($$k{'namespaces'}{$$o{'ns'}}{'secrets'} || {})->{$$_{'secret'}} || {}
l!l
00
$$k{'namespaces'}{$$o{'ns'}}{'secrets'} || {}
l!l
00
$$c{'env'} || []
l!l
03
MC/DC0%0/1
(($$k{"namespaces"}{$$o{"ns"}}{"secrets"} || {})->{$$_{"secret"}} || {})->{$$_{"key"}} // ""
$$k{'namespaces'}{$$o{'ns'}}{'secrets'}
MC/DC0%0/1
$$c{'env'} || []
$$c{'env'}
Truth table0%0/2
A
A= $$k{'namespaces'}{$$o{'ns'}}{'secrets'}
Aresult
11
00
Truth table50%1/2
A
A= $$c{'env'}
Aresult
11
00
1128 my $pd = { type => 'linux', hostname => $src->{name}, pod => { ns => $o->{ns}, name => $src->{name} }, kubernetes => $k, env => \%env,
1129 files => { '/etc/hosts' => "127.0.0.1\tlocalhost\n$src->{ip}\t$src->{name}\n",
1130 '/etc/resolv.conf' => "search $o->{ns}.svc.cluster.local svc.cluster.local cluster.local\nnameserver 10.43.0.10\noptions ndots:5\n" },
1131 3 dirs => { map { $_ => {} } qw( /bin /etc /tmp /usr /var /proc /dev /app ) } };
1132 3 my ( $out, $ok, $gap ) = Langertha::Holmgang::Sim::Linux->run( $pd, $line, { host => $src->{name}, state => {} } );
1133 0 ▶ push @GAPS, map {"kubectl exec -- $_"} split /; /, $gap if defined $gap;
Branch: 1 branch
BranchTrueFalseTotal
if defined $gap 0 3 3
1134 3 return ( $out, $ok );
1135 }
1136  
1137  
1138 16 ▶sub pod_tool {
Subroutine pod_tool: called CC=46 SCAR=44.4
Pod documented
1139 16 my ( $k, $srcns, $src, $cmdref ) = @_;
1140 16 my @cmd = @$cmdref;
1141 16 my $o = { ns => $srcns };
1142 16 ▶ my $tool = $cmd[0] // '';
Condition50%1/2
$cmd[0] // ""
l!l
160
MC/DC0%0/1
$cmd[0] // ""
$cmd[0]
Truth table50%1/2
A
A= $cmd[0]
Aresult
11
00
1143 16 ▶ if ( $tool eq 'openssl' && ( $cmd[1] // '' ) eq 's_client' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($tool eq "openssl" and ($cmd[1] // "") eq "s_client") 2 14 16
Condition60%3/5
$tool eq "openssl" and ($cmd[1] // "") eq "s_client"
!ll&&!rl&&r
1402
$cmd[1] // ""
l!l
20
MC/DC50%1/2
$tool eq "openssl" and ($cmd[1] // "") eq "s_client"
$tool eq "openssl" $cmd[1]
Truth table66%2/3
A and B
A= $tool eq "openssl"B= $cmd[1]
ABresult
0X0
100
111
1144 2 my ( $conn, $sni );
1145 2 ▶ for my $i ( 2 .. $#cmd ) { $conn = $cmd[ $i + 1 ] if $cmd[$i] eq '-connect'; $sni = $cmd[ $i + 1 ] if $cmd[$i] eq '-servername' }
Branch: 2 branches
BranchTrueFalseTotal
if $cmd[$i] eq "-connect" 2 6 8
if $cmd[$i] eq "-servername" 2 6 8
1146 2 ▶ my ($h) = ( $conn // '' ) =~ /\A([^:]+)/;
Condition50%1/2
$conn // ""
l!l
20
MC/DC0%0/1
$conn // ""
$conn
Truth table50%1/2
A
A= $conn
Aresult
11
00
1147 2 ▶ return ( 's_client: -connect requires an argument', 0 ) unless defined $h;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $h 0 2 2
1148 2 return tls_probe( $k, $h, $sni );
1149 }
1150 0 ▶ if ( $tool !~ /\A(?:curl|wget)\z/ || $o->{interactive} ) { push @GAPS, "kubectl exec -- @cmd"; return ( '', 0 ) }
Branch: 1 branch
BranchTrueFalseTotal
if (not $tool =~ /\A(?:curl|wget)\z/ or $$o{"interactive"}) 0 14 14
Condition33%1/3
not $tool =~ /\A(?:curl|wget)\z/ or $$o{"interactive"}
l!l&&r!l&&!r
0014
MC/DC0%0/2
not $tool =~ /\A(?:curl|wget)\z/ or $$o{"interactive"}
not $tool =~ /\A(?:curl|wget)\z/ $$o{"interactive"}
Truth table33%1/3
not(A) or B
A= not $tool =~ /\A(?:curl|wget)\z/B= $$o{"interactive"}
ABresult
1X1
011
000
1151 14 my ($url) = grep {m{\Ahttps?://}} @cmd;
1152 0 ▶ ($url) = grep { !/\A-/ && $_ ne $tool } @cmd unless $url;
Branch: 1 branch
BranchTrueFalseTotal
unless $url 0 14 14
Condition0%0/3
!/\A-/ && $_ ne $tool
!ll&&!rl&&r
000
MC/DC0%0/2
!/\A-/ && $_ ne $tool
!/\A-/ $_ ne $tool
Truth table0%0/3
not(A) && B
A= !/\A-/B= $_ ne $tool
ABresult
0X0
100
111
1153 14 ▶ return ( "$tool: no URL specified", 1 ) unless defined $url;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $url 0 14 14
1154 14 ▶ my ( $host, $port, $path ) = $url =~ m{\A(?:https?://)?([^/:]+)(?::(\d+))?(/.*)?\z} or return ( "$tool: bad URL", 1 );
Branch: 1 branch
BranchTrueFalseTotal
() = $url =~ m[\A(?:https?://)?([^/:]+)(?::(\d+))?(/.*)?\z] or return "${tool}: bad URL", 1 14 0 14
1155 # oeffentliche Namen (DNS auf den Ingress-Controller): ueber den Ingress
1156 14 ▶ my ($hh) = map { /\AHost:\s*(\S+)/i ? $1 : () } @cmd;
Branch: 1 branch
BranchTrueFalseTotal
/\AHost:\s*(\S+)/i ? : 1 42 43
1157 14 ▶ if ( defined $hh || _public_host( $k, $host ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $hh or _public_host($k, $host)) 9 5 14
Condition100%3/3
defined $hh or _public_host($k, $host)
l!l&&r!l&&!r
185
MC/DC100%2/2
defined $hh or _public_host($k, $host)
defined $hh _public_host($k, $host)
Truth table100%3/3
A or B
A= defined $hhB= _public_host($k, $host)
ABresult
1X1
011
000
1158 9 ▶ return _client_ingress( $k, $tool, \@cmd, $url =~ m{\Ahttps://} ? 'https' : 'http', $hh // $host, $path // '/' );
Branch: 1 branch
BranchTrueFalseTotal
$url =~ m[\Ahttps://] ? : 8 1 9
Condition60%3/5
$hh // $host
l!l&&r!l&&!r
180
$path // "/"
l!l
90
MC/DC0%0/2
$hh // $host
$hh $host
MC/DC0%0/1
$path // "/"
$path
Truth table66%2/3
A // B
A= $hhB= $host
ABresult
1X1
011
000
Truth table50%1/2
A
A= $path
Aresult
11
00
1159 }
1160 5 ( my $svcname = $host ) =~ s/\..*//;
1161 5 ▶ my $ns = $host =~ /\A[^.]+\.([^.]+)/ && $1 ne 'svc' ? $1 : $o->{ns};
Branch: 1 branch
BranchTrueFalseTotal
$host =~ /\A[^.]+\.([^.]+)/ && $1 ne 'svc' ? : 1 4 5
Condition66%2/3
$host =~ /\A[^.]+\.([^.]+)/ and $1 ne "svc"
!ll&&!rl&&r
401
MC/DC50%1/2
$host =~ /\A[^.]+\.([^.]+)/ and $1 ne "svc"
$host =~ /\A[^.]+\.([^.]+)/ $1 ne "svc"
Truth table66%2/3
A and B
A= $host =~ /\A[^.]+\.([^.]+)/B= $1 ne "svc"
ABresult
0X0
100
111
1162 5 ▶ my $svc = ( $k->{namespaces}{$ns} || {} )->{services}{$svcname};
Condition50%1/2
$$k{'namespaces'}{$ns} || {}
l!l
50
MC/DC0%0/1
$$k{'namespaces'}{$ns} || {}
$$k{'namespaces'}{$ns}
Truth table50%1/2
A
A= $$k{'namespaces'}{$ns}
Aresult
11
00
1163 5 ▶ my $fail = sub { $tool eq 'curl' ? ( "curl: ($_[0]) $_[1]", 0 ) : ( "wget: $_[2]", 0 ) };
Subroutine __ANON__: called CC=2 SCAR=7.2
Branch: 1 branch
BranchTrueFalseTotal
$tool eq 'curl' ? : 2 0 2
1164 5 ▶ return $fail->( 6, "Could not resolve host: $host", "bad address '$host'" ) unless $svc;
Branch: 1 branch
BranchTrueFalseTotal
unless $svc 0 5 5
1165 5 ▶ my ($sp) = grep { $_->{port} == ( $port // 80 ) } @{ $svc->{ports} || [] };
Condition50%2/4
$port // 80
l!l
05
$$svc{'ports'} || []
l!l
50
MC/DC0%0/1
$port // 80
$port
MC/DC0%0/1
$$svc{'ports'} || []
$$svc{'ports'}
Truth table50%1/2
A
A= $port
Aresult
11
00
Truth table50%1/2
A
A= $$svc{'ports'}
Aresult
11
00
1166 5 ▶ return $fail->( 28, "Failed to connect to $host port " . ( $port // 80 ) . " after 10001 ms: Timeout was reached", 'download timed out' ) unless $sp;
Branch: 1 branch
BranchTrueFalseTotal
unless $sp 0 5 5
Condition0%0/2
$port // 80
l!l
00
MC/DC0%0/1
$port // 80
$port
Truth table0%0/2
A
A= $port
Aresult
11
00
1167 5 my @e = _endpoints( $k, $ns, $svcname );
1168 5 ▶ return $fail->( 7, "Failed to connect to $host port " . ( $port // 80 ) . " after 2 ms: Couldn't connect to server", "can't connect to remote host: Connection refused" ) unless @e;
Branch: 1 branch
BranchTrueFalseTotal
unless @e 1 4 5
Condition50%1/2
$port // 80
l!l
01
MC/DC0%0/1
$port // 80
$port
Truth table50%1/2
A
A= $port
Aresult
11
00
1169 4 my $dst = $e[0];
1170 # NetworkPolicies (Ingress) des Ziel-Namespace
1171 4 ▶ my @pol = grep { _sel_match( $_->{pod_selector}, $dst->{labels} ) } values %{ $k->{namespaces}{$ns}{networkpolicies} || {} };
Condition100%2/2
$$k{'namespaces'}{$ns}{'networkpolicies'} || {}
l!l
31
MC/DC100%1/1
$$k{'namespaces'}{$ns}{'networkpolicies'} || {}
$$k{'namespaces'}{$ns}{'networkpolicies'}
Truth table100%2/2
A
A= $$k{'namespaces'}{$ns}{'networkpolicies'}
Aresult
11
00
1172 4 ▶ if (@pol) {
Branch: 1 branch
BranchTrueFalseTotal
if (@pol) 3 1 4
1173 my $ok = grep {
1174 3 my $r = $_;
1175 3 ▶ ( !$r->{from} || grep { $ns eq $o->{ns} && _sel_match( $_, $src->{labels} ) } @{ $r->{from} } )
Condition50%3/6
$ns eq $$o{'ns'} && _sel_match($_, $$src{'labels'})
!ll&&!rl&&r
012
not $$r{"ports"} or grep {$_ == $$sp{"target"};} @{$$r{"ports"};}
l!l&&r!l&&!r
020
MC/DC50%1/2
$ns eq $$o{'ns'} && _sel_match($_, $$src{'labels'})
$ns eq $$o{'ns'} _sel_match($_, $$src{'labels'})
MC/DC0%0/2
not $$r{"ports"} or grep {$_ == $$sp{"target"};} @{$$r{"ports"};}
not $$r{"ports"} grep {$_ == $$sp{"target"};} @{$$r{"ports"};}
Truth table66%2/3
A && B
A= $ns eq $$o{'ns'}B= _sel_match($_, $$src{'labels'})
ABresult
0X0
100
111
Truth table33%1/3
not(A) or B
A= not $$r{"ports"}B= grep {$_ == $$sp{"target"};} @{$$r{"ports"};}
ABresult
1X1
011
000
1176 3 ▶ && ( !$r->{ports} || grep { $_ == $sp->{target} } @{ $r->{ports} } );
Condition66%4/6
(!$$r{'from'} || grep({$ns eq $$o{'ns'} and _sel_match($_, $$src{'labels'});} @{$$r{'from'};})) && (!$$r{'ports'} || grep({$_ == $$sp{'target'};} @{$$r{'ports'};}))
!ll&&!rl&&r
102
not $$r{"from"} or grep {$ns eq $$o{"ns"} and _sel_match($_, $$src{"labels"});} @{$$r{"from"};}
l!l&&r!l&&!r
021
MC/DC0%0/3
(!$$r{'from'} || grep({$ns eq $$o{'ns'} and _sel_match($_, $$src{'labels'});} @{$$r{'from'};})) && (!$$r{'ports'} || grep({$_ == $$sp{'target'};} @{$$r{'ports'};}))
not $$r{"from"} grep {$ns eq $$o{"ns"} and _sel_match($_, $$src{"labels"});} @{$$r{"from"};} (!$$r{'ports'} || grep({$_ == $$sp{'target'};} @{$$r{'ports'};}))
Truth table40%2/5
not(A) or B && C
A= not $$r{"from"}B= grep {$ns eq $$o{"ns"} and _sel_match($_, $$src{"labels"});} @{$$r{"from"};}C= (!$$r{'ports'} || grep({$_ == $$sp{'target'};} @{$$r{'ports'};}))
ABCresult
00X0
1X00
0100
1X11
0111
1177 3 ▶ } map { @{ $_->{ingress} || [] } } @pol;
Condition50%1/2
$$_{'ingress'} || []
l!l
60
MC/DC0%0/1
$$_{'ingress'} || []
$$_{'ingress'}
Truth table50%1/2
A
A= $$_{'ingress'}
Aresult
11
00
1178 3 ▶ return $fail->( 28, "Failed to connect to $host port " . ( $port // 80 ) . " after 10001 ms: Timeout was reached", 'download timed out' ) unless $ok;
Branch: 1 branch
BranchTrueFalseTotal
unless $ok 1 2 3
Condition50%1/2
$port // 80
l!l
01
MC/DC0%0/1
$port // 80
$port
Truth table50%1/2
A
A= $port
Aresult
11
00
1179 }
1180 3 my ($dc) = @{ $dst->{template}{containers} };
1181 return $fail->( 7, "Failed to connect to $host port " . ( $port // 80 ) . " after 2 ms: Couldn't connect to server", "can't connect to remote host: Connection refused" )
1182 3 ▶ unless grep { $_ == $sp->{target} } @{ $dc->{listens} || $dc->{ports} || [] };
Branch: 1 branch
BranchTrueFalseTotal
unless grep {$_ == $$sp{"target"};} @{$$dc{"listens"} or $$dc{"ports"} or [];} 0 3 3
Condition28%2/7
$$dc{'listens'} || $$dc{'ports'} || []
l!l
30
$$dc{"listens"} or $$dc{"ports"}
l!l&&r!l&&!r
300
$port // 80
l!l
00
MC/DC0%0/2
$$dc{'listens'} || $$dc{'ports'} || []
$$dc{"listens"} $$dc{"ports"}
MC/DC0%0/1
$port // 80
$port
Truth table33%1/3
A or B
A= $$dc{"listens"}B= $$dc{"ports"}
ABresult
1X1
011
000
Truth table0%0/2
A
A= $port
Aresult
11
00
1183 3 ▶ return ( $dc->{http_body} // '{"status":"ok"}', 1 );
Condition100%2/2
$$dc{"http_body"} // "{\"status\":\"ok\"}"
l!l
12
MC/DC100%1/1
$$dc{"http_body"} // "{\"status\":\"ok\"}"
$$dc{"http_body"}
Truth table100%2/2
A
A= $$dc{"http_body"}
Aresult
11
00
1184 }
1185  
1186 # --- openssl s_client gegen den Ingress ------------------------------------------------
1187  
1188 4 ▶sub _dn_issuer {
Subroutine _dn_issuer: called CC=4 SCAR=14.0
1189 4 my ($i) = @_;
1190 4 ▶ return 'O = Acme Co, CN = Kubernetes Ingress Controller Fake Certificate' unless defined $i;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $i 0 4 4
1191 4 ▶ return "C = US, O = (STAGING) Let's Encrypt, CN = (STAGING) Counterfeit Cashew R10" if $i =~ /staging/i;
Branch: 1 branch
BranchTrueFalseTotal
if $i =~ /staging/i 0 4 4
1192 4 ▶ return "C = US, O = Let's Encrypt, CN = R11" if $i =~ /letsencrypt|acme/i;
Branch: 1 branch
BranchTrueFalseTotal
if $i =~ /letsencrypt|acme/i 3 1 4
1193 1 ( my $n = $i ) =~ s{\A\w+/}{};
1194 1 return "CN = $n";
1195 }
1196  
1197  
1198 3 ▶sub tls_probe {
Subroutine tls_probe: called CC=17 SCAR=33.2
Pod documented
1199 3 my ( $k, $host, $sni ) = @_;
1200 3 ▶ $sni //= $host;
Condition33%1/3
$sni //= $host
l!l&&r!l&&!r
300
MC/DC0%0/2
$sni //= $host
$sni $host
Truth table33%1/3
A //= B
A= $sniB= $host
ABresult
1X1
011
000
1201 3 ▶ return ( "$host: Name or service not known\nconnect:errno=2", 0 ) unless _public_host( $k, $host ) || $host =~ /\A[\d.]+\z/ && $host eq ( ( $k->{ingress} || {} )->{address} // '' );
Branch: 1 branch
BranchTrueFalseTotal
unless _public_host($k, $host) or $host =~ /\A[\d.]+\z/ and $host eq (($$k{"ingress"} || {})->{"address"} // "") 0 3 3
Condition10%1/10
_public_host($k, $host) or $host =~ /\A[\d.]+\z/ and $host eq (($$k{"ingress"} || {})->{"address"} // "")
l!l&&r!l&&!r
300
$host =~ /\A[\d.]+\z/ and $host eq (($$k{"ingress"} || {})->{"address"} // "")
!ll&&!rl&&r
000
($$k{"ingress"} || {})->{"address"} // ""
l!l
00
$$k{'ingress'} || {}
l!l
00
MC/DC0%0/3
_public_host($k, $host) or $host =~ /\A[\d.]+\z/ and $host eq (($$k{"ingress"} || {})->{"address"} // "")
_public_host($k, $host) $host =~ /\A[\d.]+\z/ $host eq (($$k{"ingress"} || {})->{"address"} // "")
MC/DC0%0/1
($$k{"ingress"} || {})->{"address"} // ""
$$k{'ingress'}
Truth table25%1/4
A or B and C
A= _public_host($k, $host)B= $host =~ /\A[\d.]+\z/C= $host eq (($$k{"ingress"} || {})->{"address"} // "")
ABCresult
1XX1
0111
00X0
0100
Truth table0%0/2
A
A= $$k{'ingress'}
Aresult
11
00
1202 3 my ( $ns, $sec ) = _tls_for_host( $k, $sni );
1203 3 ▶ my $s = defined $sec ? _secret( $k, $ns, $sec ) : undef;
Branch: 1 branch
BranchTrueFalseTotal
defined $sec ? : 2 1 3
1204 3 ▶ my $info = $s && defined $s->{'tls.crt'} ? _cert_info( $s->{'tls.crt'} ) : undef;
Branch: 1 branch
BranchTrueFalseTotal
$s && defined $$s{'tls.crt'} ? : 2 1 3
Condition66%2/3
$s and defined $$s{"tls.crt"}
!ll&&!rl&&r
102
MC/DC50%1/2
$s and defined $$s{"tls.crt"}
$s defined $$s{"tls.crt"}
Truth table66%2/3
A and B
A= $sB= defined $$s{"tls.crt"}
ABresult
0X0
100
111
1205 3 my ( $subj, $iss, $pem, $verify );
1206 3 ▶ if ($info) {
Branch: 1 branch
BranchTrueFalseTotal
if ($info) { } 2 1 3
1207 2 ▶ ( $subj = $info->{subject} // 'CN=' . ( $info->{san}[0] // $sni ) ) =~ s/=/ = /g; $subj =~ s/,\s*/, /g;
Condition20%1/5
$$info{"subject"} // 'CN=' . ($$info{"san"}[0] // $sni)
l!l
20
$$info{"san"}[0] // $sni
l!l&&r!l&&!r
000
MC/DC0%0/1
$$info{"subject"} // 'CN=' . ($$info{"san"}[0] // $sni)
$$info{"subject"}
MC/DC0%0/2
$$info{"san"}[0] // $sni
$$info{"san"}[0] $sni
Truth table50%1/2
A
A= $$info{"subject"}
Aresult
11
00
Truth table0%0/3
A // B
A= $$info{"san"}[0]B= $sni
ABresult
1X1
011
000
1208 2 $iss = _dn_issuer( $info->{issuer} );
1209 2 $pem = $s->{'tls.crt'};
1210 2 ▶ $verify = !( grep { _host_match( $_, $sni ) } @{ $info->{san} } ) ? '62 (hostname mismatch)' : $info->{trusted} ? '0 (ok)' : '20 (unable to get local issuer certificate)';
Branch: 2 branches
BranchTrueFalseTotal
!grep({_host_match($_, $sni);} @{$$info{'san'};}) ? : 0 2 2
$$info{'trusted'} ? : 2 0 2
1211 }
1212 else {
1213 1 $subj = 'O = Acme Co, CN = Kubernetes Ingress Controller Fake Certificate';
1214 1 $iss = $subj;
1215 1 $pem = _pem( subject => 'O=Acme Co,CN=Kubernetes Ingress Controller Fake Certificate', san => 'ingress.local', issuer => 'fake', trusted => 0 );
1216 1 $verify = '18 (self-signed certificate)';
1217 }
1218 3 ▶ return ( join( "\n", 'CONNECTED(00000003)', "depth=0 $subj", ( $verify =~ /\A0 / ? 'verify return:1' : 'verify error:num=' . ( $verify =~ s/ \((.*)\)/:$1/r ) ),
Branch: 2 branches
BranchTrueFalseTotal
$verify =~ /\A0 / ? : 2 1 3
$verify =~ /\A0 / ? : 2 1 3
1219 '---', 'Certificate chain', " 0 s:$subj", " i:$iss", '---', 'Server certificate', $pem =~ s/\n\z//r, "subject=$subj", "issuer=$iss", '---',
1220 'SSL handshake has read 3214 bytes and written 389 bytes', 'Verification' . ( $verify =~ /\A0 / ? ': OK' : ' error: ' . ( $verify =~ s/\A\d+ \((.*)\)/$1/r ) ), '---',
1221 " Verify return code: $verify", '---', 'DONE' ), 1 );
1222 }
1223  
1224  
1225 2 ▶sub x509 {
Subroutine x509: called CC=14 SCAR=30.0
Pod documented
1226 2 my ( $pem, $o ) = @_;
1227 2 ▶ my $info = _cert_info($pem) or return ( "Could not read certificate from <stdin>\nUnable to load certificate", 0 );
Branch: 1 branch
BranchTrueFalseTotal
my $info = _cert_info($pem) or return "Could not read certificate from <stdin>\nUnable to load certificate", 0 2 0 2
1228 2 ▶ ( my $subj = $info->{subject} // 'CN=' . ( $info->{san}[0] // '' ) ) =~ s/=/ = /g; $subj =~ s/,\s*/, /g;
Condition25%1/4
$$info{"subject"} // 'CN=' . ($$info{"san"}[0] // "")
l!l
20
$$info{"san"}[0] // ""
l!l
00
MC/DC0%0/1
$$info{"subject"} // 'CN=' . ($$info{"san"}[0] // "")
$$info{"subject"}
MC/DC0%0/1
$$info{"san"}[0] // ""
$$info{"san"}[0]
Truth table50%1/2
A
A= $$info{"subject"}
Aresult
11
00
Truth table0%0/2
A
A= $$info{"san"}[0]
Aresult
11
00
1229 2 my $iss = _dn_issuer( $info->{issuer} );
1230 2 my @san = map {"DNS:$_"} grep {length} @{ $info->{san} };
1231 2 my %w = map { $_ => 1 } @$o;
1232 2 my @l;
1233 2 ▶ if ( $w{'-text'} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($w{"-text"}) 0 2 2
1234 0 return ( join( "\n", 'Certificate:', ' Data:', ' Version: 3 (0x2)', " Issuer: $iss", ' Validity', ' Not Before: Oct 21 07:12:44 2026 GMT',
1235 ' Not After : Jan 19 07:12:43 2027 GMT', " Subject: $subj", ' X509v3 extensions:', ' X509v3 Subject Alternative Name: ', ' ' . join( ', ', @san ) ), 1 );
1236 }
1237 2 ▶ push @l, "subject=$subj" if $w{'-subject'};
Branch: 1 branch
BranchTrueFalseTotal
if $w{"-subject"} 1 1 2
1238 2 ▶ push @l, "issuer=$iss" if $w{'-issuer'};
Branch: 1 branch
BranchTrueFalseTotal
if $w{"-issuer"} 0 2 2
1239 2 ▶ push @l, 'notBefore=Oct 21 07:12:44 2026 GMT' if $w{'-dates'} || $w{'-startdate'};
Branch: 1 branch
BranchTrueFalseTotal
if $w{"-dates"} or $w{"-startdate"} 0 2 2
Condition33%1/3
$w{"-dates"} or $w{"-startdate"}
l!l&&r!l&&!r
002
MC/DC0%0/2
$w{"-dates"} or $w{"-startdate"}
$w{"-dates"} $w{"-startdate"}
Truth table33%1/3
A or B
A= $w{"-dates"}B= $w{"-startdate"}
ABresult
1X1
011
000
1240 2 ▶ push @l, 'notAfter=Jan 19 07:12:43 2027 GMT' if $w{'-dates'} || $w{'-enddate'};
Branch: 1 branch
BranchTrueFalseTotal
if $w{"-dates"} or $w{"-enddate"} 0 2 2
Condition33%1/3
$w{"-dates"} or $w{"-enddate"}
l!l&&r!l&&!r
002
MC/DC0%0/2
$w{"-dates"} or $w{"-enddate"}
$w{"-dates"} $w{"-enddate"}
Truth table33%1/3
A or B
A= $w{"-dates"}B= $w{"-enddate"}
ABresult
1X1
011
000
1241 2 ▶ push @l, 'X509v3 Subject Alternative Name: ', ' ' . join( ', ', @san ) if grep {/subjectAltName/} @$o;
Branch: 1 branch
BranchTrueFalseTotal
if grep {/subjectAltName/;} @$o 1 1 2
1242 2 ▶ push @l, $pem =~ s/\n\z//r unless $w{'-noout'} || @l;
Branch: 1 branch
BranchTrueFalseTotal
unless $w{"-noout"} or @l 0 2 2
Condition33%1/3
$w{"-noout"} or @l
l!l&&r!l&&!r
200
MC/DC0%0/2
$w{"-noout"} or @l
$w{"-noout"} @l
Truth table33%1/3
A or B
A= $w{"-noout"}B= @l
ABresult
1X1
011
000
1243 2 return ( join( "\n", @l ), 1 );
1244 }
1245  
1246 # --- -o jsonpath / custom-columns ---------------------------------------------------
1247  
1248  
1249 22 ▶sub _jp_segments {
Subroutine _jp_segments: called CC=14 SCAR=34.9
1250 22 my ($p) = @_;
1251 22 my @s;
1252 22 $p =~ s/\A\s+|\s+\z//g;
1253 22 $p =~ s/\A\$//;
1254 22 ▶ while ( length $p ) {
Branch: 1 branch
BranchTrueFalseTotal
if (length $p) 78 22 100
1255 0 ▶ if ( $p =~ s/\A\.\.((?:[^.\[\\]|\\.)+)// ) { push @s, [ 'rec', $1 =~ s/\\(.)/$1/gr ] }
Branch: 9 branches
BranchTrueFalseTotal
if ($p =~ s/\A\.\.((?:[^.\[\\]|\\.)+)//) { } 0 78 78
elsif ($p =~ s/\A\.((?:[^.\[\\]|\\.)+)//) { } 66 12 78
elsif ($p =~ s/\A\[\s*['"]([^'"]*)['"]\s*\]//) { } 0 12 12
elsif ($p =~ s/\A\[\s*\*\s*\]//) { } 1 11 12
elsif ($p =~ s/\A\[\s*(-?\d+)\s*\]//) { } 10 1 11
elsif ($p =~ s/\A\[\s*(-?\d*)\s*:\s*(-?\d*)\s*\]//) { } 0 1 1
elsif ($p =~ s/\A\[\s*\?\(\s*@((?:\.(?:[^.\s=!<>)\\]|\\.)+)+)\s*(==|!=)\s*(?:"([^"]*)"|'([^']*)'|(\S+?))\s*\)\s*\]//) { } 1 0 1
elsif ($p =~ s/\A\[\s*\?\(\s*@((?:\.(?:[^.\s)\\]|\\.)+)+)\s*\)\s*\]//) { } 0 0 0
elsif ($p eq '.' or $p eq '@') { } 0 0 0
1256 66 elsif ( $p =~ s/\A\.((?:[^.\[\\]|\\.)+)// ) { push @s, [ 'key', $1 =~ s/\\(.)/$1/gr ] }
1257 0 elsif ( $p =~ s/\A\[\s*['"]([^'"]*)['"]\s*\]// ) { push @s, [ 'key', $1 ] }
1258 1 elsif ( $p =~ s/\A\[\s*\*\s*\]// ) { push @s, ['all'] }
1259 10 elsif ( $p =~ s/\A\[\s*(-?\d+)\s*\]// ) { push @s, [ 'idx', $1 ] }
1260 0 elsif ( $p =~ s/\A\[\s*(-?\d*)\s*:\s*(-?\d*)\s*\]// ) { push @s, [ 'slice', $1, $2 ] }
1261 1 ▶ elsif ( $p =~ s/\A\[\s*\?\(\s*@((?:\.(?:[^.\s=!<>)\\]|\\.)+)+)\s*(==|!=)\s*(?:"([^"]*)"|'([^']*)'|(\S+?))\s*\)\s*\]// ) { push @s, [ 'filter', $1, $2, $3 // $4 // $5 ] }
Condition33%2/6
($3 // $4) // $5
l!l&&r!l&&!r
100
$3 // $4
l!l&&r!l&&!r
100
MC/DC0%0/3
($3 // $4) // $5
$3 $4 $5
Truth table25%1/4
A // B // C
A= $3B= $4C= $5
ABCresult
1XX1
01X1
0011
0000
1262 0 elsif ( $p =~ s/\A\[\s*\?\(\s*@((?:\.(?:[^.\s)\\]|\\.)+)+)\s*\)\s*\]// ) { push @s, [ 'has', $1 ] }
1263 0 ▶ elsif ( $p eq '.' || $p eq '@' ) { last }
Condition0%0/3
$p eq "." or $p eq "\@"
l!l&&r!l&&!r
000
MC/DC0%0/2
$p eq "." or $p eq "\@"
$p eq "." $p eq "\@"
Truth table0%0/3
A or B
A= $p eq "."B= $p eq "\@"
ABresult
1X1
011
000
1264 0 else { return undef }
1265 }
1266 22 return \@s;
1267 }
1268  
1269 23 ▶sub _jp_eval {
Subroutine _jp_eval: called CC=38 SCAR=57.9
1270 23 my ( $nodes, $segs ) = @_;
1271 23 my @cur = @$nodes;
1272 23 for my $s (@$segs) {
1273 79 my @n;
1274 79 for my $x (@cur) {
1275 79 ▶ if ( $s->[0] eq 'key' ) { push @n, $x->{ $s->[1] } if ref $x eq 'HASH' && exists $x->{ $s->[1] } }
Branch: 7 branches
BranchTrueFalseTotal
if ($$s[0] eq 'key') { } 67 12 79
elsif ($$s[0] eq 'all') { } 1 11 12
elsif ($$s[0] eq 'idx') { } 10 1 11
elsif ($$s[0] eq 'slice') { } 0 1 1
elsif ($$s[0] eq 'filter' or $$s[0] eq 'has') { } 1 0 1
elsif ($$s[0] eq 'rec') { } 0 0 0
if ref $x eq "HASH" and exists $$x{$$s[1]} 67 0 67
Condition33%1/3
ref $x eq "HASH" and exists $$x{$$s[1]}
!ll&&!rl&&r
0067
MC/DC0%0/2
ref $x eq "HASH" and exists $$x{$$s[1]}
ref $x eq "HASH" exists $$x{$$s[1]}
Truth table33%1/3
A and B
A= ref $x eq "HASH"B= exists $$x{$$s[1]}
ABresult
0X0
100
111
1276 0 ▶ elsif ( $s->[0] eq 'all' ) { push @n, ref $x eq 'ARRAY' ? @$x : ref $x eq 'HASH' ? @{$x}{ sort keys %$x } : () }
Branch: 2 branches
BranchTrueFalseTotal
ref $x eq 'ARRAY' ? : 1 0 1
ref $x eq 'HASH' ? : 0 0 0
1277 10 ▶ elsif ( $s->[0] eq 'idx' ) { push @n, $x->[ $s->[1] ] if ref $x eq 'ARRAY' && defined $x->[ $s->[1] ] }
Branch: 1 branch
BranchTrueFalseTotal
if ref $x eq "ARRAY" and defined $$x[$$s[1]] 10 0 10
Condition33%1/3
ref $x eq "ARRAY" and defined $$x[$$s[1]]
!ll&&!rl&&r
0010
MC/DC0%0/2
ref $x eq "ARRAY" and defined $$x[$$s[1]]
ref $x eq "ARRAY" defined $$x[$$s[1]]
Truth table33%1/3
A and B
A= ref $x eq "ARRAY"B= defined $$x[$$s[1]]
ABresult
0X0
100
111
1278 elsif ( $s->[0] eq 'slice' ) {
1279 0 ▶ next unless ref $x eq 'ARRAY';
Branch: 1 branch
BranchTrueFalseTotal
unless ref $x eq "ARRAY" 0 0 0
1280 0 ▶ my ( $f, $t ) = ( length $s->[1] ? $s->[1] : 0, length $s->[2] ? $s->[2] : scalar @$x );
Branch: 2 branches
BranchTrueFalseTotal
length $$s[1] ? : 0 0 0
length $$s[2] ? : 0 0 0
1281 0 $_ += @$x for grep { $_ < 0 } $f, $t;
1282 0 ▶ push @n, @$x[ $f .. ( $t > @$x ? $#$x : $t - 1 ) ] if $f < @$x;
Branch: 2 branches
BranchTrueFalseTotal
if $f < @$x 0 0 0
$t > @$x ? : 0 0 0
1283 }
1284 ▶ elsif ( $s->[0] eq 'filter' || $s->[0] eq 'has' ) {
Condition33%1/3
$$s[0] eq "filter" or $$s[0] eq "has"
l!l&&r!l&&!r
100
MC/DC0%0/2
$$s[0] eq "filter" or $$s[0] eq "has"
$$s[0] eq "filter" $$s[0] eq "has"
Truth table33%1/3
A or B
A= $$s[0] eq "filter"B= $$s[0] eq "has"
ABresult
1X1
011
000
1285 1 ▶ next unless ref $x eq 'ARRAY';
Branch: 1 branch
BranchTrueFalseTotal
unless ref $x eq "ARRAY" 0 1 1
1286 1 ▶ my $sub = _jp_segments( $s->[1] ) or next;
Branch: 1 branch
BranchTrueFalseTotal
my $sub = _jp_segments($$s[1]) or next 1 0 1
1287 1 for my $el (@$x) {
1288 2 my ($v) = _jp_eval( [$el], $sub );
1289 0 ▶ if ( $s->[0] eq 'has' ) { push @n, $el if defined $v; next }
Branch: 2 branches
BranchTrueFalseTotal
if ($$s[0] eq "has") 0 2 2
if defined $v 0 0 0
1290 2 ▶ my $vs = defined $v && !ref $v ? ( JSON::MaybeXS::is_bool($v) ? ( $v ? 'true' : 'false' ) : "$v" ) : undef;
Branch: 3 branches
BranchTrueFalseTotal
defined $v && !ref($v) ? : 2 0 2
JSON::MaybeXS::is_bool($v) ? : 0 2 2
$v ? : 0 0 0
Condition33%1/3
defined $v and not ref $v
!ll&&!rl&&r
002
MC/DC0%0/2
defined $v and not ref $v
defined $v not ref $v
Truth table33%1/3
A and not(B)
A= defined $vB= not ref $v
ABresult
0X0
100
111
1291 2 ▶ my $eq = defined $vs && $vs eq $s->[3];
Condition66%2/3
defined $vs && $vs eq $$s[3]
!ll&&!rl&&r
011
MC/DC50%1/2
defined $vs && $vs eq $$s[3]
defined $vs $vs eq $$s[3]
Truth table66%2/3
A && B
A= defined $vsB= $vs eq $$s[3]
ABresult
0X0
100
111
1292 2 ▶ push @n, $el if $s->[2] eq '==' ? $eq : !$eq;
Branch: 2 branches
BranchTrueFalseTotal
if $$s[2] eq "==" ? $eq : !$eq 1 1 2
$$s[2] eq '==' ? : 2 0 2
1293 }
1294 }
1295 elsif ( $s->[0] eq 'rec' ) {
1296 0 my @q = ($x);
1297 0 ▶ while (@q) {
Branch: 1 branch
BranchTrueFalseTotal
if (@q) 0 0 0
1298 0 my $y = shift @q;
1299 0 ▶ if ( ref $y eq 'HASH' ) { push @n, $y->{ $s->[1] } if exists $y->{ $s->[1] }; push @q, @{$y}{ sort keys %$y } }
Branch: 3 branches
BranchTrueFalseTotal
if (ref $y eq 'HASH') { } 0 0 0
elsif (ref $y eq 'ARRAY') { } 0 0 0
if exists $$y{$$s[1]} 0 0 0
1300 0 elsif ( ref $y eq 'ARRAY' ) { push @q, @$y }
1301 }
1302 }
1303 }
1304 79 @cur = @n;
1305 }
1306 23 return @cur;
1307 }
1308  
1309 20 ▶sub _jp_text {
Subroutine _jp_text: called CC=5 SCAR=18.6
1310 20 my ($v) = @_;
1311 20 ▶ return '' unless defined $v;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $v 0 20 20
1312 20 ▶ return $v ? 'true' : 'false' if JSON::MaybeXS::is_bool($v);
Branch: 2 branches
BranchTrueFalseTotal
if JSON::MaybeXS::is_bool($v) 0 20 20
$v ? : 0 0 0
1313 20 ▶ return JSON::MaybeXS->new( canonical => 1 )->encode($v) if ref $v;
Branch: 1 branch
BranchTrueFalseTotal
if ref $v 0 20 20
1314 20 return "$v";
1315 }
1316  
1317 9 ▶sub jsonpath {
Subroutine jsonpath: called CC=5 SCAR=16.2
Pod documented
1318 9 my ( $data, $tpl ) = @_;
1319 9 $tpl =~ s/\A\s*'(.*)'\s*\z/$1/s;
1320 9 my @tok;
1321 9 ▶ while ( length $tpl ) {
Branch: 1 branch
BranchTrueFalseTotal
if (length $tpl) 14 9 23
1322 14 ▶ if ( $tpl =~ s/\A\{((?:[^{}"]|"(?:[^"\\]|\\.)*")*)\}// ) { push @tok, [ 'e', $1 ] }
Branch: 2 branches
BranchTrueFalseTotal
if ($tpl =~ s/\A\{((?:[^{}"]|"(?:[^"\\]|\\.)*")*)\}//) { } 13 1 14
elsif ($tpl =~ s/\A([^{]+)//) { } 1 0 1
1323 1 elsif ( $tpl =~ s/\A([^{]+)// ) { push @tok, [ 't', $1 ] }
1324 0 else { return ( undef, 'error: error parsing jsonpath ' . $tpl . ', unclosed action' ) }
1325 }
1326 9 my $err;
1327 my $run;
1328 13 ▶ $run = sub {
Subroutine __ANON__: called CC=13 SCAR=26.0
1329 13 my ( $toks, $ctx ) = @_;
1330 13 my $out = '';
1331 13 my $i = 0;
1332 13 ▶ while ( $i < @$toks ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($i < @$toks) 25 13 38
1333 25 my ( $t, $v ) = @{ $toks->[$i] };
1334 25 ▶ if ( $t eq 't' ) { $out .= $v; $i++; next }
Branch: 1 branch
BranchTrueFalseTotal
if ($t eq "t") 4 21 25
1335 21 $v =~ s/\A\s+|\s+\z//g;
1336 21 ▶ if ( $v =~ /\A"((?:[^"\\]|\\.)*)"\z/ ) { ( my $l = $1 ) =~ s/\\n/\n/g; $l =~ s/\\t/\t/g; $l =~ s/\\(.)/$1/g; $out .= $l; $i++; next }
Branch: 1 branch
BranchTrueFalseTotal
if ($v =~ /\A"((?:[^"\\]|\\.)*)"\z/) 4 17 21
1337 17 ▶ if ( $v =~ /\Arange\s+(.+)\z/ ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($v =~ /\Arange\s+(.+)\z/) 1 16 17
1338 1 my $path = $1;
1339 1 my ( $depth, $j ) = ( 1, $i + 1 );
1340 1 ▶ for ( ; $j < @$toks; $j++ ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($j < @$toks) 5 0 5
1341 5 ▶ next unless $toks->[$j][0] eq 'e';
Branch: 1 branch
BranchTrueFalseTotal
unless $$toks[$j][0] eq "e" 1 4 5
1342 4 ▶ $depth++ if $toks->[$j][1] =~ /\A\s*range\s/;
Branch: 1 branch
BranchTrueFalseTotal
if $$toks[$j][1] =~ /\A\s*range\s/ 0 4 4
1343 4 ▶ last if $toks->[$j][1] =~ /\A\s*end\s*\z/ && !--$depth;
Branch: 1 branch
BranchTrueFalseTotal
if $$toks[$j][1] =~ /\A\s*end\s*\z/ and not --$depth 1 3 4
Condition66%2/3
$$toks[$j][1] =~ /\A\s*end\s*\z/ and not --$depth
!ll&&!rl&&r
301
MC/DC50%1/2
$$toks[$j][1] =~ /\A\s*end\s*\z/ and not --$depth
$$toks[$j][1] =~ /\A\s*end\s*\z/ not --$depth
Truth table66%2/3
A and not(B)
A= $$toks[$j][1] =~ /\A\s*end\s*\z/B= not --$depth
ABresult
0X0
100
111
1344 }
1345 0 ▶ my $segs = _jp_segments($path) or do { $err = "error: error parsing jsonpath $path"; return '' };
Branch: 1 branch
BranchTrueFalseTotal
my $segs = _jp_segments($path) or do { $err = "error: error parsing jsonpath $path"; return "" } 1 0 1
1346 1 my @body = @$toks[ $i + 1 .. $j - 1 ];
1347 1 $out .= $run->( \@body, $_ ) for _jp_eval( [$ctx], $segs );
1348 1 $i = $j + 1;
1349 1 next;
1350 }
1351 0 ▶ my $segs = _jp_segments($v) or do { $err = "error: error parsing jsonpath {$v}, unrecognized character"; return '' };
Branch: 1 branch
BranchTrueFalseTotal
my $segs = _jp_segments($v) or do { $err = "error: error parsing jsonpath {$v}, unrecognized character"; return "" } 16 0 16
1352 16 $out .= join ' ', map { _jp_text($_) } _jp_eval( [$ctx], $segs );
1353 16 $i++;
1354 }
1355 13 return $out;
1356 9 };
1357 9 my $o = $run->( \@tok, $data );
1358 9 ▶ return ( undef, $err ) if defined $err;
Branch: 1 branch
BranchTrueFalseTotal
if defined $err 0 9 9
1359 9 return ( $o =~ s/\n\z//r );
1360 }
1361  
1362 1 ▶sub _custom_columns {
Subroutine _custom_columns: called CC=9 SCAR=23.2
1363 1 my ( $data, $spec ) = @_;
1364 1 my @cols = map { [ split /:/, $_, 2 ] } split /,/, $spec;
1365 1 ▶ return ( undef, 'error: custom-columns format specified but no custom columns given' ) unless @cols;
Branch: 1 branch
BranchTrueFalseTotal
unless @cols 0 1 1
1366 1 ▶ my @items = ( $data->{kind} // '' ) eq 'List' ? @{ $data->{items} || [] } : ($data);
Branch: 1 branch
BranchTrueFalseTotal
($$data{'kind'} // '') eq 'List' ? : 1 0 1
Condition50%2/4
$$data{"kind"} // ""
l!l
10
$$data{'items'} || []
l!l
10
MC/DC0%0/1
$$data{"kind"} // ""
$$data{"kind"}
MC/DC0%0/1
$$data{'items'} || []
$$data{'items'}
Truth table50%1/2
A
A= $$data{"kind"}
Aresult
11
00
Truth table50%1/2
A
A= $$data{'items'}
Aresult
11
00
1367 1 my @rows = ( [ map { $_->[0] } @cols ] );
1368 1 for my $it (@items) {
1369 2 ▶ push @rows, [ map { my $s = _jp_segments( ( $_->[1] // '' ) =~ s/\A\{|\}\z//gr ); my @v = $s ? _jp_eval( [$it], $s ) : (); @v ? join( ',', map { _jp_text($_) } @v ) : '<none>' } @cols ];
Branch: 2 branches
BranchTrueFalseTotal
$s ? : 4 0 4
@v ? : 4 0 4
Condition50%1/2
$$_[1] // ""
l!l
40
MC/DC0%0/1
$$_[1] // ""
$$_[1]
Truth table50%1/2
A
A= $$_[1]
Aresult
11
00
1370 }
1371 1 return ( _cols(@rows) );
1372 }
1373  
1374 # --- RBAC ---------------------------------------------------------------------
1375  
1376 # API-Gruppe je Ressource (Plural der API)
1377 our %GROUP = (
1378 55 ( map { $_ => '' } qw( pods services endpoints secrets configmaps persistentvolumeclaims persistentvolumes serviceaccounts events namespaces nodes ) ),
1379 20 ( map { $_ => 'apps' } qw( deployments replicasets statefulsets daemonsets ) ),
1380 10 ( map { $_ => 'batch' } qw( jobs cronjobs ) ),
1381 15 ( map { $_ => 'networking.k8s.io' } qw( ingresses ingressclasses networkpolicies ) ),
1382 20 ( map { $_ => 'rbac.authorization.k8s.io' } qw( roles rolebindings clusterroles clusterrolebindings ) ),
1383 20 ( map { $_ => 'cert-manager.io' } qw( certificates issuers clusterissuers certificaterequests ) ),
1384 5 ( map { $_ => 'acme.cert-manager.io' } qw( challenges orders ) ),
1385 storageclasses => 'storage.k8s.io', leases => 'coordination.k8s.io',
1386 );
1387 5 my %API_PLURAL = ( pvcs => 'persistentvolumeclaims' );
1388  
1389 # Ressource aus der Kommandozeile (pods, deploy, pods/log, deployments.apps) -> ( plural, gruppe ) oder ()
1390 10 ▶sub _resource {
Subroutine _resource: called CC=11 SCAR=27.7
1391 10 my ($r) = @_;
1392 10 ▶ my ( $base, $sub ) = split m{/}, lc( $r // '' ), 2;
Condition50%1/2
$r // ""
l!l
100
MC/DC0%0/1
$r // ""
$r
Truth table50%1/2
A
A= $r
Aresult
11
00
1393 10 my $group;
1394 10 ▶ ( $base, $group ) = ( $1, $2 ) if $base =~ /\A([a-z]+)\.(.+)\z/;
Branch: 1 branch
BranchTrueFalseTotal
if $base =~ /\A([a-z]+)\.(.+)\z/ 1 9 10
1395 10 ▶ my $plural = $KIND{$base} ? ( $API_PLURAL{ $KIND{$base} } // $KIND{$base} ) : exists $GROUP{$base} ? $base : $base eq '*' ? '*' : undef;
Branch: 3 branches
BranchTrueFalseTotal
$Langertha::Holmgang::Sim::Linux::Kubernetes::KIND{$base} ? : 10 0 10
exists $Langertha::Holmgang::Sim::Linux::Kubernetes::GROUP{$base} ? : 0 0 0
$base eq '*' ? : 0 0 0
Condition33%1/3
$API_PLURAL{$Langertha::Holmgang::Sim::Linux::Kubernetes::KIND{$base}} // $Langertha::Holmgang::Sim::Linux::Kubernetes::KIND{$base}
l!l&&r!l&&!r
0100
MC/DC0%0/2
$API_PLURAL{$Langertha::Holmgang::Sim::Linux::Kubernetes::KIND{$base}} // $Langertha::Holmgang::Sim::Linux::Kubernetes::KIND{$base}
$API_PLURAL{$Langertha::Holmgang::Sim::Linux::Kubernetes::KIND{$base}} $Langertha::Holmgang::Sim::Linux::Kubernetes::KIND{$base}
Truth table33%1/3
A // B
A= $API_PLURAL{$Langertha::Holmgang::Sim::Linux::Kubernetes::KIND{$base}}B= $Langertha::Holmgang::Sim::Linux::Kubernetes::KIND{$base}
ABresult
1X1
011
000
1396 10 ▶ return () unless defined $plural;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $plural 0 10 10
1397 10 ▶ $group //= $GROUP{$plural} // '*';
Condition75%3/4
$group //= $Langertha::Holmgang::Sim::Linux::Kubernetes::GROUP{$plural} // "*"
l!l
19
$Langertha::Holmgang::Sim::Linux::Kubernetes::GROUP{$plural} // "*"
l!l
90
MC/DC100%1/1
$group //= $Langertha::Holmgang::Sim::Linux::Kubernetes::GROUP{$plural} // "*"
$group
Truth table100%2/2
A
A= $group
Aresult
11
00
1398 10 ▶ return ( $plural . ( defined $sub ? "/$sub" : '' ), $group );
Branch: 1 branch
BranchTrueFalseTotal
defined $sub ? : 1 9 10
1399 }
1400  
1401 5 my @VIEW_RES = qw( pods pods/log services endpoints configmaps persistentvolumeclaims serviceaccounts events
1402 deployments replicasets statefulsets daemonsets jobs cronjobs ingresses networkpolicies );
1403 42 ▶sub _builtin_roles {
Subroutine _builtin_roles: called CC=1 SCAR=0.0
1404 126 ▶ my $rule = sub { my ( $verbs, @res ) = @_; my %g; push @{ $g{ $GROUP{ $_ =~ s{/.*}{}r } } }, $_ for @res;
Subroutine __ANON__: called CC=2 SCAR=6.9
1405 42 return map { { apiGroups => [$_], resources => $g{$_}, verbs => $verbs } } sort keys %g };
1406 42 my @ro = qw( get list watch );
1407 42 my @rw = ( @ro, qw( create update patch delete deletecollection ) );
1408 return {
1409 42 'cluster-admin' => { rules => [ { apiGroups => ['*'], resources => ['*'], verbs => ['*'] } ] },
1410 admin => { rules => [ $rule->( \@rw, @VIEW_RES, qw( secrets roles rolebindings pods/exec ) ) ] },
1411 edit => { rules => [ $rule->( \@rw, @VIEW_RES, qw( secrets pods/exec ) ) ] },
1412 view => { rules => [ $rule->( \@ro, @VIEW_RES ) ] },
1413 };
1414 }
1415  
1416 42 ▶sub _clusterroles { my ($k) = @_; return { %{ _builtin_roles() }, %{ $k->{clusterroles} || {} } } }
Subroutine _clusterroles: called CC=2 SCAR=7.0
Condition50%1/2
$$k{'clusterroles'} || {}
l!l
042
MC/DC0%0/1
$$k{'clusterroles'} || {}
$$k{'clusterroles'}
Truth table50%1/2
A
A= $$k{'clusterroles'}
Aresult
11
00
1417  
1418 # Wer: { user, groups }
1419 203 ▶sub _who_sa { my ( $ns, $sa ) = @_; return { user => "system:serviceaccount:$ns:$sa", groups => [ 'system:serviceaccounts', "system:serviceaccounts:$ns", 'system:authenticated' ] } }
Subroutine _who_sa: called CC=1 SCAR=0.0
1420  
1421 17 ▶sub _subject_match {
Subroutine _subject_match: called CC=11 SCAR=27.7
1422 17 my ( $s, $who, $bns ) = @_;
1423 17 ▶ my $kind = $s->{kind} // '';
Condition50%1/2
$$s{"kind"} // ""
l!l
170
MC/DC0%0/1
$$s{"kind"} // ""
$$s{"kind"}
Truth table50%1/2
A
A= $$s{"kind"}
Aresult
11
00
1424 17 ▶ return $who->{user} eq 'system:serviceaccount:' . ( $s->{namespace} // $bns // '' ) . ':' . ( $s->{name} // '' ) if $kind eq 'ServiceAccount';
Branch: 1 branch
BranchTrueFalseTotal
if $kind eq "ServiceAccount" 7 10 17
Condition42%3/7
($$s{"namespace"} // $bns) // ""
l!l
70
$$s{"namespace"} // $bns
l!l&&r!l&&!r
700
$$s{"name"} // ""
l!l
70
MC/DC0%0/2
($$s{"namespace"} // $bns) // ""
$$s{"namespace"} $bns
MC/DC0%0/1
$$s{"name"} // ""
$$s{"name"}
Truth table33%1/3
A // B
A= $$s{"namespace"}B= $bns
ABresult
1X1
011
000
Truth table50%1/2
A
A= $$s{"name"}
Aresult
11
00
1425 10 ▶ return $who->{user} eq ( $s->{name} // '' ) if $kind eq 'User';
Branch: 1 branch
BranchTrueFalseTotal
if $kind eq "User" 6 4 10
Condition50%1/2
$$s{"name"} // ""
l!l
60
MC/DC0%0/1
$$s{"name"} // ""
$$s{"name"}
Truth table50%1/2
A
A= $$s{"name"}
Aresult
11
00
1426 4 ▶ return scalar grep { $_ eq ( $s->{name} // '' ) } @{ $who->{groups} || [] } if $kind eq 'Group';
Branch: 1 branch
BranchTrueFalseTotal
if $kind eq "Group" 4 0 4
Condition50%2/4
$$s{"name"} // ""
l!l
60
$$who{'groups'} || []
l!l
40
MC/DC0%0/1
$$s{"name"} // ""
$$s{"name"}
MC/DC0%0/1
$$who{'groups'} || []
$$who{'groups'}
Truth table50%1/2
A
A= $$s{"name"}
Aresult
11
00
Truth table50%1/2
A
A= $$who{'groups'}
Aresult
11
00
1427 0 return 0;
1428 }
1429  
1430 13 ▶sub _rule_allows {
Subroutine _rule_allows: called CC=7 SCAR=19.6
1431 13 my ( $r, $verb, $group, $res, $name ) = @_;
1432 13 ▶ my $in = sub { my ( $l, $v ) = @_; scalar grep { $_ eq '*' || $_ eq $v } @{ ref $l eq 'ARRAY' ? $l : [] } };
Subroutine __ANON__: called CC=3 SCAR=11.2
Branch: 1 branch
BranchTrueFalseTotal
ref $l eq 'ARRAY' ? : 33 0 33
Condition66%2/3
$_ eq '*' || $_ eq $v
l!l&&r!l&&!r
02540
MC/DC50%1/2
$_ eq '*' || $_ eq $v
$_ eq '*' $_ eq $v
Truth table66%2/3
A || B
A= $_ eq '*'B= $_ eq $v
ABresult
1X1
011
000
1433 13 ▶ return 0 unless $in->( $r->{verbs}, $verb ) && $in->( $r->{apiGroups}, $group ) && $in->( $r->{resources}, $res );
Branch: 1 branch
BranchTrueFalseTotal
unless &$in($$r{"verbs"}, $verb) and &$in($$r{"apiGroups"}, $group) and &$in($$r{"resources"}, $res) 8 5 13
Condition83%5/6
&$in($$r{"verbs"}, $verb) and &$in($$r{"apiGroups"}, $group) and &$in($$r{"resources"}, $res)
!ll&&!rl&&r
625
&$in($$r{"verbs"}, $verb) and &$in($$r{"apiGroups"}, $group)
!ll&&!rl&&r
067
MC/DC66%2/3
&$in($$r{"verbs"}, $verb) and &$in($$r{"apiGroups"}, $group) and &$in($$r{"resources"}, $res)
&$in($$r{"verbs"}, $verb) &$in($$r{"apiGroups"}, $group) &$in($$r{"resources"}, $res)
Truth table75%3/4
A and B and C
A= &$in($$r{"verbs"}, $verb)B= &$in($$r{"apiGroups"}, $group)C= &$in($$r{"resources"}, $res)
ABCresult
0XX0
10X0
1100
1111
1434 5 ▶ my @rn = @{ ref $r->{resourceNames} eq 'ARRAY' ? $r->{resourceNames} : [] };
Branch: 1 branch
BranchTrueFalseTotal
ref $$r{'resourceNames'} eq 'ARRAY' ? : 2 3 5
1435 5 ▶ return 1 unless @rn;
Branch: 1 branch
BranchTrueFalseTotal
unless @rn 3 2 5
1436 2 ▶ return defined $name && scalar grep { $_ eq $name } @rn;
Condition50%1/2
defined $name && scalar grep({$_ eq $name;} @rn)
!ll
02
MC/DC0%0/1
defined $name && scalar grep({$_ eq $name;} @rn)
defined $name
Truth table50%1/2
A
A= defined $name
Aresult
00
11
1437 }
1438  
1439 # Bindungen, die fuer wen in einem Namespace gelten: ( [ regel, quelle ] … )
1440 42 ▶sub _rules_for {
Subroutine _rules_for: called CC=25 SCAR=43.9
1441 42 my ( $k, $who, $ns ) = @_;
1442 42 ▶ return ( [ { apiGroups => ['*'], resources => ['*'], verbs => ['*'] }, 'cluster-admin' ] ) if $who->{admin};
Branch: 1 branch
BranchTrueFalseTotal
if $$who{"admin"} 0 42 42
1443 42 my $crs = _clusterroles($k);
1444 42 my @r;
1445 42 ▶ for my $bn ( sort keys %{ $k->{clusterrolebindings} || {} } ) {
Condition50%1/2
$$k{'clusterrolebindings'} || {}
l!l
042
MC/DC0%0/1
$$k{'clusterrolebindings'} || {}
$$k{'clusterrolebindings'}
Truth table50%1/2
A
A= $$k{'clusterrolebindings'}
Aresult
11
00
1446 0 my $b = $k->{clusterrolebindings}{$bn};
1447 0 ▶ next unless grep { _subject_match( $_, $who, undef ) } @{ $b->{subjects} || [] };
Branch: 1 branch
BranchTrueFalseTotal
unless grep {_subject_match($_, $who, undef);} @{$$b{"subjects"} or [];} 0 0 0
Condition0%0/2
$$b{'subjects'} || []
l!l
00
MC/DC0%0/1
$$b{'subjects'} || []
$$b{'subjects'}
Truth table0%0/2
A
A= $$b{'subjects'}
Aresult
11
00
1448 0 ▶ my $role = $crs->{ ( $b->{roleRef} || {} )->{name} // '' } or next;
Branch: 1 branch
BranchTrueFalseTotal
my $role = $$crs{($$b{"roleRef"} || {})->{"name"} // ""} or next 0 0 0
Condition0%0/4
($$b{"roleRef"} || {})->{"name"} // ""
l!l
00
$$b{'roleRef'} || {}
l!l
00
MC/DC0%0/1
($$b{"roleRef"} || {})->{"name"} // ""
$$b{'roleRef'}
Truth table0%0/2
A
A= $$b{'roleRef'}
Aresult
11
00
1449 0 ▶ push @r, map { [ $_, "ClusterRoleBinding/$bn" ] } @{ $role->{rules} || [] };
Condition0%0/2
$$role{'rules'} || []
l!l
00
MC/DC0%0/1
$$role{'rules'} || []
$$role{'rules'}
Truth table0%0/2
A
A= $$role{'rules'}
Aresult
11
00
1450 }
1451 42 ▶ return @r unless defined $ns && length $ns;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $ns and length $ns 0 42 42
Condition33%1/3
defined $ns and length $ns
!ll&&!rl&&r
0042
MC/DC0%0/2
defined $ns and length $ns
defined $ns length $ns
Truth table33%1/3
A and B
A= defined $nsB= length $ns
ABresult
0X0
100
111
1452 42 ▶ my $o = $k->{namespaces}{$ns} || {};
Condition100%2/2
$$k{'namespaces'}{$ns} || {}
l!l
411
MC/DC100%1/1
$$k{'namespaces'}{$ns} || {}
$$k{'namespaces'}{$ns}
Truth table100%2/2
A
A= $$k{'namespaces'}{$ns}
Aresult
11
00
1453 42 ▶ for my $bn ( sort keys %{ $o->{rolebindings} || {} } ) {
Condition100%2/2
$$o{'rolebindings'} || {}
l!l
735
MC/DC100%1/1
$$o{'rolebindings'} || {}
$$o{'rolebindings'}
Truth table100%2/2
A
A= $$o{'rolebindings'}
Aresult
11
00
1454 13 my $b = $o->{rolebindings}{$bn};
1455 13 ▶ next unless grep { _subject_match( $_, $who, $ns ) } @{ $b->{subjects} || [] };
Branch: 1 branch
BranchTrueFalseTotal
unless grep {_subject_match($_, $who, $ns);} @{$$b{"subjects"} or [];} 6 7 13
Condition50%1/2
$$b{'subjects'} || []
l!l
130
MC/DC0%0/1
$$b{'subjects'} || []
$$b{'subjects'}
Truth table50%1/2
A
A= $$b{'subjects'}
Aresult
11
00
1456 7 ▶ my $rr = $b->{roleRef} || {};
Condition50%1/2
$$b{'roleRef'} || {}
l!l
70
MC/DC0%0/1
$$b{'roleRef'} || {}
$$b{'roleRef'}
Truth table50%1/2
A
A= $$b{'roleRef'}
Aresult
11
00
1457 7 ▶ my $role = ( $rr->{kind} // '' ) eq 'ClusterRole' ? $crs->{ $rr->{name} // '' } : ( $o->{roles} || {} )->{ $rr->{name} // '' };
Branch: 1 branch
BranchTrueFalseTotal
($$rr{'kind'} // '') eq 'ClusterRole' ? : 2 5 7
Condition50%4/8
$$rr{"kind"} // ""
l!l
70
$$rr{"name"} // ""
l!l
20
$$o{'roles'} || {}
l!l
50
$$rr{"name"} // ""
l!l
50
MC/DC0%0/1
$$rr{"kind"} // ""
$$rr{"kind"}
MC/DC0%0/1
$$rr{"name"} // ""
$$rr{"name"}
MC/DC0%0/1
$$o{'roles'} || {}
$$o{'roles'}
MC/DC0%0/1
$$rr{"name"} // ""
$$rr{"name"}
Truth table50%1/2
A
A= $$rr{"kind"}
Aresult
11
00
Truth table50%1/2
A
A= $$rr{"name"}
Aresult
11
00
Truth table50%1/2
A
A= $$o{'roles'}
Aresult
11
00
Truth table50%1/2
A
A= $$rr{"name"}
Aresult
11
00
1458 7 ▶ next unless $role;
Branch: 1 branch
BranchTrueFalseTotal
unless $role 0 7 7
1459 7 ▶ push @r, map { [ $_, "RoleBinding/$bn" ] } @{ $role->{rules} || [] };
Condition50%1/2
$$role{'rules'} || []
l!l
70
MC/DC0%0/1
$$role{'rules'} || []
$$role{'rules'}
Truth table50%1/2
A
A= $$role{'rules'}
Aresult
11
00
1460 }
1461 42 return @r;
1462 }
1463  
1464 42 ▶sub _allowed {
Subroutine _allowed: called CC=1 SCAR=0.0
1465 42 my ( $k, $who, $verb, $group, $res, $ns, $name ) = @_;
1466 42 return scalar grep { _rule_allows( $_->[0], $verb, $group, $res, $name ) } _rules_for( $k, $who, $ns );
1467 }
1468  
1469 33 ▶sub _forbidden {
Subroutine _forbidden: called CC=4 SCAR=16.1
1470 33 my ( $who, $verb, $group, $res, $ns, $name ) = @_;
1471 33 my ($base) = split m{/}, $res;
1472 33 ▶ return ( defined $name ? qq{$base "$name"} : $base ) . qq{ is forbidden: User "$who->{user}" cannot $verb resource "$res" in API group "$group" }
Branch: 2 branches
BranchTrueFalseTotal
defined $name ? : 0 33 33
defined $ns && length $ns ? : 33 0 33
Condition33%1/3
defined $ns and length $ns
!ll&&!rl&&r
0033
MC/DC0%0/2
defined $ns and length $ns
defined $ns length $ns
Truth table33%1/3
A and B
A= defined $nsB= length $ns
ABresult
0X0
100
111
1473 . ( defined $ns && length $ns ? qq{in the namespace "$ns"} : 'at the cluster scope' );
1474 }
1475  
1476 # kubectl auth can-i VERB RESOURCE[/NAME] [--as …] [--as-group …] [-n ns] | --list
1477 8 ▶sub _v_auth {
Subroutine _v_auth: called CC=35 SCAR=54.9
1478 8 my ( $k, $a, $o ) = @_;
1479 8 my ( $sub, @r ) = @$a;
1480 8 ▶ if ( ( $sub // '' ) eq 'whoami' ) {
Branch: 1 branch
BranchTrueFalseTotal
if (($sub // "") eq "whoami") 0 8 8
Condition50%1/2
$sub // ""
l!l
80
MC/DC0%0/1
$sub // ""
$sub
Truth table50%1/2
A
A= $sub
Aresult
11
00
1481 0 ▶ my $u = ( $o->{f}{as} || [] )->[0] // 'kubernetes-admin';
Condition0%0/4
($$o{"f"}{"as"} || [])->[0] // "kubernetes-admin"
l!l
00
$$o{'f'}{'as'} || []
l!l
00
MC/DC0%0/1
($$o{"f"}{"as"} || [])->[0] // "kubernetes-admin"
$$o{'f'}{'as'}
Truth table0%0/2
A
A= $$o{'f'}{'as'}
Aresult
11
00
1482 0 ▶ return ( "ATTRIBUTE VALUE\nUsername $u\nGroups [" . ( $o->{f}{as} ? 'system:authenticated' : 'kubeadm:cluster-admins system:authenticated' ) . ']', 1 );
Branch: 1 branch
BranchTrueFalseTotal
$$o{'f'}{'as'} ? : 0 0 0
1483 }
1484 0 ▶ unless ( ( $sub // '' ) eq 'can-i' ) { push @GAPS, "kubectl auth @$a"; return ( '', 0 ) }
Branch: 1 branch
BranchTrueFalseTotal
unless (($sub // "") eq "can-i") 0 8 8
Condition50%1/2
$sub // ""
l!l
80
MC/DC0%0/1
$sub // ""
$sub
Truth table50%1/2
A
A= $sub
Aresult
11
00
1485 8 ▶ my $as = ( $o->{f}{as} || [] )->[0];
Condition50%1/2
$$o{'f'}{'as'} || []
l!l
80
MC/DC0%0/1
$$o{'f'}{'as'} || []
$$o{'f'}{'as'}
Truth table50%1/2
A
A= $$o{'f'}{'as'}
Aresult
11
00
1486 my $who = !defined $as ? { admin => 1, user => 'kubernetes-admin', groups => ['system:masters'] }
1487 : $as =~ /\Asystem:serviceaccount:([^:]+):(.+)\z/ ? _who_sa( $1, $2 )
1488 8 ▶ : { user => $as, groups => [ @{ $o->{f}{'as-group'} || [] }, 'system:authenticated' ] };
Branch: 2 branches
BranchTrueFalseTotal
!defined($as) ? : 0 8 8
$as =~ /\Asystem:serviceaccount:([^:]+):(.+)\z/ ? : 4 4 8
Condition100%2/2
$$o{'f'}{'as-group'} || []
l!l
22
MC/DC100%1/1
$$o{'f'}{'as-group'} || []
$$o{'f'}{'as-group'}
Truth table100%2/2
A
A= $$o{'f'}{'as-group'}
Aresult
11
00
1489 8 ▶ my $ns = $o->{all} ? '' : $o->{ns};
Branch: 1 branch
BranchTrueFalseTotal
$$o{'all'} ? : 0 8 8
1490 8 ▶ if ( $o->{list} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($$o{"list"}) 0 8 8
1491 0 my @rows = ( [ 'Resources', 'Non-Resource URLs', 'Resource Names', 'Verbs' ] );
1492 0 for my $x ( _rules_for( $k, $who, $ns ) ) {
1493 0 my $r = $x->[0];
1494 0 ▶ for my $res ( @{ $r->{resources} || [] } ) {
Condition0%0/2
$$r{'resources'} || []
l!l
00
MC/DC0%0/1
$$r{'resources'} || []
$$r{'resources'}
Truth table0%0/2
A
A= $$r{'resources'}
Aresult
11
00
1495 0 ▶ my @g = @{ $r->{apiGroups} || [''] };
Condition0%0/2
$$r{'apiGroups'} || ['']
l!l
00
MC/DC0%0/1
$$r{'apiGroups'} || ['']
$$r{'apiGroups'}
Truth table0%0/2
A
A= $$r{'apiGroups'}
Aresult
11
00
1496 0 ▶ push @rows, map { [ ( $_ eq '' || $res eq '*' && $_ eq '*' ? $res : "$res.$_" ), '[]', '[' . join( ' ', @{ $r->{resourceNames} || [] } ) . ']', '[' . join( ' ', @{ $r->{verbs} || [] } ) . ']' ] } @g;
Branch: 1 branch
BranchTrueFalseTotal
$_ eq '' || $res eq '*' && $_ eq '*' ? : 0 0 0
Condition0%0/10
$_ eq "" or $res eq "*" and $_ eq "*"
l!l&&r!l&&!r
000
$res eq "*" and $_ eq "*"
!ll&&!rl&&r
000
$$r{'resourceNames'} || []
l!l
00
$$r{'verbs'} || []
l!l
00
MC/DC0%0/3
$_ eq "" or $res eq "*" and $_ eq "*"
$_ eq "" $res eq "*" $_ eq "*"
MC/DC0%0/1
$$r{'resourceNames'} || []
$$r{'resourceNames'}
MC/DC0%0/1
$$r{'verbs'} || []
$$r{'verbs'}
Truth table0%0/4
A or B and C
A= $_ eq ""B= $res eq "*"C= $_ eq "*"
ABCresult
1XX1
0111
00X0
0100
Truth table0%0/2
A
A= $$r{'resourceNames'}
Aresult
11
00
Truth table0%0/2
A
A= $$r{'verbs'}
Aresult
11
00
1497 }
1498 }
1499 0 push @rows, [ 'selfsubjectreviews.authentication.k8s.io', '[]', '[]', '[create]' ], [ 'selfsubjectaccessreviews.authorization.k8s.io', '[]', '[]', '[create]' ];
1500 0 return ( _cols(@rows), 1 );
1501 }
1502 8 my ( $verb, $what, $nm ) = @r;
1503 8 ▶ return ( "error: you must specify two arguments: verb resource or a single argument: nonResourceURL", 0 ) unless defined $what;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $what 0 8 8
1504 8 ▶ ( $what, $nm ) = ( $1, $2 ) if !defined $nm && $what =~ m{\A([^/]+/(?:log|exec|status|scale|portforward|attach|proxy))/([^/]+)\z};
Branch: 1 branch
BranchTrueFalseTotal
if not defined $nm and $what =~ m[\A([^/]+/(?:log|exec|status|scale|portforward|attach|proxy))/([^/]+)\z] 0 8 8
Condition33%1/3
not defined $nm and $what =~ m[\A([^/]+/(?:log|exec|status|scale|portforward|attach|proxy))/([^/]+)\z]
!ll&&!rl&&r
080
MC/DC0%0/2
not defined $nm and $what =~ m[\A([^/]+/(?:log|exec|status|scale|portforward|attach|proxy))/([^/]+)\z]
not defined $nm $what =~ m[\A([^/]+/(?:log|exec|status|scale|portforward|attach|proxy))/([^/]+)\z]
Truth table33%1/3
not(A) and B
A= not defined $nmB= $what =~ m[\A([^/]+/(?:log|exec|status|scale|portforward|attach|proxy))/([^/]+)\z]
ABresult
0X0
100
111
1505 8 ▶ ( $what, $nm ) = ( $1, $2 ) if !defined $nm && $what =~ m{\A([^/]+)/([^/]+)\z} && !grep { $2 eq $_ } qw( log exec status scale portforward attach proxy );
Branch: 1 branch
BranchTrueFalseTotal
if not defined $nm and $what =~ m[\A([^/]+)/([^/]+)\z] and not grep({$2 eq $_;} "log", "exec", "status", "scale", "portforward", "attach", "proxy") 2 6 8
Condition83%5/6
not defined $nm and $what =~ m[\A([^/]+)/([^/]+)\z] and not grep({$2 eq $_;} "log", "exec", "status", "scale", "portforward", "attach", "proxy")
!ll&&!rl&&r
512
not defined $nm and $what =~ m[\A([^/]+)/([^/]+)\z]
!ll&&!rl&&r
053
MC/DC66%2/3
not defined $nm and $what =~ m[\A([^/]+)/([^/]+)\z] and not grep({$2 eq $_;} "log", "exec", "status", "scale", "portforward", "attach", "proxy")
not defined $nm $what =~ m[\A([^/]+)/([^/]+)\z] not grep({$2 eq $_;} "log", "exec", "status", "scale", "portforward", "attach", "proxy")
Truth table75%3/4
not(A) and B and not(C)
A= not defined $nmB= $what =~ m[\A([^/]+)/([^/]+)\z]C= not grep({$2 eq $_;} "log", "exec", "status", "scale", "portforward", "attach", "proxy")
ABCresult
0XX0
10X0
1100
1111
1506 8 my ( $res, $group ) = _resource($what);
1507 8 ▶ return ( qq{Warning: the server doesn't have a resource type '$what'\n\nno}, 0 ) unless defined $res;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $res 0 8 8
1508 8 ▶ my $nsx = $CLUSTER{ $KIND{ ( split m{/}, $res )[0] } // '' } || ( split m{/}, $res )[0] =~ /\A(?:nodes|clusterroles|clusterrolebindings|clusterissuers|ingressclasses|storageclasses|namespaces|persistentvolumes)\z/ ? '' : $ns;
Branch: 1 branch
BranchTrueFalseTotal
$Langertha::Holmgang::Sim::Linux::Kubernetes::CLUSTER{$Langertha::Holmgang::Sim::Linux::Kubernetes::KIND{(split(m[/], $res, 0))[0]} // ''} || (split(m[/], $res, 0))[0] =~ /\A(?:nodes|clusterroles|clusterrolebindings|clusterissuers|ingressclasses|storageclasses|namespaces|persistentvolumes)\z/ ? : 0 8 8
Condition40%2/5
$Langertha::Holmgang::Sim::Linux::Kubernetes::CLUSTER{$Langertha::Holmgang::Sim::Linux::Kubernetes::KIND{(split(m[/], $res, 0))[0]} // ""} or (split(m[/], $res, 0))[0] =~ /\A(?:nodes|clusterroles|clusterrolebindings|clusterissuers|ingressclasses|storageclasses|namespaces|persistentvolumes)\z/
l!l&&r!l&&!r
008
$Langertha::Holmgang::Sim::Linux::Kubernetes::KIND{(split(m[/], $res, 0))[0]} // ""
l!l
80
MC/DC0%0/2
$Langertha::Holmgang::Sim::Linux::Kubernetes::CLUSTER{$Langertha::Holmgang::Sim::Linux::Kubernetes::KIND{(split(m[/], $res, 0))[0]} // ""} or (split(m[/], $res, 0))[0] =~ /\A(?:nodes|clusterroles|clusterrolebindings|clusterissuers|ingressclasses|storageclasses|namespaces|persistentvolumes)\z/
$Langertha::Holmgang::Sim::Linux::Kubernetes::CLUSTER{$Langertha::Holmgang::Sim::Linux::Kubernetes::KIND{(split(m[/], $res, 0))[0]} // ""} (split(m[/], $res, 0))[0] =~ /\A(?:nodes|clusterroles|clusterrolebindings|clusterissuers|ingressclasses|storageclasses|namespaces|persistentvolumes)\z/
MC/DC0%0/1
$Langertha::Holmgang::Sim::Linux::Kubernetes::KIND{(split(m[/], $res, 0))[0]} // ""
$Langertha::Holmgang::Sim::Linux::Kubernetes::KIND{(split(m[/], $res, 0))[0]}
Truth table33%1/3
A or B
A= $Langertha::Holmgang::Sim::Linux::Kubernetes::CLUSTER{$Langertha::Holmgang::Sim::Linux::Kubernetes::KIND{(split(m[/], $res, 0))[0]} // ""}B= (split(m[/], $res, 0))[0] =~ /\A(?:nodes|clusterroles|clusterrolebindings|clusterissuers|ingressclasses|storageclasses|namespaces|persistentvolumes)\z/
ABresult
1X1
011
000
Truth table50%1/2
A
A= $Langertha::Holmgang::Sim::Linux::Kubernetes::KIND{(split(m[/], $res, 0))[0]}
Aresult
11
00
1509 8 ▶ return _allowed( $k, $who, $verb, $group eq '*' ? '' : $group, $res, $nsx, $nm ) ? ( 'yes', 1 ) : ( 'no', 0 );
Branch: 2 branches
BranchTrueFalseTotal
_allowed($k, $who, $verb, $group eq '*' ? '' : $group, $res, $nsx, $nm) ? : 3 5 8
$group eq '*' ? : 0 8 8
1510 }
1511  
1512 226 ▶sub _sa_exists {
Subroutine _sa_exists: called CC=5 SCAR=16.8
1513 226 my ( $k, $ns, $sa ) = @_;
1514 226 ▶ return 1 if !defined $sa || $sa eq 'default';
Branch: 1 branch
BranchTrueFalseTotal
if not defined $sa or $sa eq "default" 185 41 226
Condition66%2/3
not defined $sa or $sa eq "default"
l!l&&r!l&&!r
185041
MC/DC50%1/2
not defined $sa or $sa eq "default"
not defined $sa $sa eq "default"
Truth table66%2/3
not(A) or B
A= not defined $saB= $sa eq "default"
ABresult
1X1
011
000
1515 41 ▶ return exists( ( ( $k->{namespaces}{$ns} || {} )->{serviceaccounts} || {} )->{$sa} );
Condition50%2/4
($$k{'namespaces'}{$ns} || {})->{'serviceaccounts'} || {}
l!l
410
$$k{'namespaces'}{$ns} || {}
l!l
410
MC/DC0%0/1
($$k{'namespaces'}{$ns} || {})->{'serviceaccounts'} || {}
$$k{'namespaces'}{$ns}
Truth table50%1/2
A
A= $$k{'namespaces'}{$ns}
Aresult
11
00
1516 }
1517  
1518 # erste nicht erlaubte Anforderung eines Containers (needs_rbac) -> Meldung oder undef
1519 199 ▶sub _rbac_denied {
Subroutine _rbac_denied: called CC=9 SCAR=23.0
1520 199 my ( $k, $ns, $tpl, $c ) = @_;
1521 199 ▶ my $sa = $tpl->{service_account} // 'default';
Condition100%2/2
$$tpl{"service_account"} // "default"
l!l
34165
MC/DC100%1/1
$$tpl{"service_account"} // "default"
$$tpl{"service_account"}
Truth table100%2/2
A
A= $$tpl{"service_account"}
Aresult
11
00
1522 199 my $who = _who_sa( $ns, $sa );
1523 199 ▶ for my $n ( @{ $c->{needs_rbac} || [] } ) {
Condition100%2/2
$$c{'needs_rbac'} || []
l!l
34165
MC/DC100%1/1
$$c{'needs_rbac'} || []
$$c{'needs_rbac'}
Truth table100%2/2
A
A= $$c{'needs_rbac'}
Aresult
11
00
1524 34 my $res = $n->{resource};
1525 34 ▶ my $group = $n->{group} // $GROUP{ ( split m{/}, $res )[0] } // '';
Condition40%2/5
($$n{"group"} // $Langertha::Holmgang::Sim::Linux::Kubernetes::GROUP{(split(m[/], $res, 0))[0]}) // ""
l!l
340
$$n{"group"} // $Langertha::Holmgang::Sim::Linux::Kubernetes::GROUP{(split(m[/], $res, 0))[0]}
l!l&&r!l&&!r
0340
MC/DC0%0/2
($$n{"group"} // $Langertha::Holmgang::Sim::Linux::Kubernetes::GROUP{(split(m[/], $res, 0))[0]}) // ""
$$n{"group"} $Langertha::Holmgang::Sim::Linux::Kubernetes::GROUP{(split(m[/], $res, 0))[0]}
Truth table33%1/3
A // B
A= $$n{"group"}B= $Langertha::Holmgang::Sim::Linux::Kubernetes::GROUP{(split(m[/], $res, 0))[0]}
ABresult
1X1
011
000
1526 34 ▶ my $nsx = exists $n->{namespace} ? $n->{namespace} // '' : $ns;
Branch: 1 branch
BranchTrueFalseTotal
exists $$n{'namespace'} ? : 0 34 34
Condition0%0/2
$$n{"namespace"} // ""
l!l
00
MC/DC0%0/1
$$n{"namespace"} // ""
$$n{"namespace"}
Truth table0%0/2
A
A= $$n{"namespace"}
Aresult
11
00
1527 34 ▶ next if _allowed( $k, $who, $n->{verb}, $group, $res, $nsx, $n->{name} );
Branch: 1 branch
BranchTrueFalseTotal
if _allowed($k, $who, $$n{"verb"}, $group, $res, $nsx, $$n{"name"}) 1 33 34
1528 33 return _forbidden( $who, $n->{verb}, $group, $res, $nsx, $n->{name} );
1529 }
1530 166 return undef;
1531 }
1532  
1533 # --- Ingress --------------------------------------------------------------------
1534  
1535 5 ▶sub _gen_objs {
Subroutine _gen_objs: called CC=5 SCAR=17.1
1536 5 my ( $k, $kind, $ns ) = @_;
1537 5 ▶ return $k->{$kind} || {} if $GEN{$kind}[2];
Branch: 1 branch
BranchTrueFalseTotal
if $Langertha::Holmgang::Sim::Linux::Kubernetes::GEN{$kind}[2] 1 4 5
Condition50%1/2
$$k{$kind} || {}
l!l
10
MC/DC0%0/1
$$k{$kind} || {}
$$k{$kind}
Truth table50%1/2
A
A= $$k{$kind}
Aresult
11
00
1538 4 ▶ return ( ( $k->{namespaces}{$ns} || {} )->{$kind} ) || {};
Condition50%2/4
($$k{'namespaces'}{$ns} || {})->{$kind} || {}
l!l
40
$$k{'namespaces'}{$ns} || {}
l!l
40
MC/DC0%0/1
($$k{'namespaces'}{$ns} || {})->{$kind} || {}
$$k{'namespaces'}{$ns}
Truth table50%1/2
A
A= $$k{'namespaces'}{$ns}
Aresult
11
00
1539 }
1540  
1541 26 ▶sub _ingress_class {
Subroutine _ingress_class: called CC=10 SCAR=40.2
1542 26 my ( $k, $ing ) = @_;
1543 26 ▶ my $c = ( $ing->{spec} || {} )->{ingressClassName} // ( ( $ing->{metadata} || {} )->{annotations} || {} )->{'kubernetes.io/ingress.class'};
Condition22%2/9
($$ing{"spec"} || {})->{"ingressClassName"} // (($$ing{"metadata"} || {})->{"annotations"} || {})->{"kubernetes.io/ingress.class"}
l!l&&r!l&&!r
2600
$$ing{'spec'} || {}
l!l
260
($$ing{'metadata'} || {})->{'annotations'} || {}
l!l
00
$$ing{'metadata'} || {}
l!l
00
MC/DC0%0/2
($$ing{"spec"} || {})->{"ingressClassName"} // (($$ing{"metadata"} || {})->{"annotations"} || {})->{"kubernetes.io/ingress.class"}
$$ing{'spec'} $$ing{'metadata'}
Truth table33%1/3
A // B
A= $$ing{'spec'}B= $$ing{'metadata'}
ABresult
1X1
011
000
1544 26 ▶ return $c if defined $c;
Branch: 1 branch
BranchTrueFalseTotal
if defined $c 26 0 26
1545 0 ▶ my $ics = $k->{ingressclasses} || {};
Condition0%0/2
$$k{'ingressclasses'} || {}
l!l
00
MC/DC0%0/1
$$k{'ingressclasses'} || {}
$$k{'ingressclasses'}
Truth table0%0/2
A
A= $$k{'ingressclasses'}
Aresult
11
00
1546 0 ▶ my ($d) = grep { ( ( ( $ics->{$_}{metadata} || {} )->{annotations} || {} )->{'ingressclass.kubernetes.io/is-default-class'} // '' ) eq 'true' } sort keys %$ics;
Condition0%0/6
(($$ics{$_}{"metadata"} || {})->{"annotations"} || {})->{"ingressclass.kubernetes.io/is-default-class"} // ""
l!l
00
($$ics{$_}{'metadata'} || {})->{'annotations'} || {}
l!l
00
$$ics{$_}{'metadata'} || {}
l!l
00
MC/DC0%0/1
(($$ics{$_}{"metadata"} || {})->{"annotations"} || {})->{"ingressclass.kubernetes.io/is-default-class"} // ""
$$ics{$_}{'metadata'}
Truth table0%0/2
A
A= $$ics{$_}{'metadata'}
Aresult
11
00
1547 0 return $d;
1548 }
1549  
1550 # behandelt der Ingress-Controller des Clusters diese Klasse?
1551 48 ▶sub _handled {
Subroutine _handled: called CC=8 SCAR=24.7
1552 48 my ( $k, $cls ) = @_;
1553 48 ▶ my $ctl = ( $k->{ingress} || {} )->{controller} // return 0;
Condition50%2/4
($$k{"ingress"} || {})->{"controller"} // (return 0)
l!l
480
$$k{'ingress'} || {}
l!l
480
MC/DC0%0/1
($$k{"ingress"} || {})->{"controller"} // (return 0)
$$k{'ingress'}
Truth table50%1/2
A
A= $$k{'ingress'}
Aresult
11
00
1554 48 ▶ my $ic = ( $k->{ingressclasses} || {} )->{ $cls // '' } or return 0;
Branch: 1 branch
BranchTrueFalseTotal
my $ic = ($$k{"ingressclasses"} || {})->{$cls // ""} or return 0 48 0 48
Condition50%2/4
$$k{'ingressclasses'} || {}
l!l
480
$cls // ""
l!l
480
MC/DC0%0/1
$$k{'ingressclasses'} || {}
$$k{'ingressclasses'}
MC/DC0%0/1
$cls // ""
$cls
Truth table50%1/2
A
A= $$k{'ingressclasses'}
Aresult
11
00
Truth table50%1/2
A
A= $cls
Aresult
11
00
1555 48 ▶ return ( ( $ic->{spec} || {} )->{controller} // '' ) eq $ctl;
Condition50%2/4
($$ic{"spec"} || {})->{"controller"} // ""
l!l
480
$$ic{'spec'} || {}
l!l
480
MC/DC0%0/1
($$ic{"spec"} || {})->{"controller"} // ""
$$ic{'spec'}
Truth table50%1/2
A
A= $$ic{'spec'}
Aresult
11
00
1556 }
1557  
1558 22 ▶sub _host_match {
Subroutine _host_match: called CC=5 SCAR=22.7
1559 22 my ( $pat, $host ) = @_;
1560 22 ▶ return 1 unless defined $pat && length $pat;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $pat and length $pat 0 22 22
Condition33%1/3
defined $pat and length $pat
!ll&&!rl&&r
0022
MC/DC0%0/2
defined $pat and length $pat
defined $pat length $pat
Truth table33%1/3
A and B
A= defined $patB= length $pat
ABresult
0X0
100
111
1561 22 ▶ return lc $pat eq lc $host unless $pat =~ /\A\*\.(.+)\z/;
Branch: 1 branch
BranchTrueFalseTotal
unless $pat =~ /\A\*\.(.+)\z/ 22 0 22
1562 0 my $d = $1;
1563 0 ▶ return $host =~ /\A[^.]+\.\Q$d\E\z/i ? 1 : 0;
Branch: 1 branch
BranchTrueFalseTotal
$host =~ /\A[^.]+\.\Q$d\E\z/i ? : 0 0 0
1564 }
1565  
1566 71 ▶sub _all_ingresses {
Subroutine _all_ingresses: called CC=4 SCAR=13.9
1567 71 my ($k) = @_;
1568 71 my @i;
1569 71 ▶ for my $ns ( sort keys %{ $k->{namespaces} || {} } ) {
Condition50%1/2
$$k{'namespaces'} || {}
l!l
710
MC/DC0%0/1
$$k{'namespaces'} || {}
$$k{'namespaces'}
Truth table50%1/2
A
A= $$k{'namespaces'}
Aresult
11
00
1570 213 ▶ my $m = $k->{namespaces}{$ns}{ingresses} || {};
Condition100%2/2
$$k{'namespaces'}{$ns}{'ingresses'} || {}
l!l
71142
MC/DC100%1/1
$$k{'namespaces'}{$ns}{'ingresses'} || {}
$$k{'namespaces'}{$ns}{'ingresses'}
Truth table100%2/2
A
A= $$k{'namespaces'}{$ns}{'ingresses'}
Aresult
11
00
1571 213 push @i, map { [ $ns, $_, $m->{$_} ] } sort keys %$m;
1572 }
1573 71 return @i;
1574 }
1575  
1576 # Wohin fuehrt host+path? -> ( ns, ingress, backend ) oder ()
1577 7 ▶sub _ingress_route {
Subroutine _ingress_route: called CC=23 SCAR=34.4
1578 7 my ( $k, $host, $path ) = @_;
1579 7 my @cand;
1580 7 for my $x ( _all_ingresses($k) ) {
1581 7 my ( $ns, $n, $ing ) = @$x;
1582 7 ▶ next unless _handled( $k, _ingress_class( $k, $ing ) );
Branch: 1 branch
BranchTrueFalseTotal
unless _handled($k, _ingress_class($k, $ing)) 1 6 7
1583 6 ▶ for my $r ( @{ ( $ing->{spec} || {} )->{rules} || [] } ) {
Condition50%2/4
($$ing{'spec'} || {})->{'rules'} || []
l!l
60
$$ing{'spec'} || {}
l!l
60
MC/DC0%0/1
($$ing{'spec'} || {})->{'rules'} || []
$$ing{'spec'}
Truth table50%1/2
A
A= $$ing{'spec'}
Aresult
11
00
1584 6 ▶ next unless _host_match( $r->{host}, $host );
Branch: 1 branch
BranchTrueFalseTotal
unless _host_match($$r{"host"}, $host) 1 5 6
1585 5 ▶ my $exact = defined $r->{host} && $r->{host} !~ /\*/ ? 1 : 0;
Branch: 1 branch
BranchTrueFalseTotal
defined $$r{'host'} && !($$r{'host'} =~ /\*/) ? : 5 0 5
Condition33%1/3
defined $$r{"host"} and not $$r{"host"} =~ /\*/
!ll&&!rl&&r
005
MC/DC0%0/2
defined $$r{"host"} and not $$r{"host"} =~ /\*/
defined $$r{"host"} not $$r{"host"} =~ /\*/
Truth table33%1/3
A and not(B)
A= defined $$r{"host"}B= not $$r{"host"} =~ /\*/
ABresult
0X0
100
111
1586 5 ▶ for my $p ( @{ ( $r->{http} || {} )->{paths} || [] } ) {
Condition50%2/4
($$r{'http'} || {})->{'paths'} || []
l!l
50
$$r{'http'} || {}
l!l
50
MC/DC0%0/1
($$r{'http'} || {})->{'paths'} || []
$$r{'http'}
Truth table50%1/2
A
A= $$r{'http'}
Aresult
11
00
1587 10 ▶ my $pp = $p->{path} // '/';
Condition50%1/2
$$p{"path"} // "/"
l!l
100
MC/DC0%0/1
$$p{"path"} // "/"
$$p{"path"}
Truth table50%1/2
A
A= $$p{"path"}
Aresult
11
00
1588 10 ▶ my $t = $p->{pathType} // 'ImplementationSpecific';
Condition50%1/2
$$p{"pathType"} // "ImplementationSpecific"
l!l
100
MC/DC0%0/1
$$p{"pathType"} // "ImplementationSpecific"
$$p{"pathType"}
Truth table50%1/2
A
A= $$p{"pathType"}
Aresult
11
00
1589 10 ▶ my $m = $t eq 'Exact' ? ( $path eq $pp ? 100000 : 0 )
Branch: 4 branches
BranchTrueFalseTotal
$t eq 'Exact' ? : 0 10 10
$path eq $pp ? : 0 0 0
$t eq 'Prefix' ? : 10 0 10
$pp eq '/' || $path eq $pp || $path =~ m[\A\Q${\($pp =~ s[/\z][]r);}\E/] ? : 7 3 10
Condition100%6/6
$pp eq "/" or $path eq $pp or $path =~ m[\A\Q${\($pp =~ s[/\z][]r);}\E/]
l!l&&r!l&&!r
613
$pp eq "/" or $path eq $pp
l!l&&r!l&&!r
514
MC/DC100%3/3
$pp eq "/" or $path eq $pp or $path =~ m[\A\Q${\($pp =~ s[/\z][]r);}\E/]
$pp eq "/" $path eq $pp $path =~ m[\A\Q${\($pp =~ s[/\z][]r);}\E/]
Truth table100%4/4
A or B or C
A= $pp eq "/"B= $path eq $ppC= $path =~ m[\A\Q${\($pp =~ s[/\z][]r);}\E/]
ABCresult
1XX1
01X1
0011
0000
1590 4 ▶ : $t eq 'Prefix' ? ( $pp eq '/' || $path eq $pp || $path =~ m{\A\Q${\( $pp =~ s{/\z}{}r )}\E/} ? 1 + length $pp : 0 )
Branch: 1 branch
BranchTrueFalseTotal
index($path, $pp) == 0 ? : 0 0 0
1591 : ( index( $path, $pp ) == 0 ? 1 + length $pp : 0 );
1592 10 ▶ push @cand, [ $m + 1000000 * $exact, $ns, $n, $p->{backend} ] if $m;
Branch: 1 branch
BranchTrueFalseTotal
if $m 7 3 10
1593 }
1594 }
1595 }
1596 7 my ($best) = sort { $b->[0] <=> $a->[0] } @cand;
1597 7 ▶ return $best ? @$best[ 1 .. 3 ] : ();
Branch: 1 branch
BranchTrueFalseTotal
$best ? : 5 2 7
1598 }
1599  
1600 # Zertifikat des Ingress-Controllers fuer einen Host: ( ns, secret ) oder ()
1601 12 ▶sub _tls_for_host {
Subroutine _tls_for_host: called CC=8 SCAR=21.1
1602 12 my ( $k, $host ) = @_;
1603 12 for my $x ( _all_ingresses($k) ) {
1604 12 my ( $ns, $n, $ing ) = @$x;
1605 12 ▶ next unless _handled( $k, _ingress_class( $k, $ing ) );
Branch: 1 branch
BranchTrueFalseTotal
unless _handled($k, _ingress_class($k, $ing)) 1 11 12
1606 11 ▶ for my $t ( @{ ( $ing->{spec} || {} )->{tls} || [] } ) {
Condition50%2/4
($$ing{'spec'} || {})->{'tls'} || []
l!l
110
$$ing{'spec'} || {}
l!l
110
MC/DC0%0/1
($$ing{'spec'} || {})->{'tls'} || []
$$ing{'spec'}
Truth table50%1/2
A
A= $$ing{'spec'}
Aresult
11
00
1607 11 ▶ return ( $ns, $t->{secretName}, $n ) if grep { _host_match( $_, $host ) } @{ $t->{hosts} || [] };
Branch: 1 branch
BranchTrueFalseTotal
if grep {_host_match($_, $host);} @{$$t{"hosts"} or [];} 8 3 11
Condition50%1/2
$$t{'hosts'} || []
l!l
110
MC/DC0%0/1
$$t{'hosts'} || []
$$t{'hosts'}
Truth table50%1/2
A
A= $$t{'hosts'}
Aresult
11
00
1608 }
1609 }
1610 4 return ();
1611 }
1612  
1613 # Pseudo-PEM: Nutzlast "subject=…;san=a,b;issuer=…;trusted=1" in Base64
1614 15 ▶sub _pem {
Subroutine _pem: called CC=1 SCAR=0.0
1615 15 my (%c) = @_;
1616 15 return "-----BEGIN CERTIFICATE-----\n" . MIME::Base64::encode_base64( join ';', map {"$_=$c{$_}"} sort keys %c ) . "-----END CERTIFICATE-----\n";
1617 }
1618  
1619 9 ▶sub _cert_info {
Subroutine _cert_info: called CC=5 SCAR=17.0
1620 9 my ($pem) = @_;
1621 9 ▶ my ($b) = ( $pem // '' ) =~ /-----BEGIN CERTIFICATE-----\s*(.*?)\s*-----END/s or return undef;
Branch: 1 branch
BranchTrueFalseTotal
my($b) = ($pem // "") =~ /-----BEGIN CERTIFICATE-----\s*(.*?)\s*-----END/s or return undef 9 0 9
Condition50%1/2
$pem // ""
l!l
90
MC/DC0%0/1
$pem // ""
$pem
Truth table50%1/2
A
A= $pem
Aresult
11
00
1622 9 my $t = MIME::Base64::decode_base64($b);
1623 9 ▶ return undef unless $t =~ /san=/;
Branch: 1 branch
BranchTrueFalseTotal
unless $t =~ /san=/ 0 9 9
1624 9 my %c = map { split /=/, $_, 2 } split /;/, $t;
1625 9 ▶ return { %c, san => [ split /,/, $c{san} // '' ] };
Condition50%1/2
$c{"san"} // ""
l!l
90
MC/DC0%0/1
$c{"san"} // ""
$c{"san"}
Truth table50%1/2
A
A= $c{"san"}
Aresult
11
00
1626 }
1627  
1628 # Was ein Client von https://host sieht: ( ok, curl-code, meldung )
1629 8 ▶sub _tls_check {
Subroutine _tls_check: called CC=8 SCAR=20.9
1630 8 my ( $k, $host, $insecure ) = @_;
1631 8 my ( $ns, $sec ) = _tls_for_host( $k, $host );
1632 8 ▶ my $s = defined $sec ? _secret( $k, $ns, $sec ) : undef;
Branch: 1 branch
BranchTrueFalseTotal
defined $sec ? : 5 3 8
1633 8 ▶ my $info = $s && defined $s->{'tls.crt'} ? _cert_info( $s->{'tls.crt'} ) : undef;
Branch: 1 branch
BranchTrueFalseTotal
$s && defined $$s{'tls.crt'} ? : 4 4 8
Condition66%2/3
$s and defined $$s{"tls.crt"}
!ll&&!rl&&r
404
MC/DC50%1/2
$s and defined $$s{"tls.crt"}
$s defined $$s{"tls.crt"}
Truth table66%2/3
A and B
A= $sB= defined $$s{"tls.crt"}
ABresult
0X0
100
111
1634 8 ▶ return (1) if $insecure;
Branch: 1 branch
BranchTrueFalseTotal
if $insecure 5 3 8
1635 3 ▶ return ( 0, 60, 'SSL certificate problem: self-signed certificate' ) unless $info;
Branch: 1 branch
BranchTrueFalseTotal
unless $info 2 1 3
1636 1 ▶ return ( 0, 60, "SSL: no alternative certificate subject name matches target host name '$host'" ) unless grep { _host_match( $_, $host ) } @{ $info->{san} };
Branch: 1 branch
BranchTrueFalseTotal
unless grep {_host_match($_, $host);} @{$$info{"san"};} 0 1 1
1637 1 ▶ return ( 0, 60, 'SSL certificate problem: unable to get local issuer certificate' ) unless $info->{trusted};
Branch: 1 branch
BranchTrueFalseTotal
unless $$info{"trusted"} 0 1 1
1638 1 return (1);
1639 }
1640  
1641 5 my %HTTP = ( 200 => 'OK', 308 => 'Permanent Redirect', 404 => 'Not Found', 502 => 'Bad Gateway', 503 => 'Service Temporarily Unavailable' );
1642 4 ▶sub _nginx_page { my ($c) = @_; return "<html>\n<head><title>$c $HTTP{$c}</title></head>\n<body>\n<center><h1>$c $HTTP{$c}</h1></center>\n<hr><center>nginx</center>\n</body>\n</html>" }
Subroutine _nginx_page: called CC=1 SCAR=0.0
1643  
1644 # Antwort des Ingress-Controllers: ( http-code, rumpf )
1645 7 ▶sub _ingress_http {
Subroutine _ingress_http: called CC=20 SCAR=33.5
1646 7 my ( $k, $scheme, $host, $path ) = @_;
1647 7 my ( $ns, $ing, $be ) = _ingress_route( $k, $host, $path );
1648 7 ▶ return ( 404, _nginx_page(404) ) unless $ns;
Branch: 1 branch
BranchTrueFalseTotal
unless $ns 2 5 7
1649 5 ▶ return ( 308, _nginx_page(308) ) if $scheme eq 'http' && _tls_for_host( $k, $host );
Branch: 1 branch
BranchTrueFalseTotal
if $scheme eq "http" and _tls_for_host($k, $host) 1 4 5
Condition66%2/3
$scheme eq "http" and _tls_for_host($k, $host)
!ll&&!rl&&r
401
MC/DC50%1/2
$scheme eq "http" and _tls_for_host($k, $host)
$scheme eq "http" _tls_for_host($k, $host)
Truth table66%2/3
A and B
A= $scheme eq "http"B= _tls_for_host($k, $host)
ABresult
0X0
100
111
1650 4 ▶ my $sb = ( $be || {} )->{service} || {};
Condition50%2/4
($be || {})->{'service'} || {}
l!l
40
$be || {}
l!l
40
MC/DC0%0/1
($be || {})->{'service'} || {}
$be
Truth table50%1/2
A
A= $be
Aresult
11
00
1651 4 ▶ my $svc = ( $k->{namespaces}{$ns}{services} || {} )->{ $sb->{name} // '' } or return ( 503, _nginx_page(503) );
Branch: 1 branch
BranchTrueFalseTotal
my $svc = ($$k{"namespaces"}{$ns}{"services"} || {})->{$$sb{"name"} // ""} or return 503, _nginx_page(503) 3 1 4
Condition50%2/4
$$k{'namespaces'}{$ns}{'services'} || {}
l!l
40
$$sb{"name"} // ""
l!l
40
MC/DC0%0/1
$$k{'namespaces'}{$ns}{'services'} || {}
$$k{'namespaces'}{$ns}{'services'}
MC/DC0%0/1
$$sb{"name"} // ""
$$sb{"name"}
Truth table50%1/2
A
A= $$k{'namespaces'}{$ns}{'services'}
Aresult
11
00
Truth table50%1/2
A
A= $$sb{"name"}
Aresult
11
00
1652 3 ▶ my $want = $sb->{port} || {};
Condition50%1/2
$$sb{'port'} || {}
l!l
30
MC/DC0%0/1
$$sb{'port'} || {}
$$sb{'port'}
Truth table50%1/2
A
A= $$sb{'port'}
Aresult
11
00
1653 3 ▶ my ($sp) = grep { defined $want->{number} ? $_->{port} == $want->{number} : ( $_->{name} // '' ) eq ( $want->{name} // '' ) } @{ $svc->{ports} || [] };
Branch: 1 branch
BranchTrueFalseTotal
defined $$want{'number'} ? : 1 2 3
Condition50%3/6
$$_{"name"} // ""
l!l
20
$$want{"name"} // ""
l!l
20
$$svc{'ports'} || []
l!l
30
MC/DC0%0/1
$$_{"name"} // ""
$$_{"name"}
MC/DC0%0/1
$$want{"name"} // ""
$$want{"name"}
MC/DC0%0/1
$$svc{'ports'} || []
$$svc{'ports'}
Truth table50%1/2
A
A= $$_{"name"}
Aresult
11
00
Truth table50%1/2
A
A= $$want{"name"}
Aresult
11
00
Truth table50%1/2
A
A= $$svc{'ports'}
Aresult
11
00
1654 3 ▶ return ( 503, _nginx_page(503) ) unless $sp;
Branch: 1 branch
BranchTrueFalseTotal
unless $sp 0 3 3
1655 3 ▶ my @e = _endpoints( $k, $ns, $sb->{name} ) or return ( 503, _nginx_page(503) );
Branch: 1 branch
BranchTrueFalseTotal
my(@e) = _endpoints($k, $ns, $$sb{"name"}) or return 503, _nginx_page(503) 3 0 3
1656 3 my ($dc) = @{ $e[0]{template}{containers} };
1657 3 ▶ return ( 502, _nginx_page(502) ) unless grep { $_ == $sp->{target} } @{ $dc->{listens} || $dc->{ports} || [] };
Branch: 1 branch
BranchTrueFalseTotal
unless grep {$_ == $$sp{"target"};} @{$$dc{"listens"} or $$dc{"ports"} or [];} 0 3 3
Condition40%2/5
$$dc{'listens'} || $$dc{'ports'} || []
l!l
30
$$dc{"listens"} or $$dc{"ports"}
l!l&&r!l&&!r
300
MC/DC0%0/2
$$dc{'listens'} || $$dc{'ports'} || []
$$dc{"listens"} $$dc{"ports"}
Truth table33%1/3
A or B
A= $$dc{"listens"}B= $$dc{"ports"}
ABresult
1X1
011
000
1658 3 ▶ return ( 200, $dc->{http_body} // '{"status":"ok"}' );
Condition50%1/2
$$dc{"http_body"} // "{\"status\":\"ok\"}"
l!l
30
MC/DC0%0/1
$$dc{"http_body"} // "{\"status\":\"ok\"}"
$$dc{"http_body"}
Truth table50%1/2
A
A= $$dc{"http_body"}
Aresult
11
00
1659 }
1660  
1661 16 ▶sub _public_host {
Subroutine _public_host: called CC=9 SCAR=23.0
1662 16 my ( $k, $host ) = @_;
1663 16 ▶ return 0 unless $k->{ingress};
Branch: 1 branch
BranchTrueFalseTotal
unless $$k{"ingress"} 4 12 16
1664 12 ▶ return 1 if $host eq ( $k->{ingress}{address} // '' ) || exists( ( $k->{dns} || {} )->{$host} );
Branch: 1 branch
BranchTrueFalseTotal
if $host eq ($$k{"ingress"}{"address"} // "") or exists(($$k{"dns"} || {})->{$host}) 11 1 12
Condition71%5/7
$host eq ($$k{"ingress"}{"address"} // "") or exists(($$k{"dns"} || {})->{$host})
l!l&&r!l&&!r
291
$$k{"ingress"}{"address"} // ""
l!l
120
$$k{'dns'} || {}
l!l
100
MC/DC0%0/2
$host eq ($$k{"ingress"}{"address"} // "") or exists(($$k{"dns"} || {})->{$host})
$host eq ($$k{"ingress"}{"address"} // "") $$k{'dns'}
MC/DC0%0/1
$$k{"ingress"}{"address"} // ""
$$k{"ingress"}{"address"}
Truth table66%2/3
A or B
A= $host eq ($$k{"ingress"}{"address"} // "")B= $$k{'dns'}
ABresult
1X1
011
000
Truth table50%1/2
A
A= $$k{"ingress"}{"address"}
Aresult
11
00
1665 1 ▶ return scalar grep { my $i = $_->[2]; grep { defined $_->{host} && _host_match( $_->{host}, $host ) } @{ ( $i->{spec} || {} )->{rules} || [] } } _all_ingresses($k);
Condition42%3/7
defined $$_{'host'} && _host_match($$_{'host'}, $host)
!ll&&!rl&&r
010
($$i{'spec'} || {})->{'rules'} || []
l!l
10
$$i{'spec'} || {}
l!l
10
MC/DC0%0/2
defined $$_{'host'} && _host_match($$_{'host'}, $host)
defined $$_{'host'} _host_match($$_{'host'}, $host)
MC/DC0%0/1
($$i{'spec'} || {})->{'rules'} || []
$$i{'spec'}
Truth table33%1/3
A && B
A= defined $$_{'host'}B= _host_match($$_{'host'}, $host)
ABresult
0X0
100
111
Truth table50%1/2
A
A= $$i{'spec'}
Aresult
11
00
1666 }
1667  
1668 # curl|wget gegen den Ingress-Controller
1669 9 ▶sub _client_ingress {
Subroutine _client_ingress: called CC=35 SCAR=51.0
1670 9 my ( $k, $tool, $cmd, $scheme, $host, $path ) = @_;
1671 9 my ( %f, $w );
1672 9 my @c = @$cmd[ 1 .. $#$cmd ];
1673 9 ▶ while (@c) {
Branch: 1 branch
BranchTrueFalseTotal
if (@c) 19 9 28
1674 19 my $x = shift @c;
1675 19 ▶ if ( $tool eq 'curl' && $x =~ /\A-([a-zA-Z]+)\z/ ) {
Branch: 8 branches
BranchTrueFalseTotal
if ($tool eq 'curl' and $x =~ /\A-([a-zA-Z]+)\z/) { } 10 9 19
elsif ($x eq '--insecure' or $x eq '--no-check-certificate') { } 0 9 9
elsif ($x eq '--fail') { } 0 9 9
elsif ($x eq '--location') { } 0 9 9
elsif ($x eq '--head') { } 0 9 9
elsif ($x =~ /\A--(?:write-out|output|header|max-time|connect-timeout|resolve|user-agent)\z/) { } 0 9 9
elsif ($x =~ /\A--write-out=(.*)\z/s) { } 0 9 9
elsif ($tool eq 'wget' and $x =~ /\A-[qOST]+\z/ and $x =~ /[OT]\z/) { } 0 18 18
Condition66%2/3
$tool eq "curl" and $x =~ /\A-([a-zA-Z]+)\z/
!ll&&!rl&&r
0910
MC/DC50%1/2
$tool eq "curl" and $x =~ /\A-([a-zA-Z]+)\z/
$tool eq "curl" $x =~ /\A-([a-zA-Z]+)\z/
Truth table66%2/3
A and B
A= $tool eq "curl"B= $x =~ /\A-([a-zA-Z]+)\z/
ABresult
0X0
100
111
1676 10 my $fl = $1;
1677 10 $f{$_} = 1 for split //, $fl;
1678 10 ▶ if ( $fl =~ /[owHmXdA]\z/ ) { my $v = shift @c; $w = $v if $fl =~ /w\z/ }
Branch: 2 branches
BranchTrueFalseTotal
if ($fl =~ /[owHmXdA]\z/) 1 9 10
if $fl =~ /w\z/ 0 1 1
1679 }
1680 0 ▶ elsif ( $x eq '--insecure' || $x eq '--no-check-certificate' ) { $f{k} = 1 }
Condition33%1/3
$x eq "--insecure" or $x eq "--no-check-certificate"
l!l&&r!l&&!r
009
MC/DC0%0/2
$x eq "--insecure" or $x eq "--no-check-certificate"
$x eq "--insecure" $x eq "--no-check-certificate"
Truth table33%1/3
A or B
A= $x eq "--insecure"B= $x eq "--no-check-certificate"
ABresult
1X1
011
000
1681 0 elsif ( $x eq '--fail' ) { $f{f} = 1 }
1682 0 elsif ( $x eq '--location' ) { $f{L} = 1 }
1683 0 elsif ( $x eq '--head' ) { $f{I} = 1 }
1684 0 ▶ elsif ( $x =~ /\A--(?:write-out|output|header|max-time|connect-timeout|resolve|user-agent)\z/ ) { my $v = shift @c; $w = $v if $x eq '--write-out' }
Branch: 1 branch
BranchTrueFalseTotal
if $x eq "--write-out" 0 0 0
1685 0 elsif ( $x =~ /\A--write-out=(.*)\z/s ) { $w = $1 }
1686 0 ▶ elsif ( $tool eq 'wget' && $x =~ /\A-[qOST]+\z/ && $x =~ /[OT]\z/ ) { shift @c }
Condition33%2/6
$tool eq "wget" and $x =~ /\A-[qOST]+\z/ and $x =~ /[OT]\z/
!ll&&!rl&&r
900
$tool eq "wget" and $x =~ /\A-[qOST]+\z/
!ll&&!rl&&r
900
MC/DC0%0/3
$tool eq "wget" and $x =~ /\A-[qOST]+\z/ and $x =~ /[OT]\z/
$tool eq "wget" $x =~ /\A-[qOST]+\z/ $x =~ /[OT]\z/
Truth table25%1/4
A and B and C
A= $tool eq "wget"B= $x =~ /\A-[qOST]+\z/C= $x =~ /[OT]\z/
ABCresult
0XX0
10X0
1100
1111
1687 }
1688 9 for my $hop ( 1 .. 3 ) {
1689 9 ▶ if ( $scheme eq 'https' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($scheme eq "https") 8 1 9
1690 8 my ( $ok, $code, $msg ) = _tls_check( $k, $host, $f{k} );
1691 8 ▶ unless ($ok) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($ok) 2 6 8
1692 2 ▶ return ( "curl: ($code) $msg\nMore details here: https://curl.se/docs/sslcerts.html", 0 ) if $tool eq 'curl';
Branch: 1 branch
BranchTrueFalseTotal
if $tool eq "curl" 2 0 2
1693 0 ▶ return ( "Connecting to $host (" . ( ( $k->{ingress} || {} )->{address} // '' ) . ":443)\nssl_client: $host: certificate verification failed: " . ( $msg =~ s/\ASSL(?: certificate problem)?:\s*//r ) . "\nwget: error getting response: Connection reset by peer", 0 );
Condition0%0/4
($$k{"ingress"} || {})->{"address"} // ""
l!l
00
$$k{'ingress'} || {}
l!l
00
MC/DC0%0/1
($$k{"ingress"} || {})->{"address"} // ""
$$k{'ingress'}
Truth table0%0/2
A
A= $$k{'ingress'}
Aresult
11
00
1694 }
1695 }
1696 7 my ( $st, $body ) = _ingress_http( $k, $scheme, $host, $path );
1697 0 ▶ if ( $st == 308 && ( $f{L} || $tool eq 'wget' ) ) { $scheme = 'https'; next }
Branch: 1 branch
BranchTrueFalseTotal
if ($st == 308 and $f{"L"} || $tool eq "wget") 0 7 7
Condition50%3/6
$st == 308 and $f{"L"} || $tool eq "wget"
!ll&&!rl&&r
610
$f{"L"} or $tool eq "wget"
l!l&&r!l&&!r
001
MC/DC0%0/3
$st == 308 and $f{"L"} || $tool eq "wget"
$st == 308 $f{"L"} $tool eq "wget"
Truth table50%2/4
A and B or C
A= $st == 308B= $f{"L"}C= $tool eq "wget"
ABCresult
0XX0
1000
11X1
1011
1698 7 ▶ return ( $st == 200 ? ( $body, 1 ) : ( "wget: server returned error: HTTP/1.1 $st $HTTP{$st}", 0 ) ) if $tool eq 'wget';
Branch: 2 branches
BranchTrueFalseTotal
if $tool eq "wget" 0 7 7
$st == 200 ? : 0 0 0
1699 7 ▶ return ( "curl: (22) The requested URL returned error: $st", 0 ) if $f{f} && $st >= 400;
Branch: 1 branch
BranchTrueFalseTotal
if $f{"f"} and $st >= 400 0 7 7
Condition33%1/3
$f{"f"} and $st >= 400
!ll&&!rl&&r
700
MC/DC0%0/2
$f{"f"} and $st >= 400
$f{"f"} $st >= 400
Truth table33%1/3
A and B
A= $f{"f"}B= $st >= 400
ABresult
0X0
100
111
1700 7 ▶ my $out = $f{I} ? "HTTP/1.1 $st $HTTP{$st}\nContent-Type: text/html\n" . ( $st == 308 ? "Location: https://$host$path\n" : '' ) : $body;
Branch: 2 branches
BranchTrueFalseTotal
$f{'I'} ? : 0 7 7
$st == 308 ? : 0 0 0
1701 7 ▶ $out = '' if $f{o};
Branch: 1 branch
BranchTrueFalseTotal
if $f{"o"} 0 7 7
1702 0 ▶ if ( defined $w ) { ( my $ww = $w ) =~ s/%\{http_code\}/$st/g; $ww =~ s/\\n/\n/g; $out .= $ww }
Branch: 1 branch
BranchTrueFalseTotal
if (defined $w) 0 7 7
1703 7 return ( $out =~ s/\n\z//r, 1 );
1704 }
1705 0 return ( 'curl: (47) Maximum (3) redirects followed', 0 );
1706 }
1707  
1708 # Hinweise des Ingress-Controllers (wie im Log von ingress-nginx)
1709 2 ▶sub _ingress_log {
Subroutine _ingress_log: called CC=34 SCAR=43.9
1710 2 my ($k) = @_;
1711 2 my @l;
1712 2 my $i = 0;
1713 2 ▶ my $ts = sub { sprintf 'W1024 08:%02d:%02d.%06d 7', 10 + $i, ( 7 * ++$i ) % 60, 118223 + 977 * $i };
Subroutine __ANON__: called CC=1 SCAR=0.0
1714 2 for my $x ( _all_ingresses($k) ) {
1715 2 my ( $ns, $n, $ing ) = @$x;
1716 2 my $cls = _ingress_class( $k, $ing );
1717 2 ▶ unless ( _handled( $k, $cls ) ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (_handled($k, $cls)) 1 1 2
1718 1 ▶ push @l, $ts->() =~ s/\AW/I/r . qq{ store.go:440] "Ignoring ingress because of error while validating ingress class" ingress="$ns/$n" error="}
Branch: 1 branch
BranchTrueFalseTotal
defined $cls ? : 1 0 1
1719 . ( defined $cls ? qq{no object matching key \\"$cls\\" in local store} : 'ingress does not contain a valid IngressClass' ) . '"';
1720 1 next;
1721 }
1722 1 ▶ for my $r ( @{ ( $ing->{spec} || {} )->{rules} || [] } ) {
Condition50%2/4
($$ing{'spec'} || {})->{'rules'} || []
l!l
10
$$ing{'spec'} || {}
l!l
10
MC/DC0%0/1
($$ing{'spec'} || {})->{'rules'} || []
$$ing{'spec'}
Truth table50%1/2
A
A= $$ing{'spec'}
Aresult
11
00
1723 1 ▶ for my $p ( @{ ( $r->{http} || {} )->{paths} || [] } ) {
Condition50%2/4
($$r{'http'} || {})->{'paths'} || []
l!l
10
$$r{'http'} || {}
l!l
10
MC/DC0%0/1
($$r{'http'} || {})->{'paths'} || []
$$r{'http'}
Truth table50%1/2
A
A= $$r{'http'}
Aresult
11
00
1724 2 ▶ my $sb = ( $p->{backend} || {} )->{service} || {};
Condition50%2/4
($$p{'backend'} || {})->{'service'} || {}
l!l
20
$$p{'backend'} || {}
l!l
20
MC/DC0%0/1
($$p{'backend'} || {})->{'service'} || {}
$$p{'backend'}
Truth table50%1/2
A
A= $$p{'backend'}
Aresult
11
00
1725 2 ▶ my $sn = $sb->{name} // '';
Condition50%1/2
$$sb{"name"} // ""
l!l
20
MC/DC0%0/1
$$sb{"name"} // ""
$$sb{"name"}
Truth table50%1/2
A
A= $$sb{"name"}
Aresult
11
00
1726 2 ▶ my $svc = ( $k->{namespaces}{$ns}{services} || {} )->{$sn};
Condition50%1/2
$$k{'namespaces'}{$ns}{'services'} || {}
l!l
20
MC/DC0%0/1
$$k{'namespaces'}{$ns}{'services'} || {}
$$k{'namespaces'}{$ns}{'services'}
Truth table50%1/2
A
A= $$k{'namespaces'}{$ns}{'services'}
Aresult
11
00
1727 2 ▶ if ( !$svc ) { push @l, $ts->() . qq{ controller.go:1214] Error obtaining Endpoints for Service "$ns/$sn": no object matching key "$ns/$sn" in local store}; next }
Branch: 1 branch
BranchTrueFalseTotal
unless ($svc) 1 1 2
1728 1 ▶ my $want = $sb->{port} || {};
Condition50%1/2
$$sb{'port'} || {}
l!l
10
MC/DC0%0/1
$$sb{'port'} || {}
$$sb{'port'}
Truth table50%1/2
A
A= $$sb{'port'}
Aresult
11
00
1729 1 ▶ my ($sp) = grep { defined $want->{number} ? $_->{port} == $want->{number} : ( $_->{name} // '' ) eq ( $want->{name} // '' ) } @{ $svc->{ports} || [] };
Branch: 1 branch
BranchTrueFalseTotal
defined $$want{'number'} ? : 0 1 1
Condition50%3/6
$$_{"name"} // ""
l!l
10
$$want{"name"} // ""
l!l
10
$$svc{'ports'} || []
l!l
10
MC/DC0%0/1
$$_{"name"} // ""
$$_{"name"}
MC/DC0%0/1
$$want{"name"} // ""
$$want{"name"}
MC/DC0%0/1
$$svc{'ports'} || []
$$svc{'ports'}
Truth table50%1/2
A
A= $$_{"name"}
Aresult
11
00
Truth table50%1/2
A
A= $$want{"name"}
Aresult
11
00
Truth table50%1/2
A
A= $$svc{'ports'}
Aresult
11
00
1730 0 ▶ if ( !$sp ) { push @l, $ts->() . qq{ controller.go:1196] Service "$ns/$sn" does not have any port matching } . ( $want->{number} // $want->{name} // '' ); next }
Branch: 1 branch
BranchTrueFalseTotal
unless ($sp) 0 1 1
Condition0%0/5
($$want{"number"} // $$want{"name"}) // ""
l!l
00
$$want{"number"} // $$want{"name"}
l!l&&r!l&&!r
000
MC/DC0%0/2
($$want{"number"} // $$want{"name"}) // ""
$$want{"number"} $$want{"name"}
Truth table0%0/3
A // B
A= $$want{"number"}B= $$want{"name"}
ABresult
1X1
011
000
1731 1 ▶ push @l, $ts->() . qq{ controller.go:1214] Service "$ns/$sn" does not have any active Endpoint.} unless _endpoints( $k, $ns, $sn );
Branch: 1 branch
BranchTrueFalseTotal
unless _endpoints($k, $ns, $sn) 0 1 1
1732 }
1733 }
1734 1 ▶ for my $t ( @{ ( $ing->{spec} || {} )->{tls} || [] } ) {
Condition50%2/4
($$ing{'spec'} || {})->{'tls'} || []
l!l
10
$$ing{'spec'} || {}
l!l
10
MC/DC0%0/1
($$ing{'spec'} || {})->{'tls'} || []
$$ing{'spec'}
Truth table50%1/2
A
A= $$ing{'spec'}
Aresult
11
00
1735 1 ▶ my $sec = $t->{secretName} // '';
Condition50%1/2
$$t{"secretName"} // ""
l!l
10
MC/DC0%0/1
$$t{"secretName"} // ""
$$t{"secretName"}
Truth table50%1/2
A
A= $$t{"secretName"}
Aresult
11
00
1736 1 my $s = _secret( $k, $ns, $sec );
1737 1 ▶ if ( !$s || !defined $s->{'tls.crt'} ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($s and defined $$s{"tls.crt"}) 0 1 1
Condition33%1/3
$s and defined $$s{"tls.crt"}
!ll&&!rl&&r
001
MC/DC0%0/2
$s and defined $$s{"tls.crt"}
$s defined $$s{"tls.crt"}
Truth table33%1/3
A and B
A= $sB= defined $$s{"tls.crt"}
ABresult
0X0
100
111
1738 0 push @l, $ts->() . qq{ backend_ssl.go:47] Error obtaining X.509 certificate: no object matching key "$ns/$sec" in local store},
1739 $ts->() . qq{ controller.go:1418] Error getting SSL certificate "$ns/$sec": local SSL certificate $ns/$sec was not found. Using default certificate};
1740 0 next;
1741 }
1742 1 ▶ my $info = _cert_info( $s->{'tls.crt'} ) or next;
Branch: 1 branch
BranchTrueFalseTotal
my $info = _cert_info($$s{"tls.crt"}) or next 1 0 1
1743 1 ▶ for my $h ( @{ $t->{hosts} || [] } ) {
Condition50%1/2
$$t{'hosts'} || []
l!l
10
MC/DC0%0/1
$$t{'hosts'} || []
$$t{'hosts'}
Truth table50%1/2
A
A= $$t{'hosts'}
Aresult
11
00
1744 push @l, $ts->() . qq{ controller.go:1442] Unexpected error validating SSL certificate "$ns/$sec" for server "$h": x509: certificate is valid for }
1745 0 ▶ . join( ', ', @{ $info->{san} } ) . ", not $h" unless grep { _host_match( $_, $h ) } @{ $info->{san} };
Branch: 1 branch
BranchTrueFalseTotal
unless grep {_host_match($_, $h);} @{$$info{"san"};} 0 1 1
1746 }
1747 }
1748 }
1749 2 return @l;
1750 }
1751  
1752 # --- cert-manager ---------------------------------------------------------------
1753  
1754 39 ▶sub _cm_ns { my ($k) = @_; return ( $k->{cert_manager} || {} )->{namespace} // 'cert-manager' }
Subroutine _cm_ns: called CC=3 SCAR=12.0
Condition50%2/4
($$k{"cert_manager"} || {})->{"namespace"} // "cert-manager"
l!l
039
$$k{'cert_manager'} || {}
l!l
039
MC/DC0%0/1
($$k{"cert_manager"} || {})->{"namespace"} // "cert-manager"
$$k{'cert_manager'}
Truth table50%1/2
A
A= $$k{'cert_manager'}
Aresult
11
00
1755  
1756 5 our @ACME = ( 'https://acme-v02.api.letsencrypt.org/directory', 'https://acme-staging-v02.api.letsencrypt.org/directory' );
1757  
1758 # Certificates eines Namespace: gespeicherte und die aus Ingress-Annotationen (ingress-shim)
1759 49 ▶sub _certs {
Subroutine _certs: called CC=14 SCAR=29.8
1760 49 my ( $k, $ns ) = @_;
1761 49 ▶ my %c = %{ ( ( $k->{namespaces}{$ns} || {} )->{certificates} ) || {} };
Condition75%3/4
($$k{'namespaces'}{$ns} || {})->{'certificates'} || {}
l!l
3712
$$k{'namespaces'}{$ns} || {}
l!l
490
MC/DC0%0/1
($$k{'namespaces'}{$ns} || {})->{'certificates'} || {}
$$k{'namespaces'}{$ns}
Truth table50%1/2
A
A= $$k{'namespaces'}{$ns}
Aresult
11
00
1762 49 for my $x ( grep { $_->[0] eq $ns } _all_ingresses($k) ) {
1763 37 my ( undef, $n, $ing ) = @$x;
1764 37 ▶ my $an = ( $ing->{metadata} || {} )->{annotations} || {};
Condition50%2/4
($$ing{'metadata'} || {})->{'annotations'} || {}
l!l
370
$$ing{'metadata'} || {}
l!l
370
MC/DC0%0/1
($$ing{'metadata'} || {})->{'annotations'} || {}
$$ing{'metadata'}
Truth table50%1/2
A
A= $$ing{'metadata'}
Aresult
11
00
1765 my ( $kind, $iss ) = defined $an->{'cert-manager.io/cluster-issuer'} ? ( 'ClusterIssuer', $an->{'cert-manager.io/cluster-issuer'} )
1766 37 ▶ : defined $an->{'cert-manager.io/issuer'} ? ( 'Issuer', $an->{'cert-manager.io/issuer'} ) : next;
Branch: 2 branches
BranchTrueFalseTotal
defined $$an{'cert-manager.io/cluster-issuer'} ? : 37 0 37
defined $$an{'cert-manager.io/issuer'} ? : 0 0 0
1767 37 ▶ for my $t ( @{ ( $ing->{spec} || {} )->{tls} || [] } ) {
Condition50%2/4
($$ing{'spec'} || {})->{'tls'} || []
l!l
370
$$ing{'spec'} || {}
l!l
370
MC/DC0%0/1
($$ing{'spec'} || {})->{'tls'} || []
$$ing{'spec'}
Truth table50%1/2
A
A= $$ing{'spec'}
Aresult
11
00
1768 37 ▶ next unless defined $t->{secretName};
Branch: 1 branch
BranchTrueFalseTotal
unless defined $$t{"secretName"} 0 37 37
1769 $c{ $t->{secretName} } //= { metadata => { ownerReferences => [ { apiVersion => "networking.k8s.io/v1", kind => "Ingress", name => $n, controller => JSON::MaybeXS::true(), blockOwnerDeletion => JSON::MaybeXS::true() } ] },
1770 37 ▶ spec => { secretName => $t->{secretName}, dnsNames => [ @{ $t->{hosts} || [] } ], issuerRef => { kind => $kind, name => $iss, group => 'cert-manager.io' } } };
Condition50%2/4
$c{$$t{"secretName"}} //= {"metadata", {"ownerReferences", [{"apiVersion", "networking.k8s.io/v1", "kind", "Ingress", "name", $n, "controller", bless( do{\(my $o = 1)}, 'JSON::PP::Boolean' ), "blockOwnerDeletion", bless( do{\(my $o = 1)}, 'JSON::PP::Boolean' )}]}, "spec", {"secretName", $$t{"secretName"}, "dnsNames", [@{$$t{"hosts"} or [];}], "issuerRef", {"kind", $kind, "name", $iss, "group", "cert-manager.io"}}}
l!l
037
$$t{'hosts'} || []
l!l
370
MC/DC0%0/1
$c{$$t{"secretName"}} //= {"metadata", {"ownerReferences", [{"apiVersion", "networking.k8s.io/v1", "kind", "Ingress", "name", $n, "controller", bless( do{\(my $o = 1)}, 'JSON::PP::Boolean' ), "blockOwnerDeletion", bless( do{\(my $o = 1)}, 'JSON::PP::Boolean' )}]}, "spec", {"secretName", $$t{"secretName"}, "dnsNames", [@{$$t{"hosts"} or [];}], "issuerRef", {"kind", $kind, "name", $iss, "group", "cert-manager.io"}}}
$c{$$t{"secretName"}}
MC/DC0%0/1
$$t{'hosts'} || []
$$t{'hosts'}
Truth table50%1/2
A
A= $c{$$t{"secretName"}}
Aresult
11
00
Truth table50%1/2
A
A= $$t{'hosts'}
Aresult
11
00
1771 }
1772 }
1773 49 return \%c;
1774 }
1775  
1776 # ( issuer, art, namespace-der-geheimnisse ) oder ()
1777 41 ▶sub _issuer_of {
Subroutine _issuer_of: called CC=12 SCAR=34.0
1778 41 my ( $k, $ns, $ref ) = @_;
1779 41 ▶ my $kind = $ref->{kind} // 'Issuer';
Condition50%1/2
$$ref{"kind"} // "Issuer"
l!l
410
MC/DC0%0/1
$$ref{"kind"} // "Issuer"
$$ref{"kind"}
Truth table50%1/2
A
A= $$ref{"kind"}
Aresult
11
00
1780 41 ▶ return () if ( $ref->{group} // 'cert-manager.io' ) ne 'cert-manager.io';
Branch: 1 branch
BranchTrueFalseTotal
if ($$ref{"group"} // "cert-manager.io") ne "cert-manager.io" 0 41 41
Condition100%2/2
$$ref{"group"} // "cert-manager.io"
l!l
2516
MC/DC100%1/1
$$ref{"group"} // "cert-manager.io"
$$ref{"group"}
Truth table100%2/2
A
A= $$ref{"group"}
Aresult
11
00
1781 41 ▶ if ( $kind eq 'ClusterIssuer' ) { my $i = ( $k->{clusterissuers} || {} )->{ $ref->{name} // '' } or return (); return ( $i, $kind, _cm_ns($k) ) }
Branch: 2 branches
BranchTrueFalseTotal
if ($kind eq "ClusterIssuer") 41 0 41
my $i = ($$k{"clusterissuers"} || {})->{$$ref{"name"} // ""} or return () 38 3 41
Condition50%2/4
$$k{'clusterissuers'} || {}
l!l
410
$$ref{"name"} // ""
l!l
410
MC/DC0%0/1
$$k{'clusterissuers'} || {}
$$k{'clusterissuers'}
MC/DC0%0/1
$$ref{"name"} // ""
$$ref{"name"}
Truth table50%1/2
A
A= $$k{'clusterissuers'}
Aresult
11
00
Truth table50%1/2
A
A= $$ref{"name"}
Aresult
11
00
1782 0 ▶ my $i = ( ( $k->{namespaces}{$ns} || {} )->{issuers} || {} )->{ $ref->{name} // '' } or return ();
Branch: 1 branch
BranchTrueFalseTotal
my $i = (($$k{"namespaces"}{$ns} || {})->{"issuers"} || {})->{$$ref{"name"} // ""} or return () 0 0 0
Condition0%0/6
($$k{'namespaces'}{$ns} || {})->{'issuers'} || {}
l!l
00
$$k{'namespaces'}{$ns} || {}
l!l
00
$$ref{"name"} // ""
l!l
00
MC/DC0%0/1
($$k{'namespaces'}{$ns} || {})->{'issuers'} || {}
$$k{'namespaces'}{$ns}
MC/DC0%0/1
$$ref{"name"} // ""
$$ref{"name"}
Truth table0%0/2
A
A= $$k{'namespaces'}{$ns}
Aresult
11
00
Truth table0%0/2
A
A= $$ref{"name"}
Aresult
11
00
1783 0 return ( $i, 'Issuer', $ns );
1784 }
1785  
1786 # ( bereit, grund, meldung )
1787 39 ▶sub _issuer_state {
Subroutine _issuer_state: called CC=14 SCAR=33.3
1788 39 my ( $k, $i, $sns ) = @_;
1789 39 ▶ my $s = $i->{spec} || {};
Condition50%1/2
$$i{'spec'} || {}
l!l
390
MC/DC0%0/1
$$i{'spec'} || {}
$$i{'spec'}
Truth table50%1/2
A
A= $$i{'spec'}
Aresult
11
00
1790 39 ▶ if ( $s->{ca} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($$s{"ca"}) 17 22 39
1791 17 ▶ my $sn = $s->{ca}{secretName} // '';
Condition50%1/2
$$s{"ca"}{"secretName"} // ""
l!l
170
MC/DC0%0/1
$$s{"ca"}{"secretName"} // ""
$$s{"ca"}{"secretName"}
Truth table50%1/2
A
A= $$s{"ca"}{"secretName"}
Aresult
11
00
1792 17 ▶ my $sec = _secret( $k, $sns, $sn ) or return ( 0, 'ErrGetKeyPair', qq{Error getting keypair for CA issuer: secrets "$sn" not found} );
Branch: 1 branch
BranchTrueFalseTotal
my $sec = _secret($k, $sns, $sn) or return 0, "ErrGetKeyPair", qq[Error getting keypair for CA issuer: secrets "$sn" not found] 5 12 17
1793 5 ▶ return ( 0, 'ErrInvalidKeyPair', 'Error getting keypair for CA issuer: certificate data is empty' ) unless defined $sec->{'tls.crt'} && defined $sec->{'tls.key'};
Branch: 1 branch
BranchTrueFalseTotal
unless defined $$sec{"tls.crt"} and defined $$sec{"tls.key"} 0 5 5
Condition33%1/3
defined $$sec{"tls.crt"} and defined $$sec{"tls.key"}
!ll&&!rl&&r
005
MC/DC0%0/2
defined $$sec{"tls.crt"} and defined $$sec{"tls.key"}
defined $$sec{"tls.crt"} defined $$sec{"tls.key"}
Truth table33%1/3
A and B
A= defined $$sec{"tls.crt"}B= defined $$sec{"tls.key"}
ABresult
0X0
100
111
1794 5 return ( 1, 'KeyPairVerified', 'Signing CA verified' );
1795 }
1796 22 ▶ if ( $s->{acme} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($$s{"acme"}) 22 0 22
1797 22 ▶ my $srv = $s->{acme}{server} // '';
Condition50%1/2
$$s{"acme"}{"server"} // ""
l!l
220
MC/DC0%0/1
$$s{"acme"}{"server"} // ""
$$s{"acme"}{"server"}
Truth table50%1/2
A
A= $$s{"acme"}{"server"}
Aresult
11
00
1798 22 ▶ my @known = ( @ACME, @{ ( $k->{cert_manager} || {} )->{acme_servers} || [] } );
Condition50%2/4
($$k{'cert_manager'} || {})->{'acme_servers'} || []
l!l
022
$$k{'cert_manager'} || {}
l!l
022
MC/DC0%0/1
($$k{'cert_manager'} || {})->{'acme_servers'} || []
$$k{'cert_manager'}
Truth table50%1/2
A
A= $$k{'cert_manager'}
Aresult
11
00
1799 22 ▶ unless ( grep { $_ eq $srv } @known ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (grep {$_ eq $srv;} @known) 0 22 22
1800 0 my ($h) = $srv =~ m{\Ahttps?://([^/:]+)};
1801 0 ▶ return ( 0, 'ErrRegisterACMEAccount', qq{Failed to register ACME account: Get "$srv": dial tcp: lookup } . ( $h // $srv ) . ' on 10.43.0.10:53: no such host' );
Condition0%0/3
$h // $srv
l!l&&r!l&&!r
000
MC/DC0%0/2
$h // $srv
$h $srv
Truth table0%0/3
A // B
A= $hB= $srv
ABresult
1X1
011
000
1802 }
1803 22 return ( 1, 'ACMEAccountRegistered', 'The ACME account was registered with the ACME server' );
1804 }
1805 0 ▶ return ( 1, 'IsReady', '' ) if $s->{selfSigned};
Branch: 1 branch
BranchTrueFalseTotal
if $$s{"selfSigned"} 0 0 0
1806 0 return ( 0, 'InvalidConfig', 'no issuer type specified for Issuer' );
1807 }
1808  
1809 # Zustand eines Certificate: { ready, reason, message, cr => [bereit, grund, meldung], challenges => [ … ], issuer => … }
1810 41 ▶sub _cert_state {
Subroutine _cert_state: called CC=48 SCAR=55.0
1811 41 my ( $k, $ns, $name, $c ) = @_;
1812 41 ▶ my $s = $c->{spec} || {};
Condition50%1/2
$$c{'spec'} || {}
l!l
410
MC/DC0%0/1
$$c{'spec'} || {}
$$c{'spec'}
Truth table50%1/2
A
A= $$c{'spec'}
Aresult
11
00
1813 41 ▶ my $ref = $s->{issuerRef} || {};
Condition50%1/2
$$s{'issuerRef'} || {}
l!l
410
MC/DC0%0/1
$$s{'issuerRef'} || {}
$$s{'issuerRef'}
Truth table50%1/2
A
A= $$s{'issuerRef'}
Aresult
11
00
1814 41 ▶ my %r = ( name => $name, secret => $s->{secretName}, dns => [ @{ $s->{dnsNames} || [] } ], challenges => [] );
Condition50%1/2
$$s{'dnsNames'} || []
l!l
410
MC/DC0%0/1
$$s{'dnsNames'} || []
$$s{'dnsNames'}
Truth table50%1/2
A
A= $$s{'dnsNames'}
Aresult
11
00
1815 41 ▶ my $not = sub { my ( $cr_reason, $cr_msg ) = @_; return { %r, ready => 0, reason => 'DoesNotExist', message => 'Issuing certificate as Secret does not exist', cr => [ 0, $cr_reason, $cr_msg ] } };
Subroutine __ANON__: called CC=1 SCAR=0.0
1816 41 my ( $i, $ikind, $sns ) = _issuer_of( $k, $ns, $ref );
1817 41 ▶ my $ik = $ref->{kind} // 'Issuer';
Condition50%1/2
$$ref{"kind"} // "Issuer"
l!l
410
MC/DC0%0/1
$$ref{"kind"} // "Issuer"
$$ref{"kind"}
Truth table50%1/2
A
A= $$ref{"kind"}
Aresult
11
00
1818 41 ▶ return $not->( 'Pending', qq{Referenced "$ik" not found: } . lc($ik) . qq{.cert-manager.io "} . ( $ref->{name} // '' ) . '" not found' ) unless $i;
Branch: 1 branch
BranchTrueFalseTotal
unless $i 3 38 41
Condition50%1/2
$$ref{"name"} // ""
l!l
30
MC/DC0%0/1
$$ref{"name"} // ""
$$ref{"name"}
Truth table50%1/2
A
A= $$ref{"name"}
Aresult
11
00
1819 38 my ($iready) = _issuer_state( $k, $i, $sns );
1820 38 ▶ return $not->( 'Pending', 'Referenced issuer does not have a Ready status condition' ) unless $iready;
Branch: 1 branch
BranchTrueFalseTotal
unless $iready 11 27 38
1821 27 ▶ return $not->( 'Pending', 'spec.dnsNames: at least one DNS name is required' ) unless @{ $r{dns} } || defined $s->{commonName};
Branch: 1 branch
BranchTrueFalseTotal
unless @{$r{"dns"};} or defined $$s{"commonName"} 0 27 27
Condition33%1/3
@{$r{"dns"};} or defined $$s{"commonName"}
l!l&&r!l&&!r
2700
MC/DC0%0/2
@{$r{"dns"};} or defined $$s{"commonName"}
@{$r{"dns"};} defined $$s{"commonName"}
Truth table33%1/3
A or B
A= @{$r{"dns"};}B= defined $$s{"commonName"}
ABresult
1X1
011
000
1822 27 my $is = $i->{spec};
1823 27 my $trusted = 1;
1824 27 ▶ if ( $is->{acme} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($$is{"acme"}) 22 5 27
1825 22 ▶ $trusted = ( $is->{acme}{server} // '' ) !~ /staging/ ? 1 : 0;
Branch: 1 branch
BranchTrueFalseTotal
!(($$is{'acme'}{'server'} // '') =~ /staging/) ? : 22 0 22
Condition50%1/2
$$is{"acme"}{"server"} // ""
l!l
220
MC/DC0%0/1
$$is{"acme"}{"server"} // ""
$$is{"acme"}{"server"}
Truth table50%1/2
A
A= $$is{"acme"}{"server"}
Aresult
11
00
1826 22 my $pending = 0;
1827 22 for my $d ( @{ $r{dns} } ) {
1828 22 my ( $state, $reason ) = ( 'valid', 'Successfully authorized domain' );
1829 0 ▶ my ($sol) = grep { my $sel = ( $_->{selector} || {} )->{dnsNames}; !$sel || grep { $_ eq $d } @$sel } @{ $is->{acme}{solvers} || [] };
Condition42%3/7
$$_{'selector'} || {}
l!l
022
!$sel || grep({$_ eq $d;} @$sel)
l!l&&r!l&&!r
2200
$$is{'acme'}{'solvers'} || []
l!l
220
MC/DC0%0/1
$$_{'selector'} || {}
$$_{'selector'}
MC/DC0%0/2
!$sel || grep({$_ eq $d;} @$sel)
!$sel grep({$_ eq $d;} @$sel)
MC/DC0%0/1
$$is{'acme'}{'solvers'} || []
$$is{'acme'}{'solvers'}
Truth table50%1/2
A
A= $$_{'selector'}
Aresult
11
00
Truth table33%1/3
not(A) || B
A= !$selB= grep({$_ eq $d;} @$sel)
ABresult
1X1
011
000
Truth table50%1/2
A
A= $$is{'acme'}{'solvers'}
Aresult
11
00
1830 22 ▶ if ( !$sol || ( $d =~ /\A\*/ && !$sol->{dns01} ) ) {
Branch: 3 branches
BranchTrueFalseTotal
if (not $sol or $d =~ /\A\*/ and not $$sol{'dns01'}) { } 0 22 22
elsif (my $h = $$sol{'http01'}) { } 22 0 22
elsif (my $dn = $$sol{'dns01'}) { } 0 0 0
Condition33%2/6
not $sol or $d =~ /\A\*/ and not $$sol{"dns01"}
l!l&&r!l&&!r
0022
$d =~ /\A\*/ and not $$sol{"dns01"}
!ll&&!rl&&r
2200
MC/DC0%0/3
not $sol or $d =~ /\A\*/ and not $$sol{"dns01"}
not $sol $d =~ /\A\*/ not $$sol{"dns01"}
Truth table25%1/4
not(A) or B and not(C)
A= not $solB= $d =~ /\A\*/C= not $$sol{"dns01"}
ABCresult
1XX1
0111
00X0
0100
1831 0 ( $state, $reason ) = ( 'errored', 'Failed to determine a valid solver configuration for the set of domains on the Order: no configured challenge solvers can be used for this challenge' );
1832 }
1833 elsif ( my $h = $sol->{http01} ) {
1834 22 ▶ my $ingc = ( $h->{ingress} || {} );
Condition50%1/2
$$h{'ingress'} || {}
l!l
220
MC/DC0%0/1
$$h{'ingress'} || {}
$$h{'ingress'}
Truth table50%1/2
A
A= $$h{'ingress'}
Aresult
11
00
1835 22 ▶ my $cls = $ingc->{ingressClassName} // $ingc->{class};
Condition33%1/3
$$ingc{"ingressClassName"} // $$ingc{"class"}
l!l&&r!l&&!r
2200
MC/DC0%0/2
$$ingc{"ingressClassName"} // $$ingc{"class"}
$$ingc{"ingressClassName"} $$ingc{"class"}
Truth table33%1/3
A // B
A= $$ingc{"ingressClassName"}B= $$ingc{"class"}
ABresult
1X1
011
000
1836 22 ▶ my %dns = %{ $k->{dns} || {} };
Condition50%1/2
$$k{'dns'} || {}
l!l
220
MC/DC0%0/1
$$k{'dns'} || {}
$$k{'dns'}
Truth table50%1/2
A
A= $$k{'dns'}
Aresult
11
00
1837 22 ▶ if ( %dns && !exists $dns{$d} ) {
Branch: 2 branches
BranchTrueFalseTotal
if (%dns and not exists $dns{$d}) { } 0 22 22
elsif (not _handled($k, $cls)) { } 6 16 22
Condition33%1/3
%dns and not exists $dns{$d}
!ll&&!rl&&r
0220
MC/DC0%0/2
%dns and not exists $dns{$d}
%dns not exists $dns{$d}
Truth table33%1/3
A and not(B)
A= %dnsB= not exists $dns{$d}
ABresult
0X0
100
111
1838 0 ( $state, $reason ) = ( 'pending', qq{Waiting for HTTP-01 challenge propagation: failed to perform self check GET request 'http://$d/.well-known/acme-challenge/tP3dBxM0Ugs3Fv2sHzv5Kp0yZq1rWc8eJn4aLo6iYuQ': Get "http://$d/.well-known/acme-challenge/tP3dBxM0Ugs3Fv2sHzv5Kp0yZq1rWc8eJn4aLo6iYuQ": dial tcp: lookup $d on 10.43.0.10:53: no such host} );
1839 }
1840 elsif ( !_handled( $k, $cls ) ) {
1841 6 ( $state, $reason ) = ( 'pending', q{Waiting for HTTP-01 challenge propagation: wrong status code '404', expected '200'} );
1842 }
1843 }
1844 elsif ( my $dn = $sol->{dns01} ) {
1845 0 my ($prov) = grep { ref $dn->{$_} eq 'HASH' } sort keys %$dn;
1846 0 ▶ my $ref2 = $prov ? ( $dn->{$prov}{apiTokenSecretRef} || $dn->{$prov}{tsigSecretSecretRef} || $dn->{$prov}{secretAccessKeySecretRef} ) : undef;
Branch: 1 branch
BranchTrueFalseTotal
$prov ? : 0 0 0
Condition0%0/6
$$dn{$prov}{"apiTokenSecretRef"} or $$dn{$prov}{"tsigSecretSecretRef"} or $$dn{$prov}{"secretAccessKeySecretRef"}
l!l&&r!l&&!r
000
$$dn{$prov}{"apiTokenSecretRef"} or $$dn{$prov}{"tsigSecretSecretRef"}
l!l&&r!l&&!r
000
MC/DC0%0/3
$$dn{$prov}{"apiTokenSecretRef"} or $$dn{$prov}{"tsigSecretSecretRef"} or $$dn{$prov}{"secretAccessKeySecretRef"}
$$dn{$prov}{"apiTokenSecretRef"} $$dn{$prov}{"tsigSecretSecretRef"} $$dn{$prov}{"secretAccessKeySecretRef"}
Truth table0%0/4
A or B or C
A= $$dn{$prov}{"apiTokenSecretRef"}B= $$dn{$prov}{"tsigSecretSecretRef"}C= $$dn{$prov}{"secretAccessKeySecretRef"}
ABCresult
1XX1
01X1
0011
0000
1847 0 ▶ if ($ref2) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ref2) 0 0 0
1848 0 ▶ my $sec = _secret( $k, $sns, $ref2->{name} // '' );
Condition0%0/2
$$ref2{"name"} // ""
l!l
00
MC/DC0%0/1
$$ref2{"name"} // ""
$$ref2{"name"}
Truth table0%0/2
A
A= $$ref2{"name"}
Aresult
11
00
1849 ( $state, $reason ) = ( 'errored', "error getting $prov secret: " . ( $sec ? qq{key "$ref2->{key}" not found in secret} : qq{secrets "} . ( $ref2->{name} // '' ) . '" not found' ) )
1850 0 ▶ unless $sec && defined $sec->{ $ref2->{key} // '' };
Branch: 2 branches
BranchTrueFalseTotal
unless $sec and defined $$sec{$$ref2{"key"} // ""} 0 0 0
$sec ? : 0 0 0
Condition0%0/7
$sec and defined $$sec{$$ref2{"key"} // ""}
!ll&&!rl&&r
000
$$ref2{"key"} // ""
l!l
00
$$ref2{"name"} // ""
l!l
00
MC/DC0%0/2
$sec and defined $$sec{$$ref2{"key"} // ""}
$sec defined $$sec{$$ref2{"key"} // ""}
MC/DC0%0/1
$$ref2{"key"} // ""
$$ref2{"key"}
MC/DC0%0/1
$$ref2{"name"} // ""
$$ref2{"name"}
Truth table0%0/3
A and B
A= $secB= defined $$sec{$$ref2{"key"} // ""}
ABresult
0X0
100
111
Truth table0%0/2
A
A= $$ref2{"key"}
Aresult
11
00
Truth table0%0/2
A
A= $$ref2{"name"}
Aresult
11
00
1851 }
1852 }
1853 22 ▶ push @{ $r{challenges} }, { domain => $d, state => $state, reason => $reason, type => $sol && $sol->{dns01} ? 'DNS-01' : 'HTTP-01' };
Branch: 1 branch
BranchTrueFalseTotal
$sol && $$sol{'dns01'} ? : 0 22 22
Condition33%1/3
$sol and $$sol{"dns01"}
!ll&&!rl&&r
0220
MC/DC0%0/2
$sol and $$sol{"dns01"}
$sol $$sol{"dns01"}
Truth table33%1/3
A and B
A= $solB= $$sol{"dns01"}
ABresult
0X0
100
111
1854 22 ▶ $pending = 1 if $state ne 'valid';
Branch: 1 branch
BranchTrueFalseTotal
if $state ne "valid" 6 16 22
1855 }
1856 22 ▶ if ($pending) {
Branch: 1 branch
BranchTrueFalseTotal
if ($pending) 6 16 22
1857 6 my ($bad) = grep { $_->{state} ne 'valid' } @{ $r{challenges} };
1858 6 ▶ return { %{ $not->( 'Pending', qq{Waiting on certificate issuance from order $ns/$name-1-2873461: "} . ( $bad->{state} eq 'errored' ? 'errored' : 'pending' ) . '"' ) }, order => $bad->{state} };
Branch: 1 branch
BranchTrueFalseTotal
$$bad{'state'} eq 'errored' ? : 0 6 6
1859 }
1860 }
1861 21 ▶ $trusted = 0 if $is->{selfSigned};
Branch: 1 branch
BranchTrueFalseTotal
if $$is{"selfSigned"} 0 21 21
1862 21 ▶ $trusted = ( $is->{ca}{trusted} // 1 ) ? 1 : 0 if $is->{ca};
Branch: 2 branches
BranchTrueFalseTotal
if $$is{"ca"} 5 16 21
$$is{'ca'}{'trusted'} // 1 ? : 5 0 5
Condition50%1/2
$$is{"ca"}{"trusted"} // 1
l!l
05
MC/DC0%0/1
$$is{"ca"}{"trusted"} // 1
$$is{"ca"}{"trusted"}
Truth table50%1/2
A
A= $$is{"ca"}{"trusted"}
Aresult
11
00
1863 return { %r, ready => 1, reason => 'Ready', message => 'Certificate is up to date and has not expired', cr => [ 1, 'Issued', 'Certificate fetched from issuer successfully' ],
1864 21 ▶ order => 'valid', trusted => $trusted, issuer => "$ikind/" . ( $ref->{name} // '' ) };
Condition50%1/2
$$ref{"name"} // ""
l!l
210
MC/DC0%0/1
$$ref{"name"} // ""
$$ref{"name"}
Truth table50%1/2
A
A= $$ref{"name"}
Aresult
11
00
1865 }
1866  
1867 # Secret aus dem Zustand, sonst eines, das cert-manager ausgestellt hat
1868 37 ▶sub _secret {
Subroutine _secret: called CC=12 SCAR=25.8
1869 37 my ( $k, $ns, $name ) = @_;
1870 37 ▶ my $s = ( ( $k->{namespaces}{$ns} || {} )->{secrets} || {} )->{ $name // '' };
Condition66%4/6
($$k{'namespaces'}{$ns} || {})->{'secrets'} || {}
l!l
2512
$$k{'namespaces'}{$ns} || {}
l!l
370
$name // ""
l!l
370
MC/DC0%0/1
($$k{'namespaces'}{$ns} || {})->{'secrets'} || {}
$$k{'namespaces'}{$ns}
MC/DC0%0/1
$name // ""
$name
Truth table50%1/2
A
A= $$k{'namespaces'}{$ns}
Aresult
11
00
Truth table50%1/2
A
A= $name
Aresult
11
00
1871 37 ▶ return $s if $s;
Branch: 1 branch
BranchTrueFalseTotal
if $s 5 32 37
1872 32 my $certs = _certs( $k, $ns );
1873 32 for my $cn ( sort keys %$certs ) {
1874 39 my $c = $certs->{$cn};
1875 39 ▶ next unless ( ( $c->{spec} || {} )->{secretName} // '' ) eq ( $name // '' );
Branch: 1 branch
BranchTrueFalseTotal
unless (($$c{"spec"} || {})->{"secretName"} // "") eq ($name // "") 19 20 39
Condition50%3/6
($$c{"spec"} || {})->{"secretName"} // ""
l!l
390
$$c{'spec'} || {}
l!l
390
$name // ""
l!l
390
MC/DC0%0/1
($$c{"spec"} || {})->{"secretName"} // ""
$$c{'spec'}
MC/DC0%0/1
$name // ""
$name
Truth table50%1/2
A
A= $$c{'spec'}
Aresult
11
00
Truth table50%1/2
A
A= $name
Aresult
11
00
1876 20 my $st = _cert_state( $k, $ns, $cn, $c );
1877 20 ▶ next unless $st->{ready};
Branch: 1 branch
BranchTrueFalseTotal
unless $$st{"ready"} 6 14 20
1878 14 my @dns = @{ $st->{dns} };
1879 14 ▶ return { 'tls.crt' => _pem( subject => 'CN=' . ( $dns[0] // $cn ), san => join( ',', @dns ), issuer => $st->{issuer}, trusted => $st->{trusted} ),
Condition33%1/3
$dns[0] // $cn
l!l&&r!l&&!r
1400
MC/DC0%0/2
$dns[0] // $cn
$dns[0] $cn
Truth table33%1/3
A // B
A= $dns[0]B= $cn
ABresult
1X1
011
000
1880 'tls.key' => "-----BEGIN PRIVATE KEY-----\nMC4CAQAwBQYDK2VwBCIEIOx0Zl8i\n-----END PRIVATE KEY-----\n", _issued => 1 };
1881 }
1882 18 return undef;
1883 }
1884  
1885 # alle Secrets eines Namespace mit den ausgestellten
1886 6 ▶sub _secrets_all {
Subroutine _secrets_all: called CC=9 SCAR=22.9
1887 6 my ( $k, $ns ) = @_;
1888 6 ▶ my %s = %{ ( ( $k->{namespaces}{$ns} || {} )->{secrets} ) || {} };
Condition50%2/4
($$k{'namespaces'}{$ns} || {})->{'secrets'} || {}
l!l
60
$$k{'namespaces'}{$ns} || {}
l!l
60
MC/DC0%0/1
($$k{'namespaces'}{$ns} || {})->{'secrets'} || {}
$$k{'namespaces'}{$ns}
Truth table50%1/2
A
A= $$k{'namespaces'}{$ns}
Aresult
11
00
1889 6 ▶ if ( $k->{helm} ) { Langertha::Holmgang::Sim::Linux::_part('Helm'); %s = ( Langertha::Holmgang::Sim::Linux::Helm::release_secrets( $k, $ns ), %s ) }
Branch: 1 branch
BranchTrueFalseTotal
if ($$k{"helm"}) 6 0 6
1890 6 for my $c ( values %{ _certs( $k, $ns ) } ) {
1891 12 ▶ my $sn = ( $c->{spec} || {} )->{secretName} // next;
Condition50%2/4
($$c{"spec"} || {})->{"secretName"} // (next)
l!l
120
$$c{'spec'} || {}
l!l
120
MC/DC0%0/1
($$c{"spec"} || {})->{"secretName"} // (next)
$$c{'spec'}
Truth table50%1/2
A
A= $$c{'spec'}
Aresult
11
00
1892 12 ▶ next if $s{$sn};
Branch: 1 branch
BranchTrueFalseTotal
if $s{$sn} 0 12 12
1893 12 ▶ my $x = _secret( $k, $ns, $sn ) or next;
Branch: 1 branch
BranchTrueFalseTotal
my $x = _secret($k, $ns, $sn) or next 7 5 12
1894 7 $s{$sn} = $x;
1895 }
1896 6 return \%s;
1897 }
1898  
1899 13 ▶sub _secret_type {
Subroutine _secret_type: called CC=4 SCAR=13.9
1900 13 my ($s) = @_;
1901 13 ▶ return 'helm.sh/release.v1' if $s->{_helm};
Branch: 1 branch
BranchTrueFalseTotal
if $$s{"_helm"} 4 9 13
1902 9 ▶ return defined $s->{'tls.crt'} && defined $s->{'tls.key'} ? 'kubernetes.io/tls' : 'Opaque';
Branch: 1 branch
BranchTrueFalseTotal
defined $$s{'tls.crt'} && defined $$s{'tls.key'} ? : 5 4 9
Condition66%2/3
defined $$s{"tls.crt"} and defined $$s{"tls.key"}
!ll&&!rl&&r
405
MC/DC50%1/2
defined $$s{"tls.crt"} and defined $$s{"tls.key"}
defined $$s{"tls.crt"} defined $$s{"tls.key"}
Truth table66%2/3
A and B
A= defined $$s{"tls.crt"}B= defined $$s{"tls.key"}
ABresult
0X0
100
111
1903 }
1904  
1905 0 ▶sub _cm_log {
Subroutine _cm_log: not called CC=9 SCAR=45.0
1906 0 my ($k) = @_;
1907 0 my @l;
1908 0 my $i = 0;
1909 0 ▶ for my $ns ( sort keys %{ $k->{namespaces} || {} } ) {
Condition0%0/2
$$k{'namespaces'} || {}
l!l
00
MC/DC0%0/1
$$k{'namespaces'} || {}
$$k{'namespaces'}
Truth table0%0/2
A
A= $$k{'namespaces'}
Aresult
11
00
1910 0 my $certs = _certs( $k, $ns );
1911 0 for my $cn ( sort keys %$certs ) {
1912 0 my $st = _cert_state( $k, $ns, $cn, $certs->{$cn} );
1913 0 ▶ next if $st->{ready};
Branch: 1 branch
BranchTrueFalseTotal
if $$st{"ready"} 0 0 0
1914 0 $i++;
1915 0 my ($ch) = grep { $_->{state} ne 'valid' } @{ $st->{challenges} };
1916 push @l, sprintf( 'E1024 08:%02d:%02d.%06d 1 controller.go:157] "re-queuing item due to error processing" err="%s" logger="cert-manager.controller" key="%s/%s-1"',
1917 0 ▶ 20 + $i, ( 13 * $i ) % 60, 418310 + 711 * $i, ( $ch ? $ch->{reason} : $st->{cr}[2] ) =~ s/"/\\"/gr, $ns, $cn );
Branch: 1 branch
BranchTrueFalseTotal
$ch ? : 0 0 0
1918 }
1919 }
1920 0 ▶ for my $ci ( sort keys %{ $k->{clusterissuers} || {} } ) {
Condition0%0/2
$$k{'clusterissuers'} || {}
l!l
00
MC/DC0%0/1
$$k{'clusterissuers'} || {}
$$k{'clusterissuers'}
Truth table0%0/2
A
A= $$k{'clusterissuers'}
Aresult
11
00
1921 0 my ( $ok, $reason, $msg ) = _issuer_state( $k, $k->{clusterissuers}{$ci}, _cm_ns($k) );
1922 0 ▶ push @l, sprintf( 'E1024 08:31:%02d.%06d 1 setup.go:%d] "%s" err="%s" logger="cert-manager.controller" resource_name="%s" resource_kind="ClusterIssuer"', ++$i % 60, 207110 + $i, 100 + $i, $reason, $msg =~ s/"/\\"/gr, $ci ) unless $ok;
Branch: 1 branch
BranchTrueFalseTotal
unless $ok 0 0 0
1923 }
1924 0 return @l;
1925 }
1926  
1927 # --- Tabellen und Beschreibungen der Arten in API-Form ---------------------------------
1928  
1929 14 ▶sub _cond_text { my ($b) = @_; return $b ? 'True' : 'False' }
Subroutine _cond_text: called CC=2 SCAR=6.9
Branch: 1 branch
BranchTrueFalseTotal
$b ? : 7 7 14
1930  
1931 # Status fuer -o yaml|json
1932 4 ▶sub _gen_status {
Subroutine _gen_status: called CC=9 SCAR=28.4
1933 4 my ( $k, $kind, $ns, $name, $x ) = @_;
1934 4 ▶ if ( $kind eq 'certificates' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($kind eq "certificates") 2 2 4
1935 2 my $st = _cert_state( $k, $ns, $name, $x );
1936 2 return { conditions => [ { type => 'Ready', status => _cond_text( $st->{ready} ), reason => $st->{reason}, message => $st->{message} } ] };
1937 }
1938 2 ▶ if ( $kind eq 'issuers' || $kind eq 'clusterissuers' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($kind eq "issuers" or $kind eq "clusterissuers") 0 2 2
Condition33%1/3
$kind eq "issuers" or $kind eq "clusterissuers"
l!l&&r!l&&!r
002
MC/DC0%0/2
$kind eq "issuers" or $kind eq "clusterissuers"
$kind eq "issuers" $kind eq "clusterissuers"
Truth table33%1/3
A or B
A= $kind eq "issuers"B= $kind eq "clusterissuers"
ABresult
1X1
011
000
1939 0 ▶ my ( $ok, $reason, $msg ) = _issuer_state( $k, $x, $kind eq 'issuers' ? $ns : _cm_ns($k) );
Branch: 1 branch
BranchTrueFalseTotal
$kind eq 'issuers' ? : 0 0 0
1940 0 return { conditions => [ { type => 'Ready', status => _cond_text($ok), reason => $reason, message => $msg } ] };
1941 }
1942 2 ▶ if ( $kind eq 'ingresses' && _handled( $k, _ingress_class( $k, $x ) ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($kind eq "ingresses" and _handled($k, _ingress_class($k, $x))) 2 0 2
Condition33%1/3
$kind eq "ingresses" and _handled($k, _ingress_class($k, $x))
!ll&&!rl&&r
002
MC/DC0%0/2
$kind eq "ingresses" and _handled($k, _ingress_class($k, $x))
$kind eq "ingresses" _handled($k, _ingress_class($k, $x))
Truth table33%1/3
A and B
A= $kind eq "ingresses"B= _handled($k, _ingress_class($k, $x))
ABresult
0X0
100
111
1943 2 ▶ return { loadBalancer => { ingress => [ { ip => ( $k->{ingress} || {} )->{address} // '' } ] } };
Condition50%2/4
($$k{"ingress"} || {})->{"address"} // ""
l!l
20
$$k{'ingress'} || {}
l!l
20
MC/DC0%0/1
($$k{"ingress"} || {})->{"address"} // ""
$$k{'ingress'}
Truth table50%1/2
A
A= $$k{'ingress'}
Aresult
11
00
1944 }
1945 0 return undef;
1946 }
1947  
1948 8 ▶sub _gen_rows {
Subroutine _gen_rows: called CC=43 SCAR=59.6
1949 8 my ( $k, $kind, $ns, $o, $name ) = @_;
1950 8 ▶ my $objs = $kind eq 'certificates' ? _certs( $k, $ns ) : _gen_objs( $k, $kind, $ns );
Branch: 1 branch
BranchTrueFalseTotal
$kind eq 'certificates' ? : 5 3 8
1951 0 ▶ $objs = { %{ _builtin_roles() }, %$objs } if $kind eq 'clusterroles';
Branch: 1 branch
BranchTrueFalseTotal
if $kind eq "clusterroles" 0 8 8
1952 8 ▶ $objs = { default => {}, %$objs } if $kind eq 'serviceaccounts' && $k->{namespaces}{$ns};
Branch: 1 branch
BranchTrueFalseTotal
if $kind eq "serviceaccounts" and $$k{"namespaces"}{$ns} 0 8 8
Condition33%1/3
$kind eq "serviceaccounts" and $$k{"namespaces"}{$ns}
!ll&&!rl&&r
800
MC/DC0%0/2
$kind eq "serviceaccounts" and $$k{"namespaces"}{$ns}
$kind eq "serviceaccounts" $$k{"namespaces"}{$ns}
Truth table33%1/3
A and B
A= $kind eq "serviceaccounts"B= $$k{"namespaces"}{$ns}
ABresult
0X0
100
111
1953 8 ▶ my @n = grep { !defined $name || $_ eq $name } sort keys %$objs;
Condition100%3/3
!defined($name) || $_ eq $name
l!l&&r!l&&!r
922
MC/DC100%2/2
!defined($name) || $_ eq $name
!defined($name) $_ eq $name
Truth table100%3/3
not(A) || B
A= !defined($name)B= $_ eq $name
ABresult
1X1
011
000
1954 8 ▶ return ( undef, qq{Error from server (NotFound): $GEN{$kind}[3] "$name" not found} ) if defined $name && !@n;
Branch: 1 branch
BranchTrueFalseTotal
if defined $name and not @n 0 8 8
Condition66%2/3
defined $name and not @n
!ll&&!rl&&r
620
MC/DC0%0/2
defined $name and not @n
defined $name not @n
Truth table66%2/3
A and not(B)
A= defined $nameB= not @n
ABresult
0X0
100
111
1955 8 ▶ return ( { map { $_ => { %{ $objs->{$_} }, ( _gen_status( $k, $kind, $ns, $_, $objs->{$_} ) ? ( _status => _gen_status( $k, $kind, $ns, $_, $objs->{$_} ) ) : () ) } } @n } ) if $o->{out} && $o->{out} =~ /\A(?:yaml|json)/;
Branch: 2 branches
BranchTrueFalseTotal
if $$o{"out"} and $$o{"out"} =~ /\A(?:yaml|json)/ 2 6 8
_gen_status($k, $kind, $ns, $_, $$objs{$_}) ? : 2 0 2
Condition66%2/3
$$o{"out"} and $$o{"out"} =~ /\A(?:yaml|json)/
!ll&&!rl&&r
602
MC/DC50%1/2
$$o{"out"} and $$o{"out"} =~ /\A(?:yaml|json)/
$$o{"out"} $$o{"out"} =~ /\A(?:yaml|json)/
Truth table66%2/3
A and B
A= $$o{"out"}B= $$o{"out"} =~ /\A(?:yaml|json)/
ABresult
0X0
100
111
1956 6 ▶ my $wide = ( $o->{out} // '' ) eq 'wide';
Condition50%1/2
$$o{"out"} // ""
l!l
06
MC/DC0%0/1
$$o{"out"} // ""
$$o{"out"}
Truth table50%1/2
A
A= $$o{"out"}
Aresult
11
00
1957 6 my @rows;
1958 6 ▶ if ( $kind eq 'ingresses' ) {
Branch: 7 branches
BranchTrueFalseTotal
if ($kind eq 'ingresses') { } 2 4 6
elsif ($kind eq 'ingressclasses') { } 0 4 4
elsif ($kind eq 'serviceaccounts') { } 0 4 4
elsif ($kind eq 'roles' or $kind eq 'clusterroles') { } 0 4 4
elsif ($kind eq 'rolebindings' or $kind eq 'clusterrolebindings') { } 0 4 4
elsif ($kind eq 'certificates') { } 4 0 4
elsif ($kind eq 'issuers' or $kind eq 'clusterissuers') { } 0 0 0
1959 @rows = ( [qw( NAME CLASS HOSTS ADDRESS PORTS AGE )], map {
1960 2 my $i = $objs->{$_};
1961 2 ▶ my $s = $i->{spec} || {};
Condition50%1/2
$$i{'spec'} || {}
l!l
20
MC/DC0%0/1
$$i{'spec'} || {}
$$i{'spec'}
Truth table50%1/2
A
A= $$i{'spec'}
Aresult
11
00
1962 2 ▶ [ $_, $s->{ingressClassName} // '<none>', join( ',', map { $_->{host} // '*' } @{ $s->{rules} || [] } ) || '*',
Branch: 2 branches
BranchTrueFalseTotal
_handled($k, _ingress_class($k, $i)) ? : 2 0 2
@{$$s{'tls'} or [];} ? : 2 0 2
Condition50%4/8
$$_{"host"} // "*"
l!l
20
$$s{'rules'} || []
l!l
20
($$k{"ingress"} || {})->{"address"} // ""
l!l
20
$$k{'ingress'} || {}
l!l
20
MC/DC0%0/1
$$_{"host"} // "*"
$$_{"host"}
MC/DC0%0/1
$$s{'rules'} || []
$$s{'rules'}
MC/DC0%0/1
($$k{"ingress"} || {})->{"address"} // ""
$$k{'ingress'}
Truth table50%1/2
A
A= $$_{"host"}
Aresult
11
00
Truth table50%1/2
A
A= $$s{'rules'}
Aresult
11
00
Truth table50%1/2
A
A= $$k{'ingress'}
Aresult
11
00
1963 2 ▶ _handled( $k, _ingress_class( $k, $i ) ) ? ( $k->{ingress} || {} )->{address} // '' : '', @{ $s->{tls} || [] } ? '80, 443' : '80', '41d' ];
Condition50%3/6
$$s{"ingressClassName"} // "<none>"
l!l
20
join(',', map({$$_{'host'} // '*';} @{$$s{'rules'} or [];})) || '*'
l!l
20
$$s{'tls'} || []
l!l
20
MC/DC0%0/1
$$s{"ingressClassName"} // "<none>"
$$s{"ingressClassName"}
MC/DC0%0/1
join(',', map({$$_{'host'} // '*';} @{$$s{'rules'} or [];})) || '*'
join(',', map({$$_{'host'} // '*';} @{$$s{'rules'} or [];}))
MC/DC0%0/1
$$s{'tls'} || []
$$s{'tls'}
Truth table50%1/2
A
A= $$s{"ingressClassName"}
Aresult
11
00
Truth table50%1/2
A
A= join(',', map({$$_{'host'} // '*';} @{$$s{'rules'} or [];}))
Aresult
11
00
Truth table50%1/2
A
A= $$s{'tls'}
Aresult
11
00
1964 } @n );
1965 }
1966 elsif ( $kind eq 'ingressclasses' ) {
1967 0 ▶ @rows = ( [qw( NAME CONTROLLER PARAMETERS AGE )], map { [ $_, ( $objs->{$_}{spec} || {} )->{controller} // '', '<none>', '41d' ] } @n );
Condition0%0/4
($$objs{$_}{"spec"} || {})->{"controller"} // ""
l!l
00
$$objs{$_}{'spec'} || {}
l!l
00
MC/DC0%0/1
($$objs{$_}{"spec"} || {})->{"controller"} // ""
$$objs{$_}{'spec'}
Truth table0%0/2
A
A= $$objs{$_}{'spec'}
Aresult
11
00
1968 }
1969 elsif ( $kind eq 'serviceaccounts' ) {
1970 0 @rows = ( [qw( NAME SECRETS AGE )], map { [ $_, 0, '41d' ] } @n );
1971 }
1972 ▶ elsif ( $kind eq 'roles' || $kind eq 'clusterroles' ) {
Condition33%1/3
$kind eq "roles" or $kind eq "clusterroles"
l!l&&r!l&&!r
004
MC/DC0%0/2
$kind eq "roles" or $kind eq "clusterroles"
$kind eq "roles" $kind eq "clusterroles"
Truth table33%1/3
A or B
A= $kind eq "roles"B= $kind eq "clusterroles"
ABresult
1X1
011
000
1973 0 @rows = ( [ 'NAME', 'CREATED AT' ], map { [ $_, '2026-09-13T08:14:51Z' ] } @n );
1974 }
1975 ▶ elsif ( $kind eq 'rolebindings' || $kind eq 'clusterrolebindings' ) {
Condition33%1/3
$kind eq "rolebindings" or $kind eq "clusterrolebindings"
l!l&&r!l&&!r
004
MC/DC0%0/2
$kind eq "rolebindings" or $kind eq "clusterrolebindings"
$kind eq "rolebindings" $kind eq "clusterrolebindings"
Truth table33%1/3
A or B
A= $kind eq "rolebindings"B= $kind eq "clusterrolebindings"
ABresult
1X1
011
000
1976 @rows = ( [ qw( NAME ROLE AGE ), ( $wide ? qw( USERS GROUPS SERVICEACCOUNTS ) : () ) ], map {
1977 0 ▶ my $b = $objs->{$_};
Branch: 1 branch
BranchTrueFalseTotal
$wide ? : 0 0 0
1978 0 ▶ my @s = @{ $b->{subjects} || [] };
Condition0%0/2
$$b{'subjects'} || []
l!l
00
MC/DC0%0/1
$$b{'subjects'} || []
$$b{'subjects'}
Truth table0%0/2
A
A= $$b{'subjects'}
Aresult
11
00
1979 0 ▶ my $sj = sub { my ($t) = @_; join ',', map { $t eq 'ServiceAccount' ? ( $_->{namespace} // $ns ) . ":$_->{name}" : $_->{name} } grep { ( $_->{kind} // '' ) eq $t } @s };
Subroutine __ANON__: not called CC=4 SCAR=30.0
Branch: 1 branch
BranchTrueFalseTotal
$t eq 'ServiceAccount' ? : 0 0 0
Condition0%0/5
$$_{"namespace"} // $ns
l!l&&r!l&&!r
000
$$_{"kind"} // ""
l!l
00
MC/DC0%0/2
$$_{"namespace"} // $ns
$$_{"namespace"} $ns
MC/DC0%0/1
$$_{"kind"} // ""
$$_{"kind"}
Truth table0%0/3
A // B
A= $$_{"namespace"}B= $ns
ABresult
1X1
011
000
Truth table0%0/2
A
A= $$_{"kind"}
Aresult
11
00
1980 0 ▶ [ $_, ( ( $b->{roleRef} || {} )->{kind} // '' ) . '/' . ( ( $b->{roleRef} || {} )->{name} // '' ), '41d', ( $wide ? ( $sj->('User'), $sj->('Group'), $sj->('ServiceAccount') ) : () ) ];
Branch: 1 branch
BranchTrueFalseTotal
$wide ? : 0 0 0
Condition0%0/8
($$b{"roleRef"} || {})->{"kind"} // ""
l!l
00
$$b{'roleRef'} || {}
l!l
00
($$b{"roleRef"} || {})->{"name"} // ""
l!l
00
$$b{'roleRef'} || {}
l!l
00
MC/DC0%0/1
($$b{"roleRef"} || {})->{"kind"} // ""
$$b{'roleRef'}
MC/DC0%0/1
($$b{"roleRef"} || {})->{"name"} // ""
$$b{'roleRef'}
Truth table0%0/2
A
A= $$b{'roleRef'}
Aresult
11
00
Truth table0%0/2
A
A= $$b{'roleRef'}
Aresult
11
00
1981 } @n );
1982 }
1983 elsif ( $kind eq 'certificates' ) {
1984 4 ▶ @rows = ( [qw( NAME READY SECRET AGE )], map { my $st = _cert_state( $k, $ns, $_, $objs->{$_} ); [ $_, _cond_text( $st->{ready} ), $st->{secret} // '', '3d' ] } @n );
Condition50%1/2
$$st{"secret"} // ""
l!l
70
MC/DC0%0/1
$$st{"secret"} // ""
$$st{"secret"}
Truth table50%1/2
A
A= $$st{"secret"}
Aresult
11
00
1985 }
1986 ▶ elsif ( $kind eq 'issuers' || $kind eq 'clusterissuers' ) {
Condition0%0/3
$kind eq "issuers" or $kind eq "clusterissuers"
l!l&&r!l&&!r
000
MC/DC0%0/2
$kind eq "issuers" or $kind eq "clusterissuers"
$kind eq "issuers" $kind eq "clusterissuers"
Truth table0%0/3
A or B
A= $kind eq "issuers"B= $kind eq "clusterissuers"
ABresult
1X1
011
000
1987 0 ▶ @rows = ( [qw( NAME READY AGE )], map { my ($ok) = _issuer_state( $k, $objs->{$_}, $kind eq 'issuers' ? $ns : _cm_ns($k) ); [ $_, _cond_text($ok), '41d' ] } @n );
Branch: 1 branch
BranchTrueFalseTotal
$kind eq 'issuers' ? : 0 0 0
1988 }
1989 6 return ( \@rows );
1990 }
1991  
1992 4 ▶sub _derived_rows {
Subroutine _derived_rows: called CC=6 SCAR=18.5
1993 4 my ( $k, $kind, $ns ) = @_;
1994 4 my $certs = _certs( $k, $ns );
1995 4 my @st = map { _cert_state( $k, $ns, $_, $certs->{$_} ) } sort keys %$certs;
1996 4 ▶ if ( $kind eq 'certificaterequests' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($kind eq "certificaterequests") 2 2 4
1997 return ( [qw( NAME APPROVED DENIED READY ISSUER REQUESTOR AGE )],
1998 2 ▶ map { [ "$_->{name}-1", 'True', '', _cond_text( $_->{cr}[0] ), ( ( $certs->{ $_->{name} }{spec} || {} )->{issuerRef} || {} )->{name} // '', 'system:serviceaccount:cert-manager:cert-manager', '12m' ] } @st );
Condition50%3/6
(($$certs{$$_{"name"}}{"spec"} || {})->{"issuerRef"} || {})->{"name"} // ""
l!l
40
($$certs{$$_{'name'}}{'spec'} || {})->{'issuerRef'} || {}
l!l
40
$$certs{$$_{'name'}}{'spec'} || {}
l!l
40
MC/DC0%0/1
(($$certs{$$_{"name"}}{"spec"} || {})->{"issuerRef"} || {})->{"name"} // ""
$$certs{$$_{'name'}}{'spec'}
Truth table50%1/2
A
A= $$certs{$$_{'name'}}{'spec'}
Aresult
11
00
1999 }
2000 2 my @acme = grep { defined $_->{order} } @st;
2001 0 ▶ if ( $kind eq 'orders' ) { return ( [qw( NAME STATE AGE )], map { [ "$_->{name}-1-2873461", $_->{order}, '12m' ] } @acme ) }
Branch: 1 branch
BranchTrueFalseTotal
if ($kind eq "orders") 0 2 2
2002 2 my $i = 0;
2003 2 return ( [qw( NAME STATE DOMAIN AGE )], map { my $c = $_; map { [ "$c->{name}-1-2873461-" . ( 1902000000 + 7919 * ++$i ), $_->{state}, $_->{domain}, '12m' ] } @{ $c->{challenges} } } @acme );
2004 }
2005  
2006 # abgeleitete Objekte in API-Form (fuer -o yaml|json|jsonpath)
2007 1 ▶sub _derived_objs {
Subroutine _derived_objs: called CC=11 SCAR=28.3
2008 1 my ( $k, $kind, $ns ) = @_;
2009 1 my $certs = _certs( $k, $ns );
2010 1 my %o;
2011 1 my $i = 0;
2012 1 for my $cn ( sort keys %$certs ) {
2013 2 my $st = _cert_state( $k, $ns, $cn, $certs->{$cn} );
2014 2 ▶ my $ref = ( $certs->{$cn}{spec} || {} )->{issuerRef} || {};
Condition50%2/4
($$certs{$cn}{'spec'} || {})->{'issuerRef'} || {}
l!l
20
$$certs{$cn}{'spec'} || {}
l!l
20
MC/DC0%0/1
($$certs{$cn}{'spec'} || {})->{'issuerRef'} || {}
$$certs{$cn}{'spec'}
Truth table50%1/2
A
A= $$certs{$cn}{'spec'}
Aresult
11
00
2015 2 ▶ my $meta = sub { { name => $_[0], namespace => $ns, ownerReferences => [ { apiVersion => 'cert-manager.io/v1', kind => $_[1], name => $_[2], controller => JSON::MaybeXS::true() } ] } };
Subroutine __ANON__: called CC=1 SCAR=0.0
2016 2 ▶ if ( $kind eq 'certificaterequests' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($kind eq "certificaterequests") 0 2 2
2017 $o{"$cn-1"} = { apiVersion => 'cert-manager.io/v1', kind => 'CertificateRequest', metadata => $meta->( "$cn-1", 'Certificate', $cn ),
2018 spec => { issuerRef => $ref, username => 'system:serviceaccount:cert-manager:cert-manager' },
2019 status => { conditions => [ { type => 'Approved', status => 'True', reason => 'cert-manager.io', message => 'Certificate request has been approved by cert-manager.io' },
2020 0 { type => 'Ready', status => _cond_text( $st->{cr}[0] ), reason => $st->{cr}[1], message => $st->{cr}[2] } ] } };
2021 0 next;
2022 }
2023 2 ▶ next unless defined $st->{order};
Branch: 1 branch
BranchTrueFalseTotal
unless defined $$st{"order"} 1 1 2
2024 1 my $on = "$cn-1-2873461";
2025 1 ▶ if ( $kind eq 'orders' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($kind eq "orders") 0 1 1
2026 0 my ($bad) = grep { $_->{state} ne 'valid' } @{ $st->{challenges} };
2027 $o{$on} = { apiVersion => 'acme.cert-manager.io/v1', kind => 'Order', metadata => $meta->( $on, 'CertificateRequest', "$cn-1" ),
2028 0 ▶ spec => { dnsNames => $st->{dns}, issuerRef => $ref }, status => { state => $st->{order}, ( $bad ? ( reason => $bad->{reason} ) : () ) } };
Branch: 1 branch
BranchTrueFalseTotal
$bad ? : 0 0 0
2029 0 next;
2030 }
2031 1 for my $c ( @{ $st->{challenges} } ) {
2032 1 my $chn = "$on-" . ( 1902000000 + 7919 * ++$i );
2033 $o{$chn} = { apiVersion => 'acme.cert-manager.io/v1', kind => 'Challenge', metadata => $meta->( $chn, 'Order', $on ),
2034 spec => { dnsName => $c->{domain}, type => $c->{type}, issuerRef => $ref },
2035 status => { state => $c->{state}, reason => $c->{reason}, presented => $c->{state} eq 'errored' ? JSON::MaybeXS::false() : JSON::MaybeXS::true(),
2036 1 ▶ processing => $c->{state} eq 'valid' ? JSON::MaybeXS::false() : JSON::MaybeXS::true() } };
Branch: 2 branches
BranchTrueFalseTotal
$$c{'state'} eq 'errored' ? : 0 1 1
$$c{'state'} eq 'valid' ? : 0 1 1
2037 }
2038 }
2039 1 return \%o;
2040 }
2041  
2042 3 ▶sub _describe_gen {
Subroutine _describe_gen: called CC=89 SCAR=70.3
2043 3 my ( $k, $kind, $ns, $name ) = @_;
2044 3 ▶ if ( $DERIVED{$kind} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($Langertha::Holmgang::Sim::Linux::Kubernetes::DERIVED{$kind}) 1 2 3
2045 1 my $certs = _certs( $k, $ns );
2046 1 for my $cn ( sort keys %$certs ) {
2047 2 my $st = _cert_state( $k, $ns, $cn, $certs->{$cn} );
2048 2 ▶ next unless index( $name // '', $cn ) == 0 || !defined $name;
Branch: 1 branch
BranchTrueFalseTotal
unless index($name // "", $cn) == 0 or not defined $name 0 2 2
Condition40%2/5
index($name // "", $cn) == 0 or not defined $name
l!l&&r!l&&!r
020
$name // ""
l!l
02
MC/DC0%0/2
index($name // "", $cn) == 0 or not defined $name
index($name // "", $cn) == 0 not defined $name
MC/DC0%0/1
$name // ""
$name
Truth table33%1/3
A or not(B)
A= index($name // "", $cn) == 0B= not defined $name
ABresult
1X1
011
000
Truth table50%1/2
A
A= $name
Aresult
11
00
2049 2 ▶ if ( $kind eq 'certificaterequests' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($kind eq "certificaterequests") 0 2 2
2050 return ( join( "\n", "Name: $cn-1", "Namespace: $ns", 'API Version: cert-manager.io/v1', 'Kind: CertificateRequest', 'Status:', ' Conditions:',
2051 0 ' Type: Approved', ' Status: True', ' Type: Ready', ' Status: ' . _cond_text( $st->{cr}[0] ), " Reason: $st->{cr}[1]", " Message: $st->{cr}[2]",
2052 'Events: <none>' ), 1 );
2053 }
2054 2 ▶ my @ch = @{ $st->{challenges} } or next;
Branch: 1 branch
BranchTrueFalseTotal
my(@ch) = @{$$st{"challenges"};} or next 1 1 2
2055 1 my ($c) = grep { $_->{state} ne 'valid' } @ch;
2056 1 ▶ $c //= $ch[0];
Condition33%1/3
$c //= $ch[0]
l!l&&r!l&&!r
100
MC/DC0%0/2
$c //= $ch[0]
$c $ch[0]
Truth table33%1/3
A //= B
A= $cB= $ch[0]
ABresult
1X1
011
000
2057 return ( join( "\n", "Name: " . ( $name // "$cn-1-2873461" ), "Namespace: $ns", 'API Version: acme.cert-manager.io/v1', 'Kind: ' . ( $kind eq 'orders' ? 'Order' : 'Challenge' ),
2058 1 ▶ 'Spec:', " Dns Name: $c->{domain}", " Type: $c->{type}", 'Status:', " Presented: " . ( $c->{state} eq 'errored' ? 'false' : 'true' ), " Processing: " . ( $c->{state} eq 'valid' ? 'false' : 'true' ),
Branch: 3 branches
BranchTrueFalseTotal
$kind eq 'orders' ? : 0 1 1
$$c{'state'} eq 'errored' ? : 0 1 1
$$c{'state'} eq 'valid' ? : 0 1 1
Condition50%1/2
$name // "$cn-1-2873461"
l!l
01
MC/DC0%0/1
$name // "$cn-1-2873461"
$name
Truth table50%1/2
A
A= $name
Aresult
11
00
2059 " Reason: $c->{reason}", " State: $c->{state}", 'Events: <none>' ), 1 );
2060 }
2061 0 ▶ return ( qq{Error from server (NotFound): $SINGULAR{$kind} "} . ( $name // '' ) . '" not found', 0 );
Condition0%0/2
$name // ""
l!l
00
MC/DC0%0/1
$name // ""
$name
Truth table0%0/2
A
A= $name
Aresult
11
00
2062 }
2063 2 ▶ my $objs = $kind eq 'certificates' ? _certs( $k, $ns ) : _gen_objs( $k, $kind, $ns );
Branch: 1 branch
BranchTrueFalseTotal
$kind eq 'certificates' ? : 0 2 2
2064 0 ▶ $objs = { %{ _builtin_roles() }, %$objs } if $kind eq 'clusterroles';
Branch: 1 branch
BranchTrueFalseTotal
if $kind eq "clusterroles" 0 2 2
2065 2 ▶ $objs = { default => {}, %$objs } if $kind eq 'serviceaccounts';
Branch: 1 branch
BranchTrueFalseTotal
if $kind eq "serviceaccounts" 0 2 2
2066 2 ▶ my $x = $objs->{ $name // '' } or return ( qq{Error from server (NotFound): $GEN{$kind}[3] "} . ( $name // '' ) . '" not found', 0 );
Branch: 1 branch
BranchTrueFalseTotal
my $x = $$objs{$name // ""} or return qq[Error from server (NotFound): $Langertha::Holmgang::Sim::Linux::Kubernetes::GEN{$kind}[3] "] . ($name // "") . '" not found', 0 2 0 2
Condition25%1/4
$name // ""
l!l
20
$name // ""
l!l
00
MC/DC0%0/1
$name // ""
$name
MC/DC0%0/1
$name // ""
$name
Truth table50%1/2
A
A= $name
Aresult
11
00
Truth table0%0/2
A
A= $name
Aresult
11
00
2067 2 ▶ my $s = $x->{spec} || {};
Condition50%1/2
$$x{'spec'} || {}
l!l
20
MC/DC0%0/1
$$x{'spec'} || {}
$$x{'spec'}
Truth table50%1/2
A
A= $$x{'spec'}
Aresult
11
00
2068 2 ▶ my $m = $x->{metadata} || {};
Condition100%2/2
$$x{'metadata'} || {}
l!l
11
MC/DC100%1/1
$$x{'metadata'} || {}
$$x{'metadata'}
Truth table100%2/2
A
A= $$x{'metadata'}
Aresult
11
00
2069 2 ▶ my $kv = sub { my ($h) = @_; my @k = sort keys %{ $h || {} }; @k ? join( "\n ", map {"$_: $h->{$_}"} @k ) : '<none>' };
Subroutine __ANON__: called CC=3 SCAR=11.0
Branch: 1 branch
BranchTrueFalseTotal
@k ? : 1 3 4
Condition100%2/2
$h || {}
l!l
13
MC/DC100%1/1
$h || {}
$h
Truth table100%2/2
A
A= $h
Aresult
11
00
2070 2 ▶ my @l = ( "Name: $name", ( $GEN{$kind}[2] ? () : "Namespace: $ns" ), 'Labels: ' . $kv->( $m->{labels} ), 'Annotations: ' . $kv->( $m->{annotations} ) );
Branch: 1 branch
BranchTrueFalseTotal
$Langertha::Holmgang::Sim::Linux::Kubernetes::GEN{$kind}[2] ? : 1 1 2
2071 2 ▶ if ( $kind eq 'ingresses' ) {
Branch: 7 branches
BranchTrueFalseTotal
if ($kind eq 'ingresses') { } 1 1 2
elsif ($kind eq 'roles' or $kind eq 'clusterroles') { } 0 1 1
elsif ($kind eq 'rolebindings' or $kind eq 'clusterrolebindings') { } 0 1 1
elsif ($kind eq 'serviceaccounts') { } 0 1 1
elsif ($kind eq 'certificates') { } 0 1 1
elsif ($kind eq 'issuers' or $kind eq 'clusterissuers') { } 1 0 1
elsif ($kind eq 'ingressclasses') { } 0 0 0
2072 1 my $cls = _ingress_class( $k, $x );
2073 1 ▶ push @l, 'Address: ' . ( _handled( $k, $cls ) ? ( $k->{ingress} || {} )->{address} // '' : '' ), 'Ingress Class: ' . ( $s->{ingressClassName} // '<none>' ), 'Default backend: <default>';
Branch: 1 branch
BranchTrueFalseTotal
_handled($k, $cls) ? : 1 0 1
Condition50%3/6
($$k{"ingress"} || {})->{"address"} // ""
l!l
10
$$k{'ingress'} || {}
l!l
10
$$s{"ingressClassName"} // "<none>"
l!l
10
MC/DC0%0/1
($$k{"ingress"} || {})->{"address"} // ""
$$k{'ingress'}
MC/DC0%0/1
$$s{"ingressClassName"} // "<none>"
$$s{"ingressClassName"}
Truth table50%1/2
A
A= $$k{'ingress'}
Aresult
11
00
Truth table50%1/2
A
A= $$s{"ingressClassName"}
Aresult
11
00
2074 1 ▶ push @l, 'TLS:', map { ' ' . ( $_->{secretName} // 'SNI routes' ) . ' terminates ' . join( ',', @{ $_->{hosts} || [] } ) } @{ $s->{tls} || [] } if @{ $s->{tls} || [] };
Branch: 1 branch
BranchTrueFalseTotal
if @{$$s{"tls"} or [];} 1 0 1
Condition50%4/8
$$s{'tls'} || []
l!l
10
$$_{"secretName"} // "SNI routes"
l!l
10
$$_{'hosts'} || []
l!l
10
$$s{'tls'} || []
l!l
10
MC/DC0%0/1
$$s{'tls'} || []
$$s{'tls'}
MC/DC0%0/1
$$_{"secretName"} // "SNI routes"
$$_{"secretName"}
MC/DC0%0/1
$$_{'hosts'} || []
$$_{'hosts'}
MC/DC0%0/1
$$s{'tls'} || []
$$s{'tls'}
Truth table50%1/2
A
A= $$s{'tls'}
Aresult
11
00
Truth table50%1/2
A
A= $$_{"secretName"}
Aresult
11
00
Truth table50%1/2
A
A= $$_{'hosts'}
Aresult
11
00
Truth table50%1/2
A
A= $$s{'tls'}
Aresult
11
00
2075 1 push @l, 'Rules:', ' Host Path Backends', ' ---- ---- --------';
2076 1 ▶ for my $r ( @{ $s->{rules} || [] } ) {
Condition50%1/2
$$s{'rules'} || []
l!l
10
MC/DC0%0/1
$$s{'rules'} || []
$$s{'rules'}
Truth table50%1/2
A
A= $$s{'rules'}
Aresult
11
00
2077 1 ▶ push @l, ' ' . ( $r->{host} // '*' );
Condition50%1/2
$$r{"host"} // "*"
l!l
10
MC/DC0%0/1
$$r{"host"} // "*"
$$r{"host"}
Truth table50%1/2
A
A= $$r{"host"}
Aresult
11
00
2078 1 ▶ for my $p ( @{ ( $r->{http} || {} )->{paths} || [] } ) {
Condition50%2/4
($$r{'http'} || {})->{'paths'} || []
l!l
10
$$r{'http'} || {}
l!l
10
MC/DC0%0/1
($$r{'http'} || {})->{'paths'} || []
$$r{'http'}
Truth table50%1/2
A
A= $$r{'http'}
Aresult
11
00
2079 2 ▶ my $sb = ( $p->{backend} || {} )->{service} || {};
Condition50%2/4
($$p{'backend'} || {})->{'service'} || {}
l!l
20
$$p{'backend'} || {}
l!l
20
MC/DC0%0/1
($$p{'backend'} || {})->{'service'} || {}
$$p{'backend'}
Truth table50%1/2
A
A= $$p{'backend'}
Aresult
11
00
2080 2 ▶ my $port = ( $sb->{port} || {} )->{number} // ( $sb->{port} || {} )->{name} // '';
Condition55%5/9
(($$sb{"port"} || {})->{"number"} // ($$sb{"port"} || {})->{"name"}) // ""
l!l
20
($$sb{"port"} || {})->{"number"} // ($$sb{"port"} || {})->{"name"}
l!l&&r!l&&!r
110
$$sb{'port'} || {}
l!l
20
$$sb{'port'} || {}
l!l
10
MC/DC0%0/2
(($$sb{"port"} || {})->{"number"} // ($$sb{"port"} || {})->{"name"}) // ""
$$sb{'port'} $$sb{'port'}
Truth table33%1/3
A // B
A= $$sb{'port'}B= $$sb{'port'}
ABresult
1X1
011
000
2081 2 ▶ my $svc = ( $k->{namespaces}{$ns}{services} || {} )->{ $sb->{name} // '' };
Condition50%2/4
$$k{'namespaces'}{$ns}{'services'} || {}
l!l
20
$$sb{"name"} // ""
l!l
20
MC/DC0%0/1
$$k{'namespaces'}{$ns}{'services'} || {}
$$k{'namespaces'}{$ns}{'services'}
MC/DC0%0/1
$$sb{"name"} // ""
$$sb{"name"}
Truth table50%1/2
A
A= $$k{'namespaces'}{$ns}{'services'}
Aresult
11
00
Truth table50%1/2
A
A= $$sb{"name"}
Aresult
11
00
2082 my $ep = !$svc ? qq{<error: services "} . ( $sb->{name} // '' ) . '" not found>'
2083 2 ▶ : do { my @e = _endpoints( $k, $ns, $sb->{name} ); my ($sp) = grep { $port =~ /\A\d+\z/ ? $_->{port} == $port : ( $_->{name} // '' ) eq $port } @{ $svc->{ports} || [] };
Branch: 2 branches
BranchTrueFalseTotal
!$svc ? : 1 1 2
$port =~ /\A\d+\z/ ? : 0 1 1
Condition50%3/6
$$sb{"name"} // ""
l!l
10
$$_{"name"} // ""
l!l
10
$$svc{'ports'} || []
l!l
10
MC/DC0%0/1
$$sb{"name"} // ""
$$sb{"name"}
MC/DC0%0/1
$$_{"name"} // ""
$$_{"name"}
MC/DC0%0/1
$$svc{'ports'} || []
$$svc{'ports'}
Truth table50%1/2
A
A= $$sb{"name"}
Aresult
11
00
Truth table50%1/2
A
A= $$_{"name"}
Aresult
11
00
Truth table50%1/2
A
A= $$svc{'ports'}
Aresult
11
00
2084 1 ▶ !$sp ? '<error: service port not found>' : @e ? join( ',', map {"$_->{ip}:$sp->{target}"} @e ) : '' };
Branch: 2 branches
BranchTrueFalseTotal
!$sp ? : 0 1 1
@e ? : 1 0 1
2085 2 ▶ push @l, sprintf( ' %-5s %s:%s (%s)', $p->{path} // '/', $sb->{name} // '', $port, $ep );
Condition50%2/4
$$p{"path"} // "/"
l!l
20
$$sb{"name"} // ""
l!l
20
MC/DC0%0/1
$$p{"path"} // "/"
$$p{"path"}
MC/DC0%0/1
$$sb{"name"} // ""
$$sb{"name"}
Truth table50%1/2
A
A= $$p{"path"}
Aresult
11
00
Truth table50%1/2
A
A= $$sb{"name"}
Aresult
11
00
2086 }
2087 }
2088 1 push @l, 'Events: <none>';
2089 }
2090 ▶ elsif ( $kind eq 'roles' || $kind eq 'clusterroles' ) {
Condition33%1/3
$kind eq "roles" or $kind eq "clusterroles"
l!l&&r!l&&!r
001
MC/DC0%0/2
$kind eq "roles" or $kind eq "clusterroles"
$kind eq "roles" $kind eq "clusterroles"
Truth table33%1/3
A or B
A= $kind eq "roles"B= $kind eq "clusterroles"
ABresult
1X1
011
000
2091 0 my @rows = ( [ 'Resources', 'Non-Resource URLs', 'Resource Names', 'Verbs' ], [ '---------', '-----------------', '--------------', '-----' ] );
2092 0 ▶ for my $r ( @{ $x->{rules} || [] } ) {
Condition0%0/2
$$x{'rules'} || []
l!l
00
MC/DC0%0/1
$$x{'rules'} || []
$$x{'rules'}
Truth table0%0/2
A
A= $$x{'rules'}
Aresult
11
00
2093 0 ▶ for my $res ( @{ $r->{resources} || [] } ) {
Condition0%0/2
$$r{'resources'} || []
l!l
00
MC/DC0%0/1
$$r{'resources'} || []
$$r{'resources'}
Truth table0%0/2
A
A= $$r{'resources'}
Aresult
11
00
2094 0 ▶ push @rows, map { [ ( $_ eq '' ? $res : "$res.$_" ), '[]', '[' . join( ' ', @{ $r->{resourceNames} || [] } ) . ']', '[' . join( ' ', @{ $r->{verbs} || [] } ) . ']' ] } @{ $r->{apiGroups} || [''] };
Branch: 1 branch
BranchTrueFalseTotal
$_ eq '' ? : 0 0 0
Condition0%0/6
$$r{'resourceNames'} || []
l!l
00
$$r{'verbs'} || []
l!l
00
$$r{'apiGroups'} || ['']
l!l
00
MC/DC0%0/1
$$r{'resourceNames'} || []
$$r{'resourceNames'}
MC/DC0%0/1
$$r{'verbs'} || []
$$r{'verbs'}
MC/DC0%0/1
$$r{'apiGroups'} || ['']
$$r{'apiGroups'}
Truth table0%0/2
A
A= $$r{'resourceNames'}
Aresult
11
00
Truth table0%0/2
A
A= $$r{'verbs'}
Aresult
11
00
Truth table0%0/2
A
A= $$r{'apiGroups'}
Aresult
11
00
2095 }
2096 }
2097 0 push @l, 'PolicyRule:', map {" $_"} split /\n/, _cols(@rows);
2098 }
2099 ▶ elsif ( $kind eq 'rolebindings' || $kind eq 'clusterrolebindings' ) {
Condition33%1/3
$kind eq "rolebindings" or $kind eq "clusterrolebindings"
l!l&&r!l&&!r
001
MC/DC0%0/2
$kind eq "rolebindings" or $kind eq "clusterrolebindings"
$kind eq "rolebindings" $kind eq "clusterrolebindings"
Truth table33%1/3
A or B
A= $kind eq "rolebindings"B= $kind eq "clusterrolebindings"
ABresult
1X1
011
000
2100 0 ▶ my $rr = $x->{roleRef} || {};
Condition0%0/2
$$x{'roleRef'} || {}
l!l
00
MC/DC0%0/1
$$x{'roleRef'} || {}
$$x{'roleRef'}
Truth table0%0/2
A
A= $$x{'roleRef'}
Aresult
11
00
2101 push @l, 'Role:', ' Kind: ' . ( $rr->{kind} // '' ), ' Name: ' . ( $rr->{name} // '' ), 'Subjects:',
2102 0 ▶ map {" $_"} split /\n/, _cols( [qw( Kind Name Namespace )], [qw( ---- ---- --------- )], map { [ $_->{kind} // '', $_->{name} // '', $_->{namespace} // '' ] } @{ $x->{subjects} || [] } );
Condition0%0/12
$$rr{"kind"} // ""
l!l
00
$$rr{"name"} // ""
l!l
00
$$_{"kind"} // ""
l!l
00
$$_{"name"} // ""
l!l
00
$$_{"namespace"} // ""
l!l
00
$$x{'subjects'} || []
l!l
00
MC/DC0%0/1
$$rr{"kind"} // ""
$$rr{"kind"}
MC/DC0%0/1
$$rr{"name"} // ""
$$rr{"name"}
MC/DC0%0/1
$$_{"kind"} // ""
$$_{"kind"}
MC/DC0%0/1
$$_{"name"} // ""
$$_{"name"}
MC/DC0%0/1
$$_{"namespace"} // ""
$$_{"namespace"}
MC/DC0%0/1
$$x{'subjects'} || []
$$x{'subjects'}
Truth table0%0/2
A
A= $$rr{"kind"}
Aresult
11
00
Truth table0%0/2
A
A= $$rr{"name"}
Aresult
11
00
Truth table0%0/2
A
A= $$_{"kind"}
Aresult
11
00
Truth table0%0/2
A
A= $$_{"name"}
Aresult
11
00
Truth table0%0/2
A
A= $$_{"namespace"}
Aresult
11
00
Truth table0%0/2
A
A= $$x{'subjects'}
Aresult
11
00
2103 }
2104 elsif ( $kind eq 'serviceaccounts' ) {
2105 0 push @l, 'Image pull secrets: <none>', 'Mountable secrets: <none>', 'Tokens: <none>', 'Events: <none>';
2106 }
2107 elsif ( $kind eq 'certificates' ) {
2108 0 my $st = _cert_state( $k, $ns, $name, $x );
2109 0 ▶ my $ir = $s->{issuerRef} || {};
Condition0%0/2
$$s{'issuerRef'} || {}
l!l
00
MC/DC0%0/1
$$s{'issuerRef'} || {}
$$s{'issuerRef'}
Truth table0%0/2
A
A= $$s{'issuerRef'}
Aresult
11
00
2110 0 ▶ push @l, 'API Version: cert-manager.io/v1', 'Kind: Certificate', 'Spec:', ' Dns Names:', ( map {" $_"} @{ $s->{dnsNames} || [] } ),
Branch: 1 branch
BranchTrueFalseTotal
$$st{'ready'} ? : 0 0 0
Condition0%0/10
$$s{'dnsNames'} || []
l!l
00
$$ir{"group"} // "cert-manager.io"
l!l
00
$$ir{"kind"} // "Issuer"
l!l
00
$$ir{"name"} // ""
l!l
00
$$s{"secretName"} // ""
l!l
00
MC/DC0%0/1
$$s{'dnsNames'} || []
$$s{'dnsNames'}
MC/DC0%0/1
$$ir{"group"} // "cert-manager.io"
$$ir{"group"}
MC/DC0%0/1
$$ir{"kind"} // "Issuer"
$$ir{"kind"}
MC/DC0%0/1
$$ir{"name"} // ""
$$ir{"name"}
MC/DC0%0/1
$$s{"secretName"} // ""
$$s{"secretName"}
Truth table0%0/2
A
A= $$s{'dnsNames'}
Aresult
11
00
Truth table0%0/2
A
A= $$ir{"group"}
Aresult
11
00
Truth table0%0/2
A
A= $$ir{"kind"}
Aresult
11
00
Truth table0%0/2
A
A= $$ir{"name"}
Aresult
11
00
Truth table0%0/2
A
A= $$s{"secretName"}
Aresult
11
00
2111 ' Issuer Ref:', ' Group: ' . ( $ir->{group} // 'cert-manager.io' ), ' Kind: ' . ( $ir->{kind} // 'Issuer' ), ' Name: ' . ( $ir->{name} // '' ),
2112 ' Secret Name: ' . ( $s->{secretName} // '' ), 'Status:', ' Conditions:', ' Type: Ready', ' Status: ' . _cond_text( $st->{ready} ), " Reason: $st->{reason}", " Message: $st->{message}",
2113 0 ( $st->{ready} ? ( 'Events:', ' Type Reason Age From Message', ' ---- ------ ---- ---- -------',
2114 " Normal Issuing 3d cert-manager-certificates-issuing The certificate has been successfully issued" )
2115 : ( 'Events:', ' Type Reason Age From Message', ' ---- ------ ---- ---- -------',
2116 " Normal Requested 12m cert-manager-certificates-request-manager Created new CertificateRequest resource \"$name-1\"" ) );
2117 }
2118 ▶ elsif ( $kind eq 'issuers' || $kind eq 'clusterissuers' ) {
Condition33%1/3
$kind eq "issuers" or $kind eq "clusterissuers"
l!l&&r!l&&!r
010
MC/DC0%0/2
$kind eq "issuers" or $kind eq "clusterissuers"
$kind eq "issuers" $kind eq "clusterissuers"
Truth table33%1/3
A or B
A= $kind eq "issuers"B= $kind eq "clusterissuers"
ABresult
1X1
011
000
2119 1 ▶ my ( $ok, $reason, $msg ) = _issuer_state( $k, $x, $kind eq 'issuers' ? $ns : _cm_ns($k) );
Branch: 1 branch
BranchTrueFalseTotal
$kind eq 'issuers' ? : 0 1 1
2120 1 my $spec = do { local $YAML::XS::Boolean = q{JSON::PP}; YAML::XS::Dump($s) } =~ s/\A---\n//r;
2121 1 push @l, "API Version: cert-manager.io/v1", "Kind: $GEN{$kind}[1]", 'Spec:', ( map {" $_"} split /\n/, $spec ),
2122 'Status:', ' Conditions:', ' Type: Ready', ' Status: ' . _cond_text($ok), " Reason: $reason", " Message: $msg", 'Events: <none>';
2123 }
2124 elsif ( $kind eq 'ingressclasses' ) {
2125 0 ▶ push @l, 'Controller: ' . ( $s->{controller} // '' ), 'Events: <none>';
Condition0%0/2
$$s{"controller"} // ""
l!l
00
MC/DC0%0/1
$$s{"controller"} // ""
$$s{"controller"}
Truth table0%0/2
A
A= $$s{"controller"}
Aresult
11
00
2126 }
2127 2 return ( join( "\n", @l ), 1 );
2128 }
2129  
2130 # --- kubectl create fuer RBAC und TLS ---------------------------------------------
2131  
2132 7 ▶sub _create_more {
Subroutine _create_more: called CC=50 SCAR=44.3
2133 7 my ( $k, $a, $o, $dev ) = @_;
2134 7 my ( $what, $name ) = @$a;
2135 7 ▶ my $f = $o->{f} || {};
Condition100%2/2
$$o{'f'} || {}
l!l
61
MC/DC100%1/1
$$o{'f'} || {}
$$o{'f'}
Truth table100%2/2
A
A= $$o{'f'}
Aresult
11
00
2136 7 my $ns = $o->{ns};
2137 7 ▶ my $split = sub { map { split /,/ } @{ $f->{ $_[0] } || [] } };
Subroutine __ANON__: called CC=2 SCAR=6.9
Condition100%2/2
$$f{$_[0]} || []
l!l
51
MC/DC100%1/1
$$f{$_[0]} || []
$$f{$_[0]}
Truth table100%2/2
A
A= $$f{$_[0]}
Aresult
11
00
2138 7 ▶ if ( $what =~ /\A(?:serviceaccount|sa)\z/ ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($what =~ /\A(?:serviceaccount|sa)\z/) 1 6 7
2139 1 ▶ return ( 'error: exactly one NAME is required, got 0', 0 ) unless defined $name;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $name 0 1 1
2140 1 ▶ return ( qq{error: failed to create serviceaccount: serviceaccounts "$name" already exists}, 0 ) if $name eq 'default' || $k->{namespaces}{$ns}{serviceaccounts}{$name};
Branch: 1 branch
BranchTrueFalseTotal
if $name eq "default" or $$k{"namespaces"}{$ns}{"serviceaccounts"}{$name} 0 1 1
Condition33%1/3
$name eq "default" or $$k{"namespaces"}{$ns}{"serviceaccounts"}{$name}
l!l&&r!l&&!r
001
MC/DC0%0/2
$name eq "default" or $$k{"namespaces"}{$ns}{"serviceaccounts"}{$name}
$name eq "default" $$k{"namespaces"}{$ns}{"serviceaccounts"}{$name}
Truth table33%1/3
A or B
A= $name eq "default"B= $$k{"namespaces"}{$ns}{"serviceaccounts"}{$name}
ABresult
1X1
011
000
2141 1 $k->{namespaces}{$ns}{serviceaccounts}{$name} = {};
2142 1 return ( "serviceaccount/$name created", 1 );
2143 }
2144 6 ▶ if ( $what eq 'role' || $what eq 'clusterrole' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($what eq "role" or $what eq "clusterrole") 2 4 6
Condition66%2/3
$what eq "role" or $what eq "clusterrole"
l!l&&r!l&&!r
204
MC/DC50%1/2
$what eq "role" or $what eq "clusterrole"
$what eq "role" $what eq "clusterrole"
Truth table66%2/3
A or B
A= $what eq "role"B= $what eq "clusterrole"
ABresult
1X1
011
000
2145 2 ▶ my $kind = $what eq 'role' ? 'roles' : 'clusterroles';
Branch: 1 branch
BranchTrueFalseTotal
$what eq 'role' ? : 2 0 2
2146 2 ▶ return ( 'error: exactly one NAME is required, got 0', 0 ) unless defined $name;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $name 0 2 2
2147 2 my @verbs = $split->('verb');
2148 2 ▶ return ( 'error: at least one verb must be specified', 0 ) unless @verbs;
Branch: 1 branch
BranchTrueFalseTotal
unless @verbs 0 2 2
2149 2 my @res = $split->('resource');
2150 2 ▶ return ( 'error: at least one resource must be specified', 0 ) unless @res;
Branch: 1 branch
BranchTrueFalseTotal
unless @res 0 2 2
2151 2 my %g;
2152 my @order;
2153 2 for my $r (@res) {
2154 2 my ( $p, $grp ) = _resource($r);
2155 2 ▶ return ( qq{error: the server doesn't have a resource type "$r"}, 0 ) unless defined $p;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $p 0 2 2
2156 2 ▶ push @order, $grp unless $g{$grp};
Branch: 1 branch
BranchTrueFalseTotal
unless $g{$grp} 2 0 2
2157 2 push @{ $g{$grp} }, $p;
2158 }
2159 2 my @rn = $split->('resource-name');
2160 2 my $t = _target( $k, $o, $kind );
2161 2 ▶ return ( qq{error: failed to create $what: $kind "$name" already exists}, 0 ) if $t->{$name};
Branch: 1 branch
BranchTrueFalseTotal
if $$t{$name} 0 2 2
2162 2 ▶ $t->{$name} = { rules => [ map { { apiGroups => [$_], resources => $g{$_}, verbs => [@verbs], ( @rn ? ( resourceNames => [@rn] ) : () ) } } @order ] };
Branch: 1 branch
BranchTrueFalseTotal
@rn ? : 1 1 2
2163 2 return ( "$GEN{$kind}[3]/$name created", 1 );
2164 }
2165 4 ▶ if ( $what eq 'rolebinding' || $what eq 'clusterrolebinding' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($what eq "rolebinding" or $what eq "clusterrolebinding") 3 1 4
Condition66%2/3
$what eq "rolebinding" or $what eq "clusterrolebinding"
l!l&&r!l&&!r
301
MC/DC50%1/2
$what eq "rolebinding" or $what eq "clusterrolebinding"
$what eq "rolebinding" $what eq "clusterrolebinding"
Truth table66%2/3
A or B
A= $what eq "rolebinding"B= $what eq "clusterrolebinding"
ABresult
1X1
011
000
2166 3 my $kind = "${what}s";
2167 3 ▶ return ( 'error: exactly one NAME is required, got 0', 0 ) unless defined $name;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $name 0 3 3
2168 3 ▶ my ($role) = @{ $f->{role} || [] };
Condition100%2/2
$$f{'role'} || []
l!l
21
MC/DC100%1/1
$$f{'role'} || []
$$f{'role'}
Truth table100%2/2
A
A= $$f{'role'}
Aresult
11
00
2169 3 ▶ my ($cr) = @{ $f->{clusterrole} || [] };
Condition100%2/2
$$f{'clusterrole'} || []
l!l
12
MC/DC100%1/1
$$f{'clusterrole'} || []
$$f{'clusterrole'}
Truth table100%2/2
A
A= $$f{'clusterrole'}
Aresult
11
00
2170 3 ▶ return ( 'error: exactly one of clusterrole or role must be specified', 0 ) unless defined $role xor defined $cr;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $role xor defined $cr 0 3 3
Condition50%2/4
defined $role xor defined $cr
l&&rl&&!r!l&&r!l&&!r
0210
MC/DC0%0/2
defined $role xor defined $cr
defined $role defined $cr
Truth table50%2/4
A xor B
A= defined $roleB= defined $cr
ABresult
110
101
011
000
2171 3 ▶ return ( 'error: unknown flag: --role', 0 ) if $what eq 'clusterrolebinding' && defined $role;
Branch: 1 branch
BranchTrueFalseTotal
if $what eq "clusterrolebinding" and defined $role 0 3 3
Condition33%1/3
$what eq "clusterrolebinding" and defined $role
!ll&&!rl&&r
300
MC/DC0%0/2
$what eq "clusterrolebinding" and defined $role
$what eq "clusterrolebinding" defined $role
Truth table33%1/3
A and B
A= $what eq "clusterrolebinding"B= defined $role
ABresult
0X0
100
111
2172 3 my @subj;
2173 3 ▶ for my $s ( @{ $f->{serviceaccount} || [] } ) {
Condition100%2/2
$$f{'serviceaccount'} || []
l!l
12
MC/DC100%1/1
$$f{'serviceaccount'} || []
$$f{'serviceaccount'}
Truth table100%2/2
A
A= $$f{'serviceaccount'}
Aresult
11
00
2174 1 my ( $sns, $sn ) = split /:/, $s, 2;
2175 1 ▶ return ( "error: serviceaccount must be <namespace>:<name>", 0 ) unless defined $sn && length $sns && length $sn;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $sn and length $sns and length $sn 0 1 1
Condition33%2/6
defined $sn and length $sns and length $sn
!ll&&!rl&&r
001
defined $sn and length $sns
!ll&&!rl&&r
001
MC/DC0%0/3
defined $sn and length $sns and length $sn
defined $sn length $sns length $sn
Truth table25%1/4
A and B and C
A= defined $snB= length $snsC= length $sn
ABCresult
0XX0
10X0
1100
1111
2176 1 push @subj, { kind => 'ServiceAccount', name => $sn, namespace => $sns };
2177 }
2178 3 ▶ push @subj, map { { kind => 'User', apiGroup => 'rbac.authorization.k8s.io', name => $_ } } @{ $f->{user} || [] };
Condition100%2/2
$$f{'user'} || []
l!l
12
MC/DC100%1/1
$$f{'user'} || []
$$f{'user'}
Truth table100%2/2
A
A= $$f{'user'}
Aresult
11
00
2179 3 ▶ push @subj, map { { kind => 'Group', apiGroup => 'rbac.authorization.k8s.io', name => $_ } } @{ $f->{group} || [] };
Condition100%2/2
$$f{'group'} || []
l!l
12
MC/DC100%1/1
$$f{'group'} || []
$$f{'group'}
Truth table100%2/2
A
A= $$f{'group'}
Aresult
11
00
2180 3 my $t = _target( $k, $o, $kind );
2181 3 ▶ return ( qq{error: failed to create $what: $kind "$name" already exists}, 0 ) if $t->{$name};
Branch: 1 branch
BranchTrueFalseTotal
if $$t{$name} 0 3 3
2182 3 ▶ $t->{$name} = { roleRef => { apiGroup => 'rbac.authorization.k8s.io', kind => defined $role ? 'Role' : 'ClusterRole', name => $role // $cr }, ( @subj ? ( subjects => \@subj ) : () ) };
Branch: 2 branches
BranchTrueFalseTotal
defined $role ? : 2 1 3
@subj ? : 3 0 3
Condition66%2/3
$role // $cr
l!l&&r!l&&!r
210
MC/DC0%0/2
$role // $cr
$role $cr
Truth table66%2/3
A // B
A= $roleB= $cr
ABresult
1X1
011
000
2183 3 return ( "$GEN{$kind}[3]/$name created", 1 );
2184 }
2185 1 ▶ if ( $what eq 'secret' && ( $name // '' ) eq 'tls' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($what eq "secret" and ($name // "") eq "tls") 1 0 1
Condition40%2/5
$what eq "secret" and ($name // "") eq "tls"
!ll&&!rl&&r
001
$name // ""
l!l
10
MC/DC0%0/2
$what eq "secret" and ($name // "") eq "tls"
$what eq "secret" $name
Truth table33%1/3
A and B
A= $what eq "secret"B= $name
ABresult
0X0
100
111
2186 1 ▶ my $sn = $a->[2] // return ( 'error: exactly one NAME is required, got 0', 0 );
Condition50%1/2
$$a[2] // (return "error: exactly one NAME is required, got 0", 0)
l!l
10
MC/DC0%0/1
$$a[2] // (return "error: exactly one NAME is required, got 0", 0)
$$a[2]
Truth table50%1/2
A
A= $$a[2]
Aresult
11
00
2187 1 ▶ my ($cert) = @{ $f->{cert} || [] };
Condition50%1/2
$$f{'cert'} || []
l!l
10
MC/DC0%0/1
$$f{'cert'} || []
$$f{'cert'}
Truth table50%1/2
A
A= $$f{'cert'}
Aresult
11
00
2188 1 ▶ my ($key) = @{ $f->{key} || [] };
Condition50%1/2
$$f{'key'} || []
l!l
10
MC/DC0%0/1
$$f{'key'} || []
$$f{'key'}
Truth table50%1/2
A
A= $$f{'key'}
Aresult
11
00
2189 1 ▶ return ( 'error: load key pair: open : no such file or directory', 0 ) unless defined $cert && defined $key;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $cert and defined $key 0 1 1
Condition33%1/3
defined $cert and defined $key
!ll&&!rl&&r
001
MC/DC0%0/2
defined $cert and defined $key
defined $cert defined $key
Truth table33%1/3
A and B
A= defined $certB= defined $key
ABresult
0X0
100
111
2190 1 my %t;
2191 1 for ( [ 'tls.crt', $cert ], [ 'tls.key', $key ] ) {
2192 2 ▶ my $fe = ( $dev->{files} || {} )->{ $_->[1] };
Condition50%1/2
$$dev{'files'} || {}
l!l
20
MC/DC0%0/1
$$dev{'files'} || {}
$$dev{'files'}
Truth table50%1/2
A
A= $$dev{'files'}
Aresult
11
00
2193 2 ▶ $fe = $fe->{content} if ref $fe eq 'HASH';
Branch: 1 branch
BranchTrueFalseTotal
if ref $fe eq "HASH" 0 2 2
2194 2 ▶ return ( "error: open $_->[1]: no such file or directory", 0 ) unless defined $fe;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $fe 0 2 2
2195 2 $t{ $_->[0] } = $fe;
2196 }
2197 1 ▶ return ( qq{error: failed to create secret secrets "$sn" already exists}, 0 ) if $k->{namespaces}{$ns}{secrets}{$sn};
Branch: 1 branch
BranchTrueFalseTotal
if $$k{"namespaces"}{$ns}{"secrets"}{$sn} 0 1 1
2198 1 $k->{namespaces}{$ns}{secrets}{$sn} = \%t;
2199 1 return ( "secret/$sn created", 1 );
2200 }
2201 0 return;
2202 }
2203 0 ▶sub _v_edit { push @GAPS, 'kubectl edit'; return ( 'error: Edit cancelled, no valid changes were saved.', 0 ) }
Subroutine _v_edit: not called CC=1 SCAR=6.9
2204 0 ▶sub _v_explain { push @GAPS, 'kubectl explain'; return ( '', 0 ) }
Subroutine _v_explain: not called CC=1 SCAR=6.9
2205 0 ▶sub _v_top { return ( 'error: Metrics API not available', 0 ) }
Subroutine _v_top: not called CC=1 SCAR=6.9
2206  
2207 # ReplicaSets der Deployments (das aktuelle je Deployment)
2208 2 ▶sub _replicasets {
Subroutine _replicasets: called CC=7 SCAR=19.8
2209 2 my ( $k, $ns ) = @_;
2210 2 ▶ my $o = $k->{namespaces}{$ns} or return ();
Branch: 1 branch
BranchTrueFalseTotal
my $o = $$k{"namespaces"}{$ns} or return () 2 0 2
2211 2 my @p = _pods( $k, $ns );
2212 2 my @r;
2213 2 ▶ for my $d ( sort keys %{ $o->{deployments} || {} } ) {
Condition50%1/2
$$o{'deployments'} || {}
l!l
20
MC/DC0%0/1
$$o{'deployments'} || {}
$$o{'deployments'}
Truth table50%1/2
A
A= $$o{'deployments'}
Aresult
11
00
2214 8 my $dep = $o->{deployments}{$d};
2215 8 ▶ my $h = _hash( [ $dep->{template}, $dep->{restarted_at} // '' ] );
Condition50%1/2
$$dep{"restarted_at"} // ""
l!l
08
MC/DC0%0/1
$$dep{"restarted_at"} // ""
$$dep{"restarted_at"}
Truth table50%1/2
A
A= $$dep{"restarted_at"}
Aresult
11
00
2216 8 my @dp = grep { $_->{deployment} eq $d } @p;
2217 8 my $sa = $dep->{template}{service_account};
2218 8 ▶ push @r, { name => "$d-$h", deployment => $d, desired => $dep->{replicas} // 1, current => scalar @dp, ready => scalar( grep { $_->{ready} } @dp ),
Branch: 1 branch
BranchTrueFalseTotal
_sa_exists($k, $ns, $sa) ? : 6 2 8
Condition50%1/2
$$dep{"replicas"} // 1
l!l
80
MC/DC0%0/1
$$dep{"replicas"} // 1
$$dep{"replicas"}
Truth table50%1/2
A
A= $$dep{"replicas"}
Aresult
11
00
2219 ( _sa_exists( $k, $ns, $sa ) ? () : ( failed => qq{Error creating: pods "$d-$h-" is forbidden: error looking up service account $ns/$sa: serviceaccount "$sa" not found} ) ) };
2220 }
2221 2 return @r;
2222 }
2223  
2224 1 ▶sub _v_api_versions {
Subroutine _v_api_versions: called CC=1 SCAR=0.0
2225 1 return ( join( "\n", qw( acme.cert-manager.io/v1 admissionregistration.k8s.io/v1 apiextensions.k8s.io/v1 apps/v1 authorization.k8s.io/v1 autoscaling/v2 batch/v1
2226 cert-manager.io/v1 coordination.k8s.io/v1 discovery.k8s.io/v1 events.k8s.io/v1 networking.k8s.io/v1 node.k8s.io/v1 policy/v1 rbac.authorization.k8s.io/v1
2227 scheduling.k8s.io/v1 storage.k8s.io/v1 v1 ) ), 1 );
2228 }
2229  
2230 0 ▶sub _v_api_resources {
Subroutine _v_api_resources: not called CC=7 SCAR=40.3
2231 0 my @r = ( [qw( NAME SHORTNAMES APIVERSION NAMESPACED KIND )] );
2232 0 my %short = ( pods => 'po', services => 'svc', deployments => 'deploy', ingresses => 'ing', serviceaccounts => 'sa', certificates => 'cert,certs', persistentvolumeclaims => 'pvc',
2233 networkpolicies => 'netpol', replicasets => 'rs', configmaps => 'cm', namespaces => 'ns', nodes => 'no', storageclasses => 'sc', certificaterequests => 'cr,crs', events => 'ev' );
2234 0 my %kind = ( %APIKIND, pods => 'Pod', replicasets => 'ReplicaSet', endpoints => 'Endpoints', nodes => 'Node', events => 'Event', certificaterequests => 'CertificateRequest', orders => 'Order', challenges => 'Challenge' );
2235 0 for my $int ( sort keys %kind ) {
2236 0 ▶ my $p = $API_PLURAL{$int} // $int;
Condition0%0/3
$API_PLURAL{$int} // $int
l!l&&r!l&&!r
000
MC/DC0%0/2
$API_PLURAL{$int} // $int
$API_PLURAL{$int} $int
Truth table0%0/3
A // B
A= $API_PLURAL{$int}B= $int
ABresult
1X1
011
000
2237 0 ▶ my $g = $GROUP{$p} // '';
Condition0%0/2
$Langertha::Holmgang::Sim::Linux::Kubernetes::GROUP{$p} // ""
l!l
00
MC/DC0%0/1
$Langertha::Holmgang::Sim::Linux::Kubernetes::GROUP{$p} // ""
$Langertha::Holmgang::Sim::Linux::Kubernetes::GROUP{$p}
Truth table0%0/2
A
A= $Langertha::Holmgang::Sim::Linux::Kubernetes::GROUP{$p}
Aresult
11
00
2238 0 ▶ push @r, [ $p, $short{$p} // '', ( $g eq '' ? 'v1' : "$g/v1" ), ( $CLUSTER{$int} ? 'false' : 'true' ), $kind{$int} ];
Branch: 2 branches
BranchTrueFalseTotal
$g eq '' ? : 0 0 0
$Langertha::Holmgang::Sim::Linux::Kubernetes::CLUSTER{$int} ? : 0 0 0
Condition0%0/2
$short{$p} // ""
l!l
00
MC/DC0%0/1
$short{$p} // ""
$short{$p}
Truth table0%0/2
A
A= $short{$p}
Aresult
11
00
2239 }
2240 0 return ( _cols(@r), 1 );
2241 }
2242  
2243 5 1;
2244  
2245 __END__
« blib/lib/Langertha/Holmgang/Sim/Linux/Redis.pm ↑ Summary blib/lib/Langertha/Holmgang/Shell.pm »