lita-stackstorm 0.5.3 → 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/lib/lita/handlers/stackstorm.rb +33 -39
- data/lita-stackstorm.gemspec +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5c6ce0e485828fef1c97a9231ebff3b9421cacdc
|
4
|
+
data.tar.gz: 89b55ca36a0a3948d319cf3c403ed5460da1179c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: efd097d6aaf2860a6f758c87576ae05be5597c63851b317e6b135c894d29647064e10121fa2e4543155b4a2ecd8978e84768a9fd7e2b92f6e646aaa6800484c0
|
7
|
+
data.tar.gz: bf18120bcdbe8f01c6445a17a2e00af550bad372eade6055ca4c7755a4bafb0217130429197fe616fd79a710fbc8953d62d92c203f4f76ad37e5b9200e1b3def
|
@@ -30,12 +30,12 @@ module Lita
|
|
30
30
|
end
|
31
31
|
|
32
32
|
route /^st2 login$/, :login, command: false, help: { "st2 login" => "login with st2-api" }
|
33
|
-
route /^st2 list$/, :list, command: false, help: { "st2 list" => "list available st2 chatops commands" }
|
33
|
+
route /^st2 (ls|aliases|list)$/, :list, command: false, help: { "st2 list" => "list available st2 chatops commands" }
|
34
34
|
|
35
35
|
route /^!(.*)$/, :call_alias, command: false, help: {}
|
36
36
|
|
37
37
|
def auth_builder
|
38
|
-
if config.auth_port ==
|
38
|
+
if Integer(config.auth_port) == 443 and config.url.start_with?('https')
|
39
39
|
"#{config.url}/auth"
|
40
40
|
else
|
41
41
|
"#{config.url}:#{config.auth_port}/v1"
|
@@ -43,7 +43,7 @@ module Lita
|
|
43
43
|
end
|
44
44
|
|
45
45
|
def url_builder
|
46
|
-
if config.execution_port ==
|
46
|
+
if Integer(config.execution_port) == 443 and config.url.start_with?('https')
|
47
47
|
"#{config.url}/api"
|
48
48
|
else
|
49
49
|
"#{config.url}:#{config.execution_port}/v1"
|
@@ -64,41 +64,31 @@ module Lita
|
|
64
64
|
if expired
|
65
65
|
authenticate
|
66
66
|
end
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
(st - command_set).length
|
67
|
+
command = msg.matches.flatten.first
|
68
|
+
found = ""
|
69
|
+
redis.scan_each do |a|
|
70
|
+
possible = /#{a}/.match(command)
|
71
|
+
if not possible.nil?
|
72
|
+
found = a
|
73
|
+
break
|
74
|
+
end
|
76
75
|
end
|
77
76
|
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
else
|
92
|
-
msg.reply "Execution failed with message: #{j['faultstring']}"
|
93
|
-
end
|
94
|
-
elsif h[h.keys.min].length > 1
|
95
|
-
response_text = "possible matches:"
|
96
|
-
h[h.keys.min].each do |match|
|
97
|
-
response_text+= "\n\t#{match}"
|
98
|
-
end
|
99
|
-
msg.reply response_text
|
77
|
+
jobject = JSON.parse(redis.get(found))
|
78
|
+
payload = {
|
79
|
+
name: jobject['object']['name'],
|
80
|
+
format: jobject['format'],
|
81
|
+
command: command,
|
82
|
+
user: msg.user.name,
|
83
|
+
source_channel: 'chatops',
|
84
|
+
notification_channel: 'lita'
|
85
|
+
}
|
86
|
+
s = make_post_request("/aliasexecution", payload)
|
87
|
+
j = JSON.parse(s.body)
|
88
|
+
if s.success?
|
89
|
+
msg.reply "Got it! Details available at #{config.url}/#/history/#{j['execution']['id']}/general"
|
100
90
|
else
|
101
|
-
msg.reply "
|
91
|
+
msg.reply "Execution failed with message: #{j['faultstring']}"
|
102
92
|
end
|
103
93
|
end
|
104
94
|
|
@@ -106,16 +96,21 @@ module Lita
|
|
106
96
|
if expired
|
107
97
|
authenticate
|
108
98
|
end
|
99
|
+
redis.keys.each {|k| redis.del k }
|
109
100
|
s = make_request("/actionalias", "")
|
110
101
|
if JSON.parse(s.body).empty?
|
111
102
|
msg.reply "No Action Aliases Registered"
|
112
103
|
else
|
113
104
|
j = JSON.parse(s.body)
|
114
105
|
a = ""
|
106
|
+
extra_params = '(\\s+(\\S+)\\s*=("([\\s\\S]*?)"|\'([\\s\\S]*?)\'|({[\\s\\S]*?})|(\\S+))\\s*)*'
|
115
107
|
j.take_while{|i| i['enabled'] }.each do |command|
|
116
108
|
command['formats'].each do |format|
|
117
|
-
|
118
|
-
|
109
|
+
f = format.gsub(/(\s*){{\s*\S+\s*=\s*(?:({.+?}|.+?))\s*}}(\s*)/, '\\s*([\\s\\S]+?)?\\s*')
|
110
|
+
f = f.gsub(/\s*{{.+?}}\s*/, '\\s*([\\s\\S]+?)\\s*')
|
111
|
+
f = "^\\s*#{f}#{extra_params}\\s*$"
|
112
|
+
redis.set(f, {format: format, object: command}.to_json)
|
113
|
+
a+= "#{format} -> #{command['description']}\n"
|
119
114
|
end
|
120
115
|
end
|
121
116
|
msg.reply a
|
@@ -139,9 +134,8 @@ module Lita
|
|
139
134
|
|
140
135
|
def make_request(path, body)
|
141
136
|
resp = http.get("#{url_builder()}#{path}") do |req|
|
142
|
-
req.body = {}
|
143
137
|
req.headers = headers
|
144
|
-
req.body = body.to_json
|
138
|
+
req.body = body.to_json if not body.empty?
|
145
139
|
end
|
146
140
|
resp
|
147
141
|
end
|
data/lita-stackstorm.gemspec
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: lita-stackstorm
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.6.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: 2016-03-
|
11
|
+
date: 2016-03-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: lita
|
@@ -176,7 +176,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
176
176
|
version: '0'
|
177
177
|
requirements: []
|
178
178
|
rubyforge_project:
|
179
|
-
rubygems_version: 2.4.5
|
179
|
+
rubygems_version: 2.4.5
|
180
180
|
signing_key:
|
181
181
|
specification_version: 4
|
182
182
|
summary: Stackstorm handler for lita 4+
|