bbc-cosmos-tools 0.1.2 → 0.1.3

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: bd2fe62898213594ae112ece7e649b43252cd876
4
- data.tar.gz: f2d9b802382334839d5d0f4489e37f062647078f
3
+ metadata.gz: b7190ff2e94981faebca714317e92216e4158b69
4
+ data.tar.gz: 22c74bf8e9a3e2e7ff70360a5f05bf2999c2246f
5
5
  SHA512:
6
- metadata.gz: 3fe64c5242a8920e6141bfee928c8f7d136e63efad9ccfb9c2663c429c745b5b1e4df1b2d51ea9fad9ef64358732ef6fe79eaf17eea153eedfd9cdbf8682d9e5
7
- data.tar.gz: 355b1b44c9d4ca7b4df2160c8111e39b3e1e970e4ce18f2b66a4e2405f7f9d8cc3124cf4dc7a082cefbb4d6525a661f2c5d7b55250c6702d51f79db10f14b362
6
+ metadata.gz: 66373735b82214ca4e9b3a4c79ddaa8838dc9dfe8691f37cf135f62cfffe0945d1fb0f983b72b8aacd324624b86cdbbcbad726cae624c5416db898a98494360b
7
+ data.tar.gz: b2164e242b15e93c2dd73c78889b1d9fd49a20c1704534622e7773ae5237ef7f7715933c516dd187d69844098118b857da9361e6fa9c93c7db0085d052913ce1
@@ -58,6 +58,11 @@ module BBC
58
58
  end
59
59
  end
60
60
 
61
+ def error(message, die = true)
62
+ say "#{message}\n", :red
63
+ exit 1 if die
64
+ end
65
+
61
66
  private
62
67
 
63
68
  def setup_config
@@ -70,11 +75,6 @@ module BBC
70
75
  )
71
76
  end
72
77
 
73
- def error(message, die = true)
74
- say "#{message}\n", :red
75
- exit 1 if die
76
- end
77
-
78
78
  end
79
79
  end
80
80
  end
@@ -51,44 +51,68 @@ module BBC
51
51
  end
52
52
 
53
53
  desc "release deploy [COMPONENT = nil, RELEASE_ID = nil]", "Deploys a release to the specific enironment"
54
- method_option :tags, :type => :array, :default => nil
54
+ method_option :tags, :type => :array, :default => nil, :desc => "The tags of the components you want to deploy (i.e 'renderer')"
55
+ method_option :from, :type => :string, :default => 'release', :desc => "The location that the deployment shold be taken from (release|int|test)"
55
56
  def deploy(component = nil, release_id = nil)
56
- begin
57
57
 
58
58
  say banner
59
59
 
60
60
  components(options, component).each do |id|
61
+ begin
62
+
63
+ component_release = release_id
64
+ if release_id.nil?
65
+
66
+ raise("From location cannot be the same as deployment location") if options[:from] == options[:env]
67
+ post_data = {}
68
+ endpoint = config.app['deploy']
69
+
70
+ case options[:from]
71
+ when 'release'
72
+ response = api.get sprintf(config.app['release'], id)
73
+ api_error response unless response.success?
74
+ component_release = JSON.parse(response.body)['releases'].first['version']
75
+ post_data = {
76
+ 'release_version' => component_release
77
+ }
78
+ when 'int', 'test', 'live'
79
+
80
+ endpoint = config.app['snapshot_deploy']
81
+ response = api.get sprintf(config.app['deployments'], id, options[:from])
82
+ api_error response unless response.success?
83
+ snapshot_id = JSON.parse(response.body).first['snapshot']['snapshot_id']
84
+ post_data = {
85
+ 'snapshot_id' => snapshot_id
86
+ }
87
+
88
+ else
89
+ raise("Invalid location: #{options[:from]} to deploy from")
90
+ end
91
+ end
61
92
 
62
- component_release = release_id
63
- if release_id.nil?
64
- response = api.get sprintf(config.app['release'], id)
65
- api_error response unless response.success?
66
- component_release = JSON.parse(response.body)['releases'].first['version']
67
- end
93
+ response = api.post sprintf(endpoint, options[:env], id), JSON.generate(post_data)
68
94
 
69
- post_data = JSON.generate({ 'release_version' => component_release })
70
- response = api.post sprintf(config.app['deploy'], options[:env], id), post_data
95
+ if response.success?
71
96
 
72
- if response.success?
97
+ say get_key_value("\nComponent", id)
98
+ say get_key_value("Version", post_data['snapshot_id'] ? post_data['snapshot_id'] : post_data['release_version'])
73
99
 
74
- say get_key_value("\nComponent", id)
75
- say get_key_value("Version", component_release)
100
+ data = JSON.parse(response.body)
101
+ say "\nDeployment started successfully: #{config.app['api']}#{data['url']}\n", :green
76
102
 
77
- data = JSON.parse(response.body)
78
- say "Deployment started successfully: #{config.app['api']}#{data['url']}\n", :green
103
+ else
104
+ api_error response
105
+ end
79
106
 
80
- else
81
- api_error response
107
+ rescue Exception => e
108
+ error(e.message, false)
82
109
  end
83
-
84
110
  end
85
111
 
86
- rescue Exception => e
87
- error e.message
88
- end
89
112
  end
90
113
 
91
114
  desc "release deployed [COMPONENT = nil]", "Lists releases deloyed for a component in the specified environment"
115
+ method_option :tags, :type => :array, :default => nil, :desc => "The tags of the components you want to deploy (i.e 'renderer')"
92
116
  def deployed(component = nil)
93
117
  begin
94
118
 
@@ -1,7 +1,7 @@
1
1
  module BBC
2
2
  module Cosmos
3
3
  module Tools
4
- VERSION = "0.1.2"
4
+ VERSION = "0.1.3"
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.1.2
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Steven Jack
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-05-05 00:00:00.000000000 Z
11
+ date: 2014-05-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler