line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
1
|
|
|
1
|
|
998
|
use strict; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
37
|
|
2
|
1
|
|
|
1
|
|
5
|
use warnings; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
56
|
|
3
|
|
|
|
|
|
|
|
4
|
|
|
|
|
|
|
package Net::Amazon::Config; |
5
|
|
|
|
|
|
|
# ABSTRACT: Manage Amazon Web Services credentials |
6
|
|
|
|
|
|
|
our $VERSION = '0.002'; # VERSION |
7
|
|
|
|
|
|
|
|
8
|
1
|
|
|
1
|
|
7
|
use Carp (); |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
20
|
|
9
|
1
|
|
|
1
|
|
774
|
use Config::Tiny 2.12 (); |
|
1
|
|
|
|
|
964
|
|
|
1
|
|
|
|
|
23
|
|
10
|
1
|
|
|
1
|
|
480
|
use Net::Amazon::Config::Profile (); |
|
1
|
|
|
|
|
4
|
|
|
1
|
|
|
|
|
25
|
|
11
|
1
|
|
|
1
|
|
7
|
use Params::Validate 0.91 (); |
|
1
|
|
|
|
|
22
|
|
|
1
|
|
|
|
|
20
|
|
12
|
1
|
|
|
1
|
|
755
|
use Path::Class 0.17 (); |
|
1
|
|
|
|
|
63389
|
|
|
1
|
|
|
|
|
39
|
|
13
|
1
|
|
|
|
|
7
|
use Object::Tiny 1.06 qw( |
14
|
|
|
|
|
|
|
config_dir |
15
|
|
|
|
|
|
|
config_file |
16
|
|
|
|
|
|
|
config_path |
17
|
1
|
|
|
1
|
|
12
|
); |
|
1
|
|
|
|
|
15
|
|
18
|
|
|
|
|
|
|
|
19
|
1
|
|
|
1
|
|
185
|
use constant IS_WIN32 => $^O eq 'MSWin32'; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
385
|
|
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
sub _default_dir { |
22
|
0
|
|
|
0
|
|
0
|
my $base = Path::Class::dir( IS_WIN32 ? $ENV{USERPROFILE} : $ENV{HOME} ); |
23
|
0
|
|
|
|
|
0
|
return $base->subdir('.amazon')->absolute->stringify; |
24
|
|
|
|
|
|
|
} |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
sub new { |
27
|
1
|
|
|
1
|
1
|
506
|
my $class = shift; |
28
|
1
|
|
33
|
|
|
51
|
my %args = Params::Validate::validate( |
|
|
|
50
|
|
|
|
|
29
|
|
|
|
|
|
|
@_, |
30
|
|
|
|
|
|
|
{ |
31
|
|
|
|
|
|
|
config_dir => { default => $ENV{NET_AMAZON_CONFIG_DIR} || _default_dir, }, |
32
|
|
|
|
|
|
|
config_file => { default => $ENV{NET_AMAZON_CONFIG} || 'profiles.conf', } |
33
|
|
|
|
|
|
|
} |
34
|
|
|
|
|
|
|
); |
35
|
|
|
|
|
|
|
|
36
|
1
|
50
|
|
|
|
9
|
if ( Path::Class::file( $args{config_file} )->is_absolute ) { |
37
|
0
|
|
|
|
|
0
|
$args{config_path} = $args{config_file}; |
38
|
|
|
|
|
|
|
} |
39
|
|
|
|
|
|
|
else { |
40
|
1
|
|
|
|
|
262
|
$args{config_path} = |
41
|
|
|
|
|
|
|
Path::Class::dir( $args{config_dir} )->file( $args{config_file} ); |
42
|
|
|
|
|
|
|
} |
43
|
|
|
|
|
|
|
|
44
|
1
|
50
|
|
|
|
307
|
unless ( -r $args{config_path} ) { |
45
|
0
|
|
|
|
|
0
|
die "Could not find readable file $args{config_path}"; |
46
|
|
|
|
|
|
|
} |
47
|
|
|
|
|
|
|
|
48
|
1
|
|
|
|
|
79
|
return bless \%args, $class; |
49
|
|
|
|
|
|
|
} |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
sub get_profile { |
52
|
1
|
|
|
1
|
1
|
387
|
my ( $self, $profile_name ) = @_; |
53
|
1
|
|
|
|
|
33
|
my $config = Config::Tiny->read( $self->config_path ); |
54
|
|
|
|
|
|
|
|
55
|
1
|
50
|
|
|
|
386
|
$profile_name = $config->{_}{default} unless defined $profile_name; |
56
|
1
|
50
|
|
|
|
5
|
my $params = $config->{$profile_name} |
57
|
|
|
|
|
|
|
or return; |
58
|
|
|
|
|
|
|
|
59
|
1
|
|
|
|
|
3
|
$params->{profile_name} = $profile_name; |
60
|
1
|
|
|
|
|
2
|
my $profile = eval { Net::Amazon::Config::Profile->new($params) }; |
|
1
|
|
|
|
|
10
|
|
61
|
1
|
50
|
|
|
|
4
|
if ($@) { |
62
|
0
|
|
|
|
|
0
|
Carp::croak "Invalid profile: $@"; |
63
|
|
|
|
|
|
|
} |
64
|
1
|
|
|
|
|
12
|
return $profile; |
65
|
|
|
|
|
|
|
} |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
1; |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
__END__ |