File Coverage

blib/lib/WebService/HashiCorp/Vault.pm
Criterion Covered Total %
statement 39 59 66.1
branch 0 2 0.0
condition 0 4 0.0
subroutine 13 15 86.6
pod 2 2 100.0
total 54 82 65.8


line stmt bran cond sub pod time code
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     3   385150 use Moo;
  3         19052  
  3         15  
12             our $VERSION = '0.04'; # VERSION
13              
14             extends 'WebService::HashiCorp::Vault::Base';
15 3     3   4924 use namespace::clean;
  3         36716  
  3         21  
16              
17 3     3   2490 use WebService::HashiCorp::Vault::Secret::Cassandra;
  3         11  
  3         112  
18 3     3   1765 use WebService::HashiCorp::Vault::Secret::Cubbyhole;
  3         10  
  3         112  
19 3     3   1643 use WebService::HashiCorp::Vault::Secret::Generic;
  3         25  
  3         114  
20 3     3   1586 use WebService::HashiCorp::Vault::Secret::Kvv2;
  3         11  
  3         120  
21 3     3   1494 use WebService::HashiCorp::Vault::Secret::MongoDB;
  3         9  
  3         100  
22 3     3   1482 use WebService::HashiCorp::Vault::Secret::MSSQL;
  3         10  
  3         138  
23 3     3   1469 use WebService::HashiCorp::Vault::Secret::MySQL;
  3         10  
  3         101  
24 3     3   1478 use WebService::HashiCorp::Vault::Secret::PostgreSQL;
  3         8  
  3         125  
25 3     3   1401 use WebService::HashiCorp::Vault::Secret::RabbitMQ;
  3         51  
  3         108  
26 3     3   1408 use WebService::HashiCorp::Vault::Secret::SSH;
  3         9  
  3         146  
27 3     3   1183 use WebService::HashiCorp::Vault::Sys;
  3         11  
  3         1185  
28              
29              
30             {
31              
32             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             sub secret {
51 0     0 1   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   0       $args{backend} ||= 'generic';
62             die sprintf( "Unknown backend type: %s\n", $args{backend} )
63 0 0         unless $backendmap{ lc($args{backend}) };
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             sub sys {
73 0     0 1   my $self = shift;
74 0           my %args = @_;
75 0   0       $args{mount} ||= 'sys';
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             1;
85              
86             __END__