lib/Rex/Rancher/Options.pm

filter: Statementstmt 100% 26 / 26 Branchbran 100% 16 / 16 Conditioncond 100% 20 / 20 MC/DCmcdc 100% 12 / 12 Subroutinesub 100% 6 / 6 Podpod 100% 4 / 4 totaltotal 100% 84 / 84 CC 16 SCAR 15.1
CC
16
Cov
100%
resolve_install_method
6.0
check_cluster_cidr
5.0
check_kubeconfig_mode
4.0
CRAP 4.5
« blib/lib/Rex/Rancher/Node.pm ↑ Summary lib/Rex/Rancher/Agent.pm »
1 # ABSTRACT: Pure checks of install options, before anything touches the host
2  
3 package Rex::Rancher::Options;
4 63 our $VERSION = '0.004';
5 63 ▶use v5.14.4;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 63 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8  
9 254 ▶sub resolve_install_method {
Subroutine resolve_install_method: called CC=6 SCAR=17.9
Pod documented
10 254 my ( $self, $method, $version ) = @_;
11 254 ▶ $method //= 'script';
Condition100%2/2
$method //= "script"
l!l
16238
MC/DC100%1/1
$method //= "script"
$method
Truth table100%2/2
A
A= $method
Aresult
11
00
12 254 ▶ die "Unknown install_method: $method (expected 'script' or 'artifact')\n"
Branch: 1 branch
BranchTrueFalseTotal
unless $method eq "script" or $method eq "artifact" 3 251 254
Condition100%3/3
$method eq "script" or $method eq "artifact"
l!l&&r!l&&!r
239123
MC/DC100%2/2
$method eq "script" or $method eq "artifact"
$method eq "script" $method eq "artifact"
Truth table100%3/3
A or B
A= $method eq "script"B= $method eq "artifact"
ABresult
1X1
011
000
13 unless $method eq 'script' || $method eq 'artifact';
14 251 ▶ die "install_method 'artifact' requires a version (e.g. v1.30.4+rke2r1)\n"
Branch: 1 branch
BranchTrueFalseTotal
if $method eq "artifact" and not $version 9 242 251
Condition100%3/3
$method eq "artifact" and not $version
!ll&&!rl&&r
23939
MC/DC100%2/2
$method eq "artifact" and not $version
$method eq "artifact" not $version
Truth table100%3/3
A and not(B)
A= $method eq "artifact"B= not $version
ABresult
0X0
100
111
15 if $method eq 'artifact' && !$version;
16 242 return $method;
17 }
18  
19  
20 427 ▶sub check_cluster_cidr {
Subroutine check_cluster_cidr: called CC=5 SCAR=16.1
Pod documented
21 427 my ( $self, $cidr ) = @_;
22 427 ▶ return unless defined $cidr;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $cidr 344 83 427
23 83 my @part = $cidr =~ m{\A(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})/(\d{1,2})\z};
24 die "cluster_cidr must be one IPv4 CIDR such as 10.42.0.0/16, got '$cidr' "
25 . "(dual-stack is not supported: Cilium's pool is IPv4 here)\n"
26 83 ▶ unless @part && !grep({ $_ > 255 } @part[0 .. 3]) && $part[4] <= 32;
Branch: 1 branch
BranchTrueFalseTotal
unless @part and not grep({$_ > 255;} @part[0..3]) and $part[4] <= 32 20 63 83
Condition100%6/6
@part and not grep({$_ > 255;} @part[0..3]) and $part[4] <= 32
!ll&&!rl&&r
17363
@part and not grep({$_ > 255;} @part[0..3])
!ll&&!rl&&r
14366
MC/DC100%3/3
@part and not grep({$_ > 255;} @part[0..3]) and $part[4] <= 32
@part not grep({$_ > 255;} @part[0..3]) $part[4] <= 32
Truth table100%4/4
A and not(B) and C
A= @partB= not grep({$_ > 255;} @part[0..3])C= $part[4] <= 32
ABCresult
0XX0
10X0
1100
1111
27 63 return $cidr;
28 }
29  
30  
31 166 ▶sub check_kubeconfig_mode {
Subroutine check_kubeconfig_mode: called CC=4 SCAR=13.9
Pod documented
32 166 my ( $self, $mode ) = @_;
33 166 ▶ return unless defined $mode;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $mode 140 26 166
34 26 ▶ die "kubeconfig_mode must be an octal file mode as a string such as '0640', "
Branch: 1 branch
BranchTrueFalseTotal
unless not ref $mode and $mode =~ /\A0[0-7]{3}\z/u 18 8 26
Condition100%3/3
not ref $mode and $mode =~ /\A0[0-7]{3}\z/u
!ll&&!rl&&r
1178
MC/DC100%2/2
not ref $mode and $mode =~ /\A0[0-7]{3}\z/u
not ref $mode $mode =~ /\A0[0-7]{3}\z/u
Truth table100%3/3
not(A) and B
A= not ref $modeB= $mode =~ /\A0[0-7]{3}\z/u
ABresult
0X0
100
111
35 . "got '$mode'\n" unless !ref $mode && $mode =~ /\A0[0-7]{3}\z/;
36 8 return "$mode";
37 }
38  
39  
40 191 ▶sub check_ipam_mode {
Subroutine check_ipam_mode: called CC=4 SCAR=13.9
Pod documented
41 191 my ( $self, $mode ) = @_;
42 191 ▶ return unless defined $mode;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $mode 170 21 191
43 21 ▶ die "ipam_mode must be 'kubernetes' or 'cluster-pool', got '$mode' (other "
Branch: 1 branch
BranchTrueFalseTotal
unless $mode eq "kubernetes" or $mode eq "cluster-pool" 5 16 21
Condition100%3/3
$mode eq "kubernetes" or $mode eq "cluster-pool"
l!l&&r!l&&!r
3135
MC/DC100%2/2
$mode eq "kubernetes" or $mode eq "cluster-pool"
$mode eq "kubernetes" $mode eq "cluster-pool"
Truth table100%3/3
A or B
A= $mode eq "kubernetes"B= $mode eq "cluster-pool"
ABresult
1X1
011
000
44 . "Cilium IPAM modes need more than a mode: set them in helm_values)\n"
45 unless $mode eq 'kubernetes' || $mode eq 'cluster-pool';
46 16 return $mode;
47 }
48  
49 63 1;
50  
51 __END__
« blib/lib/Rex/Rancher/Node.pm ↑ Summary lib/Rex/Rancher/Agent.pm »