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.
Instance Method Summary collapse
- #default_configuration_files ⇒ Object
- #define ⇒ Object
- #environment_config_file ⇒ Object
- #full_path_of(supplied_path) ⇒ Object
-
#initialize(environment = nil, 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, definition_location: nil, base_folder: '.', configuration_files: nil) ⇒ StackTask
Returns a new instance of StackTask.
11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/cloudspin/stack/rake/stack_task.rb', line 11 def initialize( environment = nil, definition_location: nil, base_folder: '.', configuration_files: nil ) @environment = environment @base_folder = base_folder set_configuration_files(configuration_files) @definition_location = definition_location define end |
Instance Attribute Details
#configuration_files ⇒ Object (readonly)
Returns the value of attribute configuration_files.
9 10 11 |
# File 'lib/cloudspin/stack/rake/stack_task.rb', line 9 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 |
Instance Method Details
#default_configuration_files ⇒ Object
41 42 43 44 45 46 |
# File 'lib/cloudspin/stack/rake/stack_task.rb', line 41 def default_configuration_files [ "#{@base_folder}/stack-instance-defaults.yaml", "#{@base_folder}/stack-instance-local.yaml" ] end |
#define ⇒ Object
56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 |
# File 'lib/cloudspin/stack/rake/stack_task.rb', line 56 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
48 49 50 |
# File 'lib/cloudspin/stack/rake/stack_task.rb', line 48 def environment_config_file "#{@base_folder}/environments/stack-instance-#{@environment}.yaml" end |
#full_path_of(supplied_path) ⇒ Object
52 53 54 |
# File 'lib/cloudspin/stack/rake/stack_task.rb', line 52 def full_path_of(supplied_path) Pathname.new(supplied_path).realdirpath.to_s end |
#instance ⇒ Object
90 91 92 93 94 95 96 97 |
# File 'lib/cloudspin/stack/rake/stack_task.rb', line 90 def instance @instance ||= Cloudspin::Stack::Instance.from_folder( @configuration_files, definition_location: @definition_location, base_folder: @base_folder, base_working_folder: "#{@base_folder}/work" ) end |
#set_configuration_files(additional_configuration_files) ⇒ Object
25 26 27 |
# File 'lib/cloudspin/stack/rake/stack_task.rb', line 25 def set_configuration_files(additional_configuration_files) @configuration_files = (the_usual_configuration_files << additional_configuration_files).flatten.compact end |
#the_usual_configuration_files ⇒ Object
29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/cloudspin/stack/rake/stack_task.rb', line 29 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 |