wavefront-cli 8.1.0 → 8.4.1

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: 53d7cbfa6e04c70f7c9c2af901ec42da4783b5b2f4aaa7552ebb53bf840395da
4
- data.tar.gz: cef50e1684db66aa4a525c7ba91088a491bb790b8562c720437a12e7692b4390
3
+ metadata.gz: d96bb27765c031f9998dfa45406581de1852f0fbdc0abff4bcea45b679963299
4
+ data.tar.gz: d40011ef4d521dd738fb594095366ee7e506bc35c9bad83e2ad421eeedab16bb
5
5
  SHA512:
6
- metadata.gz: 3ec1eacceffa1fefad6050e42eb5c3891133da9e23bcb5e62de8ee558b9535d27936e95a3a66eb6eac616d4effe371b3f66334e6a652548d3ae0b06d39747853
7
- data.tar.gz: 241a752fb0fd12225e8fa26a342380a15040d37d694fc90c23604bb96691e4ad54f97617cc1fcf688f495e8ed42f44ef0e60c9122ddaa9b2cbd7b13dbb86ac3e
6
+ metadata.gz: f4777538a7b6f116f56c24382b9f3ea54ca78d5306009a3876857ff963f481561ff28e5c925cf0e62152e686caaa3c54e3abe90f48f16cb6e7cd6f87ede9f857
7
+ data.tar.gz: 1bfab61e86f92ff9284207627615f07a701092afb6bd6f839471833db3610fb60c8e013c56b57a50329c67650e1a778c6581adb61804f4365675cb1838cb7c4f
data/HISTORY.md CHANGED
@@ -1,5 +1,22 @@
1
1
  # Changelog
2
2
 
3
+ ## 8.4.1 (2021-01-04)
4
+ * Bugfix docopt error on `event` command.
5
+
6
+ ## 8.4.0 (2020-12-16)
7
+ * Add `-f raw` option to dump the raw API response.
8
+ * Bugfix `set` subcommand, which was not reliable on certain object types.
9
+ * Require >=5.4.1 of [the SDK](https://github.com/snltd/wavefront-sdk).
10
+
11
+ ## 8.3.1 (2020-11-17)
12
+ * Catch ctrl-c properly.
13
+
14
+ ## 8.3.0 (2020-10-31)
15
+ * Add `wf proxy shutdown` command.
16
+
17
+ ## 8.2.0 (2020-10-06)
18
+ * Display spans in human-readable query output.
19
+
3
20
  ## 8.1.0 (2020-10-04)
4
21
  * Display traces in human-readable query output.
5
22
 
@@ -9,7 +26,6 @@
9
26
 
10
27
  ## 8.0.0 (2020-09-20
11
28
  * Drop Ruby 2.4.0 support. (Breaking change.)
12
- >>>>>>> master
13
29
 
14
30
  ## 7.2.0 (2020-08-12)
15
31
  * 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)
@@ -13,7 +13,7 @@ class WavefrontCommandEvent < WavefrontCommandBase
13
13
  ["list #{CMN} [-l] [-O fields] [-s start] [-e end] " \
14
14
  '[-L limit] [-o cursor]',
15
15
  "describe #{CMN} <id>",
16
- "create #{CMN} [-d description] [-s time] [-i | -e time] " \
16
+ "create #{CMN} [-d description] [-s start] [-i | -e end] " \
17
17
  '[-S severity] [-T type] [-H host...] [-g tag...] [-N] <event>',
18
18
  "close #{CMN} [<id>]",
19
19
  "delete #{CMN} <id>",
@@ -31,8 +31,10 @@ class WavefrontCommandEvent < WavefrontCommandBase
31
31
  "-o, --cursor=EVENT start listing from given #{thing}",
32
32
  '-O, --fields=F1,F2,... only show given fields',
33
33
  "-L, --limit=COUNT number of #{things} to list",
34
- "-s, --start=TIME time at which #{thing} begins",
35
- "-e, --end=TIME time at which #{thing} ends",
34
+ "-s, --start=TIME start of listed #{things} or time at which " \
35
+ "#{thing} begins",
36
+ "-e, --end=TIME end of listed #{things} or time at which " \
37
+ "#{thing} ends",
36
38
  "-S, --severity=SEVERITY severity of #{thing}",
37
39
  "-i, --instant create an instantaneous #{thing}",
38
40
  "-T, --type=TYPE type of #{thing}",
@@ -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 && depth < 3
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,15 +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),
23
24
  traces: mk_traces(data),
25
+ spans: mk_spans(data),
24
26
  events: mk_events(data) }.tap do |d|
25
27
  d[:warnings] = data[:warnings] if show_warnings?
26
28
  end
27
29
  end
30
+ # rubocop:enable Metrics/AbcSize
28
31
 
29
32
  def show_warnings?
30
33
  data.key?(:warnings) && !options[:nowarn]
@@ -61,6 +64,12 @@ module WavefrontDisplay
61
64
  data[:traces].map { |t| humanize_trace(t) }
62
65
  end
63
66
 
67
+ def mk_spans(data)
68
+ return [] unless data.key?(:spans)
69
+
70
+ data[:spans].map { |t| humanize_span(t) }
71
+ end
72
+
64
73
  def do_run
65
74
  do_default
66
75
  end
@@ -107,17 +116,24 @@ module WavefrontDisplay
107
116
  end
108
117
 
109
118
  def humanize_trace(data)
119
+ @printer_opts[:sep_depth] = 3
120
+
110
121
  data.tap do |t|
111
122
  t[:start] = human_time(t[:start_ms])
112
123
  t[:end] = human_time(t[:end_ms])
113
124
  t.delete(:start_ms)
114
125
  t.delete(:end_ms)
115
126
  t.delete(:startMs)
116
- t.spans = t.spans.map { |s| humanize_span(s) }
127
+ t.spans = t.spans.map { |s| humanize_trace_span(s) }
117
128
  end
118
129
  end
119
130
 
120
- def humanize_span(span)
131
+ def humanize_span(data)
132
+ @printer_opts[:sep_depth] = 2
133
+ data
134
+ end
135
+
136
+ def humanize_trace_span(span)
121
137
  span.tap do |s|
122
138
  s[:startMs] = human_time(s[:startMs])
123
139
  end
@@ -2,6 +2,7 @@
2
2
 
3
3
  require 'fileutils'
4
4
  require 'open3'
5
+ require 'etc'
5
6
  require 'wavefront-sdk/support/mixins'
6
7
  require_relative 'base'
7
8
  require_relative 'command_mixins/tag'
@@ -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.1.0'
3
+ WF_CLI_VERSION = '8.4.1'
@@ -22,7 +22,6 @@ unless defined?(CMD)
22
22
  'Content-Type': 'application/json', Accept: 'application/json'
23
23
  }.freeze
24
24
  BAD_TAG = '*BAD_TAG*'
25
- TW = 80
26
25
  HOME_CONFIG = Pathname.new(ENV['HOME']) + '.wavefront'
27
26
  end
28
27
 
@@ -22,6 +22,18 @@ class WavefrontCliHelpTest < MiniTest::Test
22
22
  assert_match(/^ \w+ --help$/, e.message)
23
23
  end
24
24
 
25
+ def test_commands_no_args
26
+ SupportedCommands.new.all.each do |cmd|
27
+ _test_command_no_args(cmd)
28
+ end
29
+ end
30
+
31
+ def _test_command_no_args(cmd)
32
+ capture_io { WavefrontCliController.new([cmd]) }
33
+ rescue SystemExit => e
34
+ assert e.message.end_with?("wf #{cmd} --help")
35
+ end
36
+
25
37
  def test_version
26
38
  capture_io { WavefrontCliController.new(%w[--version]) }
27
39
  rescue SystemExit => e
@@ -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.1.0
4
+ version: 8.4.1
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-10-04 00:00:00.000000000 Z
11
+ date: 2021-01-04 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