Class: StackMaster::Commands::Tidy
Instance Method Summary
collapse
#unix_window_size, #window_size, #windows_window_size
included, #initialize, #success?
Instance Method Details
#find_parameter_files ⇒ Object
59
60
61
|
# File 'lib/stack_master/commands/tidy.rb', line 59
def find_parameter_files
Dir.glob(File.absolute_path(File.join(@config.base_dir, "parameters", "*.{yml,yaml}")))
end
|
#find_templates ⇒ Object
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
|
# File 'lib/stack_master/commands/tidy.rb', line 40
def find_templates
template_dir = @config.template_dir || File.join(@config.base_dir, 'templates')
templates = Dir.glob(File.absolute_path(File.join(template_dir, '**', "*.{rb,yaml,yml,json}")))
dynamics_dir = File.join(template_dir, 'dynamics')
templates = templates.select do |path|
!path.start_with?(dynamics_dir)
end
templates
end
|
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
|
# File 'lib/stack_master/commands/tidy.rb', line 7
def perform
used_templates = []
used_parameter_files = []
templates = Set.new(find_templates())
parameter_files = Set.new(find_parameter_files())
status = @config.stacks.each do |stack_definition|
parameter_files.subtract(stack_definition.parameter_files_from_globs)
template = File.absolute_path(stack_definition.template_file_path)
if template
templates.delete(template)
if !File.exist?(template)
StackMaster.stdout.puts "Stack \"#{stack_definition.stack_name}\" in \"#{stack_definition.region}\" missing template \"#{rel_path(template)}\""
end
end
end
templates.each do |path|
StackMaster.stdout.puts "#{rel_path(path)}: no stack found for this template"
end
parameter_files.each do |path|
StackMaster.stdout.puts "#{rel_path(path)}: no stack found for this parameter file"
end
end
|
#rel_path(path) ⇒ Object
36
37
38
|
# File 'lib/stack_master/commands/tidy.rb', line 36
def rel_path(path)
Pathname.new(path).relative_path_from(Pathname.new(@config.base_dir))
end
|