| 1 | #!perl | ||||||||||||
| 2 | # vim: softtabstop=4 tabstop=4 shiftwidth=4 ft=perl expandtab smarttab | ||||||||||||
| 3 | # ABSTRACT: Perl API for HashiCorp's Vault | ||||||||||||
| 4 | |||||||||||||
| 5 | # See also https://github.com/hashicorp/vault-ruby | ||||||||||||
| 6 | # And https://github.com/ianunruh/hvac | ||||||||||||
| 7 | # And https://www.vaultproject.io/api/index.html | ||||||||||||
| 8 | |||||||||||||
| 9 | package WebService::HashiCorp::Vault; | ||||||||||||
| 10 | |||||||||||||
| 11 | 3 | ▶ | use Moo; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 12 | 3 | our $VERSION = '0.04'; # VERSION | |||||||||||
| 13 | |||||||||||||
| 14 | 3 | extends 'WebService::HashiCorp::Vault::Base'; | |||||||||||
| 15 | 3 | ▶ | use namespace::clean; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 16 | |||||||||||||
| 17 | 3 | ▶ | use WebService::HashiCorp::Vault::Secret::Cassandra; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 18 | 3 | ▶ | use WebService::HashiCorp::Vault::Secret::Cubbyhole; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 19 | 3 | ▶ | use WebService::HashiCorp::Vault::Secret::Generic; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 20 | 3 | ▶ | use WebService::HashiCorp::Vault::Secret::Kvv2; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 21 | 3 | ▶ | use WebService::HashiCorp::Vault::Secret::MongoDB; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 22 | 3 | ▶ | use WebService::HashiCorp::Vault::Secret::MSSQL; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 23 | 3 | ▶ | use WebService::HashiCorp::Vault::Secret::MySQL; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 24 | 3 | ▶ | use WebService::HashiCorp::Vault::Secret::PostgreSQL; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 25 | 3 | ▶ | use WebService::HashiCorp::Vault::Secret::RabbitMQ; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 26 | 3 | ▶ | use WebService::HashiCorp::Vault::Secret::SSH; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 27 | 3 | ▶ | use WebService::HashiCorp::Vault::Sys; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 28 | |||||||||||||
| 29 | |||||||||||||
| 30 | { | ||||||||||||
| 31 | |||||||||||||
| 32 | 3 | my %backendmap = ( | |||||||||||
| 33 | aws => 'AWS', | ||||||||||||
| 34 | cassandra => 'Cassandra', | ||||||||||||
| 35 | cubbyhole => 'Cubbyhole', | ||||||||||||
| 36 | consul => 'Consul', | ||||||||||||
| 37 | cubbyhole => 'Cubbyhole', | ||||||||||||
| 38 | generic => 'Generic', | ||||||||||||
| 39 | kvv2 => 'Kvv2', | ||||||||||||
| 40 | mongodb => 'MongoDB', | ||||||||||||
| 41 | mssql => 'MsSQL', | ||||||||||||
| 42 | mysql => 'MySQL', | ||||||||||||
| 43 | pki => 'PKI', | ||||||||||||
| 44 | postgresql => 'PostgreSQL', | ||||||||||||
| 45 | rabbitmq => 'RabbitMQ', | ||||||||||||
| 46 | ssh => 'SSH', | ||||||||||||
| 47 | transit => 'Transit', | ||||||||||||
| 48 | ); | ||||||||||||
| 49 | |||||||||||||
| 50 | 0 | ▶ | sub secret { | ||||||||||
|
Subroutine
secret: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||
| 51 | 0 | my $self = shift; | |||||||||||
| 52 | 0 | my %args = @_; | |||||||||||
| 53 | 0 | $args{approle} = $self->approle(); | |||||||||||
| 54 | 0 | $args{base_url} = $self->base_url(); | |||||||||||
| 55 | 0 | $args{log_method} = $self->log_method(); | |||||||||||
| 56 | 0 | $args{logger} = $self->logger(); | |||||||||||
| 57 | 0 | $args{token} = $self->token(); | |||||||||||
| 58 | 0 | $args{ua} = $self->ua(); | |||||||||||
| 59 | 0 | $args{version} = $self->version(); | |||||||||||
| 60 | |||||||||||||
| 61 | 0 | ▶ | $args{backend} ||= 'generic'; | ||||||||||
|
Condition0%0/2
$args{"backend"} ||= "generic"
MC/DC0%0/1
$args{"backend"} ||= "generic"
$args{"backend"}
Truth table0%0/2
A
A= $args{"backend"}
| |||||||||||||
| 62 | die sprintf( "Unknown backend type: %s\n", $args{backend} ) | ||||||||||||
| 63 | 0 | ▶ | unless $backendmap{ lc($args{backend}) }; | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 64 | my $class = 'WebService::HashiCorp::Vault::Secret::' | ||||||||||||
| 65 | 0 | . $backendmap{ lc($args{backend}) }; | |||||||||||
| 66 | 0 | return $class->new( %args ); | |||||||||||
| 67 | } | ||||||||||||
| 68 | |||||||||||||
| 69 | } | ||||||||||||
| 70 | |||||||||||||
| 71 | |||||||||||||
| 72 | 3 | ▶ | sub sys { | ||||||||||
|
Subroutine
sys: not called CC=2 SCAR=15.9
Pod
documented
| |||||||||||||
| 73 | 0 | my $self = shift; | |||||||||||
| 74 | 0 | my %args = @_; | |||||||||||
| 75 | 0 | ▶ | $args{mount} ||= 'sys'; | ||||||||||
|
Condition0%0/2
$args{"mount"} ||= "sys"
MC/DC0%0/1
$args{"mount"} ||= "sys"
$args{"mount"}
Truth table0%0/2
A
A= $args{"mount"}
| |||||||||||||
| 76 | 0 | $args{token} = $self->token(); | |||||||||||
| 77 | 0 | $args{version} = $self->version(); | |||||||||||
| 78 | 0 | $args{base_url} = $self->base_url(); | |||||||||||
| 79 | |||||||||||||
| 80 | 0 | return WebService::HashiCorp::Vault::Sys->new( %args ); | |||||||||||
| 81 | } | ||||||||||||
| 82 | |||||||||||||
| 83 | |||||||||||||
| 84 | 3 | 1; | |||||||||||
| 85 | |||||||||||||
| 86 | __END__ | ||||||||||||