chef-infra-api 0.10.0 → 0.10.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/chef-api.rb +17 -18
- data/lib/chef-api/aclable.rb +6 -6
- data/lib/chef-api/authentication.rb +18 -19
- data/lib/chef-api/configurable.rb +14 -14
- data/lib/chef-api/connection.rb +36 -36
- data/lib/chef-api/defaults.rb +25 -24
- data/lib/chef-api/error_collection.rb +1 -1
- data/lib/chef-api/errors.rb +3 -3
- data/lib/chef-api/multipart.rb +17 -17
- data/lib/chef-api/resource.rb +17 -17
- data/lib/chef-api/resources/base.rb +22 -22
- data/lib/chef-api/resources/client.rb +4 -3
- data/lib/chef-api/resources/collection_proxy.rb +4 -3
- data/lib/chef-api/resources/cookbook.rb +2 -2
- data/lib/chef-api/resources/cookbook_version.rb +1 -1
- data/lib/chef-api/resources/data_bag.rb +3 -3
- data/lib/chef-api/resources/data_bag_item.rb +2 -3
- data/lib/chef-api/resources/environment.rb +1 -1
- data/lib/chef-api/resources/group.rb +1 -2
- data/lib/chef-api/resources/node.rb +2 -2
- data/lib/chef-api/resources/organization.rb +2 -2
- data/lib/chef-api/resources/partial_search.rb +4 -4
- data/lib/chef-api/resources/principal.rb +1 -1
- data/lib/chef-api/resources/role.rb +1 -1
- data/lib/chef-api/resources/search.rb +6 -6
- data/lib/chef-api/resources/user.rb +3 -3
- data/lib/chef-api/util.rb +8 -8
- data/lib/chef-api/validator.rb +3 -3
- data/lib/chef-api/validators/base.rb +3 -3
- data/lib/chef-api/validators/required.rb +1 -1
- data/lib/chef-api/validators/type.rb +1 -1
- data/lib/chef-api/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0e7529a9909181d5243fbd14738a245a4085da4218280f8bc37257b720c10dbd
|
4
|
+
data.tar.gz: 151bc6f26f6d83c97fa9b2455bfe524984c56009abbccd196e7d19a610250331
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b84a9c599cb2944fcbacfa88083f9f41947f5ea7dcd2f32cd4010ff886dfc85bb2b73affc6b670467e13195f6856879d46429013b68609f5efe29f5047dc526b
|
7
|
+
data.tar.gz: 05015b9d844d6f9e2c76d52e08a9cb793953416e0aed3f241c0abcb343b5209d9fa375f73c49c9dece739dfec32452914405a1fedd9cc3a47a1a469bad26df8e
|
data/lib/chef-api.rb
CHANGED
@@ -1,21 +1,21 @@
|
|
1
|
-
require
|
2
|
-
require
|
3
|
-
require
|
4
|
-
|
1
|
+
require "json"
|
2
|
+
require "logify"
|
3
|
+
require "pathname"
|
4
|
+
require_relative "chef-api/version"
|
5
5
|
|
6
6
|
module ChefAPI
|
7
|
-
autoload :Authentication,
|
8
|
-
autoload :Boolean,
|
9
|
-
autoload :Configurable,
|
10
|
-
autoload :Connection,
|
11
|
-
autoload :Defaults,
|
12
|
-
autoload :Error,
|
13
|
-
autoload :ErrorCollection,
|
14
|
-
autoload :Multipart,
|
15
|
-
autoload :Resource,
|
16
|
-
autoload :Schema,
|
17
|
-
autoload :Util,
|
18
|
-
autoload :Validator,
|
7
|
+
autoload :Authentication, "chef-api/authentication"
|
8
|
+
autoload :Boolean, "chef-api/boolean"
|
9
|
+
autoload :Configurable, "chef-api/configurable"
|
10
|
+
autoload :Connection, "chef-api/connection"
|
11
|
+
autoload :Defaults, "chef-api/defaults"
|
12
|
+
autoload :Error, "chef-api/errors"
|
13
|
+
autoload :ErrorCollection, "chef-api/error_collection"
|
14
|
+
autoload :Multipart, "chef-api/multipart"
|
15
|
+
autoload :Resource, "chef-api/resource"
|
16
|
+
autoload :Schema, "chef-api/schema"
|
17
|
+
autoload :Util, "chef-api/util"
|
18
|
+
autoload :Validator, "chef-api/validator"
|
19
19
|
|
20
20
|
#
|
21
21
|
# @todo Document this and why it's important
|
@@ -54,7 +54,7 @@ module ChefAPI
|
|
54
54
|
# @return [Pathname]
|
55
55
|
#
|
56
56
|
def root
|
57
|
-
@root ||= Pathname.new(File.expand_path(
|
57
|
+
@root ||= Pathname.new(File.expand_path("../../", __FILE__))
|
58
58
|
end
|
59
59
|
|
60
60
|
#
|
@@ -93,4 +93,3 @@ end
|
|
93
93
|
|
94
94
|
# Load the initial default values
|
95
95
|
ChefAPI.setup
|
96
|
-
|
data/lib/chef-api/aclable.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
module ChefAPI
|
2
2
|
module AclAble
|
3
3
|
def acl_path
|
4
|
-
|
4
|
+
resource_path + "/_acl"
|
5
5
|
end
|
6
6
|
|
7
7
|
def load_acl
|
@@ -14,7 +14,7 @@ module ChefAPI
|
|
14
14
|
|
15
15
|
def acl
|
16
16
|
unless @acl
|
17
|
-
|
17
|
+
load_acl
|
18
18
|
end
|
19
19
|
@acl
|
20
20
|
end
|
@@ -22,14 +22,14 @@ module ChefAPI
|
|
22
22
|
def save!
|
23
23
|
super
|
24
24
|
if @acl != @orig_acl_data
|
25
|
-
%w
|
25
|
+
%w{create update grant read delete}.each { |action|
|
26
26
|
if @acl[action] != @orig_acl_data[action]
|
27
|
-
url = "#{
|
28
|
-
self.class.connection.put(url, {action => @acl[action]}.to_json)
|
27
|
+
url = "#{acl_path}/#{action}"
|
28
|
+
self.class.connection.put(url, { action => @acl[action] }.to_json)
|
29
29
|
end
|
30
30
|
}
|
31
31
|
end
|
32
32
|
end
|
33
33
|
end
|
34
|
-
|
34
|
+
|
35
35
|
end
|
@@ -1,7 +1,7 @@
|
|
1
|
-
require
|
2
|
-
require
|
3
|
-
require
|
4
|
-
require
|
1
|
+
require "base64"
|
2
|
+
require "digest"
|
3
|
+
require "openssl"
|
4
|
+
require "time"
|
5
5
|
|
6
6
|
#
|
7
7
|
# DEBUG steps:
|
@@ -17,14 +17,14 @@ module ChefAPI
|
|
17
17
|
# signing the full request body instead of just the uploaded file parameter.
|
18
18
|
SIGN_FULL_BODY = false
|
19
19
|
|
20
|
-
SIGNATURE =
|
20
|
+
SIGNATURE = "algorithm=sha1;version=1.0;".freeze
|
21
21
|
|
22
22
|
# Headers
|
23
|
-
X_OPS_SIGN =
|
24
|
-
X_OPS_USERID =
|
25
|
-
X_OPS_TIMESTAMP =
|
26
|
-
X_OPS_CONTENT_HASH =
|
27
|
-
X_OPS_AUTHORIZATION =
|
23
|
+
X_OPS_SIGN = "X-Ops-Sign".freeze
|
24
|
+
X_OPS_USERID = "X-Ops-Userid".freeze
|
25
|
+
X_OPS_TIMESTAMP = "X-Ops-Timestamp".freeze
|
26
|
+
X_OPS_CONTENT_HASH = "X-Ops-Content-Hash".freeze
|
27
|
+
X_OPS_AUTHORIZATION = "X-Ops-Authorization".freeze
|
28
28
|
|
29
29
|
class << self
|
30
30
|
#
|
@@ -96,9 +96,9 @@ module ChefAPI
|
|
96
96
|
#
|
97
97
|
def headers
|
98
98
|
{
|
99
|
-
X_OPS_SIGN
|
100
|
-
X_OPS_USERID
|
101
|
-
X_OPS_TIMESTAMP
|
99
|
+
X_OPS_SIGN => SIGNATURE,
|
100
|
+
X_OPS_USERID => @user,
|
101
|
+
X_OPS_TIMESTAMP => canonical_timestamp,
|
102
102
|
X_OPS_CONTENT_HASH => content_hash,
|
103
103
|
}.merge(signature_lines)
|
104
104
|
end
|
@@ -114,7 +114,7 @@ module ChefAPI
|
|
114
114
|
return @content_hash if @content_hash
|
115
115
|
|
116
116
|
if SIGN_FULL_BODY
|
117
|
-
@content_hash = hash(@body ||
|
117
|
+
@content_hash = hash(@body || "").chomp
|
118
118
|
else
|
119
119
|
if @body.is_a?(Multipart::MultiIO)
|
120
120
|
filepart = @body.ios.find { |io| io.is_a?(Multipart::MultiIO) }
|
@@ -122,7 +122,7 @@ module ChefAPI
|
|
122
122
|
|
123
123
|
@content_hash = hash(file).chomp
|
124
124
|
else
|
125
|
-
@content_hash = hash(@body ||
|
125
|
+
@content_hash = hash(@body || "").chomp
|
126
126
|
end
|
127
127
|
end
|
128
128
|
|
@@ -152,13 +152,13 @@ module ChefAPI
|
|
152
152
|
|
153
153
|
if @key.nil?
|
154
154
|
log.warn "No private key given!"
|
155
|
-
raise
|
155
|
+
raise "No private key given!"
|
156
156
|
end
|
157
157
|
|
158
158
|
if @key.is_a?(OpenSSL::PKey::RSA)
|
159
159
|
log.debug "Detected private key is an OpenSSL Ruby object"
|
160
160
|
@canonical_key = @key
|
161
|
-
elsif @key =~ /(.+)\.pem$/ || File.
|
161
|
+
elsif @key =~ /(.+)\.pem$/ || File.exist?(File.expand_path(@key))
|
162
162
|
log.debug "Detected private key is the path to a file"
|
163
163
|
contents = File.read(File.expand_path(@key))
|
164
164
|
@canonical_key = OpenSSL::PKey::RSA.new(contents)
|
@@ -170,7 +170,6 @@ module ChefAPI
|
|
170
170
|
@canonical_key
|
171
171
|
end
|
172
172
|
|
173
|
-
|
174
173
|
#
|
175
174
|
# The canonical path, with duplicate and trailing slashes removed. This
|
176
175
|
# value is then hashed.
|
@@ -181,7 +180,7 @@ module ChefAPI
|
|
181
180
|
# @return [String]
|
182
181
|
#
|
183
182
|
def canonical_path
|
184
|
-
@canonical_path ||= hash(@path.squeeze(
|
183
|
+
@canonical_path ||= hash(@path.squeeze("/").gsub(%r{(/)+$}, "")).chomp
|
185
184
|
end
|
186
185
|
|
187
186
|
#
|
@@ -11,20 +11,20 @@ module ChefAPI
|
|
11
11
|
# @return [Array<Symbol>]
|
12
12
|
#
|
13
13
|
def keys
|
14
|
-
@keys ||=
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
14
|
+
@keys ||= %i{
|
15
|
+
endpoint
|
16
|
+
flavor
|
17
|
+
client
|
18
|
+
key
|
19
|
+
proxy_address
|
20
|
+
proxy_password
|
21
|
+
proxy_port
|
22
|
+
proxy_username
|
23
|
+
ssl_pem_file
|
24
|
+
ssl_verify
|
25
|
+
user_agent
|
26
|
+
read_timeout
|
27
|
+
}
|
28
28
|
end
|
29
29
|
end
|
30
30
|
|
data/lib/chef-api/connection.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
|
-
require
|
2
|
-
require
|
3
|
-
require
|
4
|
-
require
|
1
|
+
require "net/http"
|
2
|
+
require "net/https"
|
3
|
+
require "openssl"
|
4
|
+
require "uri"
|
5
5
|
|
6
6
|
module ChefAPI
|
7
7
|
#
|
@@ -37,19 +37,19 @@ module ChefAPI
|
|
37
37
|
include Logify
|
38
38
|
include ChefAPI::Configurable
|
39
39
|
|
40
|
-
proxy :clients,
|
41
|
-
proxy :cookbooks,
|
42
|
-
proxy :data_bags,
|
43
|
-
proxy :data_bag_item,
|
44
|
-
proxy :environments,
|
45
|
-
proxy :groups,
|
46
|
-
proxy :nodes,
|
47
|
-
proxy :partial_search,
|
48
|
-
proxy :principals,
|
49
|
-
proxy :roles,
|
50
|
-
proxy :search,
|
51
|
-
proxy :users,
|
52
|
-
proxy :organizations,
|
40
|
+
proxy :clients, "Resource::Client"
|
41
|
+
proxy :cookbooks, "Resource::Cookbook"
|
42
|
+
proxy :data_bags, "Resource::DataBag"
|
43
|
+
proxy :data_bag_item, "Resource::DataBagItem"
|
44
|
+
proxy :environments, "Resource::Environment"
|
45
|
+
proxy :groups, "Resource::Group"
|
46
|
+
proxy :nodes, "Resource::Node"
|
47
|
+
proxy :partial_search, "Resource::PartialSearch"
|
48
|
+
proxy :principals, "Resource::Principal"
|
49
|
+
proxy :roles, "Resource::Role"
|
50
|
+
proxy :search, "Resource::Search"
|
51
|
+
proxy :users, "Resource::User"
|
52
|
+
proxy :organizations, "Resource::Organization"
|
53
53
|
|
54
54
|
#
|
55
55
|
# Create a new ChefAPI Connection with the given options. Any options
|
@@ -75,9 +75,9 @@ module ChefAPI
|
|
75
75
|
# Use any options given, but fall back to the defaults set on the module
|
76
76
|
ChefAPI::Configurable.keys.each do |key|
|
77
77
|
value = if options[key].nil?
|
78
|
-
|
79
|
-
|
80
|
-
|
78
|
+
ChefAPI.instance_variable_get(:"@#{key}")
|
79
|
+
else
|
80
|
+
options[key]
|
81
81
|
end
|
82
82
|
|
83
83
|
instance_variable_set(:"@#{key}", value)
|
@@ -202,7 +202,7 @@ module ChefAPI
|
|
202
202
|
log.debug "Chef flavor: #{flavor.inspect}"
|
203
203
|
|
204
204
|
# Build the URI and request object from the given information
|
205
|
-
if
|
205
|
+
if %i{delete get}.include?(verb)
|
206
206
|
uri = build_uri(verb, path, data)
|
207
207
|
else
|
208
208
|
uri = build_uri(verb, path, params)
|
@@ -213,7 +213,7 @@ module ChefAPI
|
|
213
213
|
add_request_headers(request)
|
214
214
|
|
215
215
|
# Setup PATCH/POST/PUT
|
216
|
-
if
|
216
|
+
if %i{patch post put}.include?(verb)
|
217
217
|
if data.respond_to?(:read)
|
218
218
|
log.info "Detected file/io presence"
|
219
219
|
request.body_stream = data
|
@@ -261,7 +261,7 @@ module ChefAPI
|
|
261
261
|
connection.read_timeout = read_timeout if read_timeout
|
262
262
|
|
263
263
|
# Apply SSL, if applicable
|
264
|
-
if uri.scheme ==
|
264
|
+
if uri.scheme == "https"
|
265
265
|
# Turn on SSL
|
266
266
|
connection.use_ssl = true
|
267
267
|
|
@@ -295,7 +295,7 @@ module ChefAPI
|
|
295
295
|
|
296
296
|
case response
|
297
297
|
when Net::HTTPRedirection
|
298
|
-
redirect = URI.parse(response[
|
298
|
+
redirect = URI.parse(response["location"]).to_s
|
299
299
|
log.debug "Performing HTTP redirect to #{redirect}"
|
300
300
|
request(verb, redirect, data)
|
301
301
|
when Net::HTTPSuccess
|
@@ -328,14 +328,14 @@ module ChefAPI
|
|
328
328
|
# @return [URI]
|
329
329
|
#
|
330
330
|
def build_uri(verb, path, params = {})
|
331
|
-
log.info
|
331
|
+
log.info "Building URI..."
|
332
332
|
|
333
333
|
# Add any query string parameters
|
334
334
|
if querystring = to_query_string(params)
|
335
335
|
log.debug "Detected verb deserves a querystring"
|
336
336
|
log.debug "Building querystring using #{params.inspect}"
|
337
337
|
log.debug "Compiled querystring is #{querystring.inspect}"
|
338
|
-
path = [path, querystring].compact.join(
|
338
|
+
path = [path, querystring].compact.join("?")
|
339
339
|
end
|
340
340
|
|
341
341
|
# Parse the URI
|
@@ -378,7 +378,7 @@ module ChefAPI
|
|
378
378
|
def to_query_string(hash)
|
379
379
|
hash.map do |key, value|
|
380
380
|
"#{URI.escape(key.to_s)}=#{URI.escape(value.to_s)}"
|
381
|
-
end.join(
|
381
|
+
end.join("&")[/.+/]
|
382
382
|
end
|
383
383
|
|
384
384
|
private
|
@@ -397,7 +397,7 @@ module ChefAPI
|
|
397
397
|
def success(response)
|
398
398
|
log.info "Parsing response as success..."
|
399
399
|
|
400
|
-
case response[
|
400
|
+
case response["Content-Type"]
|
401
401
|
when /json/
|
402
402
|
log.debug "Detected response as JSON"
|
403
403
|
log.debug "Parsing response body as JSON"
|
@@ -418,7 +418,7 @@ module ChefAPI
|
|
418
418
|
def error(response)
|
419
419
|
log.info "Parsing response as error..."
|
420
420
|
|
421
|
-
case response[
|
421
|
+
case response["Content-Type"]
|
422
422
|
when /json/
|
423
423
|
log.debug "Detected error response as JSON"
|
424
424
|
log.debug "Parsing error response as JSON"
|
@@ -459,12 +459,12 @@ module ChefAPI
|
|
459
459
|
log.info "Adding request headers..."
|
460
460
|
|
461
461
|
headers = {
|
462
|
-
|
463
|
-
|
464
|
-
|
465
|
-
|
466
|
-
|
467
|
-
|
462
|
+
"Accept" => "application/json",
|
463
|
+
"Content-Type" => "application/json",
|
464
|
+
"Connection" => "keep-alive",
|
465
|
+
"Keep-Alive" => "30",
|
466
|
+
"User-Agent" => user_agent,
|
467
|
+
"X-Chef-Version" => "11.4.0",
|
468
468
|
}
|
469
469
|
|
470
470
|
headers.each do |key, value|
|
@@ -491,7 +491,7 @@ module ChefAPI
|
|
491
491
|
key: key,
|
492
492
|
verb: verb,
|
493
493
|
path: path,
|
494
|
-
body: request.body || request.body_stream
|
494
|
+
body: request.body || request.body_stream
|
495
495
|
)
|
496
496
|
|
497
497
|
authentication.headers.each do |key, value|
|
data/lib/chef-api/defaults.rb
CHANGED
@@ -1,11 +1,11 @@
|
|
1
|
-
|
2
|
-
require
|
3
|
-
require
|
1
|
+
require_relative "version"
|
2
|
+
require "pathname"
|
3
|
+
require "json"
|
4
4
|
|
5
5
|
module ChefAPI
|
6
6
|
module Defaults
|
7
7
|
# Default API endpoint
|
8
|
-
ENDPOINT =
|
8
|
+
ENDPOINT = "https://api.opscode.com/".freeze
|
9
9
|
|
10
10
|
# Default User Agent header string
|
11
11
|
USER_AGENT = "ChefAPI Ruby Gem #{ChefAPI::VERSION}".freeze
|
@@ -37,7 +37,7 @@ module ChefAPI
|
|
37
37
|
if result = chef_api_config_path
|
38
38
|
Pathname(result).expand_path
|
39
39
|
else
|
40
|
-
Pathname(
|
40
|
+
Pathname("")
|
41
41
|
end
|
42
42
|
end
|
43
43
|
|
@@ -46,8 +46,8 @@ module ChefAPI
|
|
46
46
|
#
|
47
47
|
# @return [String, nil] Path to config file, or nil
|
48
48
|
def chef_api_config_path
|
49
|
-
ENV[
|
50
|
-
|
49
|
+
ENV["CHEF_API_CONFIG"] || if ENV.key?("HOME")
|
50
|
+
"~/.chef-api"
|
51
51
|
else
|
52
52
|
nil
|
53
53
|
end
|
@@ -70,7 +70,7 @@ module ChefAPI
|
|
70
70
|
# @return [String] (default: +https://api.opscode.com/+)
|
71
71
|
#
|
72
72
|
def endpoint
|
73
|
-
ENV[
|
73
|
+
ENV["CHEF_API_ENDPOINT"] || config["CHEF_API_ENDPOINT"] || ENDPOINT
|
74
74
|
end
|
75
75
|
|
76
76
|
#
|
@@ -85,12 +85,12 @@ module ChefAPI
|
|
85
85
|
# @return [true, false]
|
86
86
|
#
|
87
87
|
def flavor
|
88
|
-
if ENV[
|
89
|
-
ENV[
|
90
|
-
elsif config[
|
91
|
-
config[
|
88
|
+
if ENV["CHEF_API_FLAVOR"]
|
89
|
+
ENV["CHEF_API_FLAVOR"].to_sym
|
90
|
+
elsif config["CHEF_API_FLAVOR"]
|
91
|
+
config["CHEF_API_FLAVOR"]
|
92
92
|
else
|
93
|
-
endpoint.include?(
|
93
|
+
endpoint.include?("/organizations") ? :enterprise : :open_source
|
94
94
|
end
|
95
95
|
end
|
96
96
|
|
@@ -100,7 +100,7 @@ module ChefAPI
|
|
100
100
|
# @return [String]
|
101
101
|
#
|
102
102
|
def user_agent
|
103
|
-
ENV[
|
103
|
+
ENV["CHEF_API_USER_AGENT"] || config["CHEF_API_USER_AGENT"] || USER_AGENT
|
104
104
|
end
|
105
105
|
|
106
106
|
#
|
@@ -111,7 +111,7 @@ module ChefAPI
|
|
111
111
|
# @return [String, nil]
|
112
112
|
#
|
113
113
|
def client
|
114
|
-
ENV[
|
114
|
+
ENV["CHEF_API_CLIENT"] || config["CHEF_API_CLIENT"]
|
115
115
|
end
|
116
116
|
|
117
117
|
#
|
@@ -122,15 +122,16 @@ module ChefAPI
|
|
122
122
|
# @return [String, nil]
|
123
123
|
#
|
124
124
|
def key
|
125
|
-
|
125
|
+
ENV["CHEF_API_KEY"] || config["CHEF_API_KEY"]
|
126
126
|
end
|
127
|
+
|
127
128
|
#
|
128
129
|
# The HTTP Proxy server address as a string
|
129
130
|
#
|
130
131
|
# @return [String, nil]
|
131
132
|
#
|
132
133
|
def proxy_address
|
133
|
-
ENV[
|
134
|
+
ENV["CHEF_API_PROXY_ADDRESS"] || config["CHEF_API_PROXY_ADDRESS"]
|
134
135
|
end
|
135
136
|
|
136
137
|
#
|
@@ -139,7 +140,7 @@ module ChefAPI
|
|
139
140
|
# @return [String, nil]
|
140
141
|
#
|
141
142
|
def proxy_password
|
142
|
-
ENV[
|
143
|
+
ENV["CHEF_API_PROXY_PASSWORD"] || config["CHEF_API_PROXY_PASSWORD"]
|
143
144
|
end
|
144
145
|
|
145
146
|
#
|
@@ -148,7 +149,7 @@ module ChefAPI
|
|
148
149
|
# @return [String, nil]
|
149
150
|
#
|
150
151
|
def proxy_port
|
151
|
-
ENV[
|
152
|
+
ENV["CHEF_API_PROXY_PORT"] || config["CHEF_API_PROXY_PORT"]
|
152
153
|
end
|
153
154
|
|
154
155
|
#
|
@@ -157,7 +158,7 @@ module ChefAPI
|
|
157
158
|
# @return [String, nil]
|
158
159
|
#
|
159
160
|
def proxy_username
|
160
|
-
ENV[
|
161
|
+
ENV["CHEF_API_PROXY_USERNAME"] || config["CHEF_API_PROXY_USERNAME"]
|
161
162
|
end
|
162
163
|
|
163
164
|
#
|
@@ -166,7 +167,7 @@ module ChefAPI
|
|
166
167
|
# @return [String, nil]
|
167
168
|
#
|
168
169
|
def ssl_pem_file
|
169
|
-
ENV[
|
170
|
+
ENV["CHEF_API_SSL_PEM_FILE"] || config["CHEF_API_SSL_PEM_FILE"]
|
170
171
|
end
|
171
172
|
|
172
173
|
#
|
@@ -175,10 +176,10 @@ module ChefAPI
|
|
175
176
|
# @return [true, false]
|
176
177
|
#
|
177
178
|
def ssl_verify
|
178
|
-
if ENV[
|
179
|
+
if ENV["CHEF_API_SSL_VERIFY"].nil? && config["CHEF_API_SSL_VERIFY"].nil?
|
179
180
|
true
|
180
181
|
else
|
181
|
-
%w
|
182
|
+
%w{t y}.include?(ENV["CHEF_API_SSL_VERIFY"].downcase[0]) || config["CHEF_API_SSL_VERIFY"]
|
182
183
|
end
|
183
184
|
end
|
184
185
|
|
@@ -188,7 +189,7 @@ module ChefAPI
|
|
188
189
|
# @return [Integer, nil]
|
189
190
|
#
|
190
191
|
def read_timeout
|
191
|
-
timeout_from_env = ENV[
|
192
|
+
timeout_from_env = ENV["CHEF_API_READ_TIMEOUT"] || config["CHEF_API_READ_TIMEOUT"]
|
192
193
|
|
193
194
|
Integer(timeout_from_env) unless timeout_from_env.nil?
|
194
195
|
end
|