class TerraspaceBundler::Exporter::Stacks::Stack
Attributes
mod[R]
Public Class Methods
new(mod, options={})
click to toggle source
# File lib/terraspace_bundler/exporter/stacks/stack.rb, line 4 def initialize(mod, options={}) @mod, @options = mod, options end
Public Instance Methods
copy()
click to toggle source
# File lib/terraspace_bundler/exporter/stacks/stack.rb, line 13 def copy return unless @options FileUtils.rm_rf(dest) if purge? return if File.exist?(dest) FileUtils.mkdir_p(File.dirname(dest)) FileUtils.cp_r(src, dest) end
dest()
click to toggle source
# File lib/terraspace_bundler/exporter/stacks/stack.rb, line 58 def dest dest = @options[:dest] || TB.config.stack_options[:dest] name = @options[:name] || @mod.name # falls back to mod name by default "#{dest}/#{name}" end
examples()
click to toggle source
# File lib/terraspace_bundler/exporter/stacks/stack.rb, line 54 def examples @options[:examples] || TB.config.stack_options[:examples] end
examples_folder()
click to toggle source
public method used by StackConcern#all_stacks
# File lib/terraspace_bundler/exporter/stacks/stack.rb, line 50 def examples_folder [mod_path, examples].join('/') end
export()
click to toggle source
# File lib/terraspace_bundler/exporter/stacks/stack.rb, line 8 def export copy rewrite end
pretty_path(path)
click to toggle source
# File lib/terraspace_bundler/exporter/stacks/stack.rb, line 45 def pretty_path(path) path.sub("#{Dir.pwd}/",'') end
purge?()
click to toggle source
purge precedence:
1. Terrafile mod level stack option 2. Terrafile-level stack_options
# File lib/terraspace_bundler/exporter/stacks/stack.rb, line 69 def purge? # config.stack_options is set from Terrafile-level stack_options to TB.config.stack # relevant source code: dsl/syntax.rb: def stack_options config = TB.config.stack_options[:purge] config = config.nil? ? false : config @options[:purge].nil? ? config : @options[:purge] end
rewrite()
click to toggle source
# File lib/terraspace_bundler/exporter/stacks/stack.rb, line 23 def rewrite Rewrite.new(self).run end
src()
click to toggle source
# File lib/terraspace_bundler/exporter/stacks/stack.rb, line 27 def src src = @options[:src] without_examples = [mod_path, src].compact.join('/') with_examples = [examples_folder, src].compact.join('/') paths = [with_examples, without_examples] found = paths.find do |path| File.exist?(path) end unless found searched = paths.map { |p| pretty_path(p) }.map { |p| " #{p}" }.join("\n") logger.error "ERROR: Example not found. stack src: #{src}. Searched:".color(:red) logger.error searched exit 1 end found end