stack_master 2.0.1 → 2.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d31b69b485cf1a596a57888078b05db3d39b2371810b27c3ee99adff8511a99c
4
- data.tar.gz: d20bcd9566689b3f81bdb3fcb78d2b6396ab1fa7766f47f8cb6d31f0bd0664a9
3
+ metadata.gz: 07d864d8296f8ef63b16a68d3989ad872bdccf74db2d3b83ce5091f6f9ccc8d2
4
+ data.tar.gz: 1ba9e5731843eb3c0c15142d17ec194850c46eee64eb3b272b9b74724def426f
5
5
  SHA512:
6
- metadata.gz: 29bd9ff5a5b8f0277eb29afc04df6a20c2feabcad86672835572b0c50e03c7ad8785dd70bb28747e433b298476b2f388899bc9f1879df2999c1e2fc716a7687e
7
- data.tar.gz: add78325db65cc03a46cd9870e4733b02e0d8c7eaa15652f7dd97b00413adb54a1f63b2e80d1f6fcf78a4b303d8c091829c74433a924c4dfc7c7897ca7711858
6
+ metadata.gz: 984b2b33aa71a12c5c6699308d6d801c721977b308083d93bb2e9e7e8a8d442e433c7a0cfe07a91a069091504351c186989c07df668fec445b4db0432ef1e05f
7
+ data.tar.gz: a3349cbe7a82af5a9a7e044ec9a840f25e0284ac6040514b2cc3ef64db540f8ce76185084d4db74b0aab0a2af835fbf60455315412b2d1242e00b24bc1fd426f
data/README.md CHANGED
@@ -157,13 +157,15 @@ template_compilers:
157
157
 
158
158
  Parameters are loaded from multiple YAML files, merged from the following lookup paths from bottom to top:
159
159
 
160
- - parameters/[stack_name].yaml
161
- - parameters/[stack_name].yml
160
+ - parameters/[underscored_stack_name].yaml
161
+ - parameters/[underscored_stack_name].yml
162
162
  - parameters/[region]/[underscored_stack_name].yaml
163
163
  - parameters/[region]/[underscored_stack_name].yml
164
164
  - parameters/[region_alias]/[underscored_stack_name].yaml
165
165
  - parameters/[region_alias]/[underscored_stack_name].yml
166
166
 
167
+ **Note:** The file names must be underscored, not hyphenated, even if the stack names are hyphenated.
168
+
167
169
  A simple parameter file could look like this:
168
170
 
169
171
  ```
@@ -679,6 +681,7 @@ stack_master events [region-or-alias] [stack-name] # Display events for a stack
679
681
  stack_master outputs [region-or-alias] [stack-name] # Display outputs for a stack
680
682
  stack_master resources [region-or-alias] [stack-name] # Display outputs for a stack
681
683
  stack_master status # Displays the status of each stack
684
+ stack_master tidy # Find missing or extra templates or parameter files
682
685
  ```
683
686
 
684
687
  ## Applying updates
data/lib/stack_master.rb CHANGED
@@ -63,6 +63,7 @@ module StackMaster
63
63
  autoload :Resources, 'stack_master/commands/resources'
64
64
  autoload :Delete, 'stack_master/commands/delete'
65
65
  autoload :Status, 'stack_master/commands/status'
66
+ autoload :Tidy, 'stack_master/commands/tidy'
66
67
  end
67
68
 
68
69
  module ParameterResolvers
@@ -169,6 +169,19 @@ module StackMaster
169
169
  end
170
170
  end
171
171
 
172
+ command :tidy do |c|
173
+ c.syntax = 'stack_master tidy'
174
+ c.summary = 'Try to identify extra & missing files.'
175
+ c.description = 'Cross references stack_master.yml with the template and parameter directories to identify extra or missing files.'
176
+ c.example 'description', 'Check for missing or extra files'
177
+ c.action do |args, options|
178
+ options.defaults config: default_config_file
179
+ say "Invalid arguments. stack_master tidy" and return unless args.size == 0
180
+ config = load_config(options.config)
181
+ StackMaster::Commands::Tidy.perform(config)
182
+ end
183
+ end
184
+
172
185
  command :delete do |c|
173
186
  c.syntax = 'stack_master delete [region] [stack_name]'
174
187
  c.summary = 'Delete an existing stack'
@@ -0,0 +1,68 @@
1
+ module StackMaster
2
+ module Commands
3
+ class Tidy
4
+ include Command
5
+ include StackMaster::Commands::TerminalHelper
6
+
7
+ def initialize(config)
8
+ @config = config
9
+ end
10
+
11
+ def perform
12
+ used_templates = []
13
+ used_parameter_files = []
14
+
15
+ templates = Set.new(find_templates())
16
+ parameter_files = Set.new(find_parameter_files())
17
+
18
+ status = @config.stacks.each do |stack_definition|
19
+ parameter_files.subtract(stack_definition.parameter_files)
20
+ template = File.absolute_path(stack_definition.template_file_path)
21
+
22
+ if template
23
+ templates.delete(template)
24
+
25
+ if !File.exist?(template)
26
+ StackMaster.stdout.puts "Stack \"#{stack_definition.stack_name}\" in \"#{stack_definition.region}\" missing template \"#{rel_path(template)}\""
27
+ end
28
+ end
29
+ end
30
+
31
+ templates.each do |path|
32
+ StackMaster.stdout.puts "#{rel_path(path)}: no stack found for this template"
33
+ end
34
+
35
+ parameter_files.each do |path|
36
+ StackMaster.stdout.puts "#{rel_path(path)}: no stack found for this parameter file"
37
+ end
38
+ end
39
+
40
+ def rel_path(path)
41
+ Pathname.new(path).relative_path_from(Pathname.new(@config.base_dir))
42
+ end
43
+
44
+ def find_templates
45
+ # TODO: Inferring default template directory based on the behaviour in
46
+ # stack_definition.rb. For some configurations (eg, per-region
47
+ # template directories) this won't find the right directory.
48
+ template_dir = @config.template_dir || File.join(@config.base_dir, 'templates')
49
+
50
+ templates = Dir.glob(File.absolute_path(File.join(template_dir, '**', "*.{rb,yaml,yml,json}")))
51
+ dynamics_dir = File.join(template_dir, 'dynamics')
52
+
53
+ # Exclude sparkleformation dynamics
54
+ # TODO: Should this filter out anything with 'dynamics', not just the first
55
+ # subdirectory?
56
+ templates = templates.select do |path|
57
+ !path.start_with?(dynamics_dir)
58
+ end
59
+
60
+ templates
61
+ end
62
+
63
+ def find_parameter_files
64
+ Dir.glob(File.absolute_path(File.join(@config.base_dir, "parameters", "*.{yml,yaml}")))
65
+ end
66
+ end
67
+ end
68
+ end
@@ -1,3 +1,3 @@
1
1
  module StackMaster
2
- VERSION = "2.0.1"
2
+ VERSION = "2.1.0"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: stack_master
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.1
4
+ version: 2.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Steve Hodgkiss
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2020-01-22 00:00:00.000000000 Z
12
+ date: 2020-03-06 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bundler
@@ -309,16 +309,16 @@ dependencies:
309
309
  name: sparkle_formation
310
310
  requirement: !ruby/object:Gem::Requirement
311
311
  requirements:
312
- - - ">="
312
+ - - "~>"
313
313
  - !ruby/object:Gem::Version
314
- version: '0'
314
+ version: '3'
315
315
  type: :runtime
316
316
  prerelease: false
317
317
  version_requirements: !ruby/object:Gem::Requirement
318
318
  requirements:
319
- - - ">="
319
+ - - "~>"
320
320
  - !ruby/object:Gem::Version
321
- version: '0'
321
+ version: '3'
322
322
  - !ruby/object:Gem::Dependency
323
323
  name: table_print
324
324
  requirement: !ruby/object:Gem::Requirement
@@ -403,6 +403,20 @@ dependencies:
403
403
  - - ">="
404
404
  - !ruby/object:Gem::Version
405
405
  version: '0'
406
+ - !ruby/object:Gem::Dependency
407
+ name: diff-lcs
408
+ requirement: !ruby/object:Gem::Requirement
409
+ requirements:
410
+ - - ">="
411
+ - !ruby/object:Gem::Version
412
+ version: '0'
413
+ type: :runtime
414
+ prerelease: false
415
+ version_requirements: !ruby/object:Gem::Requirement
416
+ requirements:
417
+ - - ">="
418
+ - !ruby/object:Gem::Version
419
+ version: '0'
406
420
  description: ''
407
421
  email:
408
422
  - steve@hodgkiss.me
@@ -432,6 +446,7 @@ files:
432
446
  - lib/stack_master/commands/resources.rb
433
447
  - lib/stack_master/commands/status.rb
434
448
  - lib/stack_master/commands/terminal_helper.rb
449
+ - lib/stack_master/commands/tidy.rb
435
450
  - lib/stack_master/commands/validate.rb
436
451
  - lib/stack_master/config.rb
437
452
  - lib/stack_master/ctrl_c.rb
@@ -502,8 +517,8 @@ licenses:
502
517
  metadata:
503
518
  bug_tracker_uri: https://github.com/envato/stack_master/issues
504
519
  changelog_uri: https://github.com/envato/stack_master/blob/master/CHANGELOG.md
505
- documentation_uri: https://www.rubydoc.info/gems/stack_master/2.0.1
506
- source_code_uri: https://github.com/envato/stack_master/tree/v2.0.1
520
+ documentation_uri: https://www.rubydoc.info/gems/stack_master/2.1.0
521
+ source_code_uri: https://github.com/envato/stack_master/tree/v2.1.0
507
522
  post_install_message:
508
523
  rdoc_options: []
509
524
  require_paths:
@@ -519,7 +534,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
519
534
  - !ruby/object:Gem::Version
520
535
  version: '0'
521
536
  requirements: []
522
- rubygems_version: 3.0.4
537
+ rubygems_version: 3.1.2
523
538
  signing_key:
524
539
  specification_version: 4
525
540
  summary: StackMaster is a sure-footed way of creating, updating and keeping track