bbc-cosmos-tools 0.5.2 → 0.6.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 +4 -4
- data/Gemfile +1 -1
- data/bbc-cosmos-tools.gemspec +5 -4
- data/bin/bbc-cosmos-tools +3 -3
- data/lib/bbc/cosmos/tools/api.rb +6 -8
- data/lib/bbc/cosmos/tools/app.rb +4 -4
- data/lib/bbc/cosmos/tools/cloudformation/generator.rb +20 -23
- data/lib/bbc/cosmos/tools/commands/base.rb +8 -10
- data/lib/bbc/cosmos/tools/commands/component.rb +79 -19
- data/lib/bbc/cosmos/tools/commands/config.rb +24 -33
- data/lib/bbc/cosmos/tools/commands/release.rb +100 -112
- data/lib/bbc/cosmos/tools/commands/stack.rb +60 -72
- data/lib/bbc/cosmos/tools/config.rb +19 -22
- data/lib/bbc/cosmos/tools/cosmos_configuration.rb +4 -6
- data/lib/bbc/cosmos/tools/types/base_type.rb +6 -7
- data/lib/bbc/cosmos/tools/types/cfndsl.rb +2 -3
- data/lib/bbc/cosmos/tools/version.rb +1 -1
- metadata +19 -6
@@ -1,4 +1,4 @@
|
|
1
|
-
require
|
1
|
+
require "yaml"
|
2
2
|
|
3
3
|
module BBC
|
4
4
|
module Cosmos
|
@@ -6,22 +6,22 @@ module BBC
|
|
6
6
|
class Config
|
7
7
|
attr_accessor :base_path, :project, :env
|
8
8
|
|
9
|
-
def initialize(base_path, project, env =
|
9
|
+
def initialize(base_path, project, env = "int")
|
10
10
|
@base_path = base_path
|
11
11
|
@project = project
|
12
12
|
@env = env
|
13
13
|
end
|
14
14
|
|
15
15
|
def resources
|
16
|
-
if File.directory? File.join(base_path,
|
17
|
-
path = File.join(base_path,
|
16
|
+
if File.directory? File.join(base_path, "resources", env)
|
17
|
+
path = File.join(base_path, "resources", env, "#{project}.yaml")
|
18
18
|
if File.exist? path
|
19
|
-
YAML
|
19
|
+
YAML.load(File.open(path).read)
|
20
20
|
else
|
21
|
-
|
21
|
+
fail("Invalid project, please set the $BBC_COSMOS_TOOLS_PROJECT environment variable or use the --project parameter")
|
22
22
|
end
|
23
23
|
else
|
24
|
-
|
24
|
+
fail("#{env} is an invalid environment")
|
25
25
|
end
|
26
26
|
end
|
27
27
|
|
@@ -30,39 +30,36 @@ module BBC
|
|
30
30
|
if File.exist? path
|
31
31
|
template = File.open(path).read
|
32
32
|
config = resources
|
33
|
-
YAML
|
33
|
+
YAML.load(
|
34
34
|
ERB.new(template).result(binding)
|
35
|
-
)[
|
35
|
+
)["components"]
|
36
36
|
else
|
37
|
-
|
37
|
+
fail("'#{project}' isn't valid project")
|
38
38
|
end
|
39
39
|
end
|
40
40
|
|
41
41
|
def components_for(tags)
|
42
|
-
resources[
|
43
|
-
data[
|
42
|
+
resources["cloudformation"]["components"].select do |_component_id, data|
|
43
|
+
data["tags"].any? { |tag| tags.nil? ? true : tags.include?(tag) } if data["tags"]
|
44
44
|
end
|
45
45
|
end
|
46
46
|
|
47
47
|
def app
|
48
|
-
config_path = base_path.join(
|
49
|
-
|
50
|
-
YAML
|
48
|
+
config_path = base_path.join("configs", "app.yaml")
|
49
|
+
fail("Invalid application config path: #{config_path}") unless File.exist? config_path
|
50
|
+
YAML.load(File.open(config_path).read)["bbc"]["cosmos"]
|
51
51
|
end
|
52
52
|
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
component_template = (File.exists? component_template_path) ? File.read(component_template_path) : ''
|
53
|
+
def cf_templates(component, stack = "main")
|
54
|
+
aws_templates = File.join(base_path, "stacks", component, stack, "/aws/**/*.rb")
|
55
|
+
component_template_path = File.join(base_path, "stacks", component, stack, "template.rb")
|
56
|
+
component_template = (File.exist? component_template_path) ? File.read(component_template_path) : ""
|
58
57
|
|
59
58
|
Dir
|
60
59
|
.glob(aws_templates)
|
61
60
|
.reduce(component_template) { |template_string, file| template_string += File.read(file) }
|
62
61
|
end
|
63
|
-
|
64
62
|
end
|
65
63
|
end
|
66
64
|
end
|
67
65
|
end
|
68
|
-
|
@@ -1,5 +1,5 @@
|
|
1
|
-
require
|
2
|
-
require
|
1
|
+
require "yaml"
|
2
|
+
require "bbc/cosmos/tools/config"
|
3
3
|
|
4
4
|
module BBC
|
5
5
|
module Cosmos
|
@@ -17,18 +17,16 @@ module BBC
|
|
17
17
|
|
18
18
|
def component(id)
|
19
19
|
config.components[id].tap do |o|
|
20
|
-
|
20
|
+
fail("Invalid component id: #{id}") if o.nil?
|
21
21
|
end
|
22
22
|
end
|
23
23
|
|
24
24
|
def cosmos_component(id)
|
25
25
|
component(id).reduce([]) do |object, (key, value)|
|
26
|
-
object.tap { |o| o << {:value => value, :key => key} }
|
26
|
+
object.tap { |o| o << { :value => value, :key => key } }
|
27
27
|
end
|
28
28
|
end
|
29
|
-
|
30
29
|
end
|
31
30
|
end
|
32
31
|
end
|
33
32
|
end
|
34
|
-
|
@@ -15,7 +15,7 @@ module BBC
|
|
15
15
|
def generate_data(to_json = false)
|
16
16
|
if valid_component_and_stack
|
17
17
|
get_parameters.each do |key, value|
|
18
|
-
data[
|
18
|
+
data["Parameters"][key]["Default"] = value if data["Parameters"][key]
|
19
19
|
end
|
20
20
|
to_json ? JSON.pretty_generate(data) : data
|
21
21
|
end
|
@@ -24,26 +24,25 @@ module BBC
|
|
24
24
|
protected
|
25
25
|
|
26
26
|
def data
|
27
|
-
|
27
|
+
fail NotImplementedError
|
28
28
|
end
|
29
29
|
|
30
|
-
def construct_file_path
|
31
|
-
File.join(@config.base_path,
|
30
|
+
def construct_file_path(type)
|
31
|
+
File.join(@config.base_path, "stacks", @id, "#{@options[:stack]}.#{type}")
|
32
32
|
end
|
33
33
|
|
34
34
|
private
|
35
35
|
|
36
36
|
def valid_component_and_stack
|
37
37
|
Tools::Cloudformation::Generator.component_exists?(@id, @config) &&
|
38
|
-
|
38
|
+
Tools::Cloudformation::Generator.stack_exists?(@id, @config, @options[:stack])
|
39
39
|
end
|
40
40
|
|
41
41
|
def get_parameters
|
42
|
-
@config.resources[
|
42
|
+
@config.resources["cloudformation"]["components"][@id][@options[:stack]]["variants"][@options[:variant]]
|
43
43
|
end
|
44
44
|
end
|
45
45
|
end
|
46
46
|
end
|
47
47
|
end
|
48
48
|
end
|
49
|
-
|
@@ -12,7 +12,6 @@ module BBC
|
|
12
12
|
end
|
13
13
|
|
14
14
|
def generate_data(to_json = false)
|
15
|
-
|
16
15
|
# Because the block is evaluated in the context of another class
|
17
16
|
# i.e. instance_eval &block
|
18
17
|
# we need to store off the values first and *then* reference them inside the block
|
@@ -20,9 +19,9 @@ module BBC
|
|
20
19
|
config = @config
|
21
20
|
stack = @options[:stack]
|
22
21
|
|
23
|
-
Tools::Cloudformation::Generator.create(@id, @config, @options, to_json)
|
22
|
+
Tools::Cloudformation::Generator.create(@id, @config, @options, to_json) do
|
24
23
|
instance_eval config.cf_templates(component_identifier, stack)
|
25
|
-
|
24
|
+
end
|
26
25
|
end
|
27
26
|
end
|
28
27
|
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
|
+
version: 0.6.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-03-
|
11
|
+
date: 2015-03-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -86,14 +86,28 @@ dependencies:
|
|
86
86
|
requirements:
|
87
87
|
- - ~>
|
88
88
|
- !ruby/object:Gem::Version
|
89
|
-
version:
|
89
|
+
version: 1.63.0
|
90
90
|
type: :runtime
|
91
91
|
prerelease: false
|
92
92
|
version_requirements: !ruby/object:Gem::Requirement
|
93
93
|
requirements:
|
94
94
|
- - ~>
|
95
95
|
- !ruby/object:Gem::Version
|
96
|
-
version:
|
96
|
+
version: 1.63.0
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: highline
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - '>='
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '0'
|
104
|
+
type: :runtime
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - '>='
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '0'
|
97
111
|
description: Tool for interacting with BBC Cosmos platform
|
98
112
|
email:
|
99
113
|
- stevenmajack@gmail.com
|
@@ -146,9 +160,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
146
160
|
version: '0'
|
147
161
|
requirements: []
|
148
162
|
rubyforge_project:
|
149
|
-
rubygems_version: 2.
|
163
|
+
rubygems_version: 2.2.2
|
150
164
|
signing_key:
|
151
165
|
specification_version: 4
|
152
166
|
summary: Tool for pusing config to cosmos and controlling cloudformation templates
|
153
167
|
test_files: []
|
154
|
-
has_rdoc:
|