wavefront-cli 2.9.2 → 2.9.3

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
  SHA256:
3
- metadata.gz: 98b1eb89086e67e5ce3e1005b254248f712915ea9ec13c401c618544cba401f9
4
- data.tar.gz: b5595a4b8d1eee6f968c6c0c2d428dad2af59102d61d59eeb6cdaeba0f36d5d4
3
+ metadata.gz: f715afc29d378a6e84b9ce7ad2b7ade17047a85d2ae6e1280605322d87085c0e
4
+ data.tar.gz: 35ebc020f4201d6890625a62cf346d46aacf3eb7250ddaa7015dce34fb4ef93e
5
5
  SHA512:
6
- metadata.gz: 1f871775db809ba9258a008dd1a2f618abeb582e0018f54cc90c99c8f00771053591569fde1d3c9e193622f946644f8299dd63942455e53c103a596e1ba417b1
7
- data.tar.gz: 0e807a24dddcd83cb3931c83ca3fd0b879170c20e7bad3441c41ae76698b1571fa7409ccc3e23d15b329a77d9f3cacfe6a398b31a8a524a06699f2bb307daa00
6
+ metadata.gz: 61a94256695771c09205e5a5d26bedf2f45c35fc4e2ba9a6c4d03cec23cbeeed465f12f807d06d5135b63bd6af5f7956a8778ed3c5885fa5e363994d2ae0fbe8
7
+ data.tar.gz: 6722fd63e13d7178015c7960d5b8d615de73e49d3c54cf98e17d9cbd05d42ba4280e7b1ecc184b3d42e24f37a3db7405f9548ffbc486095971db6bb7dcf65a9b
data/HISTORY.md CHANGED
@@ -1,5 +1,9 @@
1
1
  # Changelog
2
2
 
3
+ ## 2.9.3 (03/09/2018)
4
+ * Fix a bug where indefinitely snoozed alerts broke `wf alert
5
+ snoozed`.
6
+
3
7
  ## 2.9.2 (22/08/2018)
4
8
  * Fix regression which broke the `wf` command when it ran without a
5
9
  tty.
@@ -53,12 +53,23 @@ module WavefrontCli
53
53
  search = do_search([format('status=%s', status)])
54
54
 
55
55
  items = search.response.items.map do |i|
56
- { name: i.name, id: i.id, startTime: i.event.startTime }
56
+ { name: i.name, id: i.id, time: state_time(i) }
57
57
  end
58
58
 
59
59
  search.tap { |s| s.response[:items] = items }
60
60
  end
61
61
 
62
+ # Snoozed alerts don't have a start time, they have a "snoozed"
63
+ # time. This is -1 if they are snoozed forever: the formatting
64
+ # methods know what to do with that.
65
+ # @return [Integer]
66
+ #
67
+ def state_time(item)
68
+ return item[:event][:startTime] if item.key?(:event)
69
+ return item[:snoozed] if item.key?(:snoozed)
70
+ nil
71
+ end
72
+
62
73
  # Take a previously exported alert, and construct a hash which
63
74
  # create() can use to re-create it.
64
75
  #
@@ -16,13 +16,13 @@ module WavefrontDisplay
16
16
  end
17
17
 
18
18
  def do_firing
19
- readable_time_arr(:startTime)
20
- multicolumn(:id, :name, :startTime)
19
+ readable_time_arr(:time)
20
+ multicolumn(:id, :time, :name)
21
21
  end
22
22
 
23
23
  def do_snoozed
24
- readable_time_arr(:startTime)
25
- multicolumn(:id, :name, :startTime)
24
+ readable_time_arr(:time)
25
+ multicolumn(:id, :time, :name)
26
26
  end
27
27
 
28
28
  def do_describe
@@ -267,27 +267,32 @@ module WavefrontDisplay
267
267
  # used for unit tests.
268
268
  # return [String] a human-readable timestamp
269
269
  #
270
- # rubocop:disable Metrics/MethodLength
271
270
  def human_time(time, force_utc = false)
272
271
  raise ArgumentError unless time.is_a?(Numeric) || time.is_a?(String)
273
- str = time.to_s
274
272
 
275
- if str =~ /^\d{13}$/
276
- fmt = '%Q'
277
- out_fmt = HUMAN_TIME_FORMAT_MS
278
- elsif str =~ /^\d{10}$/
279
- fmt = '%s'
280
- out_fmt = HUMAN_TIME_FORMAT
281
- else
282
- raise ArgumentError
283
- end
273
+ return 'FOREVER' if time == -1
284
274
 
275
+ str = time.to_s
276
+ fmt, out_fmt = time_formats(str)
285
277
  # rubocop:disable Style/DateTime
286
278
  ret = DateTime.strptime(str, fmt).to_time
287
279
  # rubocop:enable Style/DateTime
288
280
  ret = ret.utc if force_utc
289
281
  ret.strftime(out_fmt)
290
282
  end
291
- # rubocop:enable Metrics/MethodLength
283
+
284
+ # How do we format a timestamp?
285
+ # @param str [String] an epoch timestamp, as a string
286
+ # @return [String, String] DateTime formatter, strptime formatter
287
+ #
288
+ def time_formats(str)
289
+ if str =~ /^\d{13}$/
290
+ ['%Q', HUMAN_TIME_FORMAT_MS]
291
+ elsif str =~ /^\d{10}$/
292
+ ['%s', HUMAN_TIME_FORMAT]
293
+ else
294
+ raise ArgumentError
295
+ end
296
+ end
292
297
  end
293
298
  end
@@ -1 +1 @@
1
- WF_CLI_VERSION = '2.9.2'.freeze
1
+ WF_CLI_VERSION = '2.9.3'.freeze
@@ -157,5 +157,6 @@ class WavefrontDisplayBaseTest < MiniTest::Test
157
157
  wf.human_time(Time.now.to_i))
158
158
  assert_equal('2017-07-07 11:23:35.123', wf.human_time(1_499_426_615_123,
159
159
  true))
160
+ assert_equal('FOREVER', wf.human_time(-1))
160
161
  end
161
162
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: wavefront-cli
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.9.2
4
+ version: 2.9.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Robert Fisher
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-08-22 00:00:00.000000000 Z
11
+ date: 2018-09-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: docopt