class AwsCredVault::Toml
Attributes
file[R]
Public Class Methods
new(file)
click to toggle source
# File lib/aws_cred_vault/toml.rb, line 7 def initialize file @file = file end
Public Instance Methods
account(name)
click to toggle source
Returns the account with the matching name, or nil if none exists
# File lib/aws_cred_vault/toml.rb, line 12 def account name accounts.detect { |x| x.name == name } end
accounts()
click to toggle source
Returns the list of all accounts in the vault
# 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)
click to toggle source
# 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
Private Instance Methods
account_hash()
click to toggle source
# File lib/aws_cred_vault/toml.rb, line 48 def account_hash toml["accounts"] || {} end
save(accounts)
click to toggle source
# File lib/aws_cred_vault/toml.rb, line 52 def save accounts File.open file, 'w' do |file| file.write(::TOML::Generator.new(accounts).body) end end
toml()
click to toggle source
# File lib/aws_cred_vault/toml.rb, line 43 def toml return {} unless File.exists? file ::TOML.load_file(file) end