ridley 4.0.0 → 4.3.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 +4 -4
- data/CHANGELOG.md +31 -0
- data/Gemfile +1 -1
- data/README.md +4 -4
- data/Rakefile +1 -0
- data/lib/ridley/chef/config.rb +5 -5
- data/lib/ridley/chef/cookbook/metadata.rb +59 -14
- data/lib/ridley/chef/cookbook/syntax_check.rb +57 -19
- data/lib/ridley/chef/cookbook.rb +1 -1
- data/lib/ridley/chef/digester.rb +3 -1
- data/lib/ridley/client.rb +6 -3
- data/lib/ridley/connection.rb +5 -4
- data/lib/ridley/errors.rb +1 -0
- data/lib/ridley/helpers.rb +10 -0
- data/lib/ridley/mixin/params_validate.rb +4 -0
- data/lib/ridley/resources/cookbook_resource.rb +14 -2
- data/lib/ridley/version.rb +1 -1
- data/ridley.gemspec +5 -5
- data/spec/acceptance/client_resource_spec.rb +12 -12
- data/spec/acceptance/cookbook_resource_spec.rb +15 -15
- data/spec/acceptance/data_bag_item_resource_spec.rb +14 -14
- data/spec/acceptance/data_bag_resource_spec.rb +4 -4
- data/spec/acceptance/environment_resource_spec.rb +14 -14
- data/spec/acceptance/node_resource_spec.rb +15 -15
- data/spec/acceptance/role_resource_spec.rb +14 -14
- data/spec/acceptance/sandbox_resource_spec.rb +3 -3
- data/spec/acceptance/search_resource_spec.rb +6 -6
- data/spec/acceptance/user_resource_spec.rb +21 -21
- data/spec/support/each_matcher.rb +2 -2
- data/spec/support/filepath_matchers.rb +2 -2
- data/spec/support/shared_examples/ridley_resource.rb +39 -39
- data/spec/unit/ridley/chef/cookbook/metadata_spec.rb +8 -8
- data/spec/unit/ridley/chef/cookbook/syntax_check_spec.rb +15 -15
- data/spec/unit/ridley/chef/cookbook_spec.rb +159 -114
- data/spec/unit/ridley/chef/digester_spec.rb +2 -2
- data/spec/unit/ridley/chef_object_spec.rb +35 -35
- data/spec/unit/ridley/chef_objects/client_object_spec.rb +2 -2
- data/spec/unit/ridley/chef_objects/cookbook_object_spec.rb +12 -12
- data/spec/unit/ridley/chef_objects/data_bag_item_object_spec.rb +7 -7
- data/spec/unit/ridley/chef_objects/data_bag_object_spec.rb +4 -1
- data/spec/unit/ridley/chef_objects/environment_object_spec.rb +10 -10
- data/spec/unit/ridley/chef_objects/node_object_spec.rb +28 -28
- data/spec/unit/ridley/chef_objects/role_object_spec.rb +10 -10
- data/spec/unit/ridley/chef_objects/sandbox_object_spec.rb +6 -6
- data/spec/unit/ridley/client_spec.rb +59 -21
- data/spec/unit/ridley/connection_spec.rb +7 -7
- data/spec/unit/ridley/errors_spec.rb +3 -3
- data/spec/unit/ridley/middleware/chef_auth_spec.rb +2 -2
- data/spec/unit/ridley/middleware/chef_response_spec.rb +29 -29
- data/spec/unit/ridley/middleware/parse_json_spec.rb +14 -14
- data/spec/unit/ridley/mixins/from_file_spec.rb +3 -3
- data/spec/unit/ridley/resource_spec.rb +5 -5
- data/spec/unit/ridley/resources/cookbook_resource_spec.rb +21 -21
- data/spec/unit/ridley/resources/data_bag_item_resource_spec.rb +1 -1
- data/spec/unit/ridley/resources/data_bag_resource_spec.rb +6 -3
- data/spec/unit/ridley/resources/environment_resource_spec.rb +4 -4
- data/spec/unit/ridley/resources/role_resource_spec.rb +1 -1
- data/spec/unit/ridley/resources/sandbox_resource_spec.rb +7 -7
- data/spec/unit/ridley/resources/search_resource_spec.rb +22 -22
- data/spec/unit/ridley/sandbox_uploader_spec.rb +3 -3
- data/spec/unit/ridley_spec.rb +6 -6
- metadata +62 -64
- data/.ruby-version +0 -1
- data/lib/ridley/middleware/gzip.rb +0 -18
- data/spec/unit/ridley/middleware/gzip_spec.rb +0 -59
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 1c7d2e45f884fb456322b48859368c420ec0f112
|
|
4
|
+
data.tar.gz: 0f0e0212abe893d298894fb71f7f2f385b9dd26f
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 0add3e0c899c30e52d0df48041940020c76508382ac622e3b21f8f9df39a59ccb25f5e6b1353e7ce648ba6b11ed34db644528ffad88fabbdabb909329363d066
|
|
7
|
+
data.tar.gz: 708ec93b537dd61a8443772c855345813af13de9418b9013928036efb35624465b8fd5938cc820ad3d6391ef7ebef1708294325d58e01500f2c5f9e92bac7607
|
data/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,34 @@
|
|
|
1
|
+
# 4.3.0
|
|
2
|
+
|
|
3
|
+
* Enhancements
|
|
4
|
+
* Switch internal HTTP client from `net_http_persistent` to `httpclient`
|
|
5
|
+
* Loosen constraint on Hashie to allow for both the 2.x and 3.x line
|
|
6
|
+
* Bug Fixes
|
|
7
|
+
* Fix missiong constant ValidationFailed when performing a params validation
|
|
8
|
+
|
|
9
|
+
# 4.2.0
|
|
10
|
+
|
|
11
|
+
* Enhancements
|
|
12
|
+
* Support 'root_default' files
|
|
13
|
+
|
|
14
|
+
# 4.1.2
|
|
15
|
+
|
|
16
|
+
* Fixed: permission denied errors on Windows while uploading cookbooks
|
|
17
|
+
* Fixed: no proc error when evaluating client_key option
|
|
18
|
+
* Bump required version of retryable
|
|
19
|
+
|
|
20
|
+
# 4.1.1
|
|
21
|
+
|
|
22
|
+
* Enhancements
|
|
23
|
+
* Add support for metadata source_url field
|
|
24
|
+
* Add support for metadata issues_url field
|
|
25
|
+
|
|
26
|
+
# 4.1.0
|
|
27
|
+
|
|
28
|
+
* Fix monkey patching issue with options#slice when running under Vagrant
|
|
29
|
+
* Bump required version of Celluloid `~> 0.16.0`
|
|
30
|
+
* Bump required version of Celluloid-IO `~> 0.16.1`
|
|
31
|
+
|
|
1
32
|
# 4.0.0
|
|
2
33
|
|
|
3
34
|
* Update many out of date dependencies
|
data/Gemfile
CHANGED
data/README.md
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
# Ridley
|
|
2
2
|
[](http://badge.fury.io/rb/ridley)
|
|
3
|
-
[](http://travis-ci.org/reset/ridley)
|
|
4
|
+
[](https://gemnasium.com/reset/ridley)
|
|
5
|
+
[](https://codeclimate.com/github/reset/ridley)
|
|
6
6
|
|
|
7
7
|
A reliable Chef API client with a clean syntax
|
|
8
8
|
|
|
@@ -430,4 +430,4 @@ Authors and Contributors
|
|
|
430
430
|
- Jamie Winsor (<jamie@vialstudios.com>)
|
|
431
431
|
- Kyle Allan (<kallan@riotgames.com>)
|
|
432
432
|
|
|
433
|
-
Thank you to all of our [Contributors](https://github.com/
|
|
433
|
+
Thank you to all of our [Contributors](https://github.com/reset/ridley/graphs/contributors), testers, and users.
|
data/Rakefile
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
require 'bundler/gem_tasks'
|
data/lib/ridley/chef/config.rb
CHANGED
|
@@ -43,13 +43,13 @@ module Ridley::Chef
|
|
|
43
43
|
set_assignment_mode :carefree
|
|
44
44
|
|
|
45
45
|
attribute :node_name,
|
|
46
|
-
default: Socket.gethostname
|
|
46
|
+
default: -> { Socket.gethostname }
|
|
47
47
|
attribute :chef_server_url,
|
|
48
48
|
default: 'http://localhost:4000'
|
|
49
49
|
attribute :client_key,
|
|
50
|
-
default: platform_specific_path('/etc/chef/client.pem')
|
|
50
|
+
default: -> { platform_specific_path('/etc/chef/client.pem') }
|
|
51
51
|
attribute :validation_key,
|
|
52
|
-
default: platform_specific_path('/etc/chef/validation.pem')
|
|
52
|
+
default: -> { platform_specific_path('/etc/chef/validation.pem') }
|
|
53
53
|
attribute :validation_client_name,
|
|
54
54
|
default: 'chef-validator'
|
|
55
55
|
|
|
@@ -70,9 +70,9 @@ module Ridley::Chef
|
|
|
70
70
|
# deprecated in chef/config.rb but doesn't currently trigger a warning.
|
|
71
71
|
# See also: CHEF-3715
|
|
72
72
|
attribute :syntax_check_cache_path,
|
|
73
|
-
default: Dir.mktmpdir
|
|
73
|
+
default: -> { Dir.mktmpdir }
|
|
74
74
|
attribute :cache_options,
|
|
75
|
-
default: { path: defined?(syntax_check_cache_path) ? syntax_check_cache_path : Dir.mktmpdir }
|
|
75
|
+
default: -> { { path: defined?(syntax_check_cache_path) ? syntax_check_cache_path : Dir.mktmpdir } }
|
|
76
76
|
|
|
77
77
|
# Create a new Chef Config object.
|
|
78
78
|
#
|
|
@@ -47,6 +47,8 @@ module Ridley::Chef
|
|
|
47
47
|
GROUPINGS = 'groupings'.freeze
|
|
48
48
|
RECIPES = 'recipes'.freeze
|
|
49
49
|
VERSION = 'version'.freeze
|
|
50
|
+
SOURCE_URL = 'source_url'.freeze
|
|
51
|
+
ISSUES_URL = 'issues_url'.freeze
|
|
50
52
|
|
|
51
53
|
COMPILED_FILE_NAME = "metadata.json".freeze
|
|
52
54
|
RAW_FILE_NAME = "metadata.rb".freeze
|
|
@@ -55,7 +57,8 @@ module Ridley::Chef
|
|
|
55
57
|
:name, :description, :long_description, :maintainer,
|
|
56
58
|
:maintainer_email, :license, :platforms, :dependencies,
|
|
57
59
|
:recommendations, :suggestions, :conflicting, :providing,
|
|
58
|
-
:replacing, :attributes, :groupings, :recipes, :version
|
|
60
|
+
:replacing, :attributes, :groupings, :recipes, :version,
|
|
61
|
+
:source_url, :issues_url
|
|
59
62
|
]
|
|
60
63
|
|
|
61
64
|
include Ridley::Mixin::ParamsValidate
|
|
@@ -92,17 +95,20 @@ module Ridley::Chef
|
|
|
92
95
|
self.maintainer_email(maintainer_email)
|
|
93
96
|
self.license(license)
|
|
94
97
|
self.description('A fabulous new cookbook')
|
|
95
|
-
@platforms
|
|
96
|
-
@dependencies
|
|
98
|
+
@platforms = Hashie::Mash.new
|
|
99
|
+
@dependencies = Hashie::Mash.new
|
|
97
100
|
@recommendations = Hashie::Mash.new
|
|
98
|
-
@suggestions
|
|
99
|
-
@conflicting
|
|
100
|
-
@providing
|
|
101
|
-
@replacing
|
|
102
|
-
@attributes
|
|
103
|
-
@groupings
|
|
104
|
-
@recipes
|
|
105
|
-
@version
|
|
101
|
+
@suggestions = Hashie::Mash.new
|
|
102
|
+
@conflicting = Hashie::Mash.new
|
|
103
|
+
@providing = Hashie::Mash.new
|
|
104
|
+
@replacing = Hashie::Mash.new
|
|
105
|
+
@attributes = Hashie::Mash.new
|
|
106
|
+
@groupings = Hashie::Mash.new
|
|
107
|
+
@recipes = Hashie::Mash.new
|
|
108
|
+
@version = Semverse::Version.new("0.0.0")
|
|
109
|
+
@source_url = ''
|
|
110
|
+
@issues_url = ''
|
|
111
|
+
|
|
106
112
|
if cookbook
|
|
107
113
|
@recipes = cookbook.fully_qualified_recipe_names.inject({}) do |r, e|
|
|
108
114
|
e = self.name if e =~ /::default$/
|
|
@@ -382,7 +388,9 @@ module Ridley::Chef
|
|
|
382
388
|
:type => { :equal_to => [ "string", "array", "hash", "symbol", "boolean", "numeric" ], :default => "string" },
|
|
383
389
|
:required => { :equal_to => [ "required", "recommended", "optional", true, false ], :default => "optional" },
|
|
384
390
|
:recipes => { :kind_of => [ Array ], :default => [] },
|
|
385
|
-
:default => { :kind_of => [ String, Array, Hash, Symbol, Numeric, TrueClass, FalseClass ] }
|
|
391
|
+
:default => { :kind_of => [ String, Array, Hash, Symbol, Numeric, TrueClass, FalseClass ] },
|
|
392
|
+
:source_url => { :kind_of => String },
|
|
393
|
+
:issues_url => { :kind_of => String }
|
|
386
394
|
}
|
|
387
395
|
)
|
|
388
396
|
options[:required] = remap_required_attribute(options[:required]) unless options[:required].nil?
|
|
@@ -424,13 +432,18 @@ module Ridley::Chef
|
|
|
424
432
|
ATTRIBUTES => self.attributes,
|
|
425
433
|
GROUPINGS => self.groupings,
|
|
426
434
|
RECIPES => self.recipes,
|
|
427
|
-
VERSION => self.version
|
|
435
|
+
VERSION => self.version,
|
|
436
|
+
SOURCE_URL => self.source_url,
|
|
437
|
+
ISSUES_URL => self.issues_url
|
|
428
438
|
}
|
|
429
439
|
end
|
|
430
440
|
|
|
431
441
|
# @return [String]
|
|
432
442
|
def to_json
|
|
433
|
-
|
|
443
|
+
# Switched from fast to pretty generate here
|
|
444
|
+
# to match `knife cookbook metadata from file` format
|
|
445
|
+
# See https://github.com/RiotGames/ridley/pull/287
|
|
446
|
+
JSON.pretty_generate(to_hash)
|
|
434
447
|
end
|
|
435
448
|
|
|
436
449
|
def from_hash(o)
|
|
@@ -451,6 +464,8 @@ module Ridley::Chef
|
|
|
451
464
|
@groupings = o[GROUPINGS] if o.has_key?(GROUPINGS)
|
|
452
465
|
@recipes = o[RECIPES] if o.has_key?(RECIPES)
|
|
453
466
|
@version = o[VERSION] if o.has_key?(VERSION)
|
|
467
|
+
@source_url = o[SOURCE_URL] if o.has_key?(SOURCE_URL)
|
|
468
|
+
@issues_url = o[ISSUES_URL] if o.has_key?(ISSUES_URL)
|
|
454
469
|
self
|
|
455
470
|
end
|
|
456
471
|
|
|
@@ -458,6 +473,36 @@ module Ridley::Chef
|
|
|
458
473
|
from_hash JSON.parse(json)
|
|
459
474
|
end
|
|
460
475
|
|
|
476
|
+
# Sets the cookbook's source URL, or returns it.
|
|
477
|
+
#
|
|
478
|
+
# === Parameters
|
|
479
|
+
# maintainer<String>:: The source URL
|
|
480
|
+
#
|
|
481
|
+
# === Returns
|
|
482
|
+
# source_url<String>:: Returns the current source URL.
|
|
483
|
+
def source_url(arg = nil)
|
|
484
|
+
set_or_return(
|
|
485
|
+
:source_url,
|
|
486
|
+
arg,
|
|
487
|
+
:kind_of => [ String ]
|
|
488
|
+
)
|
|
489
|
+
end
|
|
490
|
+
|
|
491
|
+
# Sets the cookbook's issues URL, or returns it.
|
|
492
|
+
#
|
|
493
|
+
# === Parameters
|
|
494
|
+
# issues_url<String>:: The issues URL
|
|
495
|
+
#
|
|
496
|
+
# === Returns
|
|
497
|
+
# issues_url<String>:: Returns the current issues URL.
|
|
498
|
+
def issues_url(arg = nil)
|
|
499
|
+
set_or_return(
|
|
500
|
+
:issues_url,
|
|
501
|
+
arg,
|
|
502
|
+
:kind_of => [ String ]
|
|
503
|
+
)
|
|
504
|
+
end
|
|
505
|
+
|
|
461
506
|
private
|
|
462
507
|
|
|
463
508
|
# Verify that the given array is an array of strings
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
require '
|
|
2
|
-
require 'buff/shell_out'
|
|
1
|
+
require 'erubis'
|
|
3
2
|
|
|
4
3
|
module Ridley::Chef
|
|
5
4
|
class Cookbook
|
|
@@ -68,7 +67,6 @@ module Ridley::Chef
|
|
|
68
67
|
end
|
|
69
68
|
end
|
|
70
69
|
|
|
71
|
-
include Buff::ShellOut
|
|
72
70
|
include Ridley::Logging
|
|
73
71
|
include Ridley::Mixin::Checksum
|
|
74
72
|
|
|
@@ -131,30 +129,55 @@ module Ridley::Chef
|
|
|
131
129
|
true
|
|
132
130
|
end
|
|
133
131
|
|
|
132
|
+
# Borrowed from: https://github.com/opscode/chef/blob/d111e82/lib/chef/cookbook/syntax_check.rb#L191-L215
|
|
134
133
|
def validate_template(erb_file)
|
|
135
|
-
|
|
134
|
+
old_stderr = $stderr
|
|
136
135
|
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
136
|
+
engine = Erubis::Eruby.new
|
|
137
|
+
engine.convert!(IO.read(erb_file))
|
|
138
|
+
|
|
139
|
+
ruby_code = engine.src
|
|
140
|
+
|
|
141
|
+
# Even when we're compiling the code w/ RubyVM, syntax errors just
|
|
142
|
+
# print to $stderr. We want to capture this and handle the printing
|
|
143
|
+
# ourselves, so we must temporarily swap $stderr to capture the output.
|
|
144
|
+
tmp_stderr = $stderr = StringIO.new
|
|
145
|
+
|
|
146
|
+
abs_path = File.expand_path(erb_file)
|
|
147
|
+
RubyVM::InstructionSequence.new(ruby_code, erb_file, abs_path, 0)
|
|
143
148
|
|
|
144
149
|
true
|
|
150
|
+
rescue SyntaxError
|
|
151
|
+
$stderr = old_stderr
|
|
152
|
+
invalid_erb_file(erb_file, tmp_stderr.string)
|
|
153
|
+
false
|
|
154
|
+
ensure
|
|
155
|
+
$stderr = old_stderr if defined?(old_stderr) && old_stderr
|
|
145
156
|
end
|
|
146
157
|
|
|
158
|
+
# Borrowed from: https://github.com/opscode/chef/blob/d111e82/lib/chef/cookbook/syntax_check.rb#L242-L264
|
|
147
159
|
def validate_ruby_file(ruby_file)
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
160
|
+
# Even when we're compiling the code w/ RubyVM, syntax errors just
|
|
161
|
+
# print to $stderr. We want to capture this and handle the printing
|
|
162
|
+
# ourselves, so we must temporarily swap $stderr to capture the output.
|
|
163
|
+
old_stderr = $stderr
|
|
164
|
+
tmp_stderr = $stderr = StringIO.new
|
|
165
|
+
abs_path = File.expand_path(ruby_file)
|
|
166
|
+
file_content = IO.read(abs_path)
|
|
167
|
+
|
|
168
|
+
# We have to wrap this in a block so the user code evaluates in a
|
|
169
|
+
# similar context as what Chef does normally. Otherwise RubyVM
|
|
170
|
+
# will reject some common idioms, like using `return` to end evaluation
|
|
171
|
+
# of a recipe. See also CHEF-5199
|
|
172
|
+
wrapped_content = "Object.new.instance_eval do\n#{file_content}\nend\n"
|
|
173
|
+
RubyVM::InstructionSequence.new(wrapped_content, ruby_file, abs_path, 0)
|
|
157
174
|
true
|
|
175
|
+
rescue SyntaxError
|
|
176
|
+
$stderr = old_stderr
|
|
177
|
+
invalid_ruby_file(ruby_file, tmp_stderr.string)
|
|
178
|
+
false
|
|
179
|
+
ensure
|
|
180
|
+
$stderr = old_stderr if defined?(old_stderr) && old_stderr
|
|
158
181
|
end
|
|
159
182
|
|
|
160
183
|
private
|
|
@@ -165,6 +188,21 @@ module Ridley::Chef
|
|
|
165
188
|
def ignored?(file)
|
|
166
189
|
!!chefignore && chefignore.ignored?(file)
|
|
167
190
|
end
|
|
191
|
+
|
|
192
|
+
# Debug a syntax error in a template.
|
|
193
|
+
def invalid_erb_file(erb_file, error_message)
|
|
194
|
+
log.error("Erb template #{erb_file} has a syntax error:")
|
|
195
|
+
error_message.each_line { |l| log.error(l.chomp) }
|
|
196
|
+
nil
|
|
197
|
+
end
|
|
198
|
+
|
|
199
|
+
# Debugs ruby syntax errors by printing the path to the file and any
|
|
200
|
+
# diagnostic info given in +error_message+
|
|
201
|
+
def invalid_ruby_file(ruby_file, error_message)
|
|
202
|
+
log.error("Cookbook file #{ruby_file} has a ruby syntax error:")
|
|
203
|
+
error_message.each_line { |l| log.error(l.chomp) }
|
|
204
|
+
false
|
|
205
|
+
end
|
|
168
206
|
end
|
|
169
207
|
end
|
|
170
208
|
end
|
data/lib/ridley/chef/cookbook.rb
CHANGED
data/lib/ridley/chef/digester.rb
CHANGED
data/lib/ridley/client.rb
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
require 'ridley/helpers'
|
|
2
|
+
|
|
1
3
|
module Ridley
|
|
2
4
|
class Client
|
|
3
5
|
class ConnectionSupervisor < ::Celluloid::SupervisionGroup
|
|
@@ -7,7 +9,7 @@ module Ridley
|
|
|
7
9
|
options[:server_url],
|
|
8
10
|
options[:client_name],
|
|
9
11
|
options[:client_key],
|
|
10
|
-
|
|
12
|
+
Ridley::Helpers.options_slice(options, *Ridley::Connection::VALID_OPTIONS)
|
|
11
13
|
], as: :connection_pool)
|
|
12
14
|
end
|
|
13
15
|
end
|
|
@@ -17,14 +19,14 @@ module Ridley
|
|
|
17
19
|
super(registry)
|
|
18
20
|
supervise_as :client_resource, Ridley::ClientResource, connection_registry
|
|
19
21
|
supervise_as :cookbook_resource, Ridley::CookbookResource, connection_registry,
|
|
20
|
-
options[:client_name], options[:client_key],
|
|
22
|
+
options[:client_name], options[:client_key], Ridley::Helpers.options_slice(options, *Ridley::Connection::VALID_OPTIONS)
|
|
21
23
|
supervise_as :data_bag_resource, Ridley::DataBagResource, connection_registry,
|
|
22
24
|
options[:encrypted_data_bag_secret]
|
|
23
25
|
supervise_as :environment_resource, Ridley::EnvironmentResource, connection_registry
|
|
24
26
|
supervise_as :node_resource, Ridley::NodeResource, connection_registry, options
|
|
25
27
|
supervise_as :role_resource, Ridley::RoleResource, connection_registry
|
|
26
28
|
supervise_as :sandbox_resource, Ridley::SandboxResource, connection_registry,
|
|
27
|
-
options[:client_name], options[:client_key],
|
|
29
|
+
options[:client_name], options[:client_key], Ridley::Helpers.options_slice(options, *Ridley::Connection::VALID_OPTIONS)
|
|
28
30
|
supervise_as :search_resource, Ridley::SearchResource, connection_registry
|
|
29
31
|
supervise_as :user_resource, Ridley::UserResource, connection_registry
|
|
30
32
|
end
|
|
@@ -137,6 +139,7 @@ module Ridley
|
|
|
137
139
|
end
|
|
138
140
|
|
|
139
141
|
unless verify_client_key(@options[:client_key])
|
|
142
|
+
@options[:client_key] = @options[:client_key].call if @options[:client_key].kind_of? Proc
|
|
140
143
|
@options[:client_key] = File.expand_path(@options[:client_key])
|
|
141
144
|
raise Errors::ClientKeyFileNotFoundOrInvalid, "client key is invalid or not found at: '#{@options[:client_key]}'" unless File.exist?(@options[:client_key]) && verify_client_key(::IO.read(@options[:client_key]))
|
|
142
145
|
end
|
data/lib/ridley/connection.rb
CHANGED
|
@@ -3,6 +3,8 @@ require 'retryable'
|
|
|
3
3
|
require 'tempfile'
|
|
4
4
|
require 'zlib'
|
|
5
5
|
|
|
6
|
+
require 'ridley/helpers'
|
|
7
|
+
|
|
6
8
|
module Ridley
|
|
7
9
|
class Connection < Faraday::Connection
|
|
8
10
|
include Celluloid
|
|
@@ -59,13 +61,12 @@ module Ridley
|
|
|
59
61
|
b.request :chef_auth, client_name, client_key
|
|
60
62
|
|
|
61
63
|
b.response :parse_json
|
|
62
|
-
b.response :gzip
|
|
63
64
|
b.response :chef_response
|
|
64
65
|
|
|
65
|
-
b.adapter :
|
|
66
|
+
b.adapter :httpclient
|
|
66
67
|
end
|
|
67
68
|
|
|
68
|
-
uri_hash = Addressable::URI.parse(server_url).to_hash
|
|
69
|
+
uri_hash = Ridley::Helpers.options_slice(Addressable::URI.parse(server_url).to_hash, :scheme, :host, :port)
|
|
69
70
|
|
|
70
71
|
unless uri_hash[:port]
|
|
71
72
|
uri_hash[:port] = (uri_hash[:scheme] == "https" ? 443 : 80)
|
|
@@ -143,7 +144,7 @@ module Ridley
|
|
|
143
144
|
local = Tempfile.new('ridley-stream')
|
|
144
145
|
local.binmode
|
|
145
146
|
|
|
146
|
-
retryable(tries: retries, on: OpenURI::HTTPError, sleep: retry_interval) do
|
|
147
|
+
Retryable.retryable(tries: retries, on: OpenURI::HTTPError, sleep: retry_interval) do
|
|
147
148
|
open(target, 'rb', headers) do |remote|
|
|
148
149
|
body = remote.read
|
|
149
150
|
case remote.content_encoding
|
data/lib/ridley/errors.rb
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
require 'ridley/errors'
|
|
2
|
+
|
|
1
3
|
module Ridley::Mixin
|
|
2
4
|
# Borrowed and modified from: {https://raw.github.com/opscode/chef/11.4.0/lib/chef/mixin/params_validate.rb}
|
|
3
5
|
#
|
|
@@ -15,6 +17,8 @@ module Ridley::Mixin
|
|
|
15
17
|
# See the License for the specific language governing permissions and
|
|
16
18
|
# limitations under the License.
|
|
17
19
|
module ParamsValidate
|
|
20
|
+
include Ridley::Errors
|
|
21
|
+
|
|
18
22
|
# Takes a hash of options, along with a map to validate them. Returns the original
|
|
19
23
|
# options hash, plus any changes that might have been made (through things like setting
|
|
20
24
|
# default values in the validation map)
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
require 'ridley/helpers'
|
|
2
|
+
|
|
1
3
|
module Ridley
|
|
2
4
|
class CookbookResource < Ridley::Resource
|
|
3
5
|
task_class TaskThread
|
|
@@ -225,10 +227,20 @@ module Ridley
|
|
|
225
227
|
|
|
226
228
|
sandbox.upload(checksums)
|
|
227
229
|
sandbox.commit
|
|
228
|
-
update(cookbook,
|
|
230
|
+
update(cookbook, Ridley::Helpers.options_slice(options, :force, :freeze))
|
|
229
231
|
ensure
|
|
230
232
|
# Destroy the compiled metadata only if it was created
|
|
231
|
-
|
|
233
|
+
if compiled_metadata
|
|
234
|
+
# The garbage collector still has a reference to the file we'd
|
|
235
|
+
# like to delete. On *nix this isn't a big deal, but on Windows
|
|
236
|
+
# [ ruby 2.0.0p451 (2014-02-24) [i386-mingw32] ] open files
|
|
237
|
+
# cannot be deleted, so we're forced to garbage collect to
|
|
238
|
+
# ensure we can delete the file. This is CRITICAL to ensure that
|
|
239
|
+
# a stale metadata file isn't left on disk because next time we
|
|
240
|
+
# would use that file instead of recompiling.
|
|
241
|
+
GC.start
|
|
242
|
+
File.delete(compiled_metadata)
|
|
243
|
+
end
|
|
232
244
|
end
|
|
233
245
|
|
|
234
246
|
# Return a list of versions for the given cookbook present on the remote Chef server
|
data/lib/ridley/version.rb
CHANGED
data/ridley.gemspec
CHANGED
|
@@ -23,15 +23,15 @@ Gem::Specification.new do |s|
|
|
|
23
23
|
s.add_dependency 'buff-extensions', '~> 1.0'
|
|
24
24
|
s.add_dependency 'buff-ignore', '~> 1.1'
|
|
25
25
|
s.add_dependency 'buff-shell_out', '~> 0.1'
|
|
26
|
-
s.add_dependency 'celluloid', '~> 0.16.0
|
|
27
|
-
s.add_dependency 'celluloid-io', '~> 0.16.
|
|
26
|
+
s.add_dependency 'celluloid', '~> 0.16.0'
|
|
27
|
+
s.add_dependency 'celluloid-io', '~> 0.16.1'
|
|
28
28
|
s.add_dependency 'erubis'
|
|
29
29
|
s.add_dependency 'faraday', '~> 0.9.0'
|
|
30
|
-
s.add_dependency 'hashie', '>= 2.0.2', '<
|
|
30
|
+
s.add_dependency 'hashie', '>= 2.0.2', '< 4.0.0'
|
|
31
|
+
s.add_dependency 'httpclient', '~> 2.6'
|
|
31
32
|
s.add_dependency 'json', '>= 1.7.7'
|
|
32
33
|
s.add_dependency 'mixlib-authentication', '>= 1.3.0'
|
|
33
|
-
s.add_dependency '
|
|
34
|
-
s.add_dependency 'retryable'
|
|
34
|
+
s.add_dependency 'retryable', '~> 2.0'
|
|
35
35
|
s.add_dependency 'semverse', '~> 1.1'
|
|
36
36
|
|
|
37
37
|
s.add_development_dependency 'buff-ruby_engine', '~> 0.1'
|
|
@@ -11,30 +11,30 @@ describe "Client API operations", type: "acceptance" do
|
|
|
11
11
|
before { chef_client("reset", admin: false) }
|
|
12
12
|
|
|
13
13
|
it "returns a ClientObject" do
|
|
14
|
-
connection.client.find("reset").
|
|
14
|
+
expect(connection.client.find("reset")).to be_a(Ridley::ClientObject)
|
|
15
15
|
end
|
|
16
16
|
end
|
|
17
17
|
|
|
18
18
|
context "when the server does not have the client" do
|
|
19
19
|
it "returns a nil value" do
|
|
20
|
-
connection.client.find("not_there").
|
|
20
|
+
expect(connection.client.find("not_there")).to be_nil
|
|
21
21
|
end
|
|
22
22
|
end
|
|
23
23
|
end
|
|
24
24
|
|
|
25
25
|
describe "creating a client" do
|
|
26
26
|
it "returns a Ridley::ClientObject" do
|
|
27
|
-
connection.client.create(name: "reset").
|
|
27
|
+
expect(connection.client.create(name: "reset")).to be_a(Ridley::ClientObject)
|
|
28
28
|
end
|
|
29
29
|
|
|
30
30
|
it "adds a client to the chef server" do
|
|
31
31
|
old = connection.client.all.length
|
|
32
32
|
connection.client.create(name: "reset")
|
|
33
|
-
connection.client.all.
|
|
33
|
+
expect(connection.client.all.size).to eq(old + 1)
|
|
34
34
|
end
|
|
35
35
|
|
|
36
36
|
it "has a value for #private_key" do
|
|
37
|
-
connection.client.create(name: "reset").private_key.
|
|
37
|
+
expect(connection.client.create(name: "reset").private_key).not_to be_nil
|
|
38
38
|
end
|
|
39
39
|
end
|
|
40
40
|
|
|
@@ -42,13 +42,13 @@ describe "Client API operations", type: "acceptance" do
|
|
|
42
42
|
before { chef_client("reset", admin: false) }
|
|
43
43
|
|
|
44
44
|
it "returns a Ridley::ClientObject object" do
|
|
45
|
-
connection.client.delete("reset").
|
|
45
|
+
expect(connection.client.delete("reset")).to be_a(Ridley::ClientObject)
|
|
46
46
|
end
|
|
47
47
|
|
|
48
48
|
it "removes the client from the server" do
|
|
49
49
|
connection.client.delete("reset")
|
|
50
50
|
|
|
51
|
-
connection.client.find("reset").
|
|
51
|
+
expect(connection.client.find("reset")).to be_nil
|
|
52
52
|
end
|
|
53
53
|
end
|
|
54
54
|
|
|
@@ -59,12 +59,12 @@ describe "Client API operations", type: "acceptance" do
|
|
|
59
59
|
end
|
|
60
60
|
|
|
61
61
|
it "returns an array of Ridley::ClientObject objects" do
|
|
62
|
-
connection.client.delete_all.
|
|
62
|
+
expect(connection.client.delete_all).to each be_a(Ridley::ClientObject)
|
|
63
63
|
end
|
|
64
64
|
|
|
65
65
|
it "deletes all clients from the remote" do
|
|
66
66
|
connection.client.delete_all
|
|
67
|
-
connection.client.all.
|
|
67
|
+
expect(connection.client.all.size).to eq(0)
|
|
68
68
|
end
|
|
69
69
|
end
|
|
70
70
|
|
|
@@ -75,11 +75,11 @@ describe "Client API operations", type: "acceptance" do
|
|
|
75
75
|
end
|
|
76
76
|
|
|
77
77
|
it "returns an array of Ridley::ClientObject objects" do
|
|
78
|
-
connection.client.all.
|
|
78
|
+
expect(connection.client.all).to each be_a(Ridley::ClientObject)
|
|
79
79
|
end
|
|
80
80
|
|
|
81
81
|
it "returns all of the clients on the server" do
|
|
82
|
-
connection.client.all.
|
|
82
|
+
expect(connection.client.all.size).to eq(4)
|
|
83
83
|
end
|
|
84
84
|
end
|
|
85
85
|
|
|
@@ -87,7 +87,7 @@ describe "Client API operations", type: "acceptance" do
|
|
|
87
87
|
before { chef_client("reset", admin: false) }
|
|
88
88
|
|
|
89
89
|
it "returns a Ridley::ClientObject object with a value for #private_key" do
|
|
90
|
-
connection.client.regenerate_key("reset").private_key.
|
|
90
|
+
expect(connection.client.regenerate_key("reset").private_key).to match(/^-----BEGIN RSA PRIVATE KEY-----/)
|
|
91
91
|
end
|
|
92
92
|
end
|
|
93
93
|
end
|