| 1 | package Kubernetes::REST::CLI::Role::Connection; | ||||||||||||||||||||||
| 2 | 1 | our $VERSION = '1.110'; | |||||||||||||||||||||
| 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 | 1 | option kubeconfig => ( | |||||||||||||||||||||
| 14 | is => 'ro', | ||||||||||||||||||||||
| 15 | format => 's', | ||||||||||||||||||||||
| 16 | doc => 'Path to kubeconfig file (default: $KUBECONFIG, else ~/.kube/config)', | ||||||||||||||||||||||
| 17 | ); | ||||||||||||||||||||||
| 18 | |||||||||||||||||||||||
| 19 | |||||||||||||||||||||||
| 20 | 1 | 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 | 0 | ▶ | builder => sub { | ||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=3 SCAR=14.2
Subroutine
_build_api: called CC=3 SCAR=14.2
| |||||||||||||||||||||||
| 31 | 0 | 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 | 0 | ▶ | my $kc = Kubernetes::REST::Kubeconfig->new( | ||||||||||||||||||||
|
Branch: 4 branches
| |||||||||||||||||||||||
| 36 | (defined $self->kubeconfig ? (kubeconfig_path => $self->kubeconfig) : ()), | ||||||||||||||||||||||
| 37 | ($self->context ? (context_name => $self->context) : ()), | ||||||||||||||||||||||
| 38 | ); | ||||||||||||||||||||||
| 39 | 0 | return $kc->api; | |||||||||||||||||||||
| 40 | }, | ||||||||||||||||||||||
| 41 | 1 | ); | |||||||||||||||||||||
| 42 | |||||||||||||||||||||||
| 43 | |||||||||||||||||||||||
| 44 | 1 | 1; | |||||||||||||||||||||
| 45 | |||||||||||||||||||||||
| 46 | __END__ | ||||||||||||||||||||||