wavefront-cli 4.0.1 → 4.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/HISTORY.md +3 -0
- data/lib/wavefront-cli/base.rb +10 -7
- data/lib/wavefront-cli/controller.rb +9 -3
- data/lib/wavefront-cli/dashboard.rb +10 -0
- data/lib/wavefront-cli/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 83528e35b66e2a098928edb63b4f62cf4f730153caf886e8d2132dd8ef870340
|
4
|
+
data.tar.gz: 9a6affc13f2b2fc1c41052abbd25dae47c2412a7bd70b39ec84ab8516ee748fa
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 46710487da70d0ea78ec7ba703b608b634a80d8b837b0ac91d0f4b9efad7a36ede6365060eb3f25455f56fbbdfd55b015a92f87c5c684af86e32f77ed00b038e
|
7
|
+
data.tar.gz: d7527a3814e9b2cc8fe1ba1f49fa294122406442e2c5c50ecdafd0f2b6a4a975a2c0c22b74fb01cb5a9379e07977b421d3a526b070714120d2ccfb64f0e59110
|
data/HISTORY.md
CHANGED
@@ -1,5 +1,8 @@
|
|
1
1
|
# Changelog
|
2
2
|
|
3
|
+
## 4.0.2 (20/06/2019)
|
4
|
+
* Allow importing of dashboards which have a URL but not an ID.
|
5
|
+
|
3
6
|
## 4.0.1 (18/06/2019)
|
4
7
|
* `update` subcommand has been changed to `set`. (Breaking change.)
|
5
8
|
* `import` subcommand now accepts `--update` (`-u`) option, which
|
data/lib/wavefront-cli/base.rb
CHANGED
@@ -325,7 +325,6 @@ module WavefrontCli
|
|
325
325
|
# filetype is unknown.
|
326
326
|
# @raise pass through any error loading or parsing the file
|
327
327
|
#
|
328
|
-
# rubocop:disable Metrics/AbcSize
|
329
328
|
def load_file(path)
|
330
329
|
return load_from_stdin if path == '-'
|
331
330
|
|
@@ -333,15 +332,16 @@ module WavefrontCli
|
|
333
332
|
|
334
333
|
raise WavefrontCli::Exception::FileNotFound unless file.exist?
|
335
334
|
|
336
|
-
|
337
|
-
|
338
|
-
|
339
|
-
|
335
|
+
extname = file.extname.downcase
|
336
|
+
|
337
|
+
if extname == '.json'
|
338
|
+
JSON.parse(IO.read(file), symbolize_names: true)
|
339
|
+
elsif %w[.yaml .yml].include?(extname)
|
340
|
+
YAML.safe_load(IO.read(file), symbolize_names: true)
|
340
341
|
else
|
341
342
|
raise WavefrontCli::Exception::UnsupportedFileFormat
|
342
343
|
end
|
343
344
|
end
|
344
|
-
# rubocop:enable Metrics/AbcSize
|
345
345
|
|
346
346
|
# Read STDIN and return a Ruby object, assuming that STDIN is
|
347
347
|
# valid JSON or YAML. This is a dumb method, it does no
|
@@ -383,8 +383,10 @@ module WavefrontCli
|
|
383
383
|
wf.describe(options[:'<id>'])
|
384
384
|
end
|
385
385
|
|
386
|
+
# rubocop:disable Metrics/AbcSize
|
386
387
|
def do_import
|
387
388
|
raw = load_file(options[:'<file>'])
|
389
|
+
raw = preprocess_rawfile(raw) if respond_to?(:preprocess_rawfile)
|
388
390
|
|
389
391
|
begin
|
390
392
|
prepped = import_to_create(raw)
|
@@ -399,9 +401,10 @@ module WavefrontCli
|
|
399
401
|
wf.create(prepped)
|
400
402
|
end
|
401
403
|
end
|
404
|
+
# rubocop:enable Metrics/AbcSize
|
402
405
|
|
403
406
|
def import_update(raw)
|
404
|
-
wf.update(raw[
|
407
|
+
wf.update(raw[:id], raw, false)
|
405
408
|
end
|
406
409
|
|
407
410
|
def do_delete
|
@@ -10,7 +10,6 @@ if defined?(DEVELOPMENT)
|
|
10
10
|
end
|
11
11
|
|
12
12
|
require 'pathname'
|
13
|
-
require 'pp'
|
14
13
|
require 'docopt'
|
15
14
|
require_relative 'version'
|
16
15
|
require_relative 'constants'
|
@@ -34,7 +33,6 @@ class WavefrontCliController
|
|
34
33
|
@usage = docopt_hash
|
35
34
|
cmd, opts = parse_args
|
36
35
|
@opts = parse_opts(opts)
|
37
|
-
pp @opts if @opts[:debug]
|
38
36
|
cli_class_obj = load_cli_class(cmd, @opts)
|
39
37
|
run_command(cli_class_obj)
|
40
38
|
end
|
@@ -144,12 +142,20 @@ class WavefrontCliController
|
|
144
142
|
abort 'Search on non-existent key. Please use a top-level field.'
|
145
143
|
rescue StandardError => e
|
146
144
|
warn "general error: #{e}"
|
147
|
-
|
145
|
+
backtrace_message(e)
|
148
146
|
abort
|
149
147
|
end
|
150
148
|
# rubocop:enable Metrics/MethodLength
|
151
149
|
# rubocop:enable Metrics/AbcSize
|
152
150
|
|
151
|
+
def backtrace_message(err)
|
152
|
+
if opts[:debug]
|
153
|
+
warn "Backtrace:\n\t#{err.backtrace.join("\n\t")}"
|
154
|
+
else
|
155
|
+
puts "Re-run command with '-D' for backtrace."
|
156
|
+
end
|
157
|
+
end
|
158
|
+
|
153
159
|
# @param error [WavefrontCli::Exception::CredentialError]
|
154
160
|
#
|
155
161
|
def handle_missing_credentials(error)
|
@@ -53,5 +53,15 @@ module WavefrontCli
|
|
53
53
|
wf.unfavorite(options[:'<id>'])
|
54
54
|
do_favs
|
55
55
|
end
|
56
|
+
|
57
|
+
# Dashboards are, AFAIK, unique in that they do NOT require an
|
58
|
+
# ID. They can have a URL instead: the two are equivalent. The
|
59
|
+
# easiest workaround for this is to copy the URL to the ID if we
|
60
|
+
# only have the former.
|
61
|
+
#
|
62
|
+
def preprocess_rawfile(raw)
|
63
|
+
raw[:id] = raw[:url] if raw.key?(:url) && !raw.key?(:id)
|
64
|
+
raw
|
65
|
+
end
|
56
66
|
end
|
57
67
|
end
|
@@ -1 +1 @@
|
|
1
|
-
WF_CLI_VERSION = '4.0.
|
1
|
+
WF_CLI_VERSION = '4.0.2'.freeze
|
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: 4.0.
|
4
|
+
version: 4.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Robert Fisher
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-06-
|
11
|
+
date: 2019-06-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: docopt
|