wavefront-sdk 5.1.0 → 5.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 6fa47f9b8dc9c71f547e50131d53cfcdf5ae0142cd75f14558afd5303576a4cc
4
- data.tar.gz: '08bea64a048f8e22e02c4b8b12fa6e413a9e26bbb1e5c55e26201ac873424812'
3
+ metadata.gz: fc04400fbf51a67e94d228b3145a9fdd5fdb484c24035f1c83ff583e755d705e
4
+ data.tar.gz: 3acd358086967628300c65bff916b541e28004a1a5ca55b44b764a7ddb277d1e
5
5
  SHA512:
6
- metadata.gz: ea55156acfeaadce57ff846aa723c936c77f061730ef7f1e91b2b2919c51dfa2cc1b0652d1485905772397da24452332e34b15ea4bae713dd4abc8aa83477dc7
7
- data.tar.gz: 953bbc44ca84d32194a231d9037ce8e47917a1895c148e1e0661c7125f24c6bba53e29d9a625b8b6d2744669b49cab99837429c0f22129fad4e6697fafb17988
6
+ metadata.gz: 665e0f09c85149b0879b868ec51336b88ac9c9c1af542df52ce0e00b932249a06236268e6398e6b828b7a7deb4421669611cdcaaf838965dd2eb560a720f0181
7
+ data.tar.gz: 519dc5ca20b01d81454bf8255815bd85ba3e016a4639eda688f1e2544b6d6c6e26ce6ff097e125fdf1eb40ab3ac10530307e0df3a31e590fac24279c89965b64
data/HISTORY.md CHANGED
@@ -1,5 +1,10 @@
1
1
  # Changelog
2
2
 
3
+ ## 5.2.0 (2020-09-03)
4
+ * Add `:raise_on_no_profile` option to `Wavefront::Credentials` constructor
5
+ options. If this is true and a specific config stanza is requested but not
6
+ found, `Wavefront::Exception::MissingConfigProfile` is thrown.
7
+
3
8
  ## 5.1.0 (2020-08-15)
4
9
  * Add `create_aws_external_id`, `delete_aws_external_id`, and
5
10
  `confirm_aws_external_id` methods to `Wavefront::CloudIntegration`.
@@ -55,6 +55,7 @@ module Wavefront
55
55
  class InvalidUserGroupId < RuntimeError; end
56
56
  class InvalidVersion < RuntimeError; end
57
57
  class InvalidWebhookId < RuntimeError; end
58
+ class MissingConfigProfile < RuntimeError; end
58
59
  class NetworkTimeout < RuntimeError; end
59
60
  class NotImplemented < RuntimeError; end
60
61
  class SocketError < RuntimeError; end
@@ -31,11 +31,16 @@ module Wavefront
31
31
  # @param options [Hash] keys may be 'file', which
32
32
  # specifies a config file which will be loaded and parsed. If
33
33
  # no file is supplied, those listed above will be used.;
34
- # and/or 'profile' which select a profile section from 'file'
34
+ # and/or 'profile' which select a profile section from 'file'.
35
+ # Specify the key :raise_noprofile to have an exception thrown
36
+ # if a given profile cannot be found. Otherwise that is ignored and
37
+ # options are built from other sources.
35
38
  #
36
39
  def initialize(options = {})
37
- raw = load_from_file(cred_files(options), options[:profile] ||
38
- 'default')
40
+ @raise_noprofile = options[:raise_on_no_profile] || false
41
+ raw = load_from_file(real_files(cred_files(options)),
42
+ options[:profile] || 'default')
43
+
39
44
  populate(env_override(raw))
40
45
  end
41
46
 
@@ -80,31 +85,45 @@ module Wavefront
80
85
  end
81
86
  end
82
87
 
88
+ def real_files(files)
89
+ files.select { |f| f.exist? && f.file? }
90
+ end
91
+
83
92
  # @param files [Array][Pathname] a list of ini-style config files
84
93
  # @param profile [String] a profile name
94
+ # @param disallow_missing [Bool] whether or not to raise an exception if
95
+ # we are given a profile but can't find it.
85
96
  # @return [Hash] the given profile from the given list of files.
86
97
  # If multiple files match, the last one will be used
87
98
  #
88
99
  def load_from_file(files, profile = 'default')
89
100
  ret = {}
101
+ profiles_found = conf_files_found = 0
90
102
 
91
103
  files.each do |f|
92
- next unless f.exist? && f.file?
93
-
94
104
  ret = load_profile(f, profile)
105
+ conf_files_found += 1
106
+ profiles_found += 1 unless ret.empty?
95
107
  ret[:file] = f
96
108
  end
97
109
 
110
+ raise_on_missing_profile(profile, profiles_found, conf_files_found)
98
111
  ret
99
112
  end
100
113
 
101
- # Load in an (optionally) given section of an ini-style
102
- # configuration file not there, we don't consider that an error.
114
+ def raise_on_missing_profile(profile, profiles_found, conf_files_found)
115
+ return true unless @raise_noprofile
116
+ return true unless profiles_found.zero? && conf_files_found.positive?
117
+
118
+ raise Wavefront::Exception::MissingConfigProfile, profile
119
+ end
120
+
121
+ # Load in an (optionally) given section of an ini-style configuration
122
+ # file. If the section is not there, we don't consider that an error.
103
123
  #
104
124
  # @param file [Pathname] the file to read
105
125
  # @param profile [String] the section in the config to read
106
- # @return [Hash] options loaded from file. Each key becomes a
107
- # symbol
126
+ # @return [Hash] options loaded from file. Each key becomes a symbol
108
127
  #
109
128
  def load_profile(file, profile = 'default')
110
129
  IniFile.load(file)[profile].each_with_object({}) do |(k, v), memo|
@@ -1,4 +1,4 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- WF_SDK_VERSION = '5.1.0'
3
+ WF_SDK_VERSION = '5.2.0'
4
4
  WF_SDK_LOCATION = Pathname.new(__dir__).parent.parent.parent
@@ -153,10 +153,9 @@ class GibletsTest < MiniTest::Test
153
153
  end
154
154
 
155
155
  def test_load_from_file
156
- assert_equal({},
157
- wf.load_from_file(
158
- [Pathname.new('/no/file/1'), Pathname.new('/no/file/2')]
159
- ))
156
+ assert_raises(Wavefront::Exception::InvalidConfigFile) do
157
+ wf.load_from_file([Pathname.new('/nofile/1'), Pathname.new('/nofile/2')])
158
+ end
160
159
 
161
160
  assert_equal({ file: CONF1 }, wf.load_from_file([CONF1], 'noprofile'))
162
161
 
@@ -27,12 +27,12 @@ Gem::Specification.new do |gem|
27
27
  gem.add_dependency 'inifile', '~> 3.0'
28
28
  gem.add_dependency 'map', '~> 6.6'
29
29
 
30
- gem.add_development_dependency 'minitest', '~> 5.11'
30
+ gem.add_development_dependency 'minitest', '~> 5.14'
31
31
  gem.add_development_dependency 'rake', '~> 13.0'
32
- gem.add_development_dependency 'rubocop', '= 0.87.1'
33
- gem.add_development_dependency 'simplecov', '~> 0.16'
34
- gem.add_development_dependency 'spy', '~> 1.0.0'
35
- gem.add_development_dependency 'webmock', '~> 3.7'
32
+ gem.add_development_dependency 'rubocop', '0.87.1'
33
+ gem.add_development_dependency 'simplecov', '~> 0.18'
34
+ gem.add_development_dependency 'spy', '1.0.0'
35
+ gem.add_development_dependency 'webmock', '~> 3.8'
36
36
  gem.add_development_dependency 'yard', '~> 0.9'
37
37
 
38
38
  gem.required_ruby_version = Gem::Requirement.new('>= 2.4.0')
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: 5.1.0
4
+ version: 5.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-08-12 00:00:00.000000000 Z
11
+ date: 2020-09-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: addressable
@@ -72,14 +72,14 @@ dependencies:
72
72
  requirements:
73
73
  - - "~>"
74
74
  - !ruby/object:Gem::Version
75
- version: '5.11'
75
+ version: '5.14'
76
76
  type: :development
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
80
  - - "~>"
81
81
  - !ruby/object:Gem::Version
82
- version: '5.11'
82
+ version: '5.14'
83
83
  - !ruby/object:Gem::Dependency
84
84
  name: rake
85
85
  requirement: !ruby/object:Gem::Requirement
@@ -114,26 +114,26 @@ dependencies:
114
114
  requirements:
115
115
  - - "~>"
116
116
  - !ruby/object:Gem::Version
117
- version: '0.16'
117
+ version: '0.18'
118
118
  type: :development
119
119
  prerelease: false
120
120
  version_requirements: !ruby/object:Gem::Requirement
121
121
  requirements:
122
122
  - - "~>"
123
123
  - !ruby/object:Gem::Version
124
- version: '0.16'
124
+ version: '0.18'
125
125
  - !ruby/object:Gem::Dependency
126
126
  name: spy
127
127
  requirement: !ruby/object:Gem::Requirement
128
128
  requirements:
129
- - - "~>"
129
+ - - '='
130
130
  - !ruby/object:Gem::Version
131
131
  version: 1.0.0
132
132
  type: :development
133
133
  prerelease: false
134
134
  version_requirements: !ruby/object:Gem::Requirement
135
135
  requirements:
136
- - - "~>"
136
+ - - '='
137
137
  - !ruby/object:Gem::Version
138
138
  version: 1.0.0
139
139
  - !ruby/object:Gem::Dependency
@@ -142,14 +142,14 @@ dependencies:
142
142
  requirements:
143
143
  - - "~>"
144
144
  - !ruby/object:Gem::Version
145
- version: '3.7'
145
+ version: '3.8'
146
146
  type: :development
147
147
  prerelease: false
148
148
  version_requirements: !ruby/object:Gem::Requirement
149
149
  requirements:
150
150
  - - "~>"
151
151
  - !ruby/object:Gem::Version
152
- version: '3.7'
152
+ version: '3.8'
153
153
  - !ruby/object:Gem::Dependency
154
154
  name: yard
155
155
  requirement: !ruby/object:Gem::Requirement