| 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"
MC/DC100%1/1
$method //= "script"
$method
Truth table100%2/2
A
A= $method
| |||||||||||||||||||||||||||||||||||||||||||
| 12 | 254 | ▶ | die "Unknown install_method: $method (expected 'script' or 'artifact')\n" | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$method eq "script" or $method eq "artifact"
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"
| |||||||||||||||||||||||||||||||||||||||||||
| 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
Condition100%3/3
$method eq "artifact" and not $version
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
| |||||||||||||||||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||||||||||||||||
| 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
Condition100%6/6
@part and not grep({$_ > 255;} @part[0..3]) and $part[4] <= 32
@part and not grep({$_ > 255;} @part[0..3])
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
| |||||||||||||||||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||||||||||||||||
| 34 | 26 | ▶ | die "kubeconfig_mode must be an octal file mode as a string such as '0640', " | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
not ref $mode and $mode =~ /\A0[0-7]{3}\z/u
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
| |||||||||||||||||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||||||||||||||||
| 43 | 21 | ▶ | die "ipam_mode must be 'kubernetes' or 'cluster-pool', got '$mode' (other " | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$mode eq "kubernetes" or $mode eq "cluster-pool"
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"
| |||||||||||||||||||||||||||||||||||||||||||
| 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__ | ||||||||||||||||||||||||||||||||||||||||||