wavefront-cli 7.1.0 → 8.2.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/.rubocop.yml +6 -37
- data/.travis.yml +4 -5
- data/HISTORY.md +20 -0
- data/README.md +1 -1
- data/lib/wavefront-cli/base.rb +10 -10
- data/lib/wavefront-cli/cloudintegration.rb +12 -0
- data/lib/wavefront-cli/commands/.rubocop.yml +9 -37
- data/lib/wavefront-cli/commands/cloudintegration.rb +4 -1
- data/lib/wavefront-cli/config.rb +3 -1
- data/lib/wavefront-cli/controller.rb +1 -3
- data/lib/wavefront-cli/display/base.rb +3 -1
- data/lib/wavefront-cli/display/cloudintegration.rb +12 -0
- data/lib/wavefront-cli/display/printer/long.rb +8 -1
- data/lib/wavefront-cli/display/query.rb +40 -0
- data/lib/wavefront-cli/event.rb +2 -0
- data/lib/wavefront-cli/exception_handler.rb +2 -2
- data/lib/wavefront-cli/externallink.rb +4 -6
- data/lib/wavefront-cli/helpers/load_file.rb +1 -1
- data/lib/wavefront-cli/opt_handler.rb +5 -3
- data/lib/wavefront-cli/version.rb +1 -1
- data/lib/wavefront-cli/write.rb +5 -7
- data/spec/.rubocop.yml +10 -37
- data/spec/support/minitest_assertions.rb +2 -4
- data/spec/wavefront-cli/cloudintegration_spec.rb +19 -6
- data/spec/wavefront-cli/config_spec.rb +1 -1
- data/spec/wavefront-cli/controller_spec.rb +2 -0
- data/spec/wavefront-cli/display/printer/long_spec.rb +2 -0
- data/wavefront-cli.gemspec +5 -5
- metadata +11 -23
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: afeb72ce32ce32e70e1f405234608ce5109d039aa6045b89e73e8351d95e459f
|
4
|
+
data.tar.gz: 06b2ab6daedba6a696b9c63208bfe9465695f224f6fab58c49c9408051f81e3f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 75b2159704ea25f5f1dea58b16e9e968b9b3ba17668a6f014a0ff75ce63be91179601a5cc917ab526b281a36d3c4e254ec8dbe0af9ac57f21274a4fbeeb5faab
|
7
|
+
data.tar.gz: 672954a741cf305255820402b0a62bf9ac8facafb9e5fbf63c633a3355117516253cc50e68247fb019e7b1797f6117062acf32b3e30d012e995a55e37c0bb53f
|
data/.rubocop.yml
CHANGED
@@ -1,49 +1,18 @@
|
|
1
1
|
---
|
2
2
|
|
3
3
|
AllCops:
|
4
|
-
TargetRubyVersion: 2.
|
4
|
+
TargetRubyVersion: 2.5
|
5
|
+
NewCops: enable
|
5
6
|
|
6
7
|
Metrics/ClassLength:
|
7
8
|
Max: 400
|
8
9
|
|
9
10
|
Style/IfUnlessModifier:
|
10
11
|
Enabled: false # because it wants to make lines >80 chars
|
11
|
-
Style/
|
12
|
-
|
13
|
-
Style/
|
14
|
-
|
15
|
-
Style/HashTransformValues:
|
16
|
-
Enabled: true
|
17
|
-
|
18
|
-
# New compatabilities
|
19
|
-
Layout/EmptyLinesAroundAttributeAccessor:
|
20
|
-
Enabled: true
|
21
|
-
Layout/SpaceAroundMethodCallOperator:
|
22
|
-
Enabled: true
|
23
|
-
Lint/RaiseException:
|
24
|
-
Enabled: true
|
25
|
-
Lint/StructNewOverride:
|
26
|
-
Enabled: true
|
27
|
-
Style/ExponentialNotation:
|
28
|
-
Enabled: true
|
29
|
-
Style/SlicingWithRange:
|
30
|
-
Enabled: true
|
31
|
-
Lint/DeprecatedOpenSSLConstant:
|
32
|
-
Enabled: true
|
33
|
-
Lint/MixedRegexpCaptureTypes:
|
34
|
-
Enabled: true
|
35
|
-
Style/RedundantRegexpCharacterClass:
|
36
|
-
Enabled: true
|
37
|
-
Style/RedundantRegexpEscape:
|
38
|
-
Enabled: true
|
39
|
-
Style/AccessorGrouping:
|
40
|
-
Enabled: true
|
41
|
-
Style/BisectedAttrAccessor:
|
42
|
-
Enabled: true
|
43
|
-
Style/RedundantAssignment:
|
44
|
-
Enabled: true
|
45
|
-
Style/RedundantFetchBlock:
|
46
|
-
Enabled: true
|
12
|
+
Style/StringConcatenation:
|
13
|
+
Enabled: false
|
14
|
+
Style/OptionalBooleanParameter:
|
15
|
+
Enabled: false
|
47
16
|
|
48
17
|
# Is nothing sacred?
|
49
18
|
Layout/LineLength:
|
data/.travis.yml
CHANGED
@@ -1,10 +1,9 @@
|
|
1
1
|
language: ruby
|
2
2
|
cache: bundler
|
3
3
|
rvm:
|
4
|
-
- 2.
|
5
|
-
- 2.
|
6
|
-
- 2.
|
7
|
-
- 2.7.0
|
4
|
+
- 2.5.8
|
5
|
+
- 2.6.6
|
6
|
+
- 2.7.1
|
8
7
|
before_install: gem install bundler --no-document
|
9
8
|
deploy:
|
10
9
|
provider: rubygems
|
@@ -14,7 +13,7 @@ deploy:
|
|
14
13
|
on:
|
15
14
|
tags: true
|
16
15
|
repo: snltd/wavefront-cli
|
17
|
-
ruby: 2.6.
|
16
|
+
ruby: 2.6.6
|
18
17
|
notifications:
|
19
18
|
email: false
|
20
19
|
slack:
|
data/HISTORY.md
CHANGED
@@ -1,5 +1,25 @@
|
|
1
1
|
# Changelog
|
2
2
|
|
3
|
+
## 8.2.0 (2020-10-06)
|
4
|
+
* Display spans in human-readable query output.
|
5
|
+
|
6
|
+
## 8.1.0 (2020-10-04)
|
7
|
+
* Display traces in human-readable query output.
|
8
|
+
|
9
|
+
## 8.0.1 (2020-09-28)
|
10
|
+
* If the user specifies a config stanza and it is not found, exit with an
|
11
|
+
error rather than silently falling back to env vars.
|
12
|
+
|
13
|
+
## 8.0.0 (2020-09-20
|
14
|
+
* Drop Ruby 2.4.0 support. (Breaking change.)
|
15
|
+
>>>>>>> master
|
16
|
+
|
17
|
+
## 7.2.0 (2020-08-12)
|
18
|
+
* Add `cloudintegration awsid generate` command.
|
19
|
+
* Add `cloudintegration awsid delete <external_id>` command.
|
20
|
+
* Add `cloudintegration awsid validate <external_id>` command.
|
21
|
+
* Require 5.1.x of [the SDK](https://github.com/snltd/wavefront-sdk).
|
22
|
+
|
3
23
|
## 7.1.0 (2020-08-07)
|
4
24
|
* Remove `user` command. (Breaking change.)
|
5
25
|
* Add `account` command.
|
data/README.md
CHANGED
@@ -15,7 +15,7 @@ $ gem install wavefront-cli
|
|
15
15
|
|
16
16
|
It is built on [our Wavefront Ruby
|
17
17
|
SDK](https://github.com/snltd/wavefront-sdk) and requires Ruby >=
|
18
|
-
2.
|
18
|
+
2.5. It has no "native extension" dependencies.
|
19
19
|
|
20
20
|
For a far more comprehensive overview/tutorial, please read [this
|
21
21
|
article](https://sysdef.xyz/article/wavefront-cli).
|
data/lib/wavefront-cli/base.rb
CHANGED
@@ -102,12 +102,10 @@ module WavefrontCli
|
|
102
102
|
|
103
103
|
def validate_tags(key = :'<tag>')
|
104
104
|
Array(options[key]).each do |t|
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
"'#{t}' is not a valid tag.")
|
110
|
-
end
|
105
|
+
send(:wf_tag?, t)
|
106
|
+
rescue Wavefront::Exception::InvalidTag
|
107
|
+
raise(WavefrontCli::Exception::InvalidInput,
|
108
|
+
"'#{t}' is not a valid tag.")
|
111
109
|
end
|
112
110
|
end
|
113
111
|
|
@@ -371,9 +369,10 @@ module WavefrontCli
|
|
371
369
|
def do_dump
|
372
370
|
cannot_noop!
|
373
371
|
|
374
|
-
|
372
|
+
case options[:format]
|
373
|
+
when 'yaml'
|
375
374
|
ok_exit dump_yaml
|
376
|
-
|
375
|
+
when 'json'
|
377
376
|
ok_exit dump_json
|
378
377
|
else
|
379
378
|
abort format("Dump format must be 'json' or 'yaml'. " \
|
@@ -539,7 +538,8 @@ module WavefrontCli
|
|
539
538
|
#
|
540
539
|
# rubocop:disable Metrics/MethodLength
|
541
540
|
def extract_values(obj, key, aggr = [])
|
542
|
-
|
541
|
+
case obj.class
|
542
|
+
when Hash
|
543
543
|
obj.each_pair do |k, v|
|
544
544
|
if k == key && !v.to_s.empty?
|
545
545
|
aggr.<< v
|
@@ -547,7 +547,7 @@ module WavefrontCli
|
|
547
547
|
extract_values(v, key, aggr)
|
548
548
|
end
|
549
549
|
end
|
550
|
-
|
550
|
+
when Array
|
551
551
|
obj.each { |e| extract_values(e, key, aggr) }
|
552
552
|
end
|
553
553
|
|
@@ -22,5 +22,17 @@ module WavefrontCli
|
|
22
22
|
def do_disable
|
23
23
|
wf.disable(options[:'<id>'])
|
24
24
|
end
|
25
|
+
|
26
|
+
def do_awsid_generate
|
27
|
+
wf.create_aws_external_id
|
28
|
+
end
|
29
|
+
|
30
|
+
def do_awsid_delete
|
31
|
+
wf.delete_aws_external_id(options[:'<external_id>'])
|
32
|
+
end
|
33
|
+
|
34
|
+
def do_awsid_confirm
|
35
|
+
wf.confirm_aws_external_id(options[:'<external_id>'])
|
36
|
+
end
|
25
37
|
end
|
26
38
|
end
|
@@ -1,47 +1,19 @@
|
|
1
1
|
---
|
2
|
+
AllCops:
|
3
|
+
NewCops: enable
|
2
4
|
|
3
5
|
# There are long things in here, but they're fine
|
4
6
|
#
|
5
7
|
Metrics/MethodLength:
|
6
8
|
Max: 25
|
7
9
|
|
8
|
-
Style/HashEachMethods:
|
9
|
-
Enabled: true
|
10
|
-
Style/HashTransformKeys:
|
11
|
-
Enabled: true
|
12
|
-
Style/HashTransformValues:
|
13
|
-
Enabled: true
|
14
|
-
|
15
|
-
# new compatabilities
|
16
|
-
Layout/EmptyLinesAroundAttributeAccessor:
|
17
|
-
Enabled: true
|
18
|
-
Layout/SpaceAroundMethodCallOperator:
|
19
|
-
Enabled: true
|
20
|
-
Lint/RaiseException:
|
21
|
-
Enabled: true
|
22
|
-
Lint/StructNewOverride:
|
23
|
-
Enabled: true
|
24
|
-
Style/ExponentialNotation:
|
25
|
-
Enabled: true
|
26
|
-
Style/SlicingWithRange:
|
27
|
-
Enabled: true
|
28
|
-
Lint/DeprecatedOpenSSLConstant:
|
29
|
-
Enabled: true
|
30
|
-
Lint/MixedRegexpCaptureTypes:
|
31
|
-
Enabled: true
|
32
|
-
Style/RedundantRegexpCharacterClass:
|
33
|
-
Enabled: true
|
34
|
-
Style/RedundantRegexpEscape:
|
35
|
-
Enabled: true
|
36
|
-
Style/AccessorGrouping:
|
37
|
-
Enabled: true
|
38
|
-
Style/BisectedAttrAccessor:
|
39
|
-
Enabled: true
|
40
|
-
Style/RedundantAssignment:
|
41
|
-
Enabled: true
|
42
|
-
Style/RedundantFetchBlock:
|
43
|
-
Enabled: true
|
44
|
-
|
45
10
|
# Is nothing sacred?
|
46
11
|
Layout/LineLength:
|
47
12
|
Max: 80
|
13
|
+
|
14
|
+
Style/IfUnlessModifier:
|
15
|
+
Enabled: false # because it wants to make lines >80 chars
|
16
|
+
Style/StringConcatenation:
|
17
|
+
Enabled: false
|
18
|
+
Style/OptionalBooleanParameter:
|
19
|
+
Enabled: false
|
@@ -26,7 +26,10 @@ class WavefrontCommandCloudintegration < WavefrontCommandBase
|
|
26
26
|
"disable #{CMN} <id>",
|
27
27
|
"dump #{CMN}",
|
28
28
|
"import #{CMN} [-uU] <file>",
|
29
|
-
"search #{CMN} [-al] [-o offset] [-L limit] [-O fields] <condition>..."
|
29
|
+
"search #{CMN} [-al] [-o offset] [-L limit] [-O fields] <condition>...",
|
30
|
+
"awsid #{CMN} generate",
|
31
|
+
"awsid #{CMN} delete <external_id>",
|
32
|
+
"awsid #{CMN} confirm <external_id>"]
|
30
33
|
end
|
31
34
|
|
32
35
|
def _options
|
data/lib/wavefront-cli/config.rb
CHANGED
@@ -36,11 +36,13 @@ module WavefrontCli
|
|
36
36
|
|
37
37
|
RX = /^[\da-f]{8}-[\da-f]{4}-[\da-f]{4}-[\da-f]{4}-[\da-f]{12}$/.freeze
|
38
38
|
|
39
|
+
# rubocop:disable Lint/MissingSuper
|
39
40
|
def initialize(options)
|
40
41
|
@options = options
|
41
42
|
@config_file = _config_file
|
42
43
|
@profile = options[:'<profile>'] || 'default'
|
43
44
|
end
|
45
|
+
# rubocop:enable Lint/MissingSuper
|
44
46
|
|
45
47
|
def do_location
|
46
48
|
puts config_file
|
@@ -144,7 +146,7 @@ module WavefrontCli
|
|
144
146
|
# catch a ctrl-d
|
145
147
|
#
|
146
148
|
def read_input
|
147
|
-
|
149
|
+
$stdin.gets.strip
|
148
150
|
rescue NoMethodError
|
149
151
|
abort "\nInput aborted at user request."
|
150
152
|
end
|
@@ -177,8 +177,6 @@ class WavefrontCliController
|
|
177
177
|
# return [Hash] h with modified keys
|
178
178
|
#
|
179
179
|
def sanitize_keys(options)
|
180
|
-
options.
|
181
|
-
r[k.to_s.delete('-').to_sym] = v
|
182
|
-
end
|
180
|
+
options.transform_keys { |k| k.to_s.delete('-').to_sym }
|
183
181
|
end
|
184
182
|
end
|
@@ -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
|
@@ -25,5 +25,17 @@ module WavefrontDisplay
|
|
25
25
|
def do_disable
|
26
26
|
puts "Disabled '#{options[:'<id>']}'."
|
27
27
|
end
|
28
|
+
|
29
|
+
def do_awsid_generate
|
30
|
+
puts data
|
31
|
+
end
|
32
|
+
|
33
|
+
def do_awsid_delete
|
34
|
+
puts "Deleted external ID '#{options[:'<external_id>']}'."
|
35
|
+
end
|
36
|
+
|
37
|
+
def do_awsid_confirm
|
38
|
+
puts "'#{data}' is a registered external ID."
|
39
|
+
end
|
28
40
|
end
|
29
41
|
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
|
|
@@ -75,6 +77,7 @@ module WavefrontDisplayPrinter
|
|
75
77
|
#
|
76
78
|
# Make an array of hashes: { key, value, depth }
|
77
79
|
#
|
80
|
+
# rubocop:disable Style/CaseLikeIf
|
78
81
|
def make_list(data, aggr = [], depth = 0, last_key = nil)
|
79
82
|
if data.is_a?(Hash)
|
80
83
|
append_hash(data, aggr, depth)
|
@@ -84,6 +87,7 @@ module WavefrontDisplayPrinter
|
|
84
87
|
aggr.<< ['', preened_value(data), depth]
|
85
88
|
end
|
86
89
|
end
|
90
|
+
# rubocop:enable Style/CaseLikeIf
|
87
91
|
|
88
92
|
def smart_value(val)
|
89
93
|
val.to_s.empty? && opts[:none] ? '<none>' : preened_value(val)
|
@@ -150,6 +154,7 @@ module WavefrontDisplayPrinter
|
|
150
154
|
# @param depth [Integer]
|
151
155
|
# @return [Array[Array]]
|
152
156
|
#
|
157
|
+
# rubocop:disable Style/CaseLikeIf
|
153
158
|
def append_hash(data, aggr, depth)
|
154
159
|
data.each_pair do |k, v|
|
155
160
|
if v.is_a?(Hash)
|
@@ -163,6 +168,7 @@ module WavefrontDisplayPrinter
|
|
163
168
|
|
164
169
|
aggr
|
165
170
|
end
|
171
|
+
# rubocop:enable Style/CaseLikeIf
|
166
172
|
|
167
173
|
# Part of the #make_list recursion. Deals with arrays.
|
168
174
|
#
|
@@ -175,7 +181,8 @@ module WavefrontDisplayPrinter
|
|
175
181
|
data.each.with_index(1) do |element, i|
|
176
182
|
aggr = make_list(element, aggr, depth, last_key)
|
177
183
|
|
178
|
-
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]
|
179
186
|
aggr.<< ['', :separator, depth]
|
180
187
|
end
|
181
188
|
end
|
@@ -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]]
|
data/lib/wavefront-cli/event.rb
CHANGED
@@ -97,6 +97,7 @@ module WavefrontCli
|
|
97
97
|
# return [Hash] body for #create() method
|
98
98
|
#
|
99
99
|
# rubocop:disable Metrics/MethodLength
|
100
|
+
# rubocop:disable Metrics/AbcSize
|
100
101
|
def create_body(opts, t_start)
|
101
102
|
{ name: opts[:'<event>'],
|
102
103
|
startTime: t_start,
|
@@ -111,6 +112,7 @@ module WavefrontCli
|
|
111
112
|
end
|
112
113
|
end
|
113
114
|
end
|
115
|
+
# rubocop:enable Metrics/AbcSize
|
114
116
|
# rubocop:enable Metrics/MethodLength
|
115
117
|
|
116
118
|
def annotations(opts)
|
@@ -8,7 +8,6 @@ module WavefrontCli
|
|
8
8
|
# rubocop:disable Metrics/MethodLength
|
9
9
|
# rubocop:disable Metrics/AbcSize
|
10
10
|
# rubocop:disable Metrics/CyclomaticComplexity
|
11
|
-
# rubocop:disable Metrics/PerceivedComplexity
|
12
11
|
def exception_handler(exception)
|
13
12
|
case exception
|
14
13
|
when WavefrontCli::Exception::UnhandledCommand
|
@@ -31,6 +30,8 @@ module WavefrontCli
|
|
31
30
|
abort "'#{exception}' is not a valid user group ID."
|
32
31
|
when Wavefront::Exception::InvalidAccountId
|
33
32
|
abort "'#{exception}' is not a valid system or user account ID."
|
33
|
+
when Wavefront::Exception::InvalidAwsExternalId
|
34
|
+
abort "'#{exception}' is not a valid AWS external ID."
|
34
35
|
when Wavefront::Exception::InvalidRoleId
|
35
36
|
abort "'#{exception}' is not a valid role ID."
|
36
37
|
when Wavefront::Exception::InvalidApiTokenId
|
@@ -81,7 +82,6 @@ module WavefrontCli
|
|
81
82
|
end
|
82
83
|
# rubocop:enable Metrics/MethodLength
|
83
84
|
# rubocop:enable Metrics/AbcSize
|
84
|
-
# rubocop:enable Metrics/PerceivedComplexity
|
85
85
|
# rubocop:enable Metrics/CyclomaticComplexity
|
86
86
|
end
|
87
87
|
end
|
@@ -38,12 +38,10 @@ module WavefrontCli
|
|
38
38
|
|
39
39
|
def point_filter_regexes
|
40
40
|
ret = options[:pointregex].each_with_object({}) do |r, a|
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
puts "cannot parse point regex '#{r}'. Skipping."
|
46
|
-
end
|
41
|
+
k, v = r.split('=', 2)
|
42
|
+
a[k.to_sym] = v
|
43
|
+
rescue StandardError
|
44
|
+
puts "cannot parse point regex '#{r}'. Skipping."
|
47
45
|
end
|
48
46
|
|
49
47
|
ret.empty? ? nil : ret
|
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
require 'pathname'
|
4
4
|
require 'wavefront-sdk/credentials'
|
5
|
-
require_relative 'constants
|
5
|
+
require_relative 'constants'
|
6
6
|
|
7
7
|
module WavefrontCli
|
8
8
|
#
|
@@ -35,6 +35,8 @@ module WavefrontCli
|
|
35
35
|
abort "Configuration file '#{e}' not found."
|
36
36
|
rescue Wavefront::Exception::InvalidConfigFile => e
|
37
37
|
abort "Could not load configuration file '#{e.message}'."
|
38
|
+
rescue Wavefront::Exception::MissingConfigProfile => e
|
39
|
+
abort "Cannot find profile '#{e}'."
|
38
40
|
end
|
39
41
|
|
40
42
|
# Create an options hash to pass to the Wavefront::Credentials
|
@@ -45,7 +47,7 @@ module WavefrontCli
|
|
45
47
|
# :profile
|
46
48
|
#
|
47
49
|
def setup_cred_opts(cli_opts)
|
48
|
-
cred_opts = {}
|
50
|
+
cred_opts = { raise_on_no_profile: true }
|
49
51
|
|
50
52
|
if cli_opts[:config]
|
51
53
|
cred_opts[:file] = Pathname.new(cli_opts[:config])
|
@@ -69,7 +71,7 @@ module WavefrontCli
|
|
69
71
|
#
|
70
72
|
def load_profile(cred_opts)
|
71
73
|
creds = Wavefront::Credentials.new(cred_opts).config
|
72
|
-
|
74
|
+
creds.transform_keys(&:to_sym)
|
73
75
|
end
|
74
76
|
end
|
75
77
|
end
|
data/lib/wavefront-cli/write.rb
CHANGED
@@ -167,12 +167,10 @@ module WavefrontCli
|
|
167
167
|
#
|
168
168
|
def process_input_file(data)
|
169
169
|
data.each_with_object([]) do |l, a|
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
next
|
175
|
-
end
|
170
|
+
a.<< process_line(l)
|
171
|
+
rescue WavefrontCli::Exception::UnparseableInput => e
|
172
|
+
puts "Bad input. #{e.message}."
|
173
|
+
next
|
176
174
|
end
|
177
175
|
end
|
178
176
|
|
@@ -193,7 +191,7 @@ module WavefrontCli
|
|
193
191
|
#
|
194
192
|
def read_stdin
|
195
193
|
open_connection
|
196
|
-
|
194
|
+
$stdin.each_line { |l| call_write(process_line(l.strip), false) }
|
197
195
|
close_connection
|
198
196
|
rescue SystemExit, Interrupt
|
199
197
|
puts 'ctrl-c. Exiting.'
|
data/spec/.rubocop.yml
CHANGED
@@ -1,4 +1,7 @@
|
|
1
1
|
---
|
2
|
+
AllCops:
|
3
|
+
NewCops: enable
|
4
|
+
|
2
5
|
Metrics/MethodLength:
|
3
6
|
Max: 30
|
4
7
|
|
@@ -8,43 +11,13 @@ Metrics/AbcSize:
|
|
8
11
|
Metrics/ClassLength:
|
9
12
|
Max: 300
|
10
13
|
|
11
|
-
Style/HashEachMethods:
|
12
|
-
Enabled: true
|
13
|
-
Style/HashTransformKeys:
|
14
|
-
Enabled: true
|
15
|
-
Style/HashTransformValues:
|
16
|
-
Enabled: true
|
17
|
-
|
18
|
-
# new compatabilities
|
19
|
-
Layout/EmptyLinesAroundAttributeAccessor:
|
20
|
-
Enabled: true
|
21
|
-
Layout/SpaceAroundMethodCallOperator:
|
22
|
-
Enabled: true
|
23
|
-
Lint/RaiseException:
|
24
|
-
Enabled: true
|
25
|
-
Lint/StructNewOverride:
|
26
|
-
Enabled: true
|
27
|
-
Style/ExponentialNotation:
|
28
|
-
Enabled: true
|
29
|
-
Style/SlicingWithRange:
|
30
|
-
Enabled: true
|
31
|
-
Lint/DeprecatedOpenSSLConstant:
|
32
|
-
Enabled: true
|
33
|
-
Lint/MixedRegexpCaptureTypes:
|
34
|
-
Enabled: true
|
35
|
-
Style/RedundantRegexpCharacterClass:
|
36
|
-
Enabled: true
|
37
|
-
Style/RedundantRegexpEscape:
|
38
|
-
Enabled: true
|
39
|
-
Style/AccessorGrouping:
|
40
|
-
Enabled: true
|
41
|
-
Style/BisectedAttrAccessor:
|
42
|
-
Enabled: true
|
43
|
-
Style/RedundantAssignment:
|
44
|
-
Enabled: true
|
45
|
-
Style/RedundantFetchBlock:
|
46
|
-
Enabled: true
|
47
|
-
|
48
14
|
# Is nothing sacred?
|
49
15
|
Layout/LineLength:
|
50
16
|
Max: 80
|
17
|
+
|
18
|
+
Style/IfUnlessModifier:
|
19
|
+
Enabled: false # because it wants to make lines >80 chars
|
20
|
+
Style/StringConcatenation:
|
21
|
+
Enabled: false
|
22
|
+
Style/OptionalBooleanParameter:
|
23
|
+
Enabled: false
|
@@ -105,11 +105,9 @@ module Minitest
|
|
105
105
|
"performed as no-ops.\n", err)
|
106
106
|
end
|
107
107
|
|
108
|
-
def assert_repeated_output(msg)
|
108
|
+
def assert_repeated_output(msg, &block)
|
109
109
|
begin
|
110
|
-
out, err = capture_io
|
111
|
-
yield
|
112
|
-
end
|
110
|
+
out, err = capture_io(&block)
|
113
111
|
rescue SystemExit => e
|
114
112
|
puts e.backtrace
|
115
113
|
p e
|
@@ -7,12 +7,11 @@ require_relative '../../lib/wavefront-cli/cloudintegration'
|
|
7
7
|
# Ensure 'cloudintegration' commands produce the correct API calls.
|
8
8
|
#
|
9
9
|
class CloudIntegrationEndToEndTest < EndToEndTest
|
10
|
-
include WavefrontCliTest::DeleteUndelete
|
11
|
-
include WavefrontCliTest::Describe
|
12
|
-
include WavefrontCliTest::Dump
|
13
|
-
include WavefrontCliTest::List
|
14
|
-
# include WavefrontCliTest::
|
15
|
-
include WavefrontCliTest::Search
|
10
|
+
# include WavefrontCliTest::DeleteUndelete
|
11
|
+
# include WavefrontCliTest::Describe
|
12
|
+
# include WavefrontCliTest::Dump
|
13
|
+
# include WavefrontCliTest::List
|
14
|
+
# include WavefrontCliTest::Search
|
16
15
|
|
17
16
|
def test_enable
|
18
17
|
assert_repeated_output("Enabled '#{id}'.") do
|
@@ -46,6 +45,20 @@ class CloudIntegrationEndToEndTest < EndToEndTest
|
|
46
45
|
'body: null')
|
47
46
|
end
|
48
47
|
|
48
|
+
def test_aws_id_generate
|
49
|
+
# assert_repeated_output("Disabled '#{id}'.") do
|
50
|
+
# assert_cmd_posts("disable #{id}",
|
51
|
+
# "/api/v2/cloudintegration/#{id}/disable")
|
52
|
+
# end
|
53
|
+
|
54
|
+
assert_abort_on_missing_creds('awsid generate')
|
55
|
+
|
56
|
+
assert_noop('awsid generate',
|
57
|
+
'uri: POST https://default.wavefront.com/api/v2/' \
|
58
|
+
'cloudintegration/awsExternalId',
|
59
|
+
'body: null')
|
60
|
+
end
|
61
|
+
|
49
62
|
private
|
50
63
|
|
51
64
|
def id
|
@@ -48,7 +48,7 @@ class WavefrontCliConfigTest < MiniTest::Test
|
|
48
48
|
|
49
49
|
def test_read_input
|
50
50
|
["value \n", " value\n", " value \t\n", "value\n"].each do |v|
|
51
|
-
|
51
|
+
$stdin.stub(:gets, v) { assert_equal('value', wf.read_input) }
|
52
52
|
end
|
53
53
|
end
|
54
54
|
|
@@ -79,9 +79,11 @@ end
|
|
79
79
|
# so we can get at the methods without triggering one of the things
|
80
80
|
# tested above.
|
81
81
|
#
|
82
|
+
# rubocop:disable Lint/MissingSuper
|
82
83
|
class Giblets < WavefrontCliController
|
83
84
|
def initialize; end
|
84
85
|
end
|
86
|
+
# rubocop:enable Lint/MissingSuper
|
85
87
|
|
86
88
|
# Here's the subclass
|
87
89
|
#
|
@@ -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
|
|
data/wavefront-cli.gemspec
CHANGED
@@ -26,14 +26,14 @@ 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.
|
29
|
+
gem.add_runtime_dependency 'wavefront-sdk', '~> 5.2'
|
30
30
|
|
31
|
-
gem.add_development_dependency 'minitest', '~> 5.
|
31
|
+
gem.add_development_dependency 'minitest', '~> 5.14'
|
32
32
|
gem.add_development_dependency 'rake', '~> 13.0'
|
33
|
-
gem.add_development_dependency 'rubocop', '0.
|
33
|
+
gem.add_development_dependency 'rubocop', '0.91.0'
|
34
34
|
gem.add_development_dependency 'spy', '~> 1.0.0'
|
35
|
-
gem.add_development_dependency 'webmock', '~> 3.
|
35
|
+
gem.add_development_dependency 'webmock', '~> 3.8'
|
36
36
|
gem.add_development_dependency 'yard', '~> 0.9.5'
|
37
37
|
|
38
|
-
gem.required_ruby_version = Gem::Requirement.new('>= 2.
|
38
|
+
gem.required_ruby_version = Gem::Requirement.new('>= 2.5.0')
|
39
39
|
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:
|
4
|
+
version: 8.2.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-
|
11
|
+
date: 2020-10-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: docopt
|
@@ -44,40 +44,28 @@ dependencies:
|
|
44
44
|
requirements:
|
45
45
|
- - "~>"
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version: '5.
|
48
|
-
- - ">="
|
49
|
-
- !ruby/object:Gem::Version
|
50
|
-
version: 5.0.1
|
47
|
+
version: '5.2'
|
51
48
|
type: :runtime
|
52
49
|
prerelease: false
|
53
50
|
version_requirements: !ruby/object:Gem::Requirement
|
54
51
|
requirements:
|
55
52
|
- - "~>"
|
56
53
|
- !ruby/object:Gem::Version
|
57
|
-
version: '5.
|
58
|
-
- - ">="
|
59
|
-
- !ruby/object:Gem::Version
|
60
|
-
version: 5.0.1
|
54
|
+
version: '5.2'
|
61
55
|
- !ruby/object:Gem::Dependency
|
62
56
|
name: minitest
|
63
57
|
requirement: !ruby/object:Gem::Requirement
|
64
58
|
requirements:
|
65
|
-
- - ">="
|
66
|
-
- !ruby/object:Gem::Version
|
67
|
-
version: 5.11.0
|
68
59
|
- - "~>"
|
69
60
|
- !ruby/object:Gem::Version
|
70
|
-
version: '5.
|
61
|
+
version: '5.14'
|
71
62
|
type: :development
|
72
63
|
prerelease: false
|
73
64
|
version_requirements: !ruby/object:Gem::Requirement
|
74
65
|
requirements:
|
75
|
-
- - ">="
|
76
|
-
- !ruby/object:Gem::Version
|
77
|
-
version: 5.11.0
|
78
66
|
- - "~>"
|
79
67
|
- !ruby/object:Gem::Version
|
80
|
-
version: '5.
|
68
|
+
version: '5.14'
|
81
69
|
- !ruby/object:Gem::Dependency
|
82
70
|
name: rake
|
83
71
|
requirement: !ruby/object:Gem::Requirement
|
@@ -98,14 +86,14 @@ dependencies:
|
|
98
86
|
requirements:
|
99
87
|
- - '='
|
100
88
|
- !ruby/object:Gem::Version
|
101
|
-
version: 0.
|
89
|
+
version: 0.91.0
|
102
90
|
type: :development
|
103
91
|
prerelease: false
|
104
92
|
version_requirements: !ruby/object:Gem::Requirement
|
105
93
|
requirements:
|
106
94
|
- - '='
|
107
95
|
- !ruby/object:Gem::Version
|
108
|
-
version: 0.
|
96
|
+
version: 0.91.0
|
109
97
|
- !ruby/object:Gem::Dependency
|
110
98
|
name: spy
|
111
99
|
requirement: !ruby/object:Gem::Requirement
|
@@ -126,14 +114,14 @@ dependencies:
|
|
126
114
|
requirements:
|
127
115
|
- - "~>"
|
128
116
|
- !ruby/object:Gem::Version
|
129
|
-
version: '3.
|
117
|
+
version: '3.8'
|
130
118
|
type: :development
|
131
119
|
prerelease: false
|
132
120
|
version_requirements: !ruby/object:Gem::Requirement
|
133
121
|
requirements:
|
134
122
|
- - "~>"
|
135
123
|
- !ruby/object:Gem::Version
|
136
|
-
version: '3.
|
124
|
+
version: '3.8'
|
137
125
|
- !ruby/object:Gem::Dependency
|
138
126
|
name: yard
|
139
127
|
requirement: !ruby/object:Gem::Requirement
|
@@ -408,7 +396,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
408
396
|
requirements:
|
409
397
|
- - ">="
|
410
398
|
- !ruby/object:Gem::Version
|
411
|
-
version: 2.
|
399
|
+
version: 2.5.0
|
412
400
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
413
401
|
requirements:
|
414
402
|
- - ">="
|