wavefront-sdk 3.0.1 → 3.0.2

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: 313adfc6845c757c8ce079ac7cc44a6a4a4979fe37204d3851d837af68496466
4
- data.tar.gz: a797317ab7e0c00c10d6231ec3c6db552f973562cc4172b620c98bf6e47af02b
3
+ metadata.gz: dc630d37510f6a1606b0680c2ea50245f569ac12d2091f8551766d9f9d6021a0
4
+ data.tar.gz: 8c458655085f9f1fd0ff7b1e2d4a01e4b277f29e500b8ec445705cbefa91b0c8
5
5
  SHA512:
6
- metadata.gz: e54e07151bf094132e03effce102428d40837605accfd03156426ecca98de7244f618f5fe191783dac6792ce8cf760f43252ea8e24b25c0d7f9b4fadced4e22f
7
- data.tar.gz: 487f7dc0c1f06be5a3b743bb97f75ac8a3e6439625d9b46caba07801aa49a279ec8d8a7c0236442496fb1312279c3d6fa263478d58293a227f2c0f8f83a88049
6
+ metadata.gz: 1450041d4c7877bee9de16e4c8942a80b6bd190f876a69bcdeb2f99afb70171eaa10ebff1db13a6d3519f021e4d0127ba8f8b47942a7626ee80e92fe3185d10e
7
+ data.tar.gz: 8ae22c21bd7338badc525648d8dac78b18255e1a32fa483ac188d3d4aa39e60b20d01ae93ac05ffe39ffc992c9e5c03c3e26929afd0ab669e02e980cb7d15700
data/HISTORY.md CHANGED
@@ -1,6 +1,12 @@
1
1
  # Changelog
2
2
 
3
- ## 3.0.1
3
+ ## 3.0.2 (06/04/2019)
4
+ * Better handling of non-existent or malformed config files.
5
+ * Look for `~/.wavefront.conf` as well as `~/.wavefront`. Both these
6
+ fixes are related to findind out that other Wavefront tooling
7
+ creates `~/.wavefront` as a directory.
8
+
9
+ ## 3.0.1 (05/04/2019)
4
10
  * User IDs do not have to be e-mail addresses.
5
11
 
6
12
  ## 3.0.0 (23/03/2019)
@@ -8,6 +8,7 @@ module Wavefront
8
8
  class EnumerableError < RuntimeError; end
9
9
  class InvalidAlertId < RuntimeError; end
10
10
  class InvalidAlertSeverity < RuntimeError; end
11
+ class InvalidConfigFile < RuntimeError; end
11
12
  class InvalidCloudIntegrationId < RuntimeError; end
12
13
  class InvalidDashboardId < RuntimeError; end
13
14
  class InvalidDerivedMetricId < RuntimeError; end
@@ -1,6 +1,7 @@
1
1
  require 'pathname'
2
2
  require 'inifile'
3
3
  require 'map'
4
+ require_relative 'core/exception'
4
5
 
5
6
  module Wavefront
6
7
  # Helper methods to get Wavefront credentials.
@@ -21,6 +22,7 @@ module Wavefront
21
22
  # Wavefront. It will look in the following places:
22
23
  #
23
24
  # ~/.wavefront
25
+ # ~/.wavefront.conf
24
26
  # /etc/wavefront/credentials
25
27
  # WAVEFRONT_ENDPOINT and WAVEFRONT_TOKEN environment variables
26
28
  #
@@ -71,6 +73,7 @@ module Wavefront
71
73
  Array(Pathname.new(opts[:file]))
72
74
  else
73
75
  [Pathname.new('/etc/wavefront/credentials'),
76
+ Pathname.new(ENV['HOME']) + '.wavefront.conf',
74
77
  Pathname.new(ENV['HOME']) + '.wavefront']
75
78
  end
76
79
  end
@@ -84,7 +87,7 @@ module Wavefront
84
87
  ret = {}
85
88
 
86
89
  files.each do |f|
87
- next unless f.exist?
90
+ next unless f.exist? && f.file?
88
91
  ret = load_profile(f, profile)
89
92
  ret[:file] = f
90
93
  end
@@ -104,6 +107,8 @@ module Wavefront
104
107
  IniFile.load(file)[profile].each_with_object({}) do |(k, v), memo|
105
108
  memo[k.to_sym] = v
106
109
  end
110
+ rescue StandardError
111
+ raise Wavefront::Exception::InvalidConfigFile, file
107
112
  end
108
113
  end
109
114
  end
@@ -1,4 +1,4 @@
1
1
  require 'pathname'
2
2
 
3
- WF_SDK_VERSION = '3.0.1'.freeze
3
+ WF_SDK_VERSION = '3.0.2'.freeze
4
4
  WF_SDK_LOCATION = Pathname.new(__FILE__).dirname.parent.parent.parent
@@ -12,8 +12,6 @@ CONF2 = RESOURCE_DIR + 'test2.conf'
12
12
  # Test SDK base class end-to-end
13
13
  #
14
14
  class WavefrontCredentialsTest < MiniTest::Test
15
- attr_reader :wf, :wf_noop, :uri_base, :headers
16
-
17
15
  def test_initialize_1
18
16
  ENV.delete('WAVEFRONT_ENDPOINT')
19
17
  ENV.delete('WAVEFRONT_TOKEN')
@@ -135,10 +133,11 @@ class GibletsTest < MiniTest::Test
135
133
  def test_cred_files_no_opts
136
134
  x = wf.cred_files
137
135
  assert_instance_of(Array, x)
138
- assert_equal(x.length, 2)
136
+ assert_equal(x.length, 3)
139
137
  x.each { |p| assert_instance_of(Pathname, p) }
140
138
  assert_includes(x, Pathname.new('/etc/wavefront/credentials'))
141
139
  assert_includes(x, Pathname.new(ENV['HOME']) + '.wavefront')
140
+ assert_includes(x, Pathname.new(ENV['HOME']) + '.wavefront.conf')
142
141
  end
143
142
 
144
143
  def test_cred_files_opts
@@ -178,4 +177,21 @@ class GibletsTest < MiniTest::Test
178
177
  assert_equal(z[:proxy], 'wavefront.lab')
179
178
  assert_equal(z[:endpoint], 'somewhere.wavefront.com')
180
179
  end
180
+
181
+ def test_load_profile
182
+ assert_equal({}, wf.load_profile(CONF1, 'nosuchprofile'))
183
+ assert_instance_of(Hash, wf.load_profile(CONF1, 'default'))
184
+
185
+ assert_raises Wavefront::Exception::InvalidConfigFile do
186
+ wf.load_profile('/no/such/file')
187
+ end
188
+
189
+ assert_raises Wavefront::Exception::InvalidConfigFile do
190
+ wf.load_profile(RESOURCE_DIR)
191
+ end
192
+
193
+ assert_raises Wavefront::Exception::InvalidConfigFile do
194
+ wf.load_profile(RESOURCE_DIR + 'malformed.conf')
195
+ end
196
+ end
181
197
  end
@@ -0,0 +1 @@
1
+ this is not a valid configuration file
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: wavefront-sdk
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.0.1
4
+ version: 3.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-04-05 00:00:00.000000000 Z
11
+ date: 2019-04-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: addressable
@@ -257,6 +257,7 @@ files:
257
257
  - spec/wavefront-sdk/query_spec.rb
258
258
  - spec/wavefront-sdk/report_spec.rb
259
259
  - spec/wavefront-sdk/resources/dummy_points.rb
260
+ - spec/wavefront-sdk/resources/malformed.conf
260
261
  - spec/wavefront-sdk/resources/test.conf
261
262
  - spec/wavefront-sdk/resources/test2.conf
262
263
  - spec/wavefront-sdk/savedsearch_spec.rb
@@ -330,6 +331,7 @@ test_files:
330
331
  - spec/wavefront-sdk/query_spec.rb
331
332
  - spec/wavefront-sdk/report_spec.rb
332
333
  - spec/wavefront-sdk/resources/dummy_points.rb
334
+ - spec/wavefront-sdk/resources/malformed.conf
333
335
  - spec/wavefront-sdk/resources/test.conf
334
336
  - spec/wavefront-sdk/resources/test2.conf
335
337
  - spec/wavefront-sdk/savedsearch_spec.rb