wavefront-cli 8.3.0 → 8.5.1

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.
Files changed (37) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/release.yml +37 -0
  3. data/.github/workflows/test.yml +23 -0
  4. data/.rubocop.yml +10 -6
  5. data/HISTORY.md +21 -1
  6. data/lib/wavefront-cli/base.rb +3 -0
  7. data/lib/wavefront-cli/commands/.rubocop.yml +2 -13
  8. data/lib/wavefront-cli/commands/event.rb +8 -6
  9. data/lib/wavefront-cli/commands/serviceaccount.rb +6 -4
  10. data/lib/wavefront-cli/controller.rb +9 -0
  11. data/lib/wavefront-cli/display/base.rb +3 -2
  12. data/lib/wavefront-cli/display/printer/sparkline.rb +1 -1
  13. data/lib/wavefront-cli/display/serviceaccount.rb +12 -4
  14. data/lib/wavefront-cli/event.rb +50 -166
  15. data/lib/wavefront-cli/event_store.rb +177 -0
  16. data/lib/wavefront-cli/exception.rb +21 -0
  17. data/lib/wavefront-cli/exception_handler.rb +4 -0
  18. data/lib/wavefront-cli/opt_handler.rb +1 -1
  19. data/lib/wavefront-cli/query.rb +1 -1
  20. data/lib/wavefront-cli/serviceaccount.rb +16 -6
  21. data/lib/wavefront-cli/settings.rb +3 -4
  22. data/lib/wavefront-cli/stdlib/string.rb +1 -1
  23. data/lib/wavefront-cli/version.rb +1 -1
  24. data/lib/wavefront-cli/write.rb +1 -1
  25. data/spec/.rubocop.yml +2 -17
  26. data/spec/spec_helper.rb +0 -1
  27. data/spec/support/minitest_assertions.rb +2 -2
  28. data/spec/wavefront-cli/commands/base_spec.rb +2 -2
  29. data/spec/wavefront-cli/commands/config_spec.rb +1 -1
  30. data/spec/wavefront-cli/controller_spec.rb +14 -0
  31. data/spec/wavefront-cli/event_spec.rb +69 -109
  32. data/spec/wavefront-cli/event_store_spec.rb +186 -0
  33. data/spec/wavefront-cli/opt_handler_spec.rb +3 -3
  34. data/spec/wavefront-cli/serviceaccount_spec.rb +53 -21
  35. data/wavefront-cli.gemspec +5 -2
  36. metadata +62 -10
  37. data/.travis.yml +0 -20
@@ -19,7 +19,7 @@ class OptHandlerTest < MiniTest::Test
19
19
  x = WavefrontCli::OptHandler.new
20
20
  assert x.is_a?(WavefrontCli::OptHandler)
21
21
  assert x.opts.is_a?(Hash)
22
- assert x.opts.keys.include?(:endpoint)
22
+ assert x.opts.key?(:endpoint)
23
23
  end
24
24
 
25
25
  def test_missing_config
@@ -36,7 +36,7 @@ class OptHandlerTest < MiniTest::Test
36
36
  o = x.opts
37
37
  assert x.is_a?(WavefrontCli::OptHandler)
38
38
  assert o.is_a?(Hash)
39
- refute o.keys.include?(:token)
39
+ refute o.key?(:token)
40
40
  assert_equal(o[:endpoint], 'metrics.wavefront.com')
41
41
  end
42
42
 
@@ -52,7 +52,7 @@ class OptHandlerTest < MiniTest::Test
52
52
  assert_equal(o[:token], 'abcd1234')
53
53
  assert_nil o[:config]
54
54
  assert_equal(o[:endpoint], 'myendpoint.wavefront.com')
55
- refute o.keys.include?(:proxy)
55
+ refute o.key?(:proxy)
56
56
  ENV['WAVEFRONT_TOKEN'] = nil
57
57
  ENV['WAVEFRONT_ENDPOINT'] = nil
58
58
  end
@@ -6,7 +6,6 @@ require_relative '../../lib/wavefront-cli/serviceaccount'
6
6
 
7
7
  # Ensure 'serviceaccount' commands produce the correct API calls.
8
8
  #
9
- # rubocop:disable Metrics/ClassLength
10
9
  class ServiceAccountEndToEndTest < EndToEndTest
11
10
  include WavefrontCliTest::Describe
12
11
  # include WavefrontCliTest::Import
@@ -41,20 +40,36 @@ class ServiceAccountEndToEndTest < EndToEndTest
41
40
  assert_abort_on_missing_creds("groups #{id}")
42
41
  end
43
42
 
44
- def test_permissions
43
+ def test_roles
45
44
  quietly do
46
- assert_cmd_gets("permissions #{id}", "/api/v2/#{api_path}/#{id}")
45
+ assert_cmd_gets("roles #{id}", "/api/v2/#{api_path}/#{id}")
47
46
  end
48
47
 
49
- assert_invalid_id("permissions #{invalid_id}")
50
- assert_usage('permissions')
48
+ assert_invalid_id("roles #{invalid_id}")
49
+ assert_usage('roles')
51
50
 
52
51
  assert_noop(
53
- "permissions #{id}",
52
+ "roles #{id}",
54
53
  "uri: GET https://default.wavefront.com/api/v2/#{api_path}/#{id}"
55
54
  )
56
55
 
57
- assert_abort_on_missing_creds("permissions #{id}")
56
+ assert_abort_on_missing_creds("roles #{id}")
57
+ end
58
+
59
+ def test_ingestionpolicy
60
+ quietly do
61
+ assert_cmd_gets("ingestionpolicy #{id}", "/api/v2/#{api_path}/#{id}")
62
+ end
63
+
64
+ assert_invalid_id("ingestionpolicy #{invalid_id}")
65
+ assert_usage('ingestionpolicy')
66
+
67
+ assert_noop(
68
+ "ingestionpolicy #{id}",
69
+ "uri: GET https://default.wavefront.com/api/v2/#{api_path}/#{id}"
70
+ )
71
+
72
+ assert_abort_on_missing_creds("ingestionpolicy #{id}")
58
73
  end
59
74
 
60
75
  def test_activate
@@ -85,7 +100,7 @@ class ServiceAccountEndToEndTest < EndToEndTest
85
100
  '/api/v2/account/serviceaccount',
86
101
  identifier: id,
87
102
  active: true,
88
- groups: [],
103
+ roles: [],
89
104
  tokens: [],
90
105
  userGroups: [])
91
106
  end
@@ -95,8 +110,8 @@ class ServiceAccountEndToEndTest < EndToEndTest
95
110
  'uri: POST https://default.wavefront.com/api/v2/account/serviceaccount',
96
111
  'body: ' + { identifier: id,
97
112
  active: true,
98
- groups: [],
99
113
  tokens: [],
114
+ roles: [],
100
115
  userGroups: [] }.to_json
101
116
  )
102
117
 
@@ -111,43 +126,56 @@ class ServiceAccountEndToEndTest < EndToEndTest
111
126
  identifier: id,
112
127
  description: 'words',
113
128
  active: false,
114
- groups: [],
129
+ roles: [],
115
130
  tokens: [],
116
131
  userGroups: [])
117
132
  end
118
133
  end
119
134
 
120
- def test_create_account_in_usergroups
135
+ def test_create_account_with_usergroups
121
136
  quietly do
122
137
  assert_cmd_posts("create -g #{usergroups[0]} -g #{usergroups[1]} #{id}",
123
138
  '/api/v2/account/serviceaccount',
124
139
  identifier: id,
125
140
  active: true,
126
- groups: [],
127
141
  tokens: [],
142
+ roles: [],
128
143
  userGroups: usergroups)
129
144
  end
130
145
  end
131
146
 
147
+ def test_create_account_with_roles
148
+ quietly do
149
+ assert_cmd_posts("create -r #{roles[0]} -r #{roles[1]} #{id}",
150
+ '/api/v2/account/serviceaccount',
151
+ identifier: id,
152
+ active: true,
153
+ tokens: [],
154
+ roles: roles,
155
+ userGroups: [])
156
+ end
157
+ end
158
+
132
159
  def test_create_account_with_tokens
133
160
  quietly do
134
161
  assert_cmd_posts("create -k #{tokens[0]} -k #{tokens[1]} #{id}",
135
162
  '/api/v2/account/serviceaccount',
136
163
  identifier: id,
137
164
  active: true,
138
- groups: [],
139
165
  tokens: tokens,
166
+ roles: [],
140
167
  userGroups: [])
141
168
  end
142
169
  end
143
170
 
144
- def test_create_account_with_permissions
171
+ def test_create_account_with_ingestion_policy
145
172
  quietly do
146
- assert_cmd_posts("create -p #{permissions[0]} -p #{permissions[1]} #{id}",
173
+ assert_cmd_posts("create -p #{ingestion_policy} #{id}",
147
174
  '/api/v2/account/serviceaccount',
148
175
  identifier: id,
149
176
  active: true,
150
- groups: permissions,
177
+ ingestionPolicyId: ingestion_policy,
178
+ roles: [],
151
179
  tokens: [],
152
180
  userGroups: [])
153
181
  end
@@ -158,8 +186,8 @@ class ServiceAccountEndToEndTest < EndToEndTest
158
186
  "create -g abcdefg #{id}")
159
187
  end
160
188
 
161
- def test_create_invalid_permission
162
- assert_exits_with("'123456' is not a valid Wavefront permission.",
189
+ def test_create_invalid_ingestion_policy
190
+ assert_exits_with("'123456' is not a valid ingestion policy ID.",
163
191
  "create -p 123456 #{id}")
164
192
  end
165
193
 
@@ -358,8 +386,9 @@ class ServiceAccountEndToEndTest < EndToEndTest
358
386
  'service account'
359
387
  end
360
388
 
361
- def permissions
362
- %w[alerts_management events_management]
389
+ def roles
390
+ %w[07fc5cdd-0979-489e-8f70-325f39d15e55
391
+ 0a42adf6-e738-4c5d-9e53-fd10bd979a31]
363
392
  end
364
393
 
365
394
  def tokens
@@ -372,6 +401,10 @@ class ServiceAccountEndToEndTest < EndToEndTest
372
401
  abcdef12-1234-abcd-1234-abcdef012345]
373
402
  end
374
403
 
404
+ def ingestion_policy
405
+ 'test-policy-1607616352537'
406
+ end
407
+
375
408
  def import_fields
376
409
  %i[identifier description active tokens groups userGroups]
377
410
  end
@@ -396,4 +429,3 @@ class ServiceAccountEndToEndTest < EndToEndTest
396
429
  identifier: 'sa::test' }
397
430
  end
398
431
  end
399
- # rubocop:enable Metrics/ClassLength
@@ -26,11 +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.3'
29
+ gem.add_runtime_dependency 'wavefront-sdk', '~> 5.4', '>= 5.4.2'
30
30
 
31
31
  gem.add_development_dependency 'minitest', '~> 5.14'
32
32
  gem.add_development_dependency 'rake', '~> 13.0'
33
- gem.add_development_dependency 'rubocop', '0.91.0'
33
+ gem.add_development_dependency 'rubocop', '~> 1.9'
34
+ gem.add_development_dependency 'rubocop-minitest', '~> 0.10'
35
+ gem.add_development_dependency 'rubocop-performance', '~> 1.3'
36
+ gem.add_development_dependency 'rubocop-rake', '~> 0.5'
34
37
  gem.add_development_dependency 'spy', '~> 1.0.0'
35
38
  gem.add_development_dependency 'webmock', '~> 3.8'
36
39
  gem.add_development_dependency 'yard', '~> 0.9.5'
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.3.0
4
+ version: 8.5.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-31 00:00:00.000000000 Z
11
+ date: 2021-01-29 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.3'
47
+ version: '5.4'
48
+ - - ">="
49
+ - !ruby/object:Gem::Version
50
+ version: 5.4.2
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.3'
57
+ version: '5.4'
58
+ - - ">="
59
+ - !ruby/object:Gem::Version
60
+ version: 5.4.2
55
61
  - !ruby/object:Gem::Dependency
56
62
  name: minitest
57
63
  requirement: !ruby/object:Gem::Requirement
@@ -84,16 +90,58 @@ dependencies:
84
90
  name: rubocop
85
91
  requirement: !ruby/object:Gem::Requirement
86
92
  requirements:
87
- - - '='
93
+ - - "~>"
88
94
  - !ruby/object:Gem::Version
89
- version: 0.91.0
95
+ version: '1.9'
90
96
  type: :development
91
97
  prerelease: false
92
98
  version_requirements: !ruby/object:Gem::Requirement
93
99
  requirements:
94
- - - '='
100
+ - - "~>"
101
+ - !ruby/object:Gem::Version
102
+ version: '1.9'
103
+ - !ruby/object:Gem::Dependency
104
+ name: rubocop-minitest
105
+ requirement: !ruby/object:Gem::Requirement
106
+ requirements:
107
+ - - "~>"
108
+ - !ruby/object:Gem::Version
109
+ version: '0.10'
110
+ type: :development
111
+ prerelease: false
112
+ version_requirements: !ruby/object:Gem::Requirement
113
+ requirements:
114
+ - - "~>"
115
+ - !ruby/object:Gem::Version
116
+ version: '0.10'
117
+ - !ruby/object:Gem::Dependency
118
+ name: rubocop-performance
119
+ requirement: !ruby/object:Gem::Requirement
120
+ requirements:
121
+ - - "~>"
122
+ - !ruby/object:Gem::Version
123
+ version: '1.3'
124
+ type: :development
125
+ prerelease: false
126
+ version_requirements: !ruby/object:Gem::Requirement
127
+ requirements:
128
+ - - "~>"
129
+ - !ruby/object:Gem::Version
130
+ version: '1.3'
131
+ - !ruby/object:Gem::Dependency
132
+ name: rubocop-rake
133
+ requirement: !ruby/object:Gem::Requirement
134
+ requirements:
135
+ - - "~>"
136
+ - !ruby/object:Gem::Version
137
+ version: '0.5'
138
+ type: :development
139
+ prerelease: false
140
+ version_requirements: !ruby/object:Gem::Requirement
141
+ requirements:
142
+ - - "~>"
95
143
  - !ruby/object:Gem::Version
96
- version: 0.91.0
144
+ version: '0.5'
97
145
  - !ruby/object:Gem::Dependency
98
146
  name: spy
99
147
  requirement: !ruby/object:Gem::Requirement
@@ -144,9 +192,10 @@ extensions: []
144
192
  extra_rdoc_files: []
145
193
  files:
146
194
  - ".codeclimate.yml"
195
+ - ".github/workflows/release.yml"
196
+ - ".github/workflows/test.yml"
147
197
  - ".gitignore"
148
198
  - ".rubocop.yml"
149
- - ".travis.yml"
150
199
  - Gemfile
151
200
  - HISTORY.md
152
201
  - LICENSE.txt
@@ -226,6 +275,7 @@ files:
226
275
  - lib/wavefront-cli/display/webhook.rb
227
276
  - lib/wavefront-cli/display/write.rb
228
277
  - lib/wavefront-cli/event.rb
278
+ - lib/wavefront-cli/event_store.rb
229
279
  - lib/wavefront-cli/exception.rb
230
280
  - lib/wavefront-cli/exception_handler.rb
231
281
  - lib/wavefront-cli/externallink.rb
@@ -316,6 +366,7 @@ files:
316
366
  - spec/wavefront-cli/display/printer/long_spec.rb
317
367
  - spec/wavefront-cli/display/printer/terse_spec.rb
318
368
  - spec/wavefront-cli/event_spec.rb
369
+ - spec/wavefront-cli/event_store_spec.rb
319
370
  - spec/wavefront-cli/externallink_spec.rb
320
371
  - spec/wavefront-cli/integration_spec.rb
321
372
  - spec/wavefront-cli/maintenancewindow_spec.rb
@@ -403,7 +454,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
403
454
  - !ruby/object:Gem::Version
404
455
  version: '0'
405
456
  requirements: []
406
- rubygems_version: 3.0.8
457
+ rubygems_version: 3.1.4
407
458
  signing_key:
408
459
  specification_version: 4
409
460
  summary: CLI for Wavefront API v2
@@ -455,6 +506,7 @@ test_files:
455
506
  - spec/wavefront-cli/display/printer/long_spec.rb
456
507
  - spec/wavefront-cli/display/printer/terse_spec.rb
457
508
  - spec/wavefront-cli/event_spec.rb
509
+ - spec/wavefront-cli/event_store_spec.rb
458
510
  - spec/wavefront-cli/externallink_spec.rb
459
511
  - spec/wavefront-cli/integration_spec.rb
460
512
  - spec/wavefront-cli/maintenancewindow_spec.rb
@@ -1,20 +0,0 @@
1
- language: ruby
2
- cache: bundler
3
- rvm:
4
- - 2.5.8
5
- - 2.6.6
6
- - 2.7.1
7
- before_install: gem install bundler --no-document
8
- deploy:
9
- provider: rubygems
10
- api_key:
11
- secure: dpVC480pAmGQrkEeugPowxhYzM8Er9UDhY02u2P5ytrCXC9J05uGKvN8uZ6H8SJr1ZKUb7OGxCq+EVKrA/q1s6Cv07Xl9u1HiOR0cB4ZUW3wBl6TGdl7c/rcor5AQxjELTcWnhCJvTzB+i46a1s4AcWjGBIVEY7/b1iloj/Sm0U43UZPcWPaIl5xfnANBk6v9F5eEfQy5IXlQUQKtRLXzgyqwyJi7DQcNcnEXA0O33KKwka7QDQsycYE7axEiJGOBt0PbYiRUXRZBxKWnsrtq9Sk9QukYsZSQqZgkykV6ImvMYzWI/vUwDRl+dJWmyAG6K2mz4kqMjhiMkB4ctbj5sxDG1BzsBlNTTEb0P8PGBEYgcf4VBd7XDlEt0Sythp6ztn9EVtw35M22n5Q7sdgalf6TFrzQpp9sec3o4AqO3IXUIqRN4VD4vPRQVBJHcwFOuZ3EUO0VekUzCUO3R/mG4oHUIQ9VgRzrUuyYpCwuwWyoVKVA/AukHHW6Y7El2g+JlpP+ijf0ABpqusHENELVWnuCRcv36sxbyM6Rbt2JrT9FrG1oSAELz4yMS86Qhq104II89d6apGJT3thUH8n9m2KA16DmxQYXkNamfygCn3D5ogC2gcIgVicQnJma+405Pv43/a+PaKy/oKr3/H7IJJmoqHfiMyG9DtkFTWQrfA=
12
- gem: wavefront-cli
13
- on:
14
- tags: true
15
- repo: snltd/wavefront-cli
16
- ruby: 2.6.6
17
- notifications:
18
- email: false
19
- slack:
20
- secure: YrwfBiBscjUCHZIyPHH/FEm5VbHZN3AczHnlOJfETsAdsVpM+JOvHnoCaY0AGjvCvmFMPE9yg11yhwMfXZJVwjAC6b75VrXoCFIvC1tjLqFizuI4VBZXUZk3CQZK0pIh1ZRYVINa0LuYLDyxF0EG2N9KTYqQcMEsBwsVohsca+zjbjyIW5H0FeVWJC4QlFqVHBwFHvylfHnPjh0pQAn3sE9j7Of3W2HQVM753/lsOkMf3sHYOv8AOrzjTNqyrageTxUGnO91S41DirNdesrjF8Qg+/s1RSiNeYSZLkqI2pk+3sdkMkpA+2z2zQ/ZbgudS/38AVlh2Wb2KkmFw0+XhdpUGqQZgLlgWMDKoiS7j2dNQ3zA4guCZIQSW6gqR76wTUqeCZQ3UNalChAhACFnG0FmZj+AIE72r28dOH747zKEmTaoJt5FR7GlSoG6cH1EV9qTeIjZ/33ehL703E6qrWITjQ6VrNrPsTCt8rvoW2MV8TP9qb32JVJqWxabqUMBicIWLEeDjPyAmOZs32cWwfk9zcJ6hIJcFffkxgVJN0vU6Qi4tGWUmYK12EIclVgrKgvN1yHUrUN/r7+sUPX9WRj82RNFU6RSPircekV9oWj9Hr8A2imnFqiMTnPpSb56y02cG9FbwFPqxLSaNNV4lALzoBmluKv0RSeEWhRvrGI=