hygroscope 1.0.0 → 1.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
  SHA1:
3
- metadata.gz: cd6ed704c9f7b15170bc39f4162300946f7f690f
4
- data.tar.gz: fd84d911d968cc9a883ded9bb45b4cbe417467db
3
+ metadata.gz: 6cf0c838143e22c457350f92b2464989b275af06
4
+ data.tar.gz: 16166f857257972e8ee90181d793a31bbebb9885
5
5
  SHA512:
6
- metadata.gz: a45f21a18bee67f59a412a5115d3a193cf53df152b5441de6090d3aed062c3a25fcf2442720af0af77e6e09bbf8e972ab46f29d842a5d5c734613e80b23cc795
7
- data.tar.gz: 813ac9c2ec94513bb791be5715efa8513bf25998a482b3df1a15d6ddac0e0df37660dfc00788037e2064a7da4bedc4e77bb454857f80d1bab58f87fd4d26d3d8
6
+ metadata.gz: 91e264b2ecca6188a62bb028388c3e51e7a21a426e6bc1a9370f44c83464beb82483f81a5cbc52edddd6f52ddcf2a989d32e317f4d87ce9634a13ead72b803be
7
+ data.tar.gz: d34c7c519cf094024ef5db03c5eed7e58be60bb330e2aad99f0adf037568961ce3965b78211ce7d4e7541c15731858f3c4dea19f5c2c03896290fdab7e69c5ba
data/CHANGELOG.md ADDED
@@ -0,0 +1,8 @@
1
+ ## 1.1.0 (2015-02-03)
2
+
3
+ - Support passing outputs from existing stacks into parameters.
4
+ - Support numeric parameters and tags.
5
+
6
+ ## 1.0.0 (2015-02-02)
7
+
8
+ - Initial functional release.
data/hygroscope.gemspec CHANGED
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = 'hygroscope'
3
- s.version = '1.0.0'
3
+ s.version = '1.1.0'
4
4
  s.summary = 'CloudFormation launcher'
5
5
  s.description = 'A tool for managing the launch of complex CloudFormation stacks'
6
6
  s.authors = ['Daniel Silverman']
@@ -66,8 +66,6 @@ module Hygroscope
66
66
  # If the paramset exists load it, otherwise instantiate an empty one
67
67
  p = Hygroscope::ParamSet.new(options[:paramset])
68
68
 
69
- # TODO: Load and merge outputs from previous invocations -- how???
70
-
71
69
  # User provided a paramset, so load it and determine which parameters
72
70
  # are set and which need to be prompted.
73
71
  if options[:paramset]
@@ -86,31 +84,55 @@ module Hygroscope
86
84
  missing = t.parameters.keys
87
85
  end
88
86
 
87
+ # If an existing stack was specified, load its outputs
88
+ if options[:existing]
89
+ e = Hygroscope::Stack.new(options[:existing])
90
+ say_status('info', "Populating parameters from #{options[:existing]} stack", :blue)
91
+
92
+ # Fill any template paramater that matches an output of existing stack,
93
+ # overriding parameters in the paramset. User can still change these if
94
+ # they were missing from paramset or --ask option is passed.
95
+ e.describe.outputs.each do |o|
96
+ p.set(o.output_key, o.output_value) if t.parameters.keys.include?(o.output_key)
97
+ end
98
+ end
99
+
89
100
  # Prompt for each missing param and save it to the paramset
90
101
  missing.each do |key|
91
102
  # Do not prompt for keys prefixed with "Hygroscope"
92
103
  next if key =~ /^Hygroscope/
93
104
 
94
- say()
95
105
  type = t.parameters[key]['Type']
96
- default = options[:ask] && pkeys.include?(key) ? p.get(key) : t.parameters[key]['Default'] || ''
106
+ default = p.get(key) ? p.get(key) : t.parameters[key]['Default'] || ''
97
107
  description = t.parameters[key]['Description'] || false
98
108
  values = t.parameters[key]['AllowedValues'] || false
99
109
  no_echo = t.parameters[key]['NoEcho'] || false
100
110
 
111
+ # Thor conveniently provides some nice logic for formatting,
112
+ # allowing defaults, and validating user input
101
113
  ask_opts = {}
102
- ask_opts[:default] = default unless default.empty?
114
+ ask_opts[:default] = default unless default.to_s.empty?
103
115
  ask_opts[:limited_to] = values if values
104
116
  ask_opts[:echo] = false if no_echo
105
117
 
118
+ puts
106
119
  say("#{description} (#{type})") if description
107
- answer = ''
120
+ # Make sure user enters a value
108
121
  # TODO: Better input validation
122
+ answer = ''
109
123
  answer = ask(key, :cyan, ask_opts) until answer != ''
124
+
125
+ # Save answer to paramset object
110
126
  p.set(key, answer)
127
+
128
+ # Add a line break
129
+ say if no_echo
111
130
  end
112
131
 
113
- unless missing.empty?
132
+ # Offer to save paramset if it was modified
133
+ # Filter out keys beginning with "Hygroscope" since they are not visible
134
+ # to the user and may be modified on each invocation.
135
+ unless missing.reject {|k| k =~ /^Hygroscope/}.empty?
114
136
  if yes?('Save changes to paramset?')
115
137
  unless options[:paramset]
116
138
  p.name = ask('Paramset name', :cyan, default: options[:name])
@@ -135,7 +157,7 @@ module Hygroscope
135
157
  [t, p]
136
158
  end
137
159
 
138
- desc 'create', "Create a new stack.\nUse the --name option to launch more than one stack from the same template.\nCommand prompts for parameters unless --paramset is specified."
160
+ desc 'create', "Create a new stack.\nUse the --name option to launch more than one stack from the same template.\nCommand prompts for parameters unless --paramset is specified.\nUse --existing to set parameters from an existing stack's outputs."
139
161
  method_option :name,
140
162
  aliases: '-n',
141
163
  default: File.basename(Dir.pwd),
@@ -144,6 +166,10 @@ module Hygroscope
144
166
  aliases: '-p',
145
167
  required: false,
146
168
  desc: 'Name of saved paramset to use (optional)'
169
+ method_option :existing,
170
+ aliases: '-e',
171
+ required: false,
172
+ desc: 'Name of an existing stack from which to retrieve outputs as parameters (optional)'
147
173
  method_option :ask,
148
174
  aliases: '-a',
149
175
  type: :boolean,
@@ -152,6 +178,8 @@ module Hygroscope
152
178
  def create
153
179
  check_path
154
180
  validate
181
+
182
+ # Prepare task takes care of shared logic between "create" and "update"
155
183
  template, paramset = prepare
156
184
 
157
185
  s = Hygroscope::Stack.new(options[:name])
@@ -159,6 +187,7 @@ module Hygroscope
159
187
  s.template = template.compress
160
188
  s.tags['X-Hygroscope-Template'] = File.basename(Dir.pwd)
161
189
  s.capabilities = ['CAPABILITY_IAM']
190
+
162
191
  s.create!
163
192
 
164
193
  status
@@ -184,6 +213,8 @@ module Hygroscope
184
213
  # whether to re-upload the payload, etc.)
185
214
  check_path
186
215
  validate
216
+
217
+ # Prepare task takes care of shared logic between "create" and "update"
187
218
  template, paramset = prepare
188
219
 
189
220
  s = Hygroscope::Stack.new(options[:name])
@@ -240,9 +271,12 @@ module Hygroscope
240
271
  print_table header
241
272
  puts
242
273
 
274
+ # Fancy acrobatics to fit output to terminal width. If the terminal
275
+ # window is too small, fallback to something appropriate for ~80 chars
243
276
  type_width = terminal_width < 80 ? 30 : terminal_width - 50
244
277
  output_width = terminal_width < 80 ? 54 : terminal_width - 31
245
278
 
279
+ # Header row
246
280
  puts set_color(sprintf(' %-28s %-*s %-18s ', 'Resource', type_width, 'Type', 'Status'), :white, :on_blue)
247
281
  resources = stack.list_resources
248
282
  resources.each do |r|
@@ -250,6 +284,7 @@ module Hygroscope
250
284
  end
251
285
 
252
286
  if s.stack_status.downcase =~ /complete$/
287
+ # If the stack is complete display any available outputs and stop refreshing
253
288
  puts
254
289
  puts set_color(sprintf(' %-28s %-*s ', 'Output', output_width, 'Value'), :white, :on_yellow)
255
290
  s.outputs.each do |o|
@@ -259,6 +294,7 @@ module Hygroscope
259
294
  puts "\nMore information: https://console.aws.amazon.com/cloudformation/home"
260
295
  break
261
296
  elsif s.stack_status.downcase =~ /failed$/
297
+ # If the stack failed to create, stop refreshing
262
298
  puts "\nMore information: https://console.aws.amazon.com/cloudformation/home"
263
299
  break
264
300
  else
@@ -22,7 +22,7 @@ module Hygroscope
22
22
  @parameters.each do |k, v|
23
23
  stack_parameters << {
24
24
  parameter_key: k,
25
- parameter_value: v
25
+ parameter_value: v.to_s
26
26
  }
27
27
  end
28
28
 
@@ -30,7 +30,7 @@ module Hygroscope
30
30
  @tags.each do |k, v|
31
31
  stack_tags << {
32
32
  key: k,
33
- value: v
33
+ value: v.to_s
34
34
  }
35
35
  end
36
36
 
@@ -59,7 +59,7 @@ module Hygroscope
59
59
  @parameters.each do |k, v|
60
60
  stack_parameters << {
61
61
  parameter_key: k,
62
- parameter_value: v
62
+ parameter_value: v.to_s
63
63
  }
64
64
  end
65
65
 
@@ -26,12 +26,13 @@ module Hygroscope
26
26
  cfoo.process(*files)
27
27
  end
28
28
 
29
- if err.string.empty?
30
- @template = out.string
31
- @template
32
- else
33
- fail TemplateYamlParseError, err.string
34
- end
29
+ fail(TemplateYamlParseError, err.string) unless err.string.empty?
30
+
31
+ # Substitute
32
+ # APP_CONFIG = YAML.load(ERB.new(File.read("#{Rails.root}/config/app_config.yml")).result)[Rails.env]
33
+ #
34
+ @template = out.string
35
+ @template
35
36
  end
36
37
 
37
38
  def compress
@@ -58,7 +59,7 @@ module Hygroscope
58
59
  # Parsing the template to JSON and then re-outputting it is a form of
59
60
  # compression (removing all extra spaces) to keep within the 50KB limit
60
61
  # for CloudFormation templates.
61
- template = self.compress
62
+ template = compress
62
63
 
63
64
  begin
64
65
  stack = Hygroscope::Stack.new('template-validator')
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hygroscope
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Daniel Silverman
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-02-02 00:00:00.000000000 Z
11
+ date: 2015-02-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: thor
@@ -130,6 +130,7 @@ extensions: []
130
130
  extra_rdoc_files: []
131
131
  files:
132
132
  - ".gitignore"
133
+ - CHANGELOG.md
133
134
  - Gemfile
134
135
  - LICENSE.txt
135
136
  - README.md
@@ -162,8 +163,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
162
163
  version: '0'
163
164
  requirements: []
164
165
  rubyforge_project:
165
- rubygems_version: 2.4.5
166
+ rubygems_version: 2.2.0
166
167
  signing_key:
167
168
  specification_version: 4
168
169
  summary: CloudFormation launcher
169
170
  test_files: []
171
+ has_rdoc: