Class: Moonshot::ControllerConfig

Inherits:
Object
  • Object
show all
Defined in:
lib/moonshot/controller_config.rb

Overview

Holds configuration for Moonshot::Controller

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeControllerConfig

Returns a new instance of ControllerConfig.



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/moonshot/controller_config.rb', line 15

def initialize
  @default_parameter_source = AskUserSource.new
  @interactive              = true
  @interactive_logger       = InteractiveLogger.new
  @parameter_overrides      = {}
  @parameter_sources        = {}
  @parameters               = ParameterCollection.new
  @parent_stacks            = []
  @account_alias            = nil
  @per_account_config       = {}
  @plugins                  = []
  @project_root             = Dir.pwd
  @show_all_stack_events    = false
  @ssh_config               = SSHConfig.new
  @extra_tags               = []

  @dev_build_name_proc = lambda do |c|
    ['dev', c.app_name, c.environment_name, Time.now.to_i].join('/')
  end

  user = ENV.fetch('USER', 'default-user').gsub(/\W/, '')
  @environment_name = "dev-#{user}"
end

Instance Attribute Details

#account_aliasObject (readonly)

Returns the value of attribute account_alias.



6
7
8
# File 'lib/moonshot/controller_config.rb', line 6

def 
  @account_alias
end

#additional_tagObject

Returns the value of attribute additional_tag.



8
9
10
# File 'lib/moonshot/controller_config.rb', line 8

def additional_tag
  @additional_tag
end

#answer_fileObject

Returns the value of attribute answer_file.



8
9
10
# File 'lib/moonshot/controller_config.rb', line 8

def answer_file
  @answer_file
end

#app_nameObject

Returns the value of attribute app_name.



8
9
10
# File 'lib/moonshot/controller_config.rb', line 8

def app_name
  @app_name
end

#artifact_repositoryObject

Returns the value of attribute artifact_repository.



8
9
10
# File 'lib/moonshot/controller_config.rb', line 8

def artifact_repository
  @artifact_repository
end

#build_mechanismObject

Returns the value of attribute build_mechanism.



8
9
10
# File 'lib/moonshot/controller_config.rb', line 8

def build_mechanism
  @build_mechanism
end

#changeset_wait_timeObject

Returns the value of attribute changeset_wait_time.



8
9
10
# File 'lib/moonshot/controller_config.rb', line 8

def changeset_wait_time
  @changeset_wait_time
end

#default_parameter_sourceObject

Returns the value of attribute default_parameter_source.



8
9
10
# File 'lib/moonshot/controller_config.rb', line 8

def default_parameter_source
  @default_parameter_source
end

#deployment_mechanismObject

Returns the value of attribute deployment_mechanism.



8
9
10
# File 'lib/moonshot/controller_config.rb', line 8

def deployment_mechanism
  @deployment_mechanism
end

#dev_build_name_procObject

Returns the value of attribute dev_build_name_proc.



8
9
10
# File 'lib/moonshot/controller_config.rb', line 8

def dev_build_name_proc
  @dev_build_name_proc
end

#environment_nameObject

Returns the value of attribute environment_name.



8
9
10
# File 'lib/moonshot/controller_config.rb', line 8

def environment_name
  @environment_name
end

#extra_tagsObject

Returns the value of attribute extra_tags.



8
9
10
# File 'lib/moonshot/controller_config.rb', line 8

def extra_tags
  @extra_tags
end

#interactiveObject

Returns the value of attribute interactive.



8
9
10
# File 'lib/moonshot/controller_config.rb', line 8

def interactive
  @interactive
end

#interactive_loggerObject

Returns the value of attribute interactive_logger.



8
9
10
# File 'lib/moonshot/controller_config.rb', line 8

def interactive_logger
  @interactive_logger
end

#parameter_overridesObject

Returns the value of attribute parameter_overrides.



8
9
10
# File 'lib/moonshot/controller_config.rb', line 8

def parameter_overrides
  @parameter_overrides
end

#parameter_sourcesObject

Returns the value of attribute parameter_sources.



8
9
10
# File 'lib/moonshot/controller_config.rb', line 8

def parameter_sources
  @parameter_sources
end

#parametersObject

Returns the value of attribute parameters.



8
9
10
# File 'lib/moonshot/controller_config.rb', line 8

def parameters
  @parameters
end

#parent_stacksObject

Returns the value of attribute parent_stacks.



8
9
10
# File 'lib/moonshot/controller_config.rb', line 8

def parent_stacks
  @parent_stacks
end

#pluginsObject

Returns the value of attribute plugins.



8
9
10
# File 'lib/moonshot/controller_config.rb', line 8

def plugins
  @plugins
end

#project_rootObject

Returns the value of attribute project_root.



8
9
10
# File 'lib/moonshot/controller_config.rb', line 8

def project_root
  @project_root
end

#show_all_stack_eventsObject

Returns the value of attribute show_all_stack_events.



8
9
10
# File 'lib/moonshot/controller_config.rb', line 8

def show_all_stack_events
  @show_all_stack_events
end

#ssh_auto_scaling_group_nameObject

Returns the value of attribute ssh_auto_scaling_group_name.



8
9
10
# File 'lib/moonshot/controller_config.rb', line 8

def ssh_auto_scaling_group_name
  @ssh_auto_scaling_group_name
end

#ssh_commandObject

Returns the value of attribute ssh_command.



8
9
10
# File 'lib/moonshot/controller_config.rb', line 8

def ssh_command
  @ssh_command
end

#ssh_configObject

Returns the value of attribute ssh_config.



8
9
10
# File 'lib/moonshot/controller_config.rb', line 8

def ssh_config
  @ssh_config
end

#ssh_instanceObject

Returns the value of attribute ssh_instance.



8
9
10
# File 'lib/moonshot/controller_config.rb', line 8

def ssh_instance
  @ssh_instance
end

#template_fileObject

Returns the value of attribute template_file.



8
9
10
# File 'lib/moonshot/controller_config.rb', line 8

def template_file
  @template_file
end

#template_s3_bucketObject

Returns the value of attribute template_s3_bucket.



8
9
10
# File 'lib/moonshot/controller_config.rb', line 8

def template_s3_bucket
  @template_s3_bucket
end

Instance Method Details

#in_account(name, &blk) ⇒ Object



39
40
41
42
43
# File 'lib/moonshot/controller_config.rb', line 39

def (name, &blk)
  # Store account specific configs as lambdas, to be evaluated
  # if the account name matches during controller execution.
  @per_account_config[name] = blk
end

#update_for_account!Object



45
46
47
48
49
50
51
52
# File 'lib/moonshot/controller_config.rb', line 45

def update_for_account!
  # Evaluated any account-specific configuration.
  @account_alias = Moonshot::AccountContext.get
  return unless @account_alias
  return unless @per_account_config.key?(@account_alias)

  @per_account_config[@account_alias].call(self)
end