wavefront-cli 8.0.1 → 8.4.0

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: d831cf75206998d12f64271f13ce2b98c5cdeef18470b7f8e366f38c46a186e7
4
- data.tar.gz: 8a0e75fe5bd16d0893d52a863daf04ed599418d848ee024d0c4177cb3837e30c
3
+ metadata.gz: 699611ad61cde3c72f79d281cecd5c11fea37209852f2a14550331bf2b3e1cf8
4
+ data.tar.gz: c4567567ebf77209ff858d2b8ac57baa5d406735415e9bcf0ae24342ea3023e8
5
5
  SHA512:
6
- metadata.gz: 10a9becb4fd55031ce4913718b9a6e65f5bc05b92ba961ee8474889733991a816e455deaed6dec4869b1058d2c8fee515c51e4f6bc4091ee3e1560f7de1bc8e1
7
- data.tar.gz: ac4a999ea2d23fc62c04612fdccb51c0bf3f66cf2017ea2980e58f3d684d2e145f53ebae429461498b832521154f674687a6cb3eaef438fb466e050ea7388e70
6
+ metadata.gz: 00b64e995bfb20a3476c49794ca661ab9cbf5d216664c1fd94de3517017c94e76149aa2a3159129921edfa512ccdf2e9f413d7c214d39ff3d2e05108635636c5
7
+ data.tar.gz: 31a1dd4fd12927a39425516da9e25744c8092968a5b06188cb16b2221bae81fae1a1362d50f0d27908048b30e8cc02c8c3b64aac4b7ce0a6d828d38d127e0f73
data/HISTORY.md CHANGED
@@ -1,12 +1,28 @@
1
1
  # Changelog
2
2
 
3
+ ## 8.4.0 (2020-12-16)
4
+ * Add `-f raw` option to dump the raw API response.
5
+ * Bugfix `set` subcommand, which was not reliable on certain object types.
6
+ * Require >=5.4.1 of [the SDK](https://github.com/snltd/wavefront-sdk).
7
+
8
+ ## 8.3.1 (2020-11-17)
9
+ * Catch ctrl-c properly.
10
+
11
+ ## 8.3.0 (2020-10-31)
12
+ * Add `wf proxy shutdown` command.
13
+
14
+ ## 8.2.0 (2020-10-06)
15
+ * Display spans in human-readable query output.
16
+
17
+ ## 8.1.0 (2020-10-04)
18
+ * Display traces in human-readable query output.
19
+
3
20
  ## 8.0.1 (2020-09-28)
4
21
  * If the user specifies a config stanza and it is not found, exit with an
5
22
  error rather than silently falling back to env vars.
6
23
 
7
24
  ## 8.0.0 (2020-09-20
8
25
  * Drop Ruby 2.4.0 support. (Breaking change.)
9
- >>>>>>> master
10
26
 
11
27
  ## 7.2.0 (2020-08-12)
12
28
  * Add `cloudintegration awsid generate` command.
@@ -147,6 +147,7 @@ module WavefrontCli
147
147
  noop: options[:noop] }
148
148
 
149
149
  ret[:verbose] = options[:noop] ? true : options[:verbose]
150
+ ret[:raw_response] = true if options[:format] == 'raw'
150
151
 
151
152
  ret.merge!(extra_options) if respond_to?(:extra_options)
152
153
  ret
@@ -228,6 +229,8 @@ module WavefrontCli
228
229
 
229
230
  exit if options[:noop]
230
231
 
232
+ ok_exit data if options[:format] == 'raw'
233
+
231
234
  check_response_blocks(data)
232
235
  warning_message(data.status)
233
236
  status_error_handler(data, method)
@@ -16,6 +16,7 @@ class WavefrontCommandProxy < WavefrontCommandBase
16
16
  "undelete #{CMN} <id>",
17
17
  "rename #{CMN} <id> <name>",
18
18
  "search #{CMN} [-al] [-o offset] [-L limit] [-O fields] <condition>...",
19
+ "shutdown #{CMN} <id>",
19
20
  "versions #{CMN}"]
20
21
  end
21
22
 
@@ -39,6 +39,15 @@ class WavefrontCliController
39
39
  @opts = parse_opts(opts)
40
40
  cli_class_obj = cli_class(cmd, @opts)
41
41
  run_command(cli_class_obj)
42
+ rescue Interrupt
43
+ handle_interrupt!
44
+ end
45
+
46
+ def handle_interrupt!
47
+ raise if opts[:debug]
48
+
49
+ puts "\nCancelled at user's request."
50
+ exit 0
42
51
  end
43
52
 
44
53
  # What you see when you do 'wf --help'
@@ -33,6 +33,7 @@ module WavefrontDisplay
33
33
 
34
34
  @data = prioritize_keys(data, priority_keys)
35
35
  @options = options
36
+ @printer_opts = {}
36
37
  end
37
38
 
38
39
  # find the correct method to deal with the output of the user's
@@ -152,7 +153,8 @@ module WavefrontDisplay
152
153
  puts 'No data.'
153
154
  else
154
155
  require_relative 'printer/long'
155
- puts WavefrontDisplayPrinter::Long.new(data, fields, modified_data)
156
+ puts WavefrontDisplayPrinter::Long.new(data, fields, modified_data,
157
+ @printer_opts)
156
158
  pagination_line
157
159
  end
158
160
  end
@@ -29,11 +29,13 @@ module WavefrontDisplayPrinter
29
29
 
30
30
  # Default options. Can all be overridden by passing them in the
31
31
  # initializer options hash.
32
+ # After sep_depth indentations we do not print separator lines
32
33
  #
33
34
  def default_opts
34
35
  { indent: 2,
35
36
  padding: 2,
36
37
  separator: true,
38
+ sep_depth: 3,
37
39
  none: true }
38
40
  end
39
41
 
@@ -179,7 +181,8 @@ module WavefrontDisplayPrinter
179
181
  data.each.with_index(1) do |element, i|
180
182
  aggr = make_list(element, aggr, depth, last_key)
181
183
 
182
- if opts[:separator] && element.is_a?(Hash) && i < data.size
184
+ if opts[:separator] && element.is_a?(Hash) && i < data.size &&
185
+ depth < opts[:sep_depth]
183
186
  aggr.<< ['', :separator, depth]
184
187
  end
185
188
  end
@@ -26,6 +26,10 @@ module WavefrontDisplay
26
26
  multicolumn(:id, :version, :name)
27
27
  end
28
28
 
29
+ def do_shutdown
30
+ puts "Requested shutdown of proxy '#{options[:'<id>']}'."
31
+ end
32
+
29
33
  private
30
34
 
31
35
  def filter_inactive_proxies!
@@ -16,14 +16,18 @@ module WavefrontDisplay
16
16
  data[:errorMessage].split("\n").first)
17
17
  end
18
18
 
19
+ # rubocop:disable Metrics/AbcSize
19
20
  def default_data_object
20
21
  { name: data.name,
21
22
  query: data.query,
22
23
  timeseries: mk_timeseries(data),
24
+ traces: mk_traces(data),
25
+ spans: mk_spans(data),
23
26
  events: mk_events(data) }.tap do |d|
24
27
  d[:warnings] = data[:warnings] if show_warnings?
25
28
  end
26
29
  end
30
+ # rubocop:enable Metrics/AbcSize
27
31
 
28
32
  def show_warnings?
29
33
  data.key?(:warnings) && !options[:nowarn]
@@ -54,6 +58,18 @@ module WavefrontDisplay
54
58
  data[:events].map { |s| humanize_event(s) }
55
59
  end
56
60
 
61
+ def mk_traces(data)
62
+ return [] unless data.key?(:traces)
63
+
64
+ data[:traces].map { |t| humanize_trace(t) }
65
+ end
66
+
67
+ def mk_spans(data)
68
+ return [] unless data.key?(:spans)
69
+
70
+ data[:spans].map { |t| humanize_span(t) }
71
+ end
72
+
57
73
  def do_run
58
74
  do_default
59
75
  end
@@ -99,6 +115,30 @@ module WavefrontDisplay
99
115
  end
100
116
  end
101
117
 
118
+ def humanize_trace(data)
119
+ @printer_opts[:sep_depth] = 3
120
+
121
+ data.tap do |t|
122
+ t[:start] = human_time(t[:start_ms])
123
+ t[:end] = human_time(t[:end_ms])
124
+ t.delete(:start_ms)
125
+ t.delete(:end_ms)
126
+ t.delete(:startMs)
127
+ t.spans = t.spans.map { |s| humanize_trace_span(s) }
128
+ end
129
+ end
130
+
131
+ def humanize_span(data)
132
+ @printer_opts[:sep_depth] = 2
133
+ data
134
+ end
135
+
136
+ def humanize_trace_span(span)
137
+ span.tap do |s|
138
+ s[:startMs] = human_time(s[:startMs])
139
+ end
140
+ end
141
+
102
142
  def row_time_and_val(row)
103
143
  if row.is_a?(Hash)
104
144
  [human_time(row[:timestamp]), row[:value]]
@@ -32,6 +32,10 @@ module WavefrontCli
32
32
  version_info(raw).sort_by { |p| Gem::Version.new(p[:version]) }.reverse
33
33
  end
34
34
 
35
+ def do_shutdown
36
+ wf.shutdown(options[:'<id>'])
37
+ end
38
+
35
39
  def version_info(raw)
36
40
  raw.response.items.map do |i|
37
41
  { id: i.id, version: i.version, name: i.name }
@@ -1,3 +1,3 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- WF_CLI_VERSION = '8.0.1'
3
+ WF_CLI_VERSION = '8.4.0'
@@ -52,12 +52,14 @@ class TestWavefrontDisplayPrinterLong < MiniTest::Test
52
52
  assert_equal({ indent: 4,
53
53
  padding: 3,
54
54
  separator: true,
55
+ sep_depth: 3,
55
56
  none: true }, pr.opts)
56
57
 
57
58
  pr = WavefrontDisplayPrinter::Long.new({}, nil, nil, none: false)
58
59
  assert_equal({ indent: 2,
59
60
  padding: 2,
60
61
  separator: true,
62
+ sep_depth: 3,
61
63
  none: false }, pr.opts)
62
64
  end
63
65
 
@@ -36,6 +36,19 @@ class ProxyEndToEndTest < EndToEndTest
36
36
  assert_abort_on_missing_creds("rename #{id} newname")
37
37
  end
38
38
 
39
+ def test_shutdown
40
+ assert_output("Requested shutdown of proxy '#{id}'.\n") do
41
+ assert_cmd_puts("shutdown #{id}", "/api/v2/proxy/#{id}",
42
+ { shutdown: true }.to_json)
43
+ end
44
+
45
+ assert_noop("shutdown #{id}",
46
+ "uri: PUT https://default.wavefront.com/api/v2/proxy/#{id}",
47
+ 'body: {"shutdown":true}')
48
+ assert_invalid_id("shutdown #{invalid_id}")
49
+ assert_abort_on_missing_creds("shutdown #{id}")
50
+ end
51
+
39
52
  private
40
53
 
41
54
  def id
@@ -26,7 +26,7 @@ Gem::Specification.new do |gem|
26
26
 
27
27
  gem.add_runtime_dependency 'docopt', '~> 0.6.0'
28
28
  gem.add_runtime_dependency 'inifile', '~> 3.0'
29
- gem.add_runtime_dependency 'wavefront-sdk', '~> 5.2'
29
+ gem.add_runtime_dependency 'wavefront-sdk', '~> 5.4', '>= 5.4.1'
30
30
 
31
31
  gem.add_development_dependency 'minitest', '~> 5.14'
32
32
  gem.add_development_dependency 'rake', '~> 13.0'
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: 8.0.1
4
+ version: 8.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Robert Fisher
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-09-28 00:00:00.000000000 Z
11
+ date: 2020-12-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: docopt
@@ -44,14 +44,20 @@ dependencies:
44
44
  requirements:
45
45
  - - "~>"
46
46
  - !ruby/object:Gem::Version
47
- version: '5.2'
47
+ version: '5.4'
48
+ - - ">="
49
+ - !ruby/object:Gem::Version
50
+ version: 5.4.1
48
51
  type: :runtime
49
52
  prerelease: false
50
53
  version_requirements: !ruby/object:Gem::Requirement
51
54
  requirements:
52
55
  - - "~>"
53
56
  - !ruby/object:Gem::Version
54
- version: '5.2'
57
+ version: '5.4'
58
+ - - ">="
59
+ - !ruby/object:Gem::Version
60
+ version: 5.4.1
55
61
  - !ruby/object:Gem::Dependency
56
62
  name: minitest
57
63
  requirement: !ruby/object:Gem::Requirement