Consul/Check.pm

filter: Statementstmt 76.6% 92 / 120 Branchbran 0.0% 0 / 24 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 59.3% 19 / 32 Podpod 0.0% 0 / 6 totaltotal 60.9% 111 / 182 CC 13 SCAR 25.8
CC
13
Cov
64%
smart_new
42.0
_build__json_hash
42.0
_build__json
12.0
CRAP 13.2
« Consul/ACL.pm ↑ Summary Consul/API/KV.pm »
1 package Consul::Check;
2 9 $Consul::Check::VERSION = '0.027';
3 9 ▶use namespace::autoclean;
Subroutine BEGIN: called CC=1 SCAR=0.0
4  
5 9 ▶use Moo::Role;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 9 ▶use Types::Standard qw(Str HashRef Enum);
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 9 ▶use Carp qw(croak);
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 9 my $status_type = Enum['passing', 'warning', 'critical'];
11  
12 9 has name => ( is => 'ro', isa => Str, required => 1 );
13 9 has id => ( is => 'ro', isa => Str );
14 9 has notes => ( is => 'ro', isa => Str );
15 9 has service_id => ( is => 'ro', isa => Str );
16 9 has status => ( is => 'ro', isa => $status_type );
17 9 has deregister_critical_service_after =>
18 ( is => 'ro', isa => Str );
19  
20 0 ▶sub smart_new {
Subroutine smart_new: not called CC=6 SCAR=37.4
Pod undocumented
21 0 my $role = shift;
22 0 my $args = Moo::Object->BUILDARGS( @_ );
23  
24 0 ▶ if (defined $args->{script}) {
Branch: 5 branches
BranchTrueFalseTotal
if (defined $args->{'script'}) { } 0 0 0
elsif (defined $args->{'ttl'}) { } 0 0 0
elsif (defined $args->{'http'}) { } 0 0 0
elsif (defined $args->{'tcp'}) { } 0 0 0
elsif (defined $args->{'docker_container_id'}) { } 0 0 0
25 0 return Consul::Check::Script->new( $args );
26 }
27 elsif (defined $args->{ttl}) {
28 0 return Consul::Check::TTL->new( $args );
29 }
30 elsif (defined $args->{http}) {
31 0 return Consul::Check::HTTP->new( $args );
32 }
33 elsif (defined $args->{tcp}) {
34 0 return Consul::Check::TCP->new( $args );
35 }
36 elsif (defined $args->{docker_container_id}) {
37 0 return Consul::Check::Docker->new( $args );
38 }
39  
40 0 croak 'Cannot create Check object because neither script, ttl, http, tcp, or docker_container_id are set';
41 }
42  
43 0 ▶sub _to_json_hash { %{shift->_json_hash} }
Subroutine _to_json_hash: not called CC=1 SCAR=6.9
44 9 has _json_hash => ( is => 'lazy', isa => HashRef[Str] );
45 0 ▶sub _build__json_hash {
Subroutine _build__json_hash: not called CC=6 SCAR=37.4
46 0 my ($self) = @_;
47 {
48 0 ▶ Name => $self->name,
Branch: 5 branches
BranchTrueFalseTotal
defined $self->id ? : 0 0 0
defined $self->notes ? : 0 0 0
defined $self->service_id ? : 0 0 0
defined $self->status ? : 0 0 0
defined $self->deregister_critical_service_after ? : 0 0 0
49 defined $self->id ? ( ID => $self->id ) : (),
50 defined $self->notes ? ( Notes => $self->notes ) : (),
51 defined $self->service_id ? ( ServiceID => $self->service_id ) : (),
52 defined $self->status ? ( Status => $self->status ) : (),
53 defined $self->deregister_critical_service_after ? (
54 DeregisterCriticalServiceAfter => $self->deregister_critical_service_after
55 ) : (),
56 };
57 }
58  
59 package Consul::Check::Script;
60 9 $Consul::Check::Script::VERSION = '0.027';
61 9 ▶use Moo;
Subroutine BEGIN: called CC=1 SCAR=0.0
62 9 ▶use Types::Standard qw(Str);
Subroutine BEGIN: called CC=1 SCAR=0.0
63 9 ▶use JSON::MaybeXS;
Subroutine BEGIN: called CC=1 SCAR=0.0
64  
65 9 has script => ( is => 'ro', isa => Str, required => 1 );
66 9 has interval => ( is => 'ro', isa => Str, required => 1 );
67  
68 0 ▶sub to_json { shift->_json }
Subroutine to_json: not called CC=1 SCAR=6.9
Pod undocumented
69 9 has _json => ( is => 'lazy', isa => Str );
70 0 ▶sub _build__json {
Subroutine _build__json: not called CC=1 SCAR=6.9
71 0 my ($self) = @_;
72 0 encode_json({
73 $self->_to_json_hash,
74 Script => $self->script,
75 Interval => $self->interval,
76 });
77 }
78  
79 9 with qw(Consul::Check);
80  
81 package Consul::Check::TTL;
82 9 $Consul::Check::TTL::VERSION = '0.027';
83 9 ▶use Moo;
Subroutine BEGIN: called CC=1 SCAR=0.0
84 9 ▶use Types::Standard qw(Str);
Subroutine BEGIN: called CC=1 SCAR=0.0
85 9 ▶use JSON::MaybeXS;
Subroutine BEGIN: called CC=1 SCAR=0.0
86  
87 9 has ttl => ( is => 'ro', isa => Str, required => 1 );
88  
89 0 ▶sub to_json { shift->_json }
Subroutine to_json: not called CC=1 SCAR=6.9
Pod undocumented
90 9 has _json => ( is => 'lazy', isa => Str );
91 0 ▶sub _build__json {
Subroutine _build__json: not called CC=1 SCAR=6.9
92 0 my ($self) = @_;
93 0 encode_json({
94 $self->_to_json_hash,
95 TTL => $self->ttl,
96 });
97 }
98  
99 9 with qw(Consul::Check);
100  
101 package Consul::Check::HTTP;
102 9 $Consul::Check::HTTP::VERSION = '0.027';
103 9 ▶use Moo;
Subroutine BEGIN: called CC=1 SCAR=0.0
104 9 ▶use Types::Standard qw(Str Bool);
Subroutine BEGIN: called CC=1 SCAR=0.0
105 9 ▶use JSON::MaybeXS;
Subroutine BEGIN: called CC=1 SCAR=0.0
106  
107 9 has http => ( is => 'ro', isa => Str, required => 1 );
108 9 has interval => ( is => 'ro', isa => Str, required => 1 );
109 9 has tls_skip_verify => ( is => 'ro', isa => Bool );
110  
111 0 ▶sub to_json { shift->_json }
Subroutine to_json: not called CC=1 SCAR=6.9
Pod undocumented
112 9 has _json => ( is => 'lazy', isa => Str );
113 0 ▶sub _build__json {
Subroutine _build__json: not called CC=3 SCAR=24.8
114 0 my ($self) = @_;
115 0 ▶ encode_json({
Branch: 2 branches
BranchTrueFalseTotal
defined $self->tls_skip_verify ? : 0 0 0
$self->tls_skip_verify ? : 0 0 0
116 $self->_to_json_hash,
117 HTTP => $self->http,
118 Interval => $self->interval,
119 defined $self->tls_skip_verify ? (
120 TLSSkipVerify =>
121 $self->tls_skip_verify ? \1 : \0
122 ) : (),
123 });
124 }
125  
126 package Consul::Check::TCP;
127 9 $Consul::Check::TCP::VERSION = '0.027';
128 9 ▶use Moo;
Subroutine BEGIN: called CC=1 SCAR=0.0
129 9 ▶use Types::Standard qw(Str);
Subroutine BEGIN: called CC=1 SCAR=0.0
130 9 ▶use JSON::MaybeXS;
Subroutine BEGIN: called CC=1 SCAR=0.0
131  
132 9 has tcp => ( is => 'ro', isa => Str, required => 1 );
133 9 has interval => ( is => 'ro', isa => Str, required => 1 );
134  
135 0 ▶sub to_json { shift->_json }
Subroutine to_json: not called CC=1 SCAR=6.9
Pod undocumented
136 9 has _json => ( is => 'lazy', isa => Str );
137 0 ▶sub _build__json {
Subroutine _build__json: not called CC=1 SCAR=6.9
138 0 my ($self) = @_;
139 0 encode_json({
140 $self->_to_json_hash,
141 TCP => $self->tcp,
142 Interval => $self->interval,
143 });
144 }
145  
146 9 with qw(Consul::Check);
147  
148 package Consul::Check::Docker;
149 9 $Consul::Check::Docker::VERSION = '0.027';
150 9 ▶use Moo;
Subroutine BEGIN: called CC=1 SCAR=0.0
151 9 ▶use Types::Standard qw(Str);
Subroutine BEGIN: called CC=1 SCAR=0.0
152 9 ▶use JSON::MaybeXS;
Subroutine BEGIN: called CC=1 SCAR=0.0
153  
154 9 has docker_container_id => ( is => 'ro', isa => Str, required => 1 );
155 9 has interval => ( is => 'ro', isa => Str, required => 1 );
156 9 has shell => ( is => 'ro', isa => Str, required => 1 );
157  
158 0 ▶sub to_json { shift->_json }
Subroutine to_json: not called CC=1 SCAR=6.9
Pod undocumented
159 9 has _json => ( is => 'lazy', isa => Str );
160 0 ▶sub _build__json {
Subroutine _build__json: not called CC=1 SCAR=6.9
161 0 my ($self) = @_;
162 0 encode_json({
163 $self->_to_json_hash,
164 DockerContainerID => $self->docker_container_id,
165 Interval => $self->interval,
166 Shell => $self->shell,
167 });
168 }
169  
170 9 with qw(Consul::Check);
171  
172 9 1;
« Consul/ACL.pm ↑ Summary Consul/API/KV.pm »