Class: CfDeployer::DeploymentStrategy::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/cf_deployer/deployment_strategy/base.rb

Direct Known Subclasses

BlueGreen, CreateOrUpdate

Constant Summary collapse

BLUE_GREEN_STRATEGY =
true

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(application_name, component_name, environment_name, context) ⇒ Base

Returns a new instance of Base.



18
19
20
21
22
23
24
# File 'lib/cf_deployer/deployment_strategy/base.rb', line 18

def initialize(application_name, component_name, environment_name, context)
  @application_name = application_name
  @component_name = component_name
  @environment_name = environment_name
  @context = context
  @auto_scaling_group_drivers = {}
end

Instance Attribute Details

#application_nameObject (readonly)

Returns the value of attribute application_name.



17
18
19
# File 'lib/cf_deployer/deployment_strategy/base.rb', line 17

def application_name
  @application_name
end

#component_nameObject (readonly)

Returns the value of attribute component_name.



17
18
19
# File 'lib/cf_deployer/deployment_strategy/base.rb', line 17

def component_name
  @component_name
end

#contextObject (readonly)

Returns the value of attribute context.



17
18
19
# File 'lib/cf_deployer/deployment_strategy/base.rb', line 17

def context
  @context
end

#environment_nameObject (readonly)

Returns the value of attribute environment_name.



17
18
19
# File 'lib/cf_deployer/deployment_strategy/base.rb', line 17

def environment_name
  @environment_name
end

Instance Method Details

#active_templateObject



45
46
47
48
# File 'lib/cf_deployer/deployment_strategy/base.rb', line 45

def active_template
  target_stack = ( active_stack || stack )
  (target_stack && target_stack.exists?) ? target_stack.template : nil
end

#blue_green_strategy?Boolean

Returns:

  • (Boolean)


26
27
28
# File 'lib/cf_deployer/deployment_strategy/base.rb', line 26

def blue_green_strategy?
  BLUE_GREEN_STRATEGY
end

#run_hook(hook_name) ⇒ Object



30
31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'lib/cf_deployer/deployment_strategy/base.rb', line 30

def run_hook(hook_name)
  CfDeployer::Driver::DryRun.guard "Skipping hook #{hook_name}" do
    unless @params_and_outputs_resolved
      target_stack = ( active_stack || stack )
      unless target_stack.exists?
        CfDeployer::Log.info "Skipping hook call for #{hook_name} since stack #{target_stack.name} doesn't exist."
        return
      end
      get_parameters_outputs target_stack
    end
    hook = Hook.new hook_name, context[hook_name]
    hook.run context
  end
end