lib/rspec/terraspace/project.rb in rspec-terraspace-0.2.3 vs lib/rspec/terraspace/project.rb in rspec-terraspace-0.3.0

- old
+ new

@@ -50,14 +50,14 @@ def build_config return unless @config config_folder = "#{build_dir}/config" - FileUtils.rm_rf(config_folder) # wipe current config folder FileUtils.mkdir_p(File.dirname(config_folder)) - src = @config - FileUtils.cp_r(src, config_folder) + Dir.glob("#{@config}/*").each do |src| + FileUtils.cp_r(src, config_folder) + end end def build_modules return unless @modules build_type_folder("modules", @modules) @@ -90,11 +90,12 @@ # app/stacks/#{stack}/tfvars/test.tfvars # def build_tfvars return unless @tfvars @tfvars.each do |stack, src| - tfvars_folder = "#{build_dir}/app/stacks/#{stack}/tfvars" + type = detected_type + tfvars_folder = "#{build_dir}/app/#{type}/#{stack}/tfvars" FileUtils.rm_rf(tfvars_folder) # wipe current tfvars folder. dont use any of the live values if File.directory?(src) FileUtils.mkdir_p(File.dirname(tfvars_folder)) FileUtils.cp_r(src, tfvars_folder) @@ -102,9 +103,16 @@ dest = "#{tfvars_folder}/test.tfvars" FileUtils.mkdir_p(File.dirname(dest)) FileUtils.cp(src, dest) end end + end + + # Returns: modules or stacks + def detected_type + dir = Dir.pwd + md = dir.match(%r{app/(stacks|modules)/(.*)?/}) + md[1] end # Inputs: # # list: options[:modules] or options[:stacks]