Class: AwsCredVault::Toml
- Inherits:
-
Object
- Object
- AwsCredVault::Toml
- Defined in:
- lib/aws_cred_vault/toml.rb
Instance Attribute Summary collapse
-
#file ⇒ Object
readonly
Returns the value of attribute file.
Instance Method Summary collapse
-
#account(name) ⇒ Object
Returns the account with the matching name, or nil if none exists.
-
#accounts ⇒ Object
Returns the list of all accounts in the vault.
- #add_account(site, name, access_key, secret) ⇒ Object
-
#initialize(file) ⇒ Toml
constructor
A new instance of Toml.
Constructor Details
#initialize(file) ⇒ Toml
Returns a new instance of Toml.
7 8 9 |
# File 'lib/aws_cred_vault/toml.rb', line 7 def initialize file @file = file end |
Instance Attribute Details
#file ⇒ Object (readonly)
Returns the value of attribute file.
6 7 8 |
# File 'lib/aws_cred_vault/toml.rb', line 6 def file @file end |
Instance Method Details
#account(name) ⇒ Object
Returns the account with the matching name, or nil if none exists
12 13 14 |
# File 'lib/aws_cred_vault/toml.rb', line 12 def account name accounts.detect { |x| x.name == name } end |
#accounts ⇒ Object
Returns the list of all accounts in the vault
17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/aws_cred_vault/toml.rb', line 17 def accounts account_hash.map do |name, user_list| account = Account.new name user_list.each do |name, credentials| account.add_user User.new name, credentials["access_key"], credentials["secret"] (credentials["bastion"] || []).each do |env, host| account.add_bastion Bastion.new env, host end end account end end |
#add_account(site, name, access_key, secret) ⇒ Object
31 32 33 34 35 36 37 38 39 40 |
# File 'lib/aws_cred_vault/toml.rb', line 31 def add_account site, name, access_key, secret new_accounts = account_hash || {} new_accounts[site] = { name => { 'access_key' => access_key, 'secret' => secret, } } save new_accounts end |