Class: Stackup::RakeTasks

Inherits:
Rake::TaskLib
  • Object
show all
Defined in:
lib/stackup/rake_tasks.rb

Overview

Declare Rake tasks for managing a stack.

Defined Under Namespace

Classes: DataOptions

Constant Summary collapse

STACKUP_CLI =

path to the “stackup” executable

File.expand_path("../../../bin/stackup", __FILE__)

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, template = nil) {|_self| ... } ⇒ RakeTasks

Returns a new instance of RakeTasks.

Yields:

  • (_self)

Yield Parameters:



19
20
21
22
23
24
25
26
27
# File 'lib/stackup/rake_tasks.rb', line 19

def initialize(name, template = nil)
  @name = name
  @stack = name
  @template = template
  yield self if block_given?
  fail ArgumentError, "no name provided" unless @name
  fail ArgumentError, "no template provided" unless @template
  define
end

Instance Attribute Details

#nameObject

Returns the value of attribute name.



11
12
13
# File 'lib/stackup/rake_tasks.rb', line 11

def name
  @name
end

#parametersObject

Returns the value of attribute parameters.



14
15
16
# File 'lib/stackup/rake_tasks.rb', line 14

def parameters
  @parameters
end

#stackObject

Returns the value of attribute stack.



12
13
14
# File 'lib/stackup/rake_tasks.rb', line 12

def stack
  @stack
end

#tagsObject

Returns the value of attribute tags.



15
16
17
# File 'lib/stackup/rake_tasks.rb', line 15

def tags
  @tags
end

#templateObject

Returns the value of attribute template.



13
14
15
# File 'lib/stackup/rake_tasks.rb', line 13

def template
  @template
end

Instance Method Details

#defineObject



36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
# File 'lib/stackup/rake_tasks.rb', line 36

def define
  namespace(name) do

    data_options = DataOptions.new
    data_options["--template"] = template
    data_options["--parameters"] = parameters if parameters
    data_options["--tags"] = tags if tags

    desc "Update #{stack} stack"
    task "up" => data_options.files do
      stackup "up", *data_options.to_a
    end

    desc "Cancel update of #{stack} stack"
    task "cancel" do
      stackup "cancel-update"
    end

    desc "Show pending changes to #{stack} stack"
    task "diff" => data_options.files do
      stackup "diff", *data_options.to_a
    end

    desc "Show #{stack} stack outputs and resources"
    task "inspect" do
      stackup "inspect"
    end

    desc "Show #{stack} stack outputs only"
    task "outputs" do
      stackup "outputs"
    end

    desc "Delete #{stack} stack"
    task "down" do
      stackup "down"
    end

  end
end

#stackup(*rest) ⇒ Object



32
33
34
# File 'lib/stackup/rake_tasks.rb', line 32

def stackup(*rest)
  sh STACKUP_CLI, "-Y", stack, *rest
end