chef-handler-opsmatic 0.0.12 → 0.0.14
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.
- data/lib/chef/handler/opsmatic.rb +29 -1
- data/lib/chef/handler/opsmatic_version.rb +1 -1
- metadata +4 -4
@@ -112,6 +112,22 @@ class Chef
|
|
112
112
|
end
|
113
113
|
end
|
114
114
|
|
115
|
+
def check_proxy(proxy)
|
116
|
+
proxy_value = ENV[proxy]
|
117
|
+
return if proxy_value.nil? || proxy_value.empty?
|
118
|
+
begin
|
119
|
+
proxy_uri = URI.parse(proxy_value)
|
120
|
+
if not proxy_uri.host
|
121
|
+
Chef::Log.warn("#{proxy} set but could not parse URI")
|
122
|
+
return nil
|
123
|
+
end
|
124
|
+
rescue URI::InvalidURIError
|
125
|
+
Chef::Log.warn("#{proxy} set with invalid URI")
|
126
|
+
return nil
|
127
|
+
end
|
128
|
+
return proxy_uri
|
129
|
+
end
|
130
|
+
|
115
131
|
# submit report to the opsmatic collector
|
116
132
|
def submit(event)
|
117
133
|
Chef::Log.info("Posting chef run report to Opsmatic")
|
@@ -121,8 +137,20 @@ class Chef
|
|
121
137
|
qs = url.query.nil? ? [] : url.query.split("&")
|
122
138
|
qs << "token=#{@config[:integration_token]}"
|
123
139
|
url.query = qs.join("&")
|
140
|
+
proxy_uri = nil
|
141
|
+
|
142
|
+
%w(HTTPS_PROXY https_proxy HTTP_PROXY http_proxy).each do |proxy|
|
143
|
+
proxy_uri = check_proxy(proxy)
|
144
|
+
break if proxy_uri
|
145
|
+
end
|
146
|
+
|
147
|
+
if proxy_uri
|
148
|
+
p_user, p_pass = proxy_uri.userinfo.split(/:/) if proxy_uri.userinfo
|
149
|
+
http = Net::HTTP.new(url.host, url.port, proxy_uri.host, proxy_uri.port, p_user, p_pass)
|
150
|
+
else
|
151
|
+
http = Net::HTTP.new(url.host, url.port)
|
152
|
+
end
|
124
153
|
|
125
|
-
http = Net::HTTP.new(url.host, url.port)
|
126
154
|
http.open_timeout = 2
|
127
155
|
http.read_timeout = 2
|
128
156
|
http.use_ssl = (url.scheme == 'https')
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: chef-handler-opsmatic
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.14
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2014-11-
|
12
|
+
date: 2014-11-11 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: bundler
|
@@ -123,7 +123,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
123
123
|
version: '0'
|
124
124
|
segments:
|
125
125
|
- 0
|
126
|
-
hash: -
|
126
|
+
hash: -881451571111827738
|
127
127
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
128
128
|
none: false
|
129
129
|
requirements:
|
@@ -132,7 +132,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
132
132
|
version: '0'
|
133
133
|
segments:
|
134
134
|
- 0
|
135
|
-
hash: -
|
135
|
+
hash: -881451571111827738
|
136
136
|
requirements: []
|
137
137
|
rubyforge_project:
|
138
138
|
rubygems_version: 1.8.23.2
|