blib/lib/Kubernetes/Comb/Client/Sync.pm

filter: Statementstmt 100% 47 / 47 Branchbran 66.6% 4 / 6 Conditioncond 66.6% 2 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 100% 22 / 22 Podpod 100% 11 / 11 totaltotal 94.5% 86 / 91 CC 5 SCAR 4.0
CC
5
Cov
95%
for_context
3.2
_build_rest
3.0
BEGIN
1.0
CRAP 1.5
« examples/lib/Example/Comb/NATS.pm ↑ Summary blib/lib/Kubernetes/Comb/CRD.pm »
1 package Kubernetes::Comb::Client::Sync;
2 # ABSTRACT: Synchronous Comb client on Kubernetes::REST, returning done Futures
3 20 our $VERSION = '0.002';
4  
5 20 ▶use Moo;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 20 with 'Kubernetes::Comb::Role::Client';
7  
8 20 ▶use Future;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 20 ▶use Types::Standard qw( InstanceOf Str );
Subroutine BEGIN: called CC=1 SCAR=0.0
10 20 ▶use Kubernetes::REST;
Subroutine BEGIN: called CC=1 SCAR=0.0
11 20 ▶use Kubernetes::REST::Kubeconfig;
Subroutine BEGIN: called CC=1 SCAR=0.0
12 20 ▶use Kubernetes::Comb::CRD;
Subroutine BEGIN: called CC=1 SCAR=0.0
13 20 ▶use namespace::autoclean;
Subroutine BEGIN: called CC=1 SCAR=0.0
14  
15  
16 20 has kubeconfig => ( is => 'ro', isa => Str, predicate => 1 );
17  
18  
19 20 has context => ( is => 'ro', isa => Str, predicate => 1 );
20  
21  
22 20 has rest => ( is => 'lazy', isa => InstanceOf['Kubernetes::REST'] );
23  
24 4 ▶sub _build_rest {
Subroutine _build_rest: called CC=3 SCAR=11.1
25 4 my ( $self ) = @_;
26 4 ▶ my $api = Kubernetes::REST::Kubeconfig->new(
Branch: 2 branches
BranchTrueFalseTotal
$self->has_kubeconfig ? : 4 0 4
$self->has_context ? : 3 1 4
27 ( $self->has_kubeconfig ? ( kubeconfig_path => $self->kubeconfig ) : () ),
28 ( $self->has_context ? ( context_name => $self->context ) : () )
29 )->api;
30 2 return Kubernetes::REST->new(
31 server => $api->server,
32 credentials => $api->credentials,
33 with => [ Kubernetes::Comb::CRD->new ]
34 );
35 }
36  
37  
38 6 ▶sub get { shift->_call( get => @_ ) }
Subroutine get: called CC=1 SCAR=0.0
Pod documented
39 2 ▶sub list { shift->_call( list => @_ ) }
Subroutine list: called CC=1 SCAR=0.0
Pod documented
40 1 ▶sub ensure { shift->_call( ensure => @_ ) }
Subroutine ensure: called CC=1 SCAR=0.0
Pod documented
41 4 ▶sub delete { shift->_call( delete => @_ ) }
Subroutine delete: called CC=1 SCAR=0.0
Pod documented
42 2 ▶sub update { shift->_call( update => @_ ) }
Subroutine update: called CC=1 SCAR=0.0
Pod documented
43 1 ▶sub patch { shift->_call( patch => @_ ) }
Subroutine patch: called CC=1 SCAR=0.0
Pod documented
44 1 ▶sub update_status { shift->_call( update_status => @_ ) }
Subroutine update_status: called CC=1 SCAR=0.0
Pod documented
45 1 ▶sub patch_status { shift->_call( patch_status => @_ ) }
Subroutine patch_status: called CC=1 SCAR=0.0
Pod documented
46 1 ▶sub log { shift->_call( log => @_ ) }
Subroutine log: called CC=1 SCAR=0.0
Pod documented
47  
48 19 ▶sub _call {
Subroutine _call: called CC=1 SCAR=0.0
49 19 my ( $self, $method, @args ) = @_;
50 19 ▶ return Future->call( sub { Future->done( scalar $self->rest->$method(@args) ) } );
Subroutine __ANON__: called CC=1 SCAR=0.0
51 }
52  
53  
54 4 ▶sub server_url { shift->rest->server->endpoint }
Subroutine server_url: called CC=1 SCAR=0.0
Pod documented
55  
56  
57 12 ▶has _for_context => ( is => 'ro', init_arg => undef, default => sub { {} } );
Subroutine __ANON__: called CC=1 SCAR=0.0
58  
59 3 ▶sub for_context {
Subroutine for_context: called CC=3 SCAR=11.7
Pod documented
60 3 my ( $self, $context ) = @_;
61 3 ▶ return $self->_for_context->{$context} //= ref($self)->new(
Branch: 1 branch
BranchTrueFalseTotal
$self->has_kubeconfig ? : 2 0 2
Condition66%2/3
$self->_for_context->{$context} //= ref($self)->new($self->has_kubeconfig ? ("kubeconfig", $self->kubeconfig) : (), "context", $context)
l!l&&r!l&&!r
120
MC/DC0%0/2
$self->_for_context->{$context} //= ref($self)->new($self->has_kubeconfig ? ("kubeconfig", $self->kubeconfig) : (), "context", $context)
$self->_for_context->{$context} ref($self)->new($self->has_kubeconfig ? ("kubeconfig", $self->kubeconfig) : (), "context", $context)
Truth table66%2/3
A //= B
A= $self->_for_context->{$context}B= ref($self)->new($self->has_kubeconfig ? ("kubeconfig", $self->kubeconfig) : (), "context", $context)
ABresult
1X1
011
000
62 ( $self->has_kubeconfig ? ( kubeconfig => $self->kubeconfig ) : () ),
63 context => $context
64 );
65 }
66  
67  
68 20 1;
69  
70 __END__
« examples/lib/Example/Comb/NATS.pm ↑ Summary blib/lib/Kubernetes/Comb/CRD.pm »