lita-ey-deploy 0.0.4 → 0.0.5

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: 47b06676ac6fad381f37a7ab3c596429748d74fd
4
- data.tar.gz: 130b27bf17759ee504fe937897b5eea3fb8e434d
3
+ metadata.gz: 324a2cc515df8474e5bf5fab341bed82435e3745
4
+ data.tar.gz: bdb8cb25d1dc67e25d7efa6d1f60ec221b7ce235
5
5
  SHA512:
6
- metadata.gz: 36745002e9bb3628118e7a783579d5e58df4e4b03db7c78b34c726c7ddd4acdf32fdd294e6fec73cc2245fd9f9d8fdf02f21654ee38599cb9257f16222f4a028
7
- data.tar.gz: 7f0f35f21d5ee1f7ec79a109f54f3f173a4c9fa35451d924acbf980b75c01881b346e4d0c7ee50b83b6b672e743a91d5df2e240a509b82c27cb8880ed9b8673e
6
+ metadata.gz: 45d03cda85b10268f17301668a69dd8d57893ffd615c9de86b5a3a82fc03a07a69adc0bf768f8c9a1cd9661a10cd33c5c677373077bc48e9d6a5956c27029136
7
+ data.tar.gz: 784ccca172548d77a13ff55681c28202234b63ee01461fea44890534c2475b4f3572d49d2de0dbf43cc45a12df52658a7cf2801f1dd5e687375c14abc512a2e3
data/Gemfile.lock CHANGED
@@ -1,9 +1,10 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- lita-ey-deploy (0.0.4)
4
+ lita-ey-deploy (0.0.5)
5
5
  engineyard
6
6
  lita (>= 3.2.0)
7
+ lita-ey-base
7
8
 
8
9
  GEM
9
10
  remote: https://rubygems.org/
@@ -17,16 +18,15 @@ GEM
17
18
  thor
18
19
  diff-lcs (1.2.5)
19
20
  docile (1.1.3)
20
- engineyard (2.3.3)
21
- engineyard-cloud-client (~> 1.0.16)
21
+ engineyard (2.3.1)
22
+ engineyard-cloud-client (~> 1.0.14)
22
23
  engineyard-serverside-adapter (= 2.2.0)
23
24
  escape (~> 0.0.4)
24
25
  highline (~> 1.6.1)
25
26
  launchy (~> 2.1)
26
- net-ssh (~> 2.7)
27
+ net-ssh (~> 2.2)
27
28
  rest-client (~> 1.6.0)
28
- engineyard-cloud-client (1.0.16)
29
- mime-types (~> 1.16)
29
+ engineyard-cloud-client (1.0.15)
30
30
  multi_json (~> 1.6)
31
31
  rest-client (~> 1.6.1)
32
32
  engineyard-serverside-adapter (2.2.0)
@@ -43,7 +43,7 @@ GEM
43
43
  ice_nine (0.11.0)
44
44
  launchy (2.4.2)
45
45
  addressable (~> 2.3)
46
- lita (3.2.0)
46
+ lita (3.3.0)
47
47
  bundler (>= 1.3)
48
48
  faraday (>= 0.8.7)
49
49
  http_router (>= 0.11.1)
@@ -52,33 +52,38 @@ GEM
52
52
  multi_json (>= 1.7.7)
53
53
  puma (>= 2.7.1)
54
54
  rack (>= 1.5.2)
55
+ rb-readline (>= 0.5.1)
55
56
  redis-namespace (>= 1.3.0)
56
57
  thor (>= 0.18.1)
57
- mime-types (1.25.1)
58
- multi_json (1.10.0)
58
+ lita-ey-base (0.0.2)
59
+ engineyard
60
+ lita (>= 3.2.0)
61
+ mime-types (2.3)
62
+ multi_json (1.10.1)
59
63
  multipart-post (2.0.0)
60
64
  net-ssh (2.9.1)
61
65
  puma (2.8.2)
62
66
  rack (>= 1.1, < 2.0)
63
67
  rack (1.5.2)
64
68
  rake (10.3.2)
69
+ rb-readline (0.5.1)
65
70
  redis (3.0.7)
66
71
  redis-namespace (1.4.1)
67
72
  redis (~> 3.0.4)
68
73
  rest-client (1.6.7)
69
74
  mime-types (>= 1.16)
70
- rspec (3.0.0.beta2)
71
- rspec-core (= 3.0.0.beta2)
72
- rspec-expectations (= 3.0.0.beta2)
73
- rspec-mocks (= 3.0.0.beta2)
74
- rspec-core (3.0.0.beta2)
75
- rspec-support (= 3.0.0.beta2)
76
- rspec-expectations (3.0.0.beta2)
75
+ rspec (3.0.0)
76
+ rspec-core (~> 3.0.0)
77
+ rspec-expectations (~> 3.0.0)
78
+ rspec-mocks (~> 3.0.0)
79
+ rspec-core (3.0.2)
80
+ rspec-support (~> 3.0.0)
81
+ rspec-expectations (3.0.2)
77
82
  diff-lcs (>= 1.2.0, < 2.0)
78
- rspec-support (= 3.0.0.beta2)
79
- rspec-mocks (3.0.0.beta2)
80
- rspec-support (= 3.0.0.beta2)
81
- rspec-support (3.0.0.beta2)
83
+ rspec-support (~> 3.0.0)
84
+ rspec-mocks (3.0.2)
85
+ rspec-support (~> 3.0.0)
86
+ rspec-support (3.0.2)
82
87
  simplecov (0.8.2)
83
88
  docile (~> 1.1.0)
84
89
  multi_json
@@ -99,5 +104,5 @@ DEPENDENCIES
99
104
  coveralls
100
105
  lita-ey-deploy!
101
106
  rake
102
- rspec (>= 3.0.0.beta1)
107
+ rspec (>= 3.0.0)
103
108
  simplecov
data/README.md CHANGED
@@ -20,20 +20,20 @@ Add required configuration to lita_config.rb file:
20
20
  config.handlers.ey.api_token = "YOUR_EY_API_TOKEN"
21
21
  config.handlers.ey.apps = {
22
22
  "my_app_name_for_lita" => {
23
- "name" => "my_app_name_at_ey",
23
+ "ey_name" => "my_app_name_at_ey",
24
24
  "envs" => {
25
25
  "test" => {
26
- name: "testing",
26
+ ey_name: "my_app_testing",
27
27
  auth_group: "devs",
28
28
  default_branch: "develop"
29
29
  },
30
30
  "stage" => {
31
- name: "staging",
31
+ ey_name: "my_app_staging",
32
32
  auth_group: "testers",
33
33
  default_branch: "stage"
34
34
  },
35
35
  "production" => {
36
- name: "production",
36
+ ey_name: "my_app_production",
37
37
  auth_group: "devops",
38
38
  default_branch: "master"
39
39
  }
@@ -48,4 +48,4 @@ Add required configuration to lita_config.rb file:
48
48
 
49
49
  ## License
50
50
 
51
- [MIT](http://opensource.org/licenses/MIT)
51
+ [MIT](http://opensource.org/licenses/MIT)
@@ -1,12 +1,6 @@
1
- require "lita"
2
-
3
1
  module Lita
4
2
  module Handlers
5
- class EyDeploy < Handler
6
-
7
- route(/ey deploy help/i, :help, command: true, help: {
8
- "ey deploy help" => "Display list of apps and envs available, and groups authorized to deploy on them"
9
- })
3
+ class EyDeploy < EyBase
10
4
 
11
5
  route(/ey deploy (\w*) (\w*)( [\w\/\.\-\_]*)?/i, :deploy, command: true, help: {
12
6
  "ey deploy [app] [env] <branch_name>" => "Deploy specified branch (or default) to a particular app env"
@@ -24,39 +18,15 @@ module Lita
24
18
  "ey maintenance off [app] [env]" => "Disable maintenance page at a particular app env"
25
19
  })
26
20
 
27
- def self.default_config(config)
28
- config.api_token = nil
29
- config.apps = {}
30
- end
31
-
32
- def self.namespace
33
- "ey"
34
- end
35
-
36
- def help(response)
37
- result = ""
38
- config.apps.each do |app_name, app_data|
39
- result += "App Name: #{app_name}\n"
40
- result += " Environments:\n"
41
- app_data["envs"].each do |env_name, env_data|
42
- result += " * #{env_name}\n"
43
- result += " Default branch: #{env_data["default_branch"]}\n"
44
- result += " Authorized users group: #{env_data["auth_group"]}\n"
45
- end
46
- result += "\n"
47
- end
48
- response.reply result
49
- end
50
-
51
21
  def deploy(response)
52
- app = response.matches[0][0].strip
53
- env = response.matches[0][1].strip
22
+ app = response.matches[0][0]
23
+ env = response.matches[0][1]
54
24
 
55
25
  response.reply "Deploy what to where?" and return unless valid_app?(app) && valid_env?(app, env)
56
26
 
57
27
  branch = (response.matches[0][2] || default_branch_for(app, env)).strip
58
28
 
59
- if can_deploy?(response.user, app, env)
29
+ do_if_can_access(response, app, env) do
60
30
  response.reply "Deploying #{app} branch '#{branch}' to #{env}"
61
31
 
62
32
  cmd = ey_deploy_cmd(app, env, branch)
@@ -65,8 +35,6 @@ module Lita
65
35
 
66
36
  feedback_msg = deploy_result.include?(ey_failure_msg) ? failed_msg : success_msg
67
37
  response.reply feedback_msg
68
- else
69
- response.reply access_denied % { group_name: required_group_to_access(app, env) }
70
38
  end
71
39
  end
72
40
 
@@ -76,7 +44,7 @@ module Lita
76
44
 
77
45
  response.reply "Rollback what?" and return unless valid_app?(app) && valid_env?(app, env)
78
46
 
79
- if can_deploy?(response.user, app, env)
47
+ do_if_can_access(response, app, env) do
80
48
  response.reply "Rolling back #{app} #{env} to previous version..."
81
49
 
82
50
  cmd = ey_rollback_cmd(app, env)
@@ -84,8 +52,6 @@ module Lita
84
52
  result = `#{cmd}`
85
53
 
86
54
  response.reply result
87
- else
88
- response.reply access_denied % { group_name: required_group_to_access(app, env) }
89
55
  end
90
56
  end
91
57
 
@@ -95,7 +61,7 @@ module Lita
95
61
 
96
62
  response.reply "Place maintenance page where?" and return unless valid_app?(app) && valid_env?(app, env)
97
63
 
98
- if can_deploy?(response.user, app, env)
64
+ do_if_can_access(response, app, env) do
99
65
  response.reply "Placing maintenance page at #{app} #{env}..."
100
66
 
101
67
  cmd = ey_maintenance_on_cmd(app, env)
@@ -103,8 +69,6 @@ module Lita
103
69
  result = `#{cmd}`
104
70
 
105
71
  response.reply result
106
- else
107
- response.reply access_denied % { group_name: required_group_to_access(app, env) }
108
72
  end
109
73
  end
110
74
 
@@ -114,7 +78,7 @@ module Lita
114
78
 
115
79
  response.reply "Disable maintenance page where?" and return unless valid_app?(app) && valid_env?(app, env)
116
80
 
117
- if can_deploy?(response.user, app, env)
81
+ do_if_can_access(response, app, env) do
118
82
  response.reply "Disabling maintenance page at #{app} #{env}..."
119
83
 
120
84
  cmd = ey_maintenance_on_cmd(app, env)
@@ -122,28 +86,10 @@ module Lita
122
86
  result = `#{cmd}`
123
87
 
124
88
  response.reply result
125
- else
126
- response.reply access_denied % { group_name: required_group_to_access(app, env) }
127
89
  end
128
90
  end
129
91
 
130
- def valid_app?(app)
131
- config.apps.keys.include?(app)
132
- end
133
-
134
- def valid_env?(app, env)
135
- config.apps[app]["envs"].keys.include?(env)
136
- end
137
-
138
- def can_deploy?(user, app, env)
139
- group = required_group_to_access(app, env)
140
- return true unless group
141
- Lita::Authorization.user_in_group? user, required_group_to_access(app, env)
142
- end
143
-
144
- def required_group_to_access(app, env)
145
- config.apps[app]["envs"][env]["auth_group"]
146
- end
92
+ private
147
93
 
148
94
  def ey_deploy_cmd(app, env, branch)
149
95
  "bundle exec ey deploy --app='#{ey_app(app)}' --environment='#{ey_env(app, env)}' --ref='refs/heads/#{branch}' --migrate='rake db:migrate' --api-token=#{config.api_token}"
@@ -173,24 +119,8 @@ module Lita
173
119
  "Deployment failed! Shame on you!"
174
120
  end
175
121
 
176
- def access_denied
177
- "Sorry, you don't have access; you must be at %{group_name} group."
178
- end
179
-
180
- def default_branch_for(app, env)
181
- config.apps[app]["envs"][env]["default_branch"] || "master"
182
- end
183
-
184
- def ey_app(app)
185
- config.apps[app]["name"]
186
- end
187
-
188
- def ey_env(app, env)
189
- config.apps[app]["envs"][env]["name"]
190
- end
191
-
192
122
  end
193
123
 
194
124
  Lita.register_handler(EyDeploy)
195
125
  end
196
- end
126
+ end
@@ -1 +1,3 @@
1
+ require "lita"
2
+ require "lita-ey-base"
1
3
  require "lita/handlers/ey_deploy"
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |spec|
2
2
  spec.name = "lita-ey-deploy"
3
- spec.version = "0.0.4"
3
+ spec.version = "0.0.5"
4
4
  spec.authors = ["Carlos Paramio"]
5
5
  spec.email = ["cparamio@avallain.com"]
6
6
  spec.description = %q{A Lita handler for EngineYard deployments.}
@@ -16,10 +16,11 @@ Gem::Specification.new do |spec|
16
16
  spec.add_runtime_dependency "lita", ">= 3.2.0"
17
17
 
18
18
  spec.add_dependency "engineyard"
19
+ spec.add_dependency "lita-ey-base"
19
20
 
20
21
  spec.add_development_dependency "bundler"
21
22
  spec.add_development_dependency "coveralls"
22
23
  spec.add_development_dependency "rake"
23
- spec.add_development_dependency "rspec", ">= 3.0.0.beta1"
24
+ spec.add_development_dependency "rspec", ">= 3.0.0"
24
25
  spec.add_development_dependency "simplecov"
25
26
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lita-ey-deploy
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 0.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Carlos Paramio
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-05-20 00:00:00.000000000 Z
11
+ date: 2014-06-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: lita
@@ -38,6 +38,20 @@ dependencies:
38
38
  - - '>='
39
39
  - !ruby/object:Gem::Version
40
40
  version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: lita-ey-base
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - '>='
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - '>='
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
41
55
  - !ruby/object:Gem::Dependency
42
56
  name: bundler
43
57
  requirement: !ruby/object:Gem::Requirement
@@ -86,14 +100,14 @@ dependencies:
86
100
  requirements:
87
101
  - - '>='
88
102
  - !ruby/object:Gem::Version
89
- version: 3.0.0.beta1
103
+ version: 3.0.0
90
104
  type: :development
91
105
  prerelease: false
92
106
  version_requirements: !ruby/object:Gem::Requirement
93
107
  requirements:
94
108
  - - '>='
95
109
  - !ruby/object:Gem::Version
96
- version: 3.0.0.beta1
110
+ version: 3.0.0
97
111
  - !ruby/object:Gem::Dependency
98
112
  name: simplecov
99
113
  requirement: !ruby/object:Gem::Requirement