opsask 2.3.0 → 2.3.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/VERSION +1 -1
- data/lib/opsask/app.rb +48 -8
- data/lib/opsask/helpers.rb +1 -27
- data/views/_components.erb +1 -4
- data/views/_form.erb +0 -8
- data/views/_queue.erb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fcb3fb4ddc972c43047b7d3054306e24c46bf84b
|
4
|
+
data.tar.gz: d64ef6ee16b59f914430269d709c23b0080aceb5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d7ab393965bc433533c93435bbd5147a1ce443507c6daad0d7a9b475102d2519af342c23f9153256f17d387d83fcf5e1f6cf24aae151e2887d957d064d0788ff
|
7
|
+
data.tar.gz: f792aa96fe731563e1b34f5e9483780ac3742fcf239ddca9d7544e04c8419af7694bc35276b2b53527cf32c569af606c932ff92e96e7a90e22311efff81d38cb
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
2.3.
|
1
|
+
2.3.1
|
data/lib/opsask/app.rb
CHANGED
@@ -5,6 +5,7 @@ require 'rack-flash'
|
|
5
5
|
require 'json'
|
6
6
|
require 'jira'
|
7
7
|
require 'tilt/erb'
|
8
|
+
require 'logger'
|
8
9
|
|
9
10
|
require_relative 'helpers'
|
10
11
|
require_relative 'metadata'
|
@@ -14,8 +15,15 @@ module OpsAsk
|
|
14
15
|
class App < Sinatra::Base
|
15
16
|
include OpsAsk::Helpers
|
16
17
|
|
18
|
+
@@room = nil
|
19
|
+
|
17
20
|
set :root, OpsAsk::ROOT
|
18
21
|
|
22
|
+
enable :logging
|
23
|
+
configure :development do
|
24
|
+
set :logging, Logger::DEBUG
|
25
|
+
end
|
26
|
+
|
19
27
|
# Add flash support
|
20
28
|
enable :sessions
|
21
29
|
use Rack::Flash
|
@@ -27,6 +35,7 @@ module OpsAsk
|
|
27
35
|
|
28
36
|
# Serve up our form
|
29
37
|
get '/' do
|
38
|
+
# $stderr.puts 'get-/'
|
30
39
|
erb :index, locals: {
|
31
40
|
jiras_for_today: issues_for(today),
|
32
41
|
jiras_for_tomorrow: issues_for(tomorrow),
|
@@ -36,6 +45,7 @@ module OpsAsk
|
|
36
45
|
end
|
37
46
|
|
38
47
|
get '/glance' do
|
48
|
+
# $stderr.puts 'get-/glance'
|
39
49
|
erb :days, locals: {
|
40
50
|
jiras_by_day: issues_for_days(2),
|
41
51
|
untracked_jiras: untracked_issues,
|
@@ -44,6 +54,7 @@ module OpsAsk
|
|
44
54
|
end
|
45
55
|
|
46
56
|
get '/week' do
|
57
|
+
# $stderr.puts 'get-/week'
|
47
58
|
erb :days, locals: {
|
48
59
|
jiras_by_day: issues_for_days(4),
|
49
60
|
untracked_jiras: untracked_issues,
|
@@ -52,6 +63,7 @@ module OpsAsk
|
|
52
63
|
end
|
53
64
|
|
54
65
|
get '/days/:n' do
|
66
|
+
# $stderr.puts 'get-/days/:n'
|
55
67
|
n, m = params[:n].split('+', 2)
|
56
68
|
n = n.to_i
|
57
69
|
m = m.nil? ? 0 : m.to_i
|
@@ -63,16 +75,21 @@ module OpsAsk
|
|
63
75
|
end
|
64
76
|
|
65
77
|
get '/room' do
|
78
|
+
# $stderr.puts 'get-/room'
|
66
79
|
content_type :json
|
67
|
-
room
|
68
|
-
|
69
|
-
|
70
|
-
|
80
|
+
@@room ||= {}
|
81
|
+
if @@room.empty?
|
82
|
+
# $stderr.puts 'RECALC ROOM!'
|
83
|
+
(0..365).each do |n|
|
84
|
+
date = today n * one_day
|
85
|
+
@@room[date] = room_for_new_jiras_for? date
|
86
|
+
end
|
71
87
|
end
|
72
|
-
JSON.pretty_generate(room)
|
88
|
+
JSON.pretty_generate(@@room)
|
73
89
|
end
|
74
90
|
|
75
91
|
get '/untracked' do
|
92
|
+
# $stderr.puts 'get-/untracked'
|
76
93
|
erb :untracked, locals: {
|
77
94
|
untracked_jiras: untracked_issues,
|
78
95
|
stragglers: straggling_issues
|
@@ -80,6 +97,7 @@ module OpsAsk
|
|
80
97
|
end
|
81
98
|
|
82
99
|
get '/stragglers' do
|
100
|
+
# $stderr.puts 'get-/stragglers'
|
83
101
|
erb :stragglers, locals: {
|
84
102
|
untracked_jiras: untracked_issues,
|
85
103
|
stragglers: straggling_issues
|
@@ -87,6 +105,7 @@ module OpsAsk
|
|
87
105
|
end
|
88
106
|
|
89
107
|
get '/sprint/:sprint_num' do
|
108
|
+
# $stderr.puts 'get-/sprint/:n'
|
90
109
|
num = params[:sprint_num]
|
91
110
|
sprint = get_sprint(num)
|
92
111
|
id = sprint['id']
|
@@ -114,6 +133,7 @@ module OpsAsk
|
|
114
133
|
end
|
115
134
|
|
116
135
|
get '/sprint' do
|
136
|
+
# $stderr.puts 'get-/sprint'
|
117
137
|
num = current_sprint_num
|
118
138
|
id = current_sprint_id
|
119
139
|
sprint = current_sprint
|
@@ -142,11 +162,13 @@ module OpsAsk
|
|
142
162
|
|
143
163
|
# I think everyone should do this
|
144
164
|
get '/version' do
|
165
|
+
# $stderr.puts 'get-/version'
|
145
166
|
content_type :txt
|
146
167
|
"opsask #{settings.config[:app_version]}"
|
147
168
|
end
|
148
169
|
|
149
170
|
get '/v' do
|
171
|
+
# $stderr.puts 'get-/v'
|
150
172
|
content_type :txt
|
151
173
|
settings.config[:app_version]
|
152
174
|
end
|
@@ -154,6 +176,7 @@ module OpsAsk
|
|
154
176
|
|
155
177
|
# Try to create a JIRA
|
156
178
|
post '/' do
|
179
|
+
# $stderr.puts 'post-/'
|
157
180
|
component, summary, description, assign_to_me, epic, ops_only, datepicker = validate_jira_params
|
158
181
|
|
159
182
|
if datepicker.nil? || datepicker.empty?
|
@@ -175,6 +198,7 @@ module OpsAsk
|
|
175
198
|
| ]
|
176
199
|
end
|
177
200
|
|
201
|
+
@@room = nil # will recalculate
|
178
202
|
redirect '/'
|
179
203
|
end
|
180
204
|
|
@@ -182,11 +206,13 @@ module OpsAsk
|
|
182
206
|
# Public assets
|
183
207
|
%w[ css img js fonts ].each do |asset|
|
184
208
|
get "/#{asset}/:file" do
|
209
|
+
# $stderr.puts 'get-/%s/:file' % asset
|
185
210
|
send_file "public/#{asset}/#{params[:file]}", :disposition => 'inline'
|
186
211
|
end
|
187
212
|
end
|
188
213
|
|
189
214
|
get '/favicon.ico' do
|
215
|
+
# $stderr.puts 'get-/favicon'
|
190
216
|
send_file 'public/favicon.ico', :disposition => 'inline'
|
191
217
|
end
|
192
218
|
|
@@ -196,6 +222,7 @@ module OpsAsk
|
|
196
222
|
# OAuth consumer details including the consumer key, private key,
|
197
223
|
# site uri, and the request token, access token, and authorize paths
|
198
224
|
before do
|
225
|
+
# $stderr.puts 'before-1'
|
199
226
|
options = {
|
200
227
|
:site => settings.config[:jira_url],
|
201
228
|
:context_path => '',
|
@@ -208,9 +235,11 @@ module OpsAsk
|
|
208
235
|
:consumer_key => settings.config[:jira_consumer_key]
|
209
236
|
}
|
210
237
|
|
238
|
+
# $stderr.puts 'before-2'
|
211
239
|
@jira_client = JIRA::Client.new(options)
|
212
240
|
# @jira_client.consumer.http.set_debug_output($stderr)
|
213
241
|
|
242
|
+
# $stderr.puts 'before-3'
|
214
243
|
# Add AccessToken if authorised previously.
|
215
244
|
if session[:jira_auth]
|
216
245
|
@jira_client.set_access_token(
|
@@ -223,6 +252,7 @@ module OpsAsk
|
|
223
252
|
end
|
224
253
|
end
|
225
254
|
|
255
|
+
# $stderr.puts 'before-4'
|
226
256
|
# Keep a pointer to myself
|
227
257
|
begin
|
228
258
|
response = @jira_client.get(
|
@@ -234,6 +264,7 @@ module OpsAsk
|
|
234
264
|
end
|
235
265
|
|
236
266
|
back_to = request.fullpath
|
267
|
+
# $stderr.puts 'before-5 (back_to=%s)' % back_to.inspect
|
237
268
|
case back_to
|
238
269
|
when /callback/
|
239
270
|
when /login/
|
@@ -245,31 +276,36 @@ module OpsAsk
|
|
245
276
|
# Retrieves the @access_token then stores it inside a session cookie. In a real app,
|
246
277
|
# you'll want to persist the token in a datastore associated with the user.
|
247
278
|
get '/callback/' do
|
279
|
+
# $stderr.puts 'callback-1'
|
248
280
|
request_token = @jira_client.set_request_token(
|
249
281
|
session[:request_token], session[:request_secret]
|
250
282
|
)
|
283
|
+
# $stderr.puts 'callback-2'
|
251
284
|
access_token = @jira_client.init_access_token(
|
252
285
|
:oauth_verifier => params[:oauth_verifier]
|
253
286
|
)
|
254
|
-
|
287
|
+
# $stderr.puts 'callback-3'
|
255
288
|
session[:jira_auth] = {
|
256
289
|
:access_token => access_token.token,
|
257
290
|
:access_key => access_token.secret
|
258
291
|
}
|
259
|
-
|
292
|
+
# $stderr.puts 'callback-4'
|
260
293
|
session.delete(:request_token)
|
261
294
|
session.delete(:request_secret)
|
262
295
|
back_to = session.delete(:back_to) || '/'
|
263
|
-
|
296
|
+
# $stderr.puts 'callback-5'
|
264
297
|
redirect back_to
|
265
298
|
end
|
266
299
|
|
267
300
|
# Initialize the JIRA session
|
268
301
|
get '/login' do
|
302
|
+
# $stderr.puts 'get-/login-1'
|
269
303
|
if logged_in?
|
304
|
+
# $stderr.puts 'get-/login-3 (was logged in)'
|
270
305
|
session.clear
|
271
306
|
redirect '/logout'
|
272
307
|
end
|
308
|
+
# $stderr.puts 'get-/login-2 (was logged out)'
|
273
309
|
request_token = @jira_client.request_token
|
274
310
|
session[:request_token] = request_token.token
|
275
311
|
session[:request_secret] = request_token.secret
|
@@ -278,7 +314,11 @@ module OpsAsk
|
|
278
314
|
|
279
315
|
# Expire the JIRA session
|
280
316
|
get '/logout' do
|
317
|
+
# $stderr.puts 'get-/logout'
|
281
318
|
session.delete(:jira_auth)
|
319
|
+
session.delete(:request_token)
|
320
|
+
session.delete(:request_secret)
|
321
|
+
session.delete(:back_to)
|
282
322
|
redirect '/'
|
283
323
|
end
|
284
324
|
|
data/lib/opsask/helpers.rb
CHANGED
@@ -356,14 +356,13 @@ module OpsAsk
|
|
356
356
|
params['jira-summary'],
|
357
357
|
params['jira-description'],
|
358
358
|
!!params['jira-assign_to_me'],
|
359
|
-
|
359
|
+
nil,
|
360
360
|
!!params['jira-ops_only'],
|
361
361
|
params['jira-datepicker']
|
362
362
|
]
|
363
363
|
end
|
364
364
|
|
365
365
|
def create_jira duedate, component, summary, description, assign_to_me, epic, ops_only
|
366
|
-
epic = 'INF-3091' if epic.nil? # OpsAsk default epic
|
367
366
|
assignee = assign_to_me ? @me : settings.config[:assignee]
|
368
367
|
components = []
|
369
368
|
components = [ { name: component } ] unless component
|
@@ -383,7 +382,6 @@ module OpsAsk
|
|
383
382
|
reporter: { name: @me },
|
384
383
|
labels: labels,
|
385
384
|
customfield_10002: 1, # Story Points = 1
|
386
|
-
# customfield_10350: epic,
|
387
385
|
customfield_10040: { id: '-1' } # Release Priority = None
|
388
386
|
}
|
389
387
|
}
|
@@ -469,30 +467,6 @@ module OpsAsk
|
|
469
467
|
end
|
470
468
|
end
|
471
469
|
|
472
|
-
def epic key
|
473
|
-
url = "#{settings.config[:jira_url]}/rest/api/latest/issue/#{key}"
|
474
|
-
curl_request = Curl::Easy.http_get(url) do |curl|
|
475
|
-
curl.headers['Accept'] = 'application/json'
|
476
|
-
curl.headers['Content-Type'] = 'application/json'
|
477
|
-
curl.http_auth_types = :basic
|
478
|
-
curl.username = settings.config[:jira_user]
|
479
|
-
curl.password = settings.config[:jira_pass]
|
480
|
-
curl.verbose = true
|
481
|
-
end
|
482
|
-
|
483
|
-
raw_response = curl_request.body_str
|
484
|
-
begin
|
485
|
-
response = JSON::parse raw_response
|
486
|
-
rescue
|
487
|
-
$stderr.puts "Failed to parse response from JIRA: #{raw_response}"
|
488
|
-
return nil
|
489
|
-
end
|
490
|
-
return {
|
491
|
-
'key' => response['key'],
|
492
|
-
'name' => response['fields']['customfield_10351'] || response['fields']['summary']
|
493
|
-
}
|
494
|
-
end
|
495
|
-
|
496
470
|
def normalized_jql query, \
|
497
471
|
project: settings.config[:project_name], \
|
498
472
|
require_label: settings.config[:require_label],
|
data/views/_components.erb
CHANGED
data/views/_form.erb
CHANGED
@@ -1,14 +1,6 @@
|
|
1
1
|
<% if not logged_in? %>
|
2
2
|
<!-- Nothing to see here... -->
|
3
3
|
|
4
|
-
<% elsif not room_for_new_jiras? %>
|
5
|
-
<h3 class="ops-queues-are-full">Sorry, we’re out of room</h3>
|
6
|
-
<p class="ops-queues-are-full">
|
7
|
-
We've reached the maximum number of OpsAsks filed for the next couple of
|
8
|
-
days. Please send your request to the Network Operations mailing list
|
9
|
-
(<a href="mailto:netops@bluejeans.com">netops@bluejeans.com</a>), and we'll
|
10
|
-
respond shortly. Our apologies for any inconvenience.</p>
|
11
|
-
|
12
4
|
<% else %>
|
13
5
|
<form method="post" action="/" data-abide>
|
14
6
|
<fieldset>
|
data/views/_queue.erb
CHANGED
@@ -16,7 +16,7 @@
|
|
16
16
|
{ 'name' => settings.config[:ignore_label] }
|
17
17
|
]
|
18
18
|
%>
|
19
|
-
<h3><%= jira.key %> <%= partial :components, locals: { components: labels
|
19
|
+
<h3><%= jira.key %> <%= partial :components, locals: { components: labels } %></h3>
|
20
20
|
<p><%= jira.fields['summary'] %></p>
|
21
21
|
<p><%= %></p>
|
22
22
|
</a>
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: opsask
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.3.
|
4
|
+
version: 2.3.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sean Clemmer
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-08-
|
11
|
+
date: 2015-08-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: thor
|