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
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# 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) # 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.
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
48 49 50 51 52 53 |
# File 'lib/cloudspin/stack/rake/stack_task.rb', line 48 def default_configuration_files [ "#{@base_folder}/stack-instance-defaults.yaml", "#{@base_folder}/stack-instance-local.yaml" ] end |
#define ⇒ Object
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 89 90 91 92 93 94 95 |
# File 'lib/cloudspin/stack/rake/stack_task.rb', line 63 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
55 56 57 |
# File 'lib/cloudspin/stack/rake/stack_task.rb', line 55 def environment_config_file "#{@base_folder}/environments/stack-instance-#{@environment}.yaml" end |
#full_path_of(supplied_path) ⇒ Object
59 60 61 |
# File 'lib/cloudspin/stack/rake/stack_task.rb', line 59 def full_path_of(supplied_path) Pathname.new(supplied_path).realdirpath.to_s end |
#instance ⇒ Object
97 98 99 100 101 102 103 104 |
# File 'lib/cloudspin/stack/rake/stack_task.rb', line 97 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
32 33 34 |
# File 'lib/cloudspin/stack/rake/stack_task.rb', line 32 def set_configuration_files(additional_configuration_files) @configuration_files = (the_usual_configuration_files << additional_configuration_files).flatten.compact end |
#the_usual_configuration_files ⇒ Object
36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/cloudspin/stack/rake/stack_task.rb', line 36 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 |