module Tacoma::Tool

Constants

DEFAULT_AWS_REGION

Attributes

aws_access_key_id[RW]
aws_identity_file[RW]
aws_secret_access_key[RW]
region[RW]
repo[RW]
s3cfg[RW]

Public Class Methods

config() click to toggle source
# File lib/tacoma/command.rb, line 19
def config
  filename = File.join(Dir.home, '.tacoma.yml')
  YAML.load_file(filename)
end
current_environment() click to toggle source

Assume there is a ~/.aws/credentials file with a valid format

# File lib/tacoma/command.rb, line 38
def current_environment
  read_environment_from_cache
end
load_vars(environment) click to toggle source
# File lib/tacoma/command.rb, line 24
def load_vars(environment)
  return false unless exists?(environment)

  config = Tool.config
  @aws_identity_file = config[environment]['aws_identity_file']
  @aws_secret_access_key = config[environment]['aws_secret_access_key']
  @aws_access_key_id = config[environment]['aws_access_key_id']
  @region = config[environment]['region'] || DEFAULT_AWS_REGION
  @repo = config[environment]['repo']
  @s3cfg = config[environment]['s3cfg'] || {}
  validate_vars
end

Private Class Methods

exists?(environment) click to toggle source
# File lib/tacoma/command.rb, line 55
def exists?(environment)
  config = Tool.config
  return true if config.keys.include?(environment)
  puts "Cannot find #{environment} key, check your YAML config file"
end
validate_vars() click to toggle source

shows error message if any attr is missing return false if any attr is missing to exit the program

# File lib/tacoma/command.rb, line 46
def validate_vars
  errors = instance_variables.map do |var|
    next unless instance_variable_get(var).to_s.empty?
    "Cannot find #{var} key, check your YAML config file."
  end.compact
  puts errors.join("\n") if errors
  errors.empty?
end