lita-salt 0.5.0 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +0 -1
- data/lib/lita/handlers/salt.rb +10 -35
- data/lita-salt.gemspec +1 -1
- data/spec/lita/handlers/salt_spec.rb +2 -23
- data/templates/.gitkeep +0 -0
- data/templates/layout.slack.erb +1 -0
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c3ccf194e0ee7613b7474562c352762bbf83f350
|
4
|
+
data.tar.gz: 5520f5836a453d87aa101dc9dfe4e4c02afc4a37
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 074650e4ff5724041abdb37c8ba01023a9520b5edd558648f4a8521be62b92e128b7b71586a592815e66bdf9d3b39250033049c01f1a29186c5b002f516be285
|
7
|
+
data.tar.gz: 4474a2794230a0e672896c61da09340e9904f67f49ecdc66b70b6050adaed5f763ce8a9a018e0953e56ea052a0dabb93fb187cc4668478d1c8ac6f8d42f66c20
|
data/README.md
CHANGED
data/lib/lita/handlers/salt.rb
CHANGED
@@ -61,15 +61,6 @@ module Lita
|
|
61
61
|
'salt minion supervisord.(status|start|stop|restart|add|remove)' => 'Execute supervisor action'
|
62
62
|
}
|
63
63
|
|
64
|
-
route /^#{abbreviate("salt")} pillar(?: #{abbreviate("help")})$/i, :pillar, command: true, help: {
|
65
|
-
'salt pillar get "some_key"' => 'get a pillar value'
|
66
|
-
}
|
67
|
-
|
68
|
-
route /^#{abbreviate("salt")} pillar (get|show)$/i, :pillar, command: true, help: {
|
69
|
-
'salt pillar get "some_key"' => 'get a pillar value',
|
70
|
-
'salt pillar show "some_minion"' => 'show pillar for given minion'
|
71
|
-
}
|
72
|
-
|
73
64
|
def authenticate
|
74
65
|
resp = http.post("#{config.url}/login") do |req|
|
75
66
|
req.body = {}
|
@@ -108,11 +99,11 @@ module Lita
|
|
108
99
|
task = msg.matches.flatten[1]
|
109
100
|
what = msg.matches.flatten[2]
|
110
101
|
if what.nil?
|
111
|
-
msg.reply "Missing data"
|
102
|
+
msg.reply(render_template("layout", response: "Missing data"))
|
112
103
|
else
|
113
104
|
body = build_local(where, "#{__callee__}.#{task}", what, returner)
|
114
105
|
response = make_request('/', body)
|
115
|
-
msg.reply process_response(response)
|
106
|
+
msg.reply(render_template("layout", response: process_response(response)))
|
116
107
|
end
|
117
108
|
end
|
118
109
|
|
@@ -126,7 +117,7 @@ module Lita
|
|
126
117
|
if response.status == 200
|
127
118
|
msg.reply response.body
|
128
119
|
else
|
129
|
-
msg.reply "Failed to run command: #{body}\nError: #{response.body}"
|
120
|
+
msg.reply(render_template("example", response: "Failed to run command: #{body}\nError: #{response.body}"))
|
130
121
|
end
|
131
122
|
end
|
132
123
|
|
@@ -139,7 +130,7 @@ module Lita
|
|
139
130
|
if response.status == 200
|
140
131
|
msg.reply response.body
|
141
132
|
else
|
142
|
-
msg.reply "Failed to run command: #{body}\nError: #{response.body}"
|
133
|
+
msg.reply(render_template("example", response: "Failed to run command: #{body}\nError: #{response.body}"))
|
143
134
|
end
|
144
135
|
end
|
145
136
|
|
@@ -151,11 +142,11 @@ module Lita
|
|
151
142
|
task = msg.matches.flatten[1]
|
152
143
|
what = msg.matches.flatten[2]
|
153
144
|
if what.nil?
|
154
|
-
msg.reply "Missing service name"
|
145
|
+
msg.reply(render_template("layout", response: "Missing service name"))
|
155
146
|
else
|
156
147
|
body = build_local(where, "#{__callee__}.#{task}", what, returner)
|
157
148
|
response = make_request('/', body)
|
158
|
-
msg.reply process_response(response)
|
149
|
+
msg.reply(render_template("layout", response: process_response(response)))
|
159
150
|
end
|
160
151
|
end
|
161
152
|
|
@@ -167,11 +158,11 @@ module Lita
|
|
167
158
|
task = msg.matches.flatten[1]
|
168
159
|
what = msg.matches.flatten[2]
|
169
160
|
if what.nil?
|
170
|
-
msg.reply "Missing job name"
|
161
|
+
msg.reply(render_template("layout", response: "Missing job name"))
|
171
162
|
else
|
172
163
|
body = build_local(where, "#{__callee__}.#{task}", what, returner)
|
173
164
|
response = make_request('/', body)
|
174
|
-
msg.reply process_response(response)
|
165
|
+
msg.reply(render_template("layout", response: process_response(response)))
|
175
166
|
end
|
176
167
|
end
|
177
168
|
|
@@ -183,11 +174,11 @@ module Lita
|
|
183
174
|
task = msg.matches.flatten[1]
|
184
175
|
what = msg.matches.flatten[2]
|
185
176
|
if what.nil?
|
186
|
-
msg.reply "Missing job name"
|
177
|
+
msg.reply(render_template("layout", response: "Missing job name"))
|
187
178
|
else
|
188
179
|
body = build_local(where, "#{__callee__}.#{task}", what, returner)
|
189
180
|
response = make_request('/', body)
|
190
|
-
msg.reply process_response(response)
|
181
|
+
msg.reply(render_template("layout", response: process_response(response)))
|
191
182
|
end
|
192
183
|
end
|
193
184
|
|
@@ -204,22 +195,6 @@ module Lita
|
|
204
195
|
out
|
205
196
|
end
|
206
197
|
|
207
|
-
def pillar(msg)
|
208
|
-
if expired
|
209
|
-
authenticate
|
210
|
-
end
|
211
|
-
where = msg.matches.flatten.first
|
212
|
-
task = msg.matches.flatten[1]
|
213
|
-
what = msg.matches.flatten[2]
|
214
|
-
if what.nil?
|
215
|
-
msg.reply "Missing job name"
|
216
|
-
else
|
217
|
-
body = build_local(where, "#{__callee__}.#{task}", what, returner)
|
218
|
-
response = make_request('/', body)
|
219
|
-
msg.reply_privately process_response(response)
|
220
|
-
end
|
221
|
-
end
|
222
|
-
|
223
198
|
def expired
|
224
199
|
self.class.token.nil? || Time.now >= Time.at(self.class.expires)
|
225
200
|
end
|
data/lita-salt.gemspec
CHANGED
@@ -2,11 +2,12 @@ require "spec_helper"
|
|
2
2
|
|
3
3
|
describe Lita::Handlers::Salt, lita_handler: true do
|
4
4
|
|
5
|
+
let(:robot) { Lita::Robot.new(registry) }
|
5
6
|
let(:response) {double("Faraday::Response")}
|
6
7
|
let(:reply) {""}
|
7
8
|
let(:vals) { {url: "https://example.com", username: "timmy", password: "12345"} }
|
8
9
|
let(:token) {"122938u98j9r82u3r"}
|
9
|
-
let(:salt) { described_class.new }
|
10
|
+
let(:salt) { described_class.new(robot) }
|
10
11
|
|
11
12
|
describe "config" do
|
12
13
|
before do
|
@@ -157,26 +158,4 @@ describe Lita::Handlers::Salt, lita_handler: true do
|
|
157
158
|
|
158
159
|
end
|
159
160
|
|
160
|
-
describe "#pillar_get" do
|
161
|
-
before do
|
162
|
-
stub_request(:post, "#{vals[:url]}/login").
|
163
|
-
with(body: {eauth: "pam", password: vals[:password], username: vals[:username]}).
|
164
|
-
to_return(status: 200,
|
165
|
-
body: JSON.dump(return: [{token: token, expire: 1424352200.50011}]),
|
166
|
-
headers: {'X-Auth-Token' => token}
|
167
|
-
)
|
168
|
-
stub_request(:post, vals[:url]).
|
169
|
-
to_return(status: 200,
|
170
|
-
body: JSON.dump(return: [[:main, :silly]])
|
171
|
-
)
|
172
|
-
end
|
173
|
-
|
174
|
-
#it { is_expected.to route_command('salt pillar').to(:pillar) }
|
175
|
-
it { is_expected.to route_command('salt pillar help').to(:pillar) }
|
176
|
-
it { is_expected.to route_command('salt pillar h').to(:pillar) }
|
177
|
-
it { is_expected.to route_command('s pillar help').to(:pillar) }
|
178
|
-
it { is_expected.to route_command('s pillar h').to(:pillar) }
|
179
|
-
|
180
|
-
end
|
181
|
-
|
182
161
|
end
|
data/templates/.gitkeep
ADDED
File without changes
|
@@ -0,0 +1 @@
|
|
1
|
+
```<%= @response %>```
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: lita-salt
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 1.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jurnell Cockhren
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-09-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: lita
|
@@ -183,6 +183,8 @@ files:
|
|
183
183
|
- lita-salt.gemspec
|
184
184
|
- spec/lita/handlers/salt_spec.rb
|
185
185
|
- spec/spec_helper.rb
|
186
|
+
- templates/.gitkeep
|
187
|
+
- templates/layout.slack.erb
|
186
188
|
homepage: https://github.com/sophicware/lita-salt
|
187
189
|
licenses:
|
188
190
|
- MIT
|