Class: Jackal::Stacks::Wrecker

Inherits:
Callback
  • Object
show all
Includes:
StackCommon
Defined in:
lib/jackal-stacks/wrecker.rb

Overview

Stack destroyer

Instance Method Summary collapse

Methods included from StackCommon

#api_config, #determine_namespace, #stack_name, #stacks_api

Instance Method Details

#execute(message) ⇒ Object

Build or update stacks

Parameters:

  • message (Carnivore::Message)


28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'lib/jackal-stacks/wrecker.rb', line 28

def execute(message)
  failure_wrap(message) do |payload|
    s_name = stack_name(payload)
    stack = stacks_api.stacks.get(s_name)
    if(stack)
      info "Stack currently exists. Destroying. [#{stack.name}]"
      stack.destroy
      payload.set(:data, :stacks, :destroyed, true)
      job_completed(:stacks, payload, message)
    else
      error "Failed to locate requested stack for destruction [#{s_name}]"
      failed(payload, message, 'Requested stack does not exist')
    end
  end
end

#setup(*_) ⇒ Object

Setup callback



11
12
13
# File 'lib/jackal-stacks/wrecker.rb', line 11

def setup(*_)
  stacks_api
end

#valid?(message) ⇒ Truthy, Falsey

Determine validity of message

Parameters:

  • message (Carnivore::Message)

Returns:

  • (Truthy, Falsey)


19
20
21
22
23
# File 'lib/jackal-stacks/wrecker.rb', line 19

def valid?(message)
  super do |payload|
    payload.get(:data, :stacks, :wrecker)
  end
end