Class: Leeroy::Env

Inherits:
Types::Mash show all
Includes:
Helpers::Dumpable, Helpers::Env, Helpers::Logging
Defined in:
lib/leeroy/env.rb

Constant Summary collapse

S3_PREFIXES =

constants

{
  :builds     => 'builds',
  :fixtures   => 'fixtures',
  :jenkins    => 'jenkins',
  :logs       => 'logs',
  :secrets    => 'secrets',
  :semaphores => 'semaphores',
  :sql        => 'fixtures/sql',
  :tests      => 'tests',
}
ENV_DEFAULTS =
{
  'LEEROY_APP_NAME' => '<identifying string, e.g. "tomcat7">',
  'LEEROY_AWS_LINUX_AMI' => '<AMI ID to be used as base for gold master>',
  'LEEROY_BUILD_INSTANCE_TYPE' => '<EC2 instance type to be used for imaging>',
  'LEEROY_BUILD_PROFILE_NAME' => '<IAM instance profile name to be applied to imaging instances>',
  'LEEROY_BUILD_SECURITY_GROUP' => '<VPC security group name to be applied to imaging instances>',
  'LEEROY_BUILD_SSH_KEYPAIR' => '<SSH keypair name for access to imaging instances>',
  'LEEROY_BUILD_SUBNET' => '<VPC subnet name to be applied to imaging instances>',
  'LEEROY_BUILD_TARGET' => '<identifying string for application build, e.g. "webapi" or "stage20">',
  'LEEROY_BUILD_VPC' => '<VPC name in which imaging instances are created>',
  'LEEROY_GOLD_MASTER_IMAGE_PREFIX' => '<identifying string used to generate AMI names>',
  'LEEROY_GOLD_MASTER_NAME' => '<identifying string used to tag gold master instances during imaging>',
  'LEEROY_POLL_INTERVAL' => '<number of seconds to wait between polling for long-running AWS operations>',
  'LEEROY_POLL_TIMEOUT' => '<number of seconds to wait between giving up on long-running AWS operations>',
  'LEEROY_PROVISIONING_TEMPLATE_PREFIX' => '<path on local filesystem to directory containing provisioning templates>',
  'LEEROY_S3_BUCKET' => '<name of bucket used as datastore>',
  'LEEROY_USER_DATA_PREFIX' => '<path on local filesystem to directory containing user-data scripts>',
}
ENV_EXTRAS =
{
  'ENVIRONMENT' => '<development or production>',
  'GLI_DEBUG' => '<true or false>',
  'AWS_REGION' => '<your AWS region>',
}

Constants included from Helpers::Logging

Helpers::Logging::TRACE_FORMAT, Helpers::Logging::TRACE_LEVELS, Helpers::Logging::TRUNCATE_THRESHOLD

Instance Attribute Summary collapse

Attributes included from Helpers::Env

#env

Attributes included from Helpers::Dumpable

#dump_properties

Instance Method Summary collapse

Methods included from Helpers::Logging

#logger

Methods included from Helpers::Env

#checkEnv

Methods included from Helpers::Dumpable

#dump, #dumper

Methods inherited from Types::Mash

#dumper

Constructor Details

#initialize(options = {}, env = ENV) ⇒ Env

Returns a new instance of Env.



55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
# File 'lib/leeroy/env.rb', line 55

def initialize(options = {}, env = ENV)
  begin
    logger.debug "initializing #{self.class}"
    logger.debug "options: #{options.inspect}"

    @defaults = options[:default]
    @profile = options[:profile]

    if self.defaults
      unfiltered = ENV_DEFAULTS
      extras = ENV_EXTRAS
    else
      unfiltered = env
      extras = {}
    end

    filtered = _filterEnv(unfiltered).merge(extras)
    logger.debug "filtered: #{filtered.inspect}"

    self.dump_properties = filtered.keys.sort.collect { |x| x.to_sym }
    super(filtered)

  rescue StandardError => e
    raise e
  end
end

Instance Attribute Details

#defaultsObject (readonly)

attr_reader :default, :profile



53
54
55
# File 'lib/leeroy/env.rb', line 53

def defaults
  @defaults
end

#profileObject (readonly)

attr_reader :default, :profile



53
54
55
# File 'lib/leeroy/env.rb', line 53

def profile
  @profile
end

Instance Method Details

#to_sObject



82
83
84
# File 'lib/leeroy/env.rb', line 82

def to_s
  _prettyPrint
end