lib/cloudspin/stack/rake/stack_task.rb in cloudspin-stack-rake-0.1.12 vs lib/cloudspin/stack/rake/stack_task.rb in cloudspin-stack-rake-0.1.13
- old
+ new
@@ -4,19 +4,23 @@
module Rake
class StackTask < ::Rake::TaskLib
attr_reader :instance
+ attr_reader :environment
+ attr_reader :role
attr_reader :configuration_files
def initialize(
environment = nil,
+ role: 'instance',
definition_folder: './src',
base_folder: '.',
configuration_files: nil
)
@environment = environment
+ @role = role
@base_folder = base_folder
@configuration_files = configuration_files || instance_configuration_files
@instance = Cloudspin::Stack::Instance.from_folder(
@configuration_files,
@@ -28,27 +32,31 @@
end
def instance_configuration_files
file_list = default_configuration_files
if @environment
- if File.exists? environment_config_file
+ if File.exists? full_path_of(environment_config_file)
file_list << environment_config_file
else
- raise "Missing configuration file for environment #{options[:environment]} (#{environment_config_file})"
+ raise "Missing configuration file for environment #{@environment} (#{environment_config_file})"
end
end
file_list
end
def default_configuration_files
[
- "#{@base_folder}/stack-instance-defaults.yaml",
- "#{@base_folder}/stack-instance-local.yaml"
+ "#{@base_folder}/stack-#{@role}-defaults.yaml",
+ "#{@base_folder}/stack-#{@role}-local.yaml"
]
end
def environment_config_file
- Pathname.new("#{@base_folder}/environments/stack-instance-#{@environment}.yaml").realdirpath.to_s
+ "#{@base_folder}/environments/stack-#{@role}-#{@environment}.yaml"
+ end
+
+ def full_path_of(supplied_path)
+ Pathname.new(supplied_path).realdirpath.to_s
end
def define
desc "Create or update stack #{@instance.id}"