ridley 4.0.0 → 4.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +6 -0
- data/lib/ridley/chef/config.rb +5 -5
- data/lib/ridley/chef/cookbook/syntax_check.rb +57 -19
- data/lib/ridley/chef/digester.rb +3 -1
- data/lib/ridley/client.rb +5 -3
- data/lib/ridley/connection.rb +3 -1
- data/lib/ridley/helpers.rb +10 -0
- data/lib/ridley/resources/cookbook_resource.rb +3 -1
- data/lib/ridley/version.rb +1 -1
- data/ridley.gemspec +2 -2
- metadata +7 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a8f779adc3b49cb4e56e8c3ec7be31f9c9d4d578
|
4
|
+
data.tar.gz: 567f7dfd4825123df48ba3481b925de1d99e2dfc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 19d7b37325d54cba04a0685999cdb753b2bec68c8361e83736049a62a3b99410dfff57ab42757943395ce3f66075725dd9b479f44d4930e08f9b9300c04de839
|
7
|
+
data.tar.gz: 15f13659355c879b27e1b5e5388f7b055baef746d5474e2478557f771f7d152727d4c609e540855a901b7d92d4360d0e3424e9fda3de542adfdfe3249682996a
|
data/CHANGELOG.md
CHANGED
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
|
#
|
@@ -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/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
|
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
|
@@ -65,7 +67,7 @@ module Ridley
|
|
65
67
|
b.adapter :net_http_persistent
|
66
68
|
end
|
67
69
|
|
68
|
-
uri_hash = Addressable::URI.parse(server_url).to_hash
|
70
|
+
uri_hash = Ridley::Helpers.options_slice(Addressable::URI.parse(server_url).to_hash, :scheme, :host, :port)
|
69
71
|
|
70
72
|
unless uri_hash[:port]
|
71
73
|
uri_hash[:port] = (uri_hash[:scheme] == "https" ? 443 : 80)
|
@@ -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,7 +227,7 @@ 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
|
File.delete(compiled_metadata) unless compiled_metadata.nil?
|
data/lib/ridley/version.rb
CHANGED
data/ridley.gemspec
CHANGED
@@ -23,8 +23,8 @@ 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
30
|
s.add_dependency 'hashie', '>= 2.0.2', '< 3.0.0'
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ridley
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 4.
|
4
|
+
version: 4.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jamie Winsor
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2014-
|
12
|
+
date: 2014-10-23 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: addressable
|
@@ -101,28 +101,28 @@ dependencies:
|
|
101
101
|
requirements:
|
102
102
|
- - ~>
|
103
103
|
- !ruby/object:Gem::Version
|
104
|
-
version: 0.16.0
|
104
|
+
version: 0.16.0
|
105
105
|
type: :runtime
|
106
106
|
prerelease: false
|
107
107
|
version_requirements: !ruby/object:Gem::Requirement
|
108
108
|
requirements:
|
109
109
|
- - ~>
|
110
110
|
- !ruby/object:Gem::Version
|
111
|
-
version: 0.16.0
|
111
|
+
version: 0.16.0
|
112
112
|
- !ruby/object:Gem::Dependency
|
113
113
|
name: celluloid-io
|
114
114
|
requirement: !ruby/object:Gem::Requirement
|
115
115
|
requirements:
|
116
116
|
- - ~>
|
117
117
|
- !ruby/object:Gem::Version
|
118
|
-
version: 0.16.
|
118
|
+
version: 0.16.1
|
119
119
|
type: :runtime
|
120
120
|
prerelease: false
|
121
121
|
version_requirements: !ruby/object:Gem::Requirement
|
122
122
|
requirements:
|
123
123
|
- - ~>
|
124
124
|
- !ruby/object:Gem::Version
|
125
|
-
version: 0.16.
|
125
|
+
version: 0.16.1
|
126
126
|
- !ruby/object:Gem::Dependency
|
127
127
|
name: erubis
|
128
128
|
requirement: !ruby/object:Gem::Requirement
|
@@ -294,6 +294,7 @@ files:
|
|
294
294
|
- lib/ridley/client.rb
|
295
295
|
- lib/ridley/connection.rb
|
296
296
|
- lib/ridley/errors.rb
|
297
|
+
- lib/ridley/helpers.rb
|
297
298
|
- lib/ridley/logger.rb
|
298
299
|
- lib/ridley/logging.rb
|
299
300
|
- lib/ridley/middleware.rb
|