stax 0.0.10 → 0.0.11

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: 0c1fb0c4863d5f462054105ec15720e4b2055ec4656d703a2217a9bec0ea7957
4
- data.tar.gz: 388679f36efeb35b963f7d0a89162282b82df717cd55d69e0100ceff8c0109c9
3
+ metadata.gz: 77112f21d23c34b627328dbe16dee4c49c380f60094a27584cbd1a58467847ed
4
+ data.tar.gz: c04005d73b1e5d2d2dd49369b66941419722f01b16a59f9f96993ae87fe95469
5
5
  SHA512:
6
- metadata.gz: 82b5a4b04a7880868e806fe561be31651efdb30127bba6a2ebd5aaaf9f9a3d314280d53098285853853107a2154d4140ab3fe84092a4e4399c45eae566939193
7
- data.tar.gz: f31ff85970907378fed57b52c2daecb0f8b93b65cd2addec05ab0676530fd23e78af870ee35be916b34deff1ccf45b558f2799c7082376f4f2d2b46eaaa85032
6
+ metadata.gz: cdb6d027064fb78ce133795d3244eed99bb76ca4b4ab1abd6fa85ab748a07d3aaa3b76d4e3bafc3c487813eb90bce623977787138e7252b543da0b9fde17ac37
7
+ data.tar.gz: 0364f0379cd4dadf176b36172cae8624ee9afb315244758fe587b14df39a705fc887f8a99653378717de34a3f4e9f24048ed9109f0bb35be6c47ab6a4b62827e
@@ -11,6 +11,7 @@ require 'stax/cfer'
11
11
 
12
12
  require 'stax/stack'
13
13
  require 'stax/stack/cfn'
14
+ require 'stax/stack/template'
14
15
  require 'stax/stack/crud'
15
16
  require 'stax/stack/changeset'
16
17
  require 'stax/stack/parameters'
@@ -15,6 +15,10 @@ module Stax
15
15
  self.class.instance_variable_get(:@imports)
16
16
  end
17
17
 
18
+ def stack_type
19
+ self.class.instance_variable_get(:@type)
20
+ end
21
+
18
22
  def exists?
19
23
  Aws::Cfn.exists?(stack_name)
20
24
  end
@@ -73,26 +73,6 @@ module Stax
73
73
  }
74
74
  end
75
75
 
76
- ## location of templates relative to Staxfile
77
- def cfn_template_dir
78
- 'cf'
79
- end
80
-
81
- ## get cfn template from file depending on the format
82
- def cfn_template
83
- @_cfn_template ||= \
84
- begin
85
- stub = File.join(cfn_template_dir, "#{class_name}")
86
- if File.exists?(f = "#{stub}.rb")
87
- cfer_generate(f)
88
- elsif File.exists?(f = "#{stub}.yaml")
89
- File.read(f)
90
- elsif File.exists?(f = "#{stub}.json")
91
- File.read(f)
92
- end
93
- end
94
- end
95
-
96
76
  ## set this to always do an S3 upload of template
97
77
  def cfn_force_s3?
98
78
  false
@@ -0,0 +1,68 @@
1
+ module Stax
2
+ class Stack < Base
3
+
4
+ no_commands do
5
+ ## location of templates relative to Staxfile
6
+ def cfn_template_dir
7
+ 'cf'
8
+ end
9
+
10
+ ## template filename without extension
11
+ def cfn_template_stub
12
+ @_cfn_template_stub ||= File.join(cfn_template_dir, "#{class_name}")
13
+ end
14
+
15
+ ## load a yaml template
16
+ def cfn_template_yaml
17
+ if File.exists?(f = "#{cfn_template_stub}.yaml")
18
+ File.read(f)
19
+ end
20
+ end
21
+
22
+ ## load a json template
23
+ def cfn_template_json
24
+ if File.exists?(f = "#{cfn_template_stub}.json")
25
+ File.read(f)
26
+ end
27
+ end
28
+
29
+ ## load a ruby cfer template
30
+ def cfn_template_cfer
31
+ if File.exists?(f = "#{cfn_template_stub}.rb")
32
+ cfer_generate(f)
33
+ end
34
+ end
35
+
36
+ ## by default look for cdk templates in same dir as Staxfile
37
+ def cfn_cdk_dir
38
+ Stax.root_path
39
+ end
40
+
41
+ ## transcompile and load a cdk template
42
+ def cfn_template_cdk
43
+ Dir.chdir(cfn_cdk_dir) do
44
+ %x[npm run build]
45
+ %x[cdk synth]
46
+ end
47
+ end
48
+
49
+ ## try to guess template by filename
50
+ def cfn_template_guess
51
+ cfn_template_cfer || cfn_template_yaml || cfn_template_json
52
+ end
53
+
54
+ ## get cfn template based on stack type
55
+ def cfn_template
56
+ @_cfn_template ||= \
57
+ begin
58
+ if stack_type
59
+ send("cfn_template_#{stack_type}")
60
+ else
61
+ cfn_template_guess || fail_task('cannot find template')
62
+ end
63
+ end
64
+ end
65
+
66
+ end
67
+ end
68
+ end
@@ -55,6 +55,7 @@ module Stax
55
55
  end
56
56
 
57
57
  klass.instance_variable_set(:@imports, Array(opt.fetch(:import, [])))
58
+ klass.instance_variable_set(:@type, opt.fetch(:type, nil))
58
59
  end
59
60
  end
60
61
 
@@ -1,3 +1,3 @@
1
1
  module Stax
2
- VERSION = '0.0.10'
2
+ VERSION = '0.0.11'
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.10
4
+ version: 0.0.11
5
5
  platform: ruby
6
6
  authors:
7
7
  - Richard Lister
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-11-22 00:00:00.000000000 Z
11
+ date: 2018-12-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -246,6 +246,7 @@ files:
246
246
  - lib/stax/stack/outputs.rb
247
247
  - lib/stax/stack/parameters.rb
248
248
  - lib/stax/stack/resources.rb
249
+ - lib/stax/stack/template.rb
249
250
  - lib/stax/staxfile.rb
250
251
  - lib/stax/subcommand.rb
251
252
  - lib/stax/version.rb