aws_cred_vault 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/aws_cred_vault/account.rb +15 -0
- data/lib/aws_cred_vault/toml.rb +13 -2
- data/lib/aws_cred_vault/user.rb +20 -0
- data/lib/aws_cred_vault/version.rb +1 -1
- data/lib/aws_cred_vault.rb +2 -0
- data/spec/lib/aws_cred_vault/account_spec.rb +22 -0
- data/spec/lib/aws_cred_vault/{toml.rb → toml_spec.rb} +1 -1
- data/spec/lib/aws_cred_vault/user_spec.rb +25 -0
- metadata +10 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 307b3e31e8b93bb5c886d47336d815aff0a7735f
|
4
|
+
data.tar.gz: f542140f62254af624cec4932ab6e26e3a9db4a9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1e86e295c4d63175d3d8369a4e6827fe3ce191d83b83cfc4294d96e6a41ffedfb6d250b19d4d03b36dd6d135fe1cf31d1a2e506d951d984eb37d1679b4893982
|
7
|
+
data.tar.gz: ade788fd581eaaeccb3e104f0dd65c164dbd1d2ad79cdd2d33f5a9a5c8fd7dbf56dd5fc205d71943a3ad350cd6fb9a19f33e5b905f35db98b8c43a25ae60d40e
|
data/lib/aws_cred_vault/toml.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
require 'toml'
|
2
|
+
require_relative 'account'
|
2
3
|
|
3
4
|
module AwsCredVault
|
4
5
|
class Toml
|
@@ -8,11 +9,17 @@ module AwsCredVault
|
|
8
9
|
end
|
9
10
|
|
10
11
|
def accounts
|
11
|
-
|
12
|
+
account_hash.map do |name, user_list|
|
13
|
+
account = Account.new name
|
14
|
+
user_list.each do |name, credentials|
|
15
|
+
account.add_user User.new name, credentials[:access_key], credentials[:secret]
|
16
|
+
end
|
17
|
+
account
|
18
|
+
end
|
12
19
|
end
|
13
20
|
|
14
21
|
def add_account site, name, access_key, secret
|
15
|
-
new_accounts =
|
22
|
+
new_accounts = account_hash || {}
|
16
23
|
new_accounts[site] = {
|
17
24
|
name => {
|
18
25
|
'access_key' => access_key,
|
@@ -28,6 +35,10 @@ module AwsCredVault
|
|
28
35
|
::TOML.load_file(file)
|
29
36
|
end
|
30
37
|
|
38
|
+
def account_hash
|
39
|
+
toml["accounts"] || {}
|
40
|
+
end
|
41
|
+
|
31
42
|
def save accounts
|
32
43
|
File.open file, 'w' do |file|
|
33
44
|
file.write(::TOML::Generator.new(accounts).body)
|
@@ -0,0 +1,20 @@
|
|
1
|
+
|
2
|
+
module AwsCredVault
|
3
|
+
class User
|
4
|
+
attr_reader :name, :access_key, :secret
|
5
|
+
|
6
|
+
def initialize name, access_key, secret
|
7
|
+
@name = name
|
8
|
+
@access_key = access_key
|
9
|
+
@secret = secret
|
10
|
+
end
|
11
|
+
|
12
|
+
def credentials
|
13
|
+
{
|
14
|
+
aws_access_key_id: access_key,
|
15
|
+
aws_secret_access_key: secret
|
16
|
+
}
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
end
|
data/lib/aws_cred_vault.rb
CHANGED
@@ -0,0 +1,22 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe AwsCredVault::Account do
|
4
|
+
describe 'name' do
|
5
|
+
let(:account) { AwsCredVault::Account.new 'test' }
|
6
|
+
|
7
|
+
it 'has the right name' do
|
8
|
+
expect(account.name).to eq 'test'
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
describe 'add_user' do
|
13
|
+
let(:account) { AwsCredVault::Account.new 'test' }
|
14
|
+
let(:user) { AwsCredVault::User.new 'test_user', 'id', 'key' }
|
15
|
+
|
16
|
+
subject { account.add_user user }
|
17
|
+
|
18
|
+
it 'adds the user' do
|
19
|
+
expect { subject }.to change {account.users.length}.by(1)
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe AwsCredVault::User do
|
4
|
+
let(:user) { AwsCredVault::User.new 'test', 'id', 'key' }
|
5
|
+
|
6
|
+
describe 'name' do
|
7
|
+
it 'has the right name' do
|
8
|
+
expect(user.name).to eq 'test'
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
describe 'credentials' do
|
13
|
+
subject { user.credentials }
|
14
|
+
|
15
|
+
it 'adds the user' do
|
16
|
+
|
17
|
+
expect(subject).to eq(
|
18
|
+
{
|
19
|
+
aws_access_key_id: 'id',
|
20
|
+
aws_secret_access_key: 'key'
|
21
|
+
}
|
22
|
+
)
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: aws_cred_vault
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Clarke Brunsdon
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-10-
|
11
|
+
date: 2014-10-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: toml
|
@@ -80,10 +80,14 @@ files:
|
|
80
80
|
- Rakefile
|
81
81
|
- aws_cred_vault.gemspec
|
82
82
|
- lib/aws_cred_vault.rb
|
83
|
+
- lib/aws_cred_vault/account.rb
|
83
84
|
- lib/aws_cred_vault/toml.rb
|
85
|
+
- lib/aws_cred_vault/user.rb
|
84
86
|
- lib/aws_cred_vault/version.rb
|
85
87
|
- spec/files/accounts.toml
|
86
|
-
- spec/lib/aws_cred_vault/
|
88
|
+
- spec/lib/aws_cred_vault/account_spec.rb
|
89
|
+
- spec/lib/aws_cred_vault/toml_spec.rb
|
90
|
+
- spec/lib/aws_cred_vault/user_spec.rb
|
87
91
|
- spec/lib/aws_cred_vault_spec.rb
|
88
92
|
- spec/spec_helper.rb
|
89
93
|
homepage: ''
|
@@ -112,6 +116,8 @@ specification_version: 4
|
|
112
116
|
summary: Stores your amazon credentials for multiple IAM accounts.
|
113
117
|
test_files:
|
114
118
|
- spec/files/accounts.toml
|
115
|
-
- spec/lib/aws_cred_vault/
|
119
|
+
- spec/lib/aws_cred_vault/account_spec.rb
|
120
|
+
- spec/lib/aws_cred_vault/toml_spec.rb
|
121
|
+
- spec/lib/aws_cred_vault/user_spec.rb
|
116
122
|
- spec/lib/aws_cred_vault_spec.rb
|
117
123
|
- spec/spec_helper.rb
|