Class: Cloudspin::Stack::Rake::StackTask
- Inherits:
-
Rake::TaskLib
- Object
- Rake::TaskLib
- Cloudspin::Stack::Rake::StackTask
- Defined in:
- lib/cloudspin/stack/rake/stack_task.rb
Instance Attribute Summary collapse
-
#configuration_files ⇒ Object
readonly
Returns the value of attribute configuration_files.
-
#environment ⇒ Object
readonly
Returns the value of attribute environment.
-
#stack_name ⇒ Object
readonly
Returns the value of attribute stack_name.
Instance Method Summary collapse
- #default_configuration_files ⇒ Object
- #define ⇒ Object
- #environment_config_file ⇒ Object
- #full_path_of(supplied_path) ⇒ Object
-
#initialize(environment = nil, stack_name: 'instance', definition_location: nil, base_folder: '.', configuration_files: nil) ⇒ StackTask
constructor
A new instance of StackTask.
- #instance ⇒ Object
- #set_configuration_files(additional_configuration_files) ⇒ Object
- #the_usual_configuration_files ⇒ Object
Constructor Details
#initialize(environment = nil, stack_name: 'instance', definition_location: nil, base_folder: '.', configuration_files: nil) ⇒ StackTask
Returns a new instance of StackTask.
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/cloudspin/stack/rake/stack_task.rb', line 12 def initialize( environment = nil, stack_name: 'instance', definition_location: nil, base_folder: '.', configuration_files: nil ) @environment = environment @stack_name = stack_name @base_folder = base_folder set_configuration_files(configuration_files) # TODO: Pick this up from the configuration files? @definition_location = if definition_location definition_location else './src' end # @remote_zipfile = remote_zipfile define end |
Instance Attribute Details
#configuration_files ⇒ Object (readonly)
Returns the value of attribute configuration_files.
10 11 12 |
# File 'lib/cloudspin/stack/rake/stack_task.rb', line 10 def configuration_files @configuration_files end |
#environment ⇒ Object (readonly)
Returns the value of attribute environment.
8 9 10 |
# File 'lib/cloudspin/stack/rake/stack_task.rb', line 8 def environment @environment end |
#stack_name ⇒ Object (readonly)
Returns the value of attribute stack_name.
9 10 11 |
# File 'lib/cloudspin/stack/rake/stack_task.rb', line 9 def stack_name @stack_name end |
Instance Method Details
#default_configuration_files ⇒ Object
51 52 53 54 55 56 |
# File 'lib/cloudspin/stack/rake/stack_task.rb', line 51 def default_configuration_files [ "#{@base_folder}/stack-instance-defaults.yaml", "#{@base_folder}/stack-instance-local.yaml" ] end |
#define ⇒ Object
66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 |
# File 'lib/cloudspin/stack/rake/stack_task.rb', line 66 def define desc "Create or update stack instance" task :up do puts instance.init_dry puts instance.up_dry puts instance.up end desc "Plan changes to stack instance" task :plan do puts instance.init_dry puts instance.plan_dry puts instance.plan end desc "Show command line to be run for stack instance" task :dry do puts instance.init_dry puts instance.up_dry end desc "Destroy stack instance" task :down do puts instance.init_dry puts instance.down_dry puts instance.down end task :refresh do puts instance.refresh end end |
#environment_config_file ⇒ Object
58 59 60 |
# File 'lib/cloudspin/stack/rake/stack_task.rb', line 58 def environment_config_file "#{@base_folder}/environments/stack-#{@stack_name}-#{@environment}.yaml" end |
#full_path_of(supplied_path) ⇒ Object
62 63 64 |
# File 'lib/cloudspin/stack/rake/stack_task.rb', line 62 def full_path_of(supplied_path) Pathname.new(supplied_path).realdirpath.to_s end |
#instance ⇒ Object
100 101 102 103 104 105 106 107 108 |
# File 'lib/cloudspin/stack/rake/stack_task.rb', line 100 def instance @instance ||= Cloudspin::Stack::Instance.from_folder( @configuration_files, stack_name: stack_name, definition_location: @definition_location, base_folder: @base_folder, base_working_folder: "#{@base_folder}/work" ) end |
#set_configuration_files(additional_configuration_files) ⇒ Object
35 36 37 |
# File 'lib/cloudspin/stack/rake/stack_task.rb', line 35 def set_configuration_files(additional_configuration_files) @configuration_files = (the_usual_configuration_files << additional_configuration_files).flatten.compact end |
#the_usual_configuration_files ⇒ Object
39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/cloudspin/stack/rake/stack_task.rb', line 39 def the_usual_configuration_files file_list = default_configuration_files if @environment if File.exists? full_path_of(environment_config_file) file_list << environment_config_file else raise "Missing configuration file for environment #{@environment} (#{environment_config_file})" end end file_list end |