Class: Cloudspin::Stack::Rake::StackTask

Inherits:
Rake::TaskLib
  • Object
show all
Defined in:
lib/cloudspin/stack/rake/stack_task.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(id:, definition_folder: './src', instance_folder: '.') ⇒ StackTask

Returns a new instance of StackTask.



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/cloudspin/stack/rake/stack_task.rb', line 13

def initialize(id:, definition_folder: './src', instance_folder: '.')
  @instance = Cloudspin::Stack::Instance.from_definition_folder(
    id: id,
    definition_folder: definition_folder,
    instance_folder: instance_folder
  )
  @instance.add_config_from_yaml("#{instance_folder}/spin-default.yaml")
  @instance.add_config_from_yaml("#{instance_folder}/stack-instance-default.yaml")
  @instance.add_config_from_yaml("#{instance_folder}/stack-instance-defaults.yaml")
  @instance.add_config_from_yaml("#{instance_folder}/spin-local.yaml")
  @instance.add_config_from_yaml("#{instance_folder}/stack-instance-local.yaml")
  @instance.add_parameter_values({ :instance_identifier => id })

  define
end

Instance Attribute Details

#definition_folderObject (readonly)

Returns the value of attribute definition_folder.



10
11
12
# File 'lib/cloudspin/stack/rake/stack_task.rb', line 10

def definition_folder
  @definition_folder
end

#idObject (readonly)

Returns the value of attribute id.



8
9
10
# File 'lib/cloudspin/stack/rake/stack_task.rb', line 8

def id
  @id
end

#instanceObject (readonly)

Returns the value of attribute instance.



9
10
11
# File 'lib/cloudspin/stack/rake/stack_task.rb', line 9

def instance
  @instance
end

#instance_folderObject (readonly)

Returns the value of attribute instance_folder.



11
12
13
# File 'lib/cloudspin/stack/rake/stack_task.rb', line 11

def instance_folder
  @instance_folder
end

Instance Method Details

#defineObject



29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
# File 'lib/cloudspin/stack/rake/stack_task.rb', line 29

def define

  desc "Create or update stack #{@instance.id}"
  task :up do
    puts @instance.up_dry
    puts @instance.up
  end

  desc "Plan changes to stack #{@instance.id}"
  task :plan do
    puts @instance.plan_dry
    puts @instance.plan
  end

  desc "Show command line to be run for stack #{@instance.id}"
  task :dry do
    puts @instance.up_dry
  end

  desc "Destroy stack #{@instance.id}"
  task :down do
    puts @instance.down_dry
    puts @instance.down
  end

end