lib/WWW/Hetzner/CLI/Cmd/LoadBalancer/Cmd/Describe.pm

filter: Statementstmt 92.8% 39 / 42 Branchbran 41.6% 5 / 12 Conditioncond 42.8% 9 / 21 MC/DCmcdc 0.0% 0 / 12 Subroutinesub 100% 5 / 5 Podpod 0.0% 0 / 1 totaltotal 62.3% 58 / 93 CC 18 SCAR 33.1
CC
18
Cov
71%
execute
33.2
BEGIN
1.0
BEGIN
1.0
CRAP 27.3
« lib/WWW/Hetzner/CLI/Cmd/StorageBox/Cmd/Create.pm ↑ Summary lib/WWW/Hetzner/Robot/CLI/Cmd/Traffic.pm »
1 package WWW::Hetzner::CLI::Cmd::LoadBalancer::Cmd::Describe;
2 # ABSTRACT: Describe a load balancer
3  
4 1 our $VERSION = '0.102';
5  
6 1 ▶use Moo;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 1 ▶use MooX::Cmd;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 1 ▶use MooX::Options protect_argv => 0, usage_string => 'USAGE: hcloud.pl load-balancer describe <id>';
Subroutine BEGIN: called CC=1 SCAR=0.0
9 1 ▶use JSON::MaybeXS qw(encode_json);
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11 1 ▶sub execute {
Subroutine execute: called CC=18 SCAR=35.0
Pod undocumented
12 1 my ($self, $args, $chain) = @_;
13 1 ▶ my $id = $args->[0] or die "Usage: hcloud.pl load-balancer describe <id>\n";
Branch: 1 branch
BranchTrueFalseTotal
my $id = $args->[0] or die "Usage: hcloud.pl load-balancer describe <id>\n" 1 0 1
14  
15 1 my $main = $chain->[0];
16 1 my $cloud = $main->cloud;
17  
18 1 my $lb = $cloud->load_balancers->get($id);
19  
20 1 ▶ if ($main->output eq 'json') {
Branch: 1 branch
BranchTrueFalseTotal
if ($main->output eq "json") 0 1 1
21 0 print encode_json($lb->data), "\n";
22 0 return;
23 }
24  
25 1 printf "ID: %s\n", $lb->id;
26 1 printf "Name: %s\n", $lb->name;
27 1 ▶ printf "Type: %s\n", $lb->type_name // '-';
Condition50%1/2
$lb->type_name // "-"
l!l
10
MC/DC0%0/1
$lb->type_name // "-"
$lb->type_name
Truth table50%1/2
A
A= $lb->type_name
Aresult
11
00
28 1 ▶ printf "IPv4: %s\n", $lb->ipv4 // '-';
Condition50%1/2
$lb->ipv4 // "-"
l!l
10
MC/DC0%0/1
$lb->ipv4 // "-"
$lb->ipv4
Truth table50%1/2
A
A= $lb->ipv4
Aresult
11
00
29 1 ▶ printf "IPv6: %s\n", $lb->ipv6 // '-';
Condition50%1/2
$lb->ipv6 // "-"
l!l
10
MC/DC0%0/1
$lb->ipv6 // "-"
$lb->ipv6
Truth table50%1/2
A
A= $lb->ipv6
Aresult
11
00
30 1 ▶ printf "Location: %s\n", $lb->location_name // '-';
Condition50%1/2
$lb->location_name // "-"
l!l
10
MC/DC0%0/1
$lb->location_name // "-"
$lb->location_name
Truth table50%1/2
A
A= $lb->location_name
Aresult
11
00
31 1 ▶ printf "Algorithm: %s\n", $lb->algorithm->{type} // '-';
Condition50%1/2
$lb->algorithm->{"type"} // "-"
l!l
10
MC/DC0%0/1
$lb->algorithm->{"type"} // "-"
$lb->algorithm->{"type"}
Truth table50%1/2
A
A= $lb->algorithm->{"type"}
Aresult
11
00
32 1 ▶ printf "Created: %s\n", $lb->created // '-';
Condition50%1/2
$lb->created // "-"
l!l
10
MC/DC0%0/1
$lb->created // "-"
$lb->created
Truth table50%1/2
A
A= $lb->created
Aresult
11
00
33  
34 1 my $targets = $lb->targets;
35 1 ▶ if ($targets && @$targets) {
Branch: 1 branch
BranchTrueFalseTotal
if ($targets and @$targets) 1 0 1
Condition33%1/3
$targets and @$targets
!ll&&!rl&&r
001
MC/DC0%0/2
$targets and @$targets
$targets @$targets
Truth table33%1/3
A and B
A= $targetsB= @$targets
ABresult
0X0
100
111
36 1 print "\nTargets:\n";
37 1 for my $t (@$targets) {
38 1 ▶ if ($t->{type} eq 'server' && $t->{server}) {
Branch: 2 branches
BranchTrueFalseTotal
if ($t->{'type'} eq 'server' and $t->{'server'}) { } 1 0 1
elsif ($t->{'type'} eq 'label_selector') { } 0 0 0
Condition33%1/3
$t->{"type"} eq "server" and $t->{"server"}
!ll&&!rl&&r
001
MC/DC0%0/2
$t->{"type"} eq "server" and $t->{"server"}
$t->{"type"} eq "server" $t->{"server"}
Truth table33%1/3
A and B
A= $t->{"type"} eq "server"B= $t->{"server"}
ABresult
0X0
100
111
39 1 printf " - Server %d\n", $t->{server}{id};
40 } elsif ($t->{type} eq 'label_selector') {
41 0 printf " - Label: %s\n", $t->{label_selector}{selector};
42 }
43 }
44 }
45  
46 1 my $services = $lb->services;
47 1 ▶ if ($services && @$services) {
Branch: 1 branch
BranchTrueFalseTotal
if ($services and @$services) 1 0 1
Condition33%1/3
$services and @$services
!ll&&!rl&&r
001
MC/DC0%0/2
$services and @$services
$services @$services
Truth table33%1/3
A and B
A= $servicesB= @$services
ABresult
0X0
100
111
48 1 print "\nServices:\n";
49 1 for my $s (@$services) {
50 printf " - %s :%d -> :%d\n",
51 $s->{protocol},
52 $s->{listen_port},
53 1 $s->{destination_port};
54 }
55 }
56 }
57  
58 1 1;
59  
60 __END__
« lib/WWW/Hetzner/CLI/Cmd/StorageBox/Cmd/Create.pm ↑ Summary lib/WWW/Hetzner/Robot/CLI/Cmd/Traffic.pm »