wavefront-cli 8.5.0 → 9.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.github/workflows/release.yml +37 -0
- data/.github/workflows/test.yml +23 -0
- data/.rubocop.yml +10 -9
- data/HISTORY.md +15 -0
- data/README.md +4 -2
- data/lib/wavefront-cli/base.rb +2 -2
- data/lib/wavefront-cli/commands/.rubocop.yml +2 -13
- data/lib/wavefront-cli/commands/base.rb +10 -9
- data/lib/wavefront-cli/commands/derivedmetric.rb +1 -1
- data/lib/wavefront-cli/commands/metric.rb +3 -3
- data/lib/wavefront-cli/commands/metricspolicy.rb +33 -0
- data/lib/wavefront-cli/commands/query.rb +5 -5
- data/lib/wavefront-cli/commands/write.rb +12 -12
- data/lib/wavefront-cli/config.rb +4 -4
- data/lib/wavefront-cli/constants.rb +2 -1
- data/lib/wavefront-cli/controller.rb +19 -15
- data/lib/wavefront-cli/display/base.rb +3 -2
- data/lib/wavefront-cli/display/metricspolicy.rb +15 -0
- data/lib/wavefront-cli/display/printer/long.rb +11 -13
- data/lib/wavefront-cli/display/printer/sparkline.rb +3 -3
- data/lib/wavefront-cli/display/query.rb +1 -1
- data/lib/wavefront-cli/display/write.rb +2 -1
- data/lib/wavefront-cli/event.rb +2 -2
- data/lib/wavefront-cli/event_store.rb +2 -2
- data/lib/wavefront-cli/exception.rb +21 -0
- data/lib/wavefront-cli/exception_handler.rb +8 -1
- data/lib/wavefront-cli/helpers/load_file.rb +2 -2
- data/lib/wavefront-cli/maintenancewindow.rb +1 -1
- data/lib/wavefront-cli/metricspolicy.rb +42 -0
- data/lib/wavefront-cli/opt_handler.rb +3 -4
- data/lib/wavefront-cli/output/csv/query.rb +2 -2
- data/lib/wavefront-cli/output/hcl/dashboard.rb +6 -6
- data/lib/wavefront-cli/output/hcl/stdlib/array.rb +1 -1
- data/lib/wavefront-cli/output/wavefront/query.rb +7 -7
- data/lib/wavefront-cli/query.rb +1 -1
- data/lib/wavefront-cli/settings.rb +3 -4
- data/lib/wavefront-cli/stdlib/string.rb +5 -5
- data/lib/wavefront-cli/usage.rb +1 -1
- data/lib/wavefront-cli/version.rb +1 -1
- data/lib/wavefront-cli/write.rb +14 -18
- data/spec/.rubocop.yml +2 -17
- data/spec/constants.rb +4 -5
- data/spec/support/command_base.rb +12 -0
- data/spec/support/minitest_assertions.rb +15 -11
- data/spec/support/output_tester.rb +2 -2
- data/spec/support/supported_commands.rb +3 -1
- data/spec/test_mixins/import.rb +2 -2
- data/spec/test_mixins/search.rb +9 -7
- data/spec/test_mixins/set.rb +1 -1
- data/spec/wavefront-cli/account_spec.rb +6 -4
- data/spec/wavefront-cli/alert_spec.rb +29 -6
- data/spec/wavefront-cli/commands/base_spec.rb +4 -4
- data/spec/wavefront-cli/commands/config_spec.rb +3 -3
- data/spec/wavefront-cli/config_spec.rb +3 -3
- data/spec/wavefront-cli/controller_spec.rb +4 -0
- data/spec/wavefront-cli/dashboard_spec.rb +1 -1
- data/spec/wavefront-cli/derivedmetric_spec.rb +9 -7
- data/spec/wavefront-cli/display/printer/long_spec.rb +5 -3
- data/spec/wavefront-cli/display/printer/terse_spec.rb +1 -1
- data/spec/wavefront-cli/event_spec.rb +14 -11
- data/spec/wavefront-cli/event_store_spec.rb +16 -12
- data/spec/wavefront-cli/externallink_spec.rb +5 -3
- data/spec/wavefront-cli/maintenancewindow_spec.rb +25 -19
- data/spec/wavefront-cli/message_spec.rb +3 -3
- data/spec/wavefront-cli/metricspolicy_spec.rb +30 -0
- data/spec/wavefront-cli/opt_handler_spec.rb +4 -4
- data/spec/wavefront-cli/output/helpers.rb +1 -1
- data/spec/wavefront-cli/proxy_spec.rb +1 -1
- data/spec/wavefront-cli/query_spec.rb +1 -1
- data/spec/wavefront-cli/role_spec.rb +4 -3
- data/spec/wavefront-cli/serviceaccount_spec.rb +7 -7
- data/spec/wavefront-cli/stdlib/string_spec.rb +3 -1
- data/spec/wavefront-cli/usage_spec.rb +1 -1
- data/spec/wavefront-cli/{write_spec.rb → write_class_spec.rb} +1 -14
- data/wavefront-cli.gemspec +13 -12
- metadata +72 -146
- data/.travis.yml +0 -20
- data/spec/spec_helper.rb +0 -113
data/spec/spec_helper.rb
DELETED
@@ -1,113 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'json'
|
4
|
-
require 'webmock/minitest'
|
5
|
-
require 'spy/integration'
|
6
|
-
require 'inifile'
|
7
|
-
require 'minitest'
|
8
|
-
require 'minitest/autorun'
|
9
|
-
require 'minitest/spec'
|
10
|
-
require 'pathname'
|
11
|
-
require_relative '../lib/wavefront-cli/controller'
|
12
|
-
|
13
|
-
unless defined?(CMD)
|
14
|
-
ROOT = Pathname.new(__FILE__).dirname.parent
|
15
|
-
CMD = 'wavefront'
|
16
|
-
ENDPOINT = 'metrics.wavefront.com'
|
17
|
-
TOKEN = '0123456789-ABCDEF'
|
18
|
-
RES_DIR = Pathname.new(__FILE__).dirname + 'wavefront-cli' + 'resources'
|
19
|
-
CF = RES_DIR + 'wavefront.conf'
|
20
|
-
CF_VAL = IniFile.load(CF)
|
21
|
-
JSON_POST_HEADERS = {
|
22
|
-
'Content-Type': 'application/json', Accept: 'application/json'
|
23
|
-
}.freeze
|
24
|
-
BAD_TAG = '*BAD_TAG*'
|
25
|
-
HOME_CONFIG = Pathname.new(ENV['HOME']) + '.wavefront'
|
26
|
-
end
|
27
|
-
|
28
|
-
# Object returned by cmd_to_call. Has just enough methods to satisfy
|
29
|
-
# the SDK
|
30
|
-
#
|
31
|
-
class DummyResponse
|
32
|
-
def more_items?
|
33
|
-
false
|
34
|
-
end
|
35
|
-
|
36
|
-
def response
|
37
|
-
Map.new(items: [])
|
38
|
-
end
|
39
|
-
|
40
|
-
def empty?
|
41
|
-
false
|
42
|
-
end
|
43
|
-
|
44
|
-
def status; end
|
45
|
-
end
|
46
|
-
|
47
|
-
CANNED_RESPONSE = DummyResponse.new
|
48
|
-
|
49
|
-
# Unit tests
|
50
|
-
#
|
51
|
-
class CliMethodTest < MiniTest::Test
|
52
|
-
attr_reader :wf
|
53
|
-
|
54
|
-
def setup
|
55
|
-
@wf = cliclass.new({})
|
56
|
-
end
|
57
|
-
|
58
|
-
def import_tester(word, have_fields, do_not_have_fields = [])
|
59
|
-
input = wf.load_file(RES_DIR + 'imports' + "#{word}.json")
|
60
|
-
x = wf.import_to_create(input)
|
61
|
-
assert_instance_of(Hash, x)
|
62
|
-
have_fields.each { |f| assert_includes(x.keys, f) }
|
63
|
-
do_not_have_fields.each { |f| refute_includes(x.keys, f) }
|
64
|
-
end
|
65
|
-
end
|
66
|
-
|
67
|
-
# stdlib extensions
|
68
|
-
#
|
69
|
-
class Hash
|
70
|
-
# A quick way to deep-copy a hash.
|
71
|
-
#
|
72
|
-
def dup
|
73
|
-
Marshal.load(Marshal.dump(self))
|
74
|
-
end
|
75
|
-
end
|
76
|
-
|
77
|
-
require 'wavefront-sdk/core/response'
|
78
|
-
require_relative '../lib/wavefront-cli/base'
|
79
|
-
|
80
|
-
# For the given command word, loads up a canned API response and
|
81
|
-
# feeds it in to the appropriate display class, running the given
|
82
|
-
# method and returning standard out and standard error.
|
83
|
-
#
|
84
|
-
# @param word [String] command word, e.g. 'alert'
|
85
|
-
# @param method [Symbol] display method to run, e.g. :do_list
|
86
|
-
# @param klass [Class, Nil] CLI class. Worked out from the command
|
87
|
-
# word in most cases, but must be overriden for two-word things.
|
88
|
-
# @return [Array] [stdout, stderr]
|
89
|
-
#
|
90
|
-
def command_output(word, method, klass = nil, infile = nil)
|
91
|
-
infile ||= "#{word}-list.json"
|
92
|
-
json = IO.read(RES_DIR + 'responses' + infile)
|
93
|
-
resp = Wavefront::Response.new(json, 200)
|
94
|
-
klass ||= Object.const_get(format('WavefrontCli::%<class_word>s',
|
95
|
-
class_word: word.capitalize))
|
96
|
-
klass = klass.new(format: :human)
|
97
|
-
|
98
|
-
capture_io { klass.display(resp, method) }
|
99
|
-
end
|
100
|
-
|
101
|
-
def test_list_output(word, klass = nil)
|
102
|
-
it 'tests terse output' do
|
103
|
-
out, err = command_output(word, :do_list_brief, klass)
|
104
|
-
refute_empty(out)
|
105
|
-
assert_empty(err)
|
106
|
-
end
|
107
|
-
|
108
|
-
it 'tests long output' do
|
109
|
-
out, err = command_output(word, :do_list_long, klass)
|
110
|
-
refute_empty(out)
|
111
|
-
assert_empty(err)
|
112
|
-
end
|
113
|
-
end
|