lib/Kubernetes/REST/CLI/Role/Connection.pm

filter: Statementstmt 100% 20 / 20 Branchbran 75.0% 6 / 8 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 5 / 5 Podpod n/a totaltotal 93.9% 31 / 33 CC 5 SCAR 8.5
CC
5
Cov
93%
__ANON__
3.0
_build_api
3.0
BEGIN
1.0
CRAP 2.4
« lib/Kubernetes/REST/AuthTokenFile.pm ↑ Summary lib/Kubernetes/REST/APIError.pm »
1 package Kubernetes::REST::CLI::Role::Connection;
2 4 our $VERSION = '1.113';
3 # ABSTRACT: Shared kubeconfig/auth options for CLI tools
4 5 ▶use Moo::Role;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 5 ▶use MooX::Options;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 5 ▶use Kubernetes::REST::Kubeconfig;
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8  
9 # Deliberately without a default: an option that always has a value is always
10 # passed on, and Kubernetes::REST::Kubeconfig never reaches its own default of
11 # $ENV{KUBECONFIG} // ~/.kube/config. Leaving it undef when the user did not ask
12 # for a path is what lets the environment variable through.
13 4 option kubeconfig => (
14 is => 'ro',
15 format => 's',
16 doc => 'Path to kubeconfig file (default: $KUBECONFIG, else ~/.kube/config)',
17 );
18  
19  
20 4 option context => (
21 is => 'ro',
22 format => 's',
23 short => 'c',
24 doc => 'Kubernetes context to use',
25 );
26  
27  
28 has api => (
29 is => 'lazy',
30 2 ▶ builder => sub {
Subroutine _build_api: called CC=3 SCAR=11.1
Subroutine __ANON__: called CC=3 SCAR=11.1
31 2 my $self = shift;
32 # kubeconfig_path is only passed when --kubeconfig was given, so an
33 # unset option falls through to Kubeconfig's own $ENV{KUBECONFIG}
34 # default rather than being overridden by a home-directory guess.
35 2 ▶ my $kc = Kubernetes::REST::Kubeconfig->new(
Branch: 4 branches
BranchTrueFalseTotal
defined $self->kubeconfig ? : 2 0 2
$self->context ? : 1 1 2
defined $self->kubeconfig ? : 4 4 8
$self->context ? : 0 8 8
36 (defined $self->kubeconfig ? (kubeconfig_path => $self->kubeconfig) : ()),
37 ($self->context ? (context_name => $self->context) : ()),
38 );
39 2 return $kc->api;
40 },
41 4 );
42  
43  
44 4 1;
45  
46 __END__
« lib/Kubernetes/REST/AuthTokenFile.pm ↑ Summary lib/Kubernetes/REST/APIError.pm »