Kubernetes/Resource/Role/HasPods.pm

filter: Statementstmt 70.9% 22 / 31 Branchbran 25.0% 2 / 8 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 3 / 3 Podpod 100% 1 / 1 totaltotal 65.1% 28 / 43 CC 7 SCAR 21.6
CC
7
Cov
62%
get_pods
12.2
_build_selector_from_hash
2.0
BEGIN
1.0
CRAP 8.7
« Kubernetes/Resource/Node.pm ↑ Summary Kubernetes/Role/ResourceFactory.pm »
1 package Net::Kubernetes::Resource::Role::HasPods;
2 # ABSTRACT: Resource role for types that may contain pods
3 4 $Net::Kubernetes::Resource::Role::HasPods::VERSION = '1.03';
4 4 ▶use Moose::Role;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 4 with 'Net::Kubernetes::Role::APIAccess';
7  
8  
9 4 ▶sub get_pods {
Subroutine get_pods: called CC=6 SCAR=25.0
Pod documented
10 4 my($self) = @_;
11 4 my $uri = URI->new_abs("../pods", $self->path);
12 4 $uri->query_form(labelSelector=>$self->_build_selector_from_hash($self->spec->{selector}));
13 4 my $res = $self->ua->request($self->create_request(GET => $uri));
14 4 ▶ if ($res->is_success) {
Branch: 1 branch
BranchTrueFalseTotal
if ($res->is_success) { } 4 0 4
15 4 my $pod_list = $self->json->decode($res->content);
16 4 my(@pods)=();
17 4 foreach my $pod (@{ $pod_list->{items}}){
18 0 $pod->{apiVersion} = $pod_list->{apiVersion};
19 0 my(%create_args) = %$pod;
20 0 $create_args{api_version} = $pod->{apiVersion};
21 0 ▶ $create_args{username} = $self->username if($self->username);
Branch: 1 branch
BranchTrueFalseTotal
if $self->username 0 0 0
22 0 ▶ $create_args{password} = $self->password if($self->password);
Branch: 1 branch
BranchTrueFalseTotal
if $self->password 0 0 0
23 0 $create_args{url} = $self->url;
24 0 $create_args{base_path} = $pod->{metadata}{selfLink};
25 0 push @pods, Net::Kubernetes::Resource::Pod->new(%create_args);
26 }
27 4 ▶ return wantarray ? @pods : \@pods;
Branch: 1 branch
BranchTrueFalseTotal
wantarray ? : 0 4 4
28 }else{
29 0 Net::Kubernetes::Exception->throw(code=>$res->code, message=>$res->message);
30 }
31 }
32  
33 4 ▶sub _build_selector_from_hash {
Subroutine _build_selector_from_hash: called CC=2 SCAR=6.9
34 4 my($self, $select_hash) = @_;
35 4 my(@selectors);
36 4 foreach my $label (keys %{ $select_hash }){
37 4 push @selectors, $label.'='.$select_hash->{$label};
38 }
39 4 return join(",", @selectors);
40 }
41  
42 4 return 42;
43  
44 __END__
« Kubernetes/Resource/Node.pm ↑ Summary Kubernetes/Role/ResourceFactory.pm »