stax 0.0.17 → 0.0.18

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: bf4f4e043c476f43efbf2dabab7197b831ca7cfb467e63102d66a0758cb49b4c
4
- data.tar.gz: 571a5d369568bd81bf6184e81e296926cfb7eb9fe904dfb931eedbcc16472909
3
+ metadata.gz: 5486562e74d9cf1667442004f01e1b16ffe2456726b4fdaddb7234aa557185ff
4
+ data.tar.gz: 8bbd5d0275c83057a51a0de9d3e7120e49438af985aff66b625aa03f23646646
5
5
  SHA512:
6
- metadata.gz: 80d4633373d3a5c724cf2908dee5dfe5dd8f628e5c731f2aac47274f9d67bb19e8548db886cc7ff1b4227d38da6c517705818a41cfb544f43b23a13497baee88
7
- data.tar.gz: 31b0e98e8347e837b160eadddac03976b36ffd7f691b40e3719ce953eb62e5b6768eb414cd57fc53b961cb988a4685a538613967b4d08d30b619a15219cde64d
6
+ metadata.gz: 50e02b4a34a8004a215e4a145cf25245267c10eec819ad6d3573f4127c6691bc7ecf15b547e6209de2924d9de6b904b302ec887b2ef2a1b2bd523f73cf377ac0
7
+ data.tar.gz: 7b29b547ab108307274d3531013c76be3933e470d8483164607f54510795a670c653648c972a45c9a359ad27fc024394e3732052a3ca6f51a2e155cb1e51af2b
data/README.md CHANGED
@@ -179,6 +179,8 @@ Stax will load template files from the path relative to its `Staxfile`
179
179
  as `cf/$stack.rb`, e.g. `cf/vpc.rb`. Modify this using the method `Stax::Stack::cfn_template_dir`.
180
180
  See `examples` for a typical setup.
181
181
 
182
+ ## Create/update/delete stacks
183
+
182
184
  Simply control stacks using the relevant subcommands:
183
185
 
184
186
  ```
@@ -194,6 +196,40 @@ etc.
194
196
  To change this scheme modify the methods `Stax::Base::stack_prefix`
195
197
  and/or `Stax::Stack::stack_name`.
196
198
 
199
+ ## Operating on multiple stacks
200
+
201
+ The following will create/update/delete all stacks in the order they
202
+ are declared in the `Staxfile` (reversed for delete):
203
+
204
+ ```
205
+ $ stax create
206
+ $ stax update
207
+ $ stax delete
208
+ ```
209
+
210
+ It is possible to group stacks in the `Staxfile`, for example to skip
211
+ optional stacks during creation:
212
+
213
+ ```
214
+ stack :vpc
215
+ stack :db
216
+ stack :app
217
+
218
+ group :production do
219
+ stack :monitor
220
+ stack :metrics
221
+ end
222
+ ```
223
+
224
+ Stacks defined outside a `group` block belong to group `:default`, and
225
+ only these are created by default during `stax create`. This behavior
226
+ can be modified using `--groups` or `--all` options:
227
+
228
+ ```
229
+ $ stax create --groups production
230
+ $ stax create --all
231
+ ```
232
+
197
233
  ## Stack parameters
198
234
 
199
235
  For any given stack, subclass `Stax::Stack` and return define a hash of
@@ -14,8 +14,19 @@ module Stax
14
14
  end
15
15
 
16
16
  desc 'create', 'meta create task'
17
+ method_option :all, type: :boolean, default: false, desc: 'create all groups'
18
+ method_option :groups, aliases: '-g', type: :array, default: %w[default], desc: 'limit to stack groups'
17
19
  def create
18
- stack_objects.each do |s|
20
+ stacks = stack_objects
21
+
22
+ ## filter by stack groups
23
+ unless options[:all]
24
+ stacks.reject! do |s|
25
+ (s.stack_groups.map(&:to_s) & options[:groups]).empty? # test intersection
26
+ end
27
+ end
28
+
29
+ stacks.each do |s|
19
30
  if s.exists?
20
31
  say("Skipping: #{s.stack_name} exists", :yellow)
21
32
  elsif y_or_n?("Create #{s.stack_name}?", :yellow)
@@ -1,13 +1,21 @@
1
1
  ## Staxfile DSL commands
2
2
  module Stax
3
3
  module Dsl
4
- def stack(*args)
5
- Stax.add_stack(*args)
4
+ def stack(name, opt = {})
5
+ opt = {groups: @groups}.merge(opt) # merge with defaults
6
+ Stax.add_stack(name, opt)
6
7
  end
7
8
 
8
9
  def command(*args)
9
10
  Stax.add_command(*args)
10
11
  end
12
+
13
+ ## temporarily change default list of groups
14
+ def group(*groups, &block)
15
+ @groups = groups
16
+ yield
17
+ @groups = nil
18
+ end
11
19
  end
12
20
  end
13
21
 
@@ -22,6 +22,10 @@ module Stax
22
22
  self.class.instance_variable_get(:@type)
23
23
  end
24
24
 
25
+ def stack_groups
26
+ self.class.instance_variable_get(:@groups) || [:default]
27
+ end
28
+
25
29
  def exists?
26
30
  Aws::Cfn.exists?(stack_name)
27
31
  end
@@ -59,6 +59,7 @@ module Stax
59
59
  klass.instance_variable_set(:@name, name)
60
60
  klass.instance_variable_set(:@imports, Array(opt.fetch(:import, [])))
61
61
  klass.instance_variable_set(:@type, opt.fetch(:type, nil))
62
+ klass.instance_variable_set(:@groups, opt.fetch(:groups, nil))
62
63
  end
63
64
  end
64
65
 
@@ -1,3 +1,3 @@
1
1
  module Stax
2
- VERSION = '0.0.17'
2
+ VERSION = '0.0.18'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: stax
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.17
4
+ version: 0.0.18
5
5
  platform: ruby
6
6
  authors:
7
7
  - Richard Lister
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-05-22 00:00:00.000000000 Z
11
+ date: 2019-06-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler