blib/lib/Kubernetes/Comb/Endpoint.pm

filter: Statementstmt 100% 34 / 34 Branchbran 100% 10 / 10 Conditioncond 75.0% 6 / 8 MC/DCmcdc 50.0% 2 / 4 Subroutinesub 100% 10 / 10 Podpod 80.0% 4 / 5 totaltotal 92.9% 66 / 71 CC 9 SCAR 9.9
CC
9
Cov
96%
name_problem
5.1
to_crd
3.0
BUILD
2.0
CRAP 2.7
« blib/lib/Kubernetes/Comb/Role/Static.pm ↑ Summary blib/lib/Kubernetes/Comb/Upstream/Static.pm »
1 package Kubernetes::Comb::Endpoint;
2 # ABSTRACT: Value object for an endpoint a Comb offers
3 18 our $VERSION = '0.002';
4  
5 18 ▶use Moo;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 18 ▶use Carp qw( croak );
Subroutine BEGIN: called CC=1 SCAR=0.0
7 18 ▶use Types::Standard qw( Int Str );
Subroutine BEGIN: called CC=1 SCAR=0.0
8 18 ▶use Kubernetes::Comb::CRD::CombEndpoint;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 18 ▶use namespace::autoclean;
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11  
12 18 has name => ( is => 'ro', isa => Str, required => 1 );
13  
14  
15 18 has protocol => ( is => 'ro', isa => Str, default => 'tcp' );
16  
17  
18 18 has port => ( is => 'ro', isa => Int, required => 1 );
19  
20  
21 18 has cluster => ( is => 'ro', isa => Str, predicate => 1 );
22  
23  
24 18 has external => ( is => 'ro', isa => Str, predicate => 1 );
25  
26  
27 198 ▶sub BUILD {
Subroutine BUILD: called CC=2 SCAR=6.9
Pod undocumented
28 198 my ( $self ) = @_;
29 198 my $problem = $self->name_problem( $self->name );
30 198 ▶ croak ref($self).': '.$problem if defined $problem;
Branch: 1 branch
BranchTrueFalseTotal
if defined $problem 7 191 198
31 }
32  
33 405 ▶sub name_problem {
Subroutine name_problem: called CC=5 SCAR=16.3
Pod documented
34 405 my ( $self, $name ) = @_;
35 405 ▶ return if defined $name && length $name <= 63 && $name =~ /\A[a-z0-9](?:[-a-z0-9]*[a-z0-9])?\z/;
Branch: 1 branch
BranchTrueFalseTotal
if defined $name and length $name <= 63 and $name =~ /\A[a-z0-9](?:[-a-z0-9]*[a-z0-9])?\z/ 395 10 405
Condition83%5/6
defined $name and length $name <= 63 and $name =~ /\A[a-z0-9](?:[-a-z0-9]*[a-z0-9])?\z/
!ll&&!rl&&r
19395
defined $name and length $name <= 63
!ll&&!rl&&r
01404
MC/DC66%2/3
defined $name and length $name <= 63 and $name =~ /\A[a-z0-9](?:[-a-z0-9]*[a-z0-9])?\z/
defined $name length $name <= 63 $name =~ /\A[a-z0-9](?:[-a-z0-9]*[a-z0-9])?\z/
Truth table75%3/4
A and B and C
A= defined $nameB= length $name <= 63C= $name =~ /\A[a-z0-9](?:[-a-z0-9]*[a-z0-9])?\z/
ABCresult
0XX0
10X0
1100
1111
36 10 ▶ return "the name '".( $name // '' )."' is not a DNS-1123 label (lowercase letters, digits and -, "
Condition50%1/2
$name // ""
l!l
100
MC/DC0%0/1
$name // ""
$name
Truth table50%1/2
A
A= $name
Aresult
11
00
37 .'alphanumeric at both ends, at most 63 characters), as the name of a Service port must be';
38 }
39  
40  
41 71 ▶sub crd_endpoint_class { 'Kubernetes::Comb::CRD::CombEndpoint' }
Subroutine crd_endpoint_class: called CC=1 SCAR=0.0
Pod documented
42  
43  
44 2 ▶sub from_crd {
Subroutine from_crd: called CC=2 SCAR=6.9
Pod documented
45 2 my ( $class, $entry ) = @_;
46 return $class->new(
47 2 ▶ map { defined $entry->$_ ? ( $_ => $entry->$_ ) : () }
Branch: 1 branch
BranchTrueFalseTotal
defined $entry->$_ ? : 7 3 10
48 qw( name protocol port cluster external )
49 );
50 }
51  
52  
53 71 ▶sub to_crd {
Subroutine to_crd: called CC=3 SCAR=11.0
Pod documented
54 71 my ( $self ) = @_;
55 71 ▶ return $self->crd_endpoint_class->new(
Branch: 2 branches
BranchTrueFalseTotal
$self->has_cluster ? : 69 2 71
$self->has_external ? : 19 52 71
56 name => $self->name,
57 protocol => $self->protocol,
58 port => $self->port,
59 ( $self->has_cluster ? ( cluster => $self->cluster ) : () ),
60 ( $self->has_external ? ( external => $self->external ) : () )
61 );
62 }
63  
64  
65 18 1;
66  
67 __END__
« blib/lib/Kubernetes/Comb/Role/Static.pm ↑ Summary blib/lib/Kubernetes/Comb/Upstream/Static.pm »