bbc-cosmos-tools 0.4.9 → 0.5.0

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
  SHA1:
3
- metadata.gz: 7b358639cde84b36b8b73c0261fdf68e7677a068
4
- data.tar.gz: 0e8a1f8dfb9c64f8fdea45efd473bfc565b165bd
3
+ metadata.gz: ae2b9e2dd15ad2345d36171607515618f1f46f3a
4
+ data.tar.gz: 773bab960e3b232518140a7dd16a9d7ec6bbc95b
5
5
  SHA512:
6
- metadata.gz: 493633c52be2c6edc27ed3582a9e10ea81cb540a278968205caf8a86ff26d4464c17462c83b702f2a577e9e84ad5cbedbfbb346489dd874c99a6f1947d944100
7
- data.tar.gz: 9c7e0494c6ca78c19cdfd2f9010b55ef1c78a5c10f66b3134a08118c1a0a23d35a790a843f5441039525c552b323c07475a5754a0950be5e1948efeb08add36e
6
+ metadata.gz: 1593ed3e95785317ca7b2626b8c80c006301be9bd77a67f802a49ebbbc39d93b90099f7fcf90be76af12bf8ddcb08256e4c05a958b831e3cc9e67351ddf264c0
7
+ data.tar.gz: e6d5038ac4673d2df28a2adb9c5e1b2b49cc8af32dcd840de56919f06e0e41b7bead000fbdd67607e265aa085fbf9cc95ee66bfcdd068cadf142cd8e33d9bab3
data/README.md CHANGED
@@ -161,6 +161,11 @@ bbc:
161
161
  stack_details: '/cosmos/env/%s/component/%s/stack/%s'
162
162
  ```
163
163
 
164
+ > Note: `stack_details` is needed for when a stack update happens. As we don't have all the config values that Cosmos should automatically add in for us when it's created, we need to get them from Cosmos and add them to the parameter list when doing the update
165
+
166
+ Steven Jack [12:38 PM]
167
+ otherwise they'll be blank
168
+
164
169
  Where as the contents of `{component}.yaml.erb` can look like the following:
165
170
 
166
171
  ```yaml
@@ -27,7 +27,7 @@ module BBC
27
27
  hash = JSON.parse(template.to_json)
28
28
 
29
29
  if component_exists?(component, config) && stack_exists?(component, config, options[:stack])
30
- config.resources['cloudformation']['components'][component][options[:stack]]['variants'][options[:variant]].each do |key, value|
30
+ component_parameters(config.resources, options, component).each do |key, value|
31
31
  hash['Parameters'][key]['Default'] = value if hash['Parameters'][key]
32
32
  end
33
33
  end
@@ -40,7 +40,7 @@ module BBC
40
40
  if data['Parameters']
41
41
  data['Parameters'].reduce({}) do |object, (key, value)|
42
42
  object.tap do |o|
43
- o[key] = value['Default'] unless reserved_main_stack_param_for(key, main_stack)
43
+ o[key] = value['Default'] unless reserved_main_stack_param_for(key, main_stack) && value['Default'].nil?
44
44
  end
45
45
  end
46
46
  else
@@ -58,6 +58,26 @@ module BBC
58
58
 
59
59
  private
60
60
 
61
+ def self.component_stack_details(resources, options, component)
62
+ raise("cloudformation: -> components: node is missing from the environment resource file") unless resources.has_key?("cloudformation") && resources['cloudformation'].has_key?("components")
63
+
64
+ components = resources['cloudformation']['components']
65
+ raise("'#{component}' node missing from cloudformation: -> components: nodes") unless components.has_key?(component)
66
+ component = components[component]
67
+
68
+ raise("'#{options[:stack]}' stack node missing from cloudformation: -> components: -> #{component}:") unless component.has_key?(options[:stack])
69
+ component[options[:stack]]
70
+ end
71
+
72
+ def self.variants(component_meta, variant = nil)
73
+ component_meta.has_key?('variants') ? component_meta['variants'][variant] : component_meta['parameters']
74
+ end
75
+
76
+ def self.component_parameters(resources, options, component)
77
+ stack_data = component_stack_details(resources, options, component)
78
+ variants(stack_data, options[:variant])
79
+ end
80
+
61
81
  def self.reserved_main_stack_param_for(key, main_stack)
62
82
  main_stack && RESERVED_MAIN_STACK_PARAMS.include?(key)
63
83
  end
@@ -85,15 +85,18 @@ module BBC
85
85
  components(options, component).each do |id|
86
86
  say get_key_value("\nComponent", id)
87
87
 
88
- type = Tools::Types::Factory.create(id, options, config)
89
- data = type.generate_data
88
+ type = Tools::Types::Factory.create(id, options, config)
89
+ data = type.generate_data
90
+ stack_data = Tools::Cloudformation::Generator.component_stack_details(config.resources, options, id)
91
+
90
92
  post_data = {
91
- 'name_suffix' => options[:stack],
92
- 'service_stack' => main_stack.match(/(true|t|yes|y|1)$/i) != nil,
93
- 'template' => data,
94
- 'parameters' => Tools::Cloudformation::Generator.parameters(data, main_stack),
93
+ 'name_suffix' => options[:stack],
94
+ 'service_stack' => main_stack.match(/(true|t|yes|y|1)$/i) != nil,
95
+ 'template' => data,
96
+ 'parameters' => Tools::Cloudformation::Generator.parameters(data, main_stack),
95
97
  }
96
98
 
99
+ post_data['aws_account_id'] = stack_data['account_id'] unless stack_data['account_id'].nil?
97
100
  response = api.post sprintf(config.app['stack_create_endpoint'], options[:env], id), JSON.pretty_generate(post_data)
98
101
 
99
102
  if response.success?
@@ -1,7 +1,7 @@
1
1
  module BBC
2
2
  module Cosmos
3
3
  module Tools
4
- VERSION = "0.4.9"
4
+ VERSION = "0.5.0"
5
5
  end
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bbc-cosmos-tools
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.9
4
+ version: 0.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Steven Jack
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-02-10 00:00:00.000000000 Z
11
+ date: 2015-02-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -146,7 +146,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
146
146
  version: '0'
147
147
  requirements: []
148
148
  rubyforge_project:
149
- rubygems_version: 2.0.14
149
+ rubygems_version: 2.2.2
150
150
  signing_key:
151
151
  specification_version: 4
152
152
  summary: Tool for pusing config to cosmos and controlling cloudformation templates