ridley 1.2.6 → 1.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/.travis.yml +0 -1
- data/README.md +49 -0
- data/lib/ridley.rb +20 -0
- data/lib/ridley/chef.rb +1 -0
- data/lib/ridley/chef/config.rb +86 -0
- data/lib/ridley/client.rb +33 -4
- data/lib/ridley/connection.rb +1 -1
- data/lib/ridley/host_connector/winrm.rb +3 -3
- data/lib/ridley/resources/cookbook_resource.rb +0 -2
- data/lib/ridley/resources/search_resource.rb +99 -13
- data/lib/ridley/version.rb +1 -1
- data/ridley.gemspec +2 -1
- data/spec/unit/ridley/resources/search_resource_spec.rb +38 -0
- data/spec/unit/ridley_spec.rb +98 -0
- metadata +18 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 29775148101ee7b5606bf8147c419def65765b13
|
4
|
+
data.tar.gz: fe10a06b4db60f71fb8832d4b59d62a83c2e6c17
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ba1cc8948844efbc746b227791f349210494ff9a4c9a21ebbc8a722eccf09fb8e7b9c4f203eee3cab2ad8161b74e94f34a673ad673e4d58b33ed06e520648d2e
|
7
|
+
data.tar.gz: b62e6e914f5696c5806dd1f0befe0713ffed69d95bc5cd6e88c7942ecb53fb0ac68672117dffeb5431d85cd96c3f60c462ab165a50658aeec199a02d1a86576d
|
data/.travis.yml
CHANGED
data/README.md
CHANGED
@@ -40,6 +40,55 @@ Ridley exposes a number of functions that return resources which you can use to
|
|
40
40
|
|
41
41
|
For more information scroll down to the Manipulating Chef Resources section of this README.
|
42
42
|
|
43
|
+
You can also tell Ridley to read the values from your Chef config (knife.rb):
|
44
|
+
|
45
|
+
```ruby
|
46
|
+
ridley = Ridley.from_chef_config('/path/to/knife.rb')
|
47
|
+
ridley.role.all #=> [
|
48
|
+
#<Ridley::RoleObject chef_id:motherbrain_srv ...>,
|
49
|
+
#<Ridley::RoleObject chef_id:motherbrain_proxy ...>
|
50
|
+
]
|
51
|
+
```
|
52
|
+
|
53
|
+
The mapping between Chef Config values and Ridley values is:
|
54
|
+
|
55
|
+
<table>
|
56
|
+
<thead>
|
57
|
+
<tr>
|
58
|
+
<th>Ridley</th>
|
59
|
+
<th>Chef</th>
|
60
|
+
</tr>
|
61
|
+
</thead>
|
62
|
+
<tbody>
|
63
|
+
<tr>
|
64
|
+
<td>validator_client</td>
|
65
|
+
<td>validation_client_name</td>
|
66
|
+
</tr>
|
67
|
+
<tr>
|
68
|
+
<td>validator_path</td>
|
69
|
+
<td>validation_key</td>
|
70
|
+
</tr>
|
71
|
+
<tr>
|
72
|
+
<td>client_name</td>
|
73
|
+
<td>node_name</td>
|
74
|
+
</tr>
|
75
|
+
<tr>
|
76
|
+
<td>server_url</td>
|
77
|
+
<td>chef_server_url</td>
|
78
|
+
</tr>
|
79
|
+
</tbody>
|
80
|
+
</table>
|
81
|
+
|
82
|
+
Additionally, you can leave the path blank and Ridley will perform a "knife.rb search" the same way Chef does:
|
83
|
+
|
84
|
+
```ruby
|
85
|
+
ridley = Ridley.from_chef_config
|
86
|
+
ridley.role.all #=> [
|
87
|
+
#<Ridley::RoleObject chef_id:motherbrain_srv ...>,
|
88
|
+
#<Ridley::RoleObject chef_id:motherbrain_proxy ...>
|
89
|
+
]
|
90
|
+
```
|
91
|
+
|
43
92
|
If you don't want to instantiate and manage a connection object you can use `Ridley.open` to open a connection, do some work, and it will be closed for you after the block executes.
|
44
93
|
|
45
94
|
Ridley.open(server_url: "https://api.opscode.com", ...) do |r|
|
data/lib/ridley.rb
CHANGED
@@ -27,6 +27,26 @@ module Ridley
|
|
27
27
|
Client.new(*args)
|
28
28
|
end
|
29
29
|
|
30
|
+
# Create a new Ridley connection from the Chef config (knife.rb)
|
31
|
+
#
|
32
|
+
# @param [#to_s] filepath
|
33
|
+
# the path to the Chef Config
|
34
|
+
#
|
35
|
+
# @param [hash] options
|
36
|
+
# list of options to pass to the Ridley connection (@see {Ridley::Client#new})
|
37
|
+
#
|
38
|
+
# @return [Ridley::Client]
|
39
|
+
def from_chef_config(filepath = nil, options = {})
|
40
|
+
config = Ridley::Chef::Config.new(filepath).to_hash
|
41
|
+
|
42
|
+
config[:validator_client] = config.delete(:validation_client_name)
|
43
|
+
config[:validator_path] = config.delete(:validation_key)
|
44
|
+
config[:client_name] = config.delete(:node_name)
|
45
|
+
config[:server_url] = config.delete(:chef_server_url)
|
46
|
+
|
47
|
+
Client.new(config.merge(options))
|
48
|
+
end
|
49
|
+
|
30
50
|
def open(*args, &block)
|
31
51
|
Client.open(*args, &block)
|
32
52
|
end
|
data/lib/ridley/chef.rb
CHANGED
@@ -0,0 +1,86 @@
|
|
1
|
+
require 'buff/config/ruby'
|
2
|
+
require 'socket'
|
3
|
+
|
4
|
+
module Ridley::Chef
|
5
|
+
class Config < Buff::Config::Ruby
|
6
|
+
class << self
|
7
|
+
# Return the most sensible path to the Chef configuration file. This can
|
8
|
+
# be configured by setting a value for the 'RIDLEY_CHEF_CONFIG' environment
|
9
|
+
# variable.
|
10
|
+
#
|
11
|
+
# @return [String, nil]
|
12
|
+
def location
|
13
|
+
possibles = []
|
14
|
+
|
15
|
+
possibles << ENV['RIDLEY_CHEF_CONFIG'] if ENV['RIDLEY_CHEF_CONFIG']
|
16
|
+
possibles << File.join(ENV['KNIFE_HOME'], 'knife.rb') if ENV['KNIFE_HOME']
|
17
|
+
possibles << File.join(working_dir, 'knife.rb') if working_dir
|
18
|
+
|
19
|
+
# Ascending search for .chef directory siblings
|
20
|
+
Pathname.new(working_dir).ascend do |file|
|
21
|
+
sibling_chef = File.join(file, '.chef')
|
22
|
+
possibles << File.join(sibling_chef, 'knife.rb')
|
23
|
+
end if working_dir
|
24
|
+
|
25
|
+
possibles << File.join(ENV['HOME'], '.chef', 'knife.rb') if ENV['HOME']
|
26
|
+
possibles.compact!
|
27
|
+
|
28
|
+
location = possibles.find { |loc| File.exists?(File.expand_path(loc)) }
|
29
|
+
|
30
|
+
File.expand_path(location) unless location.nil?
|
31
|
+
end
|
32
|
+
|
33
|
+
private
|
34
|
+
|
35
|
+
# The current working directory
|
36
|
+
#
|
37
|
+
# @return [String]
|
38
|
+
def working_dir
|
39
|
+
ENV['PWD'] || Dir.pwd
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
set_assignment_mode :carefree
|
44
|
+
|
45
|
+
attribute :node_name,
|
46
|
+
default: Socket.gethostname
|
47
|
+
attribute :chef_server_url,
|
48
|
+
default: 'http://localhost:4000'
|
49
|
+
attribute :client_key,
|
50
|
+
default: platform_specific_path('/etc/chef/client.pem')
|
51
|
+
attribute :validation_key,
|
52
|
+
default: platform_specific_path('/etc/chef/validation.pem')
|
53
|
+
attribute :validation_client_name,
|
54
|
+
default: 'chef-validator'
|
55
|
+
|
56
|
+
attribute :cookbook_copyright,
|
57
|
+
default: 'YOUR_NAME'
|
58
|
+
attribute :cookbook_email,
|
59
|
+
default: 'YOUR_EMAIL'
|
60
|
+
attribute :cookbook_license,
|
61
|
+
default: 'reserved'
|
62
|
+
|
63
|
+
attribute :knife,
|
64
|
+
default: {}
|
65
|
+
|
66
|
+
# Prior to Chef 11, the cache implementation was based on
|
67
|
+
# moneta and configured via cache_options[:path]. Knife configs
|
68
|
+
# generated with Chef 11 will have `syntax_check_cache_path`, but older
|
69
|
+
# configs will have `cache_options[:path]`. `cache_options` is marked
|
70
|
+
# deprecated in chef/config.rb but doesn't currently trigger a warning.
|
71
|
+
# See also: CHEF-3715
|
72
|
+
attribute :syntax_check_cache_path,
|
73
|
+
default: Dir.mktmpdir
|
74
|
+
attribute :cache_options,
|
75
|
+
default: { path: defined?(syntax_check_cache_path) ? syntax_check_cache_path : Dir.mktmpdir }
|
76
|
+
|
77
|
+
# Create a new Chef Config object.
|
78
|
+
#
|
79
|
+
# @param [#to_s] path
|
80
|
+
# the path to the configuration file
|
81
|
+
# @param [Hash] options
|
82
|
+
def initialize(path, options = {})
|
83
|
+
super(path || self.class.location, options)
|
84
|
+
end
|
85
|
+
end
|
86
|
+
end
|
data/lib/ridley/client.rb
CHANGED
@@ -199,7 +199,7 @@ module Ridley
|
|
199
199
|
# Perform a search the Chef Server
|
200
200
|
#
|
201
201
|
# @param [#to_sym, #to_s] index
|
202
|
-
# @param [#to_s]
|
202
|
+
# @param [#to_s] query
|
203
203
|
#
|
204
204
|
# @option options [String] :sort
|
205
205
|
# a sort string such as 'name DESC'
|
@@ -208,7 +208,7 @@ module Ridley
|
|
208
208
|
# @option options [Integer] :start
|
209
209
|
# the result number to start from
|
210
210
|
#
|
211
|
-
# @return [Hash]
|
211
|
+
# @return [Array<ChefObject>, Hash]
|
212
212
|
def search(index, query = nil, options = {})
|
213
213
|
@resources_registry[:search_resource].run(index, query, @resources_registry, options)
|
214
214
|
end
|
@@ -216,8 +216,8 @@ module Ridley
|
|
216
216
|
# Return the array of all possible search indexes for the including connection
|
217
217
|
#
|
218
218
|
# @example
|
219
|
-
#
|
220
|
-
#
|
219
|
+
# ridley = Ridley.new(...)
|
220
|
+
# ridley.search_indexes #=>
|
221
221
|
# [:client, :environment, :node, :role, :"ridley-two", :"ridley-one"]
|
222
222
|
#
|
223
223
|
# @return [Array<Symbol, String>]
|
@@ -225,6 +225,35 @@ module Ridley
|
|
225
225
|
@resources_registry[:search_resource].indexes
|
226
226
|
end
|
227
227
|
|
228
|
+
# Perform a partial search the Chef Server. Partial objects or a smaller hash will be returned resulting
|
229
|
+
# in a faster response for larger response sets. Specify the attributes you want returned with the
|
230
|
+
# attributes parameter.
|
231
|
+
#
|
232
|
+
# @param [#to_sym, #to_s] index
|
233
|
+
# @param [#to_s] query
|
234
|
+
# @param [Array] attributes
|
235
|
+
# an array of strings in dotted hash notation representing the attributes to return
|
236
|
+
#
|
237
|
+
# @option options [String] :sort
|
238
|
+
# a sort string such as 'name DESC'
|
239
|
+
# @option options [Integer] :rows
|
240
|
+
# how many rows to return
|
241
|
+
# @option options [Integer] :start
|
242
|
+
# the result number to start from
|
243
|
+
#
|
244
|
+
# @example
|
245
|
+
# ridley = Ridley.new(...)
|
246
|
+
# ridley.partial_search(:node, "chef_environment:RESET", [ 'ipaddress', 'some.application.setting' ]) #=>
|
247
|
+
# [
|
248
|
+
# #<Ridley::NodeObject: chef_id:"reset.riotgames.com" normal:
|
249
|
+
# { "ipaddress" => "192.168.1.1", "some" => { "application" => { "setting" => "value" } } } ...>
|
250
|
+
# ]
|
251
|
+
#
|
252
|
+
# @return [Array<ChefObject>, Hash]
|
253
|
+
def partial_search(index, query = nil, attributes = [], options = {})
|
254
|
+
@resources_registry[:search_resource].partial(index, query, Array(attributes), @resources_registry, options)
|
255
|
+
end
|
256
|
+
|
228
257
|
# The encrypted data bag secret for this connection.
|
229
258
|
#
|
230
259
|
# @raise [Ridley::Errors::EncryptedDataBagSecretNotFound]
|
data/lib/ridley/connection.rb
CHANGED
@@ -47,10 +47,10 @@ module Ridley
|
|
47
47
|
end
|
48
48
|
|
49
49
|
HostConnector::Response.new(host).tap do |response|
|
50
|
-
command_uploaders << command_uploader = CommandUploader.new(connection)
|
51
|
-
command = get_command(command, command_uploader)
|
52
|
-
|
53
50
|
begin
|
51
|
+
command_uploaders << command_uploader = CommandUploader.new(connection)
|
52
|
+
command = get_command(command, command_uploader)
|
53
|
+
|
54
54
|
log.info "Running WinRM Command: '#{command}' on: '#{host}' as: '#{user}'"
|
55
55
|
|
56
56
|
defer {
|
@@ -20,12 +20,42 @@ module Ridley
|
|
20
20
|
end
|
21
21
|
end
|
22
22
|
|
23
|
+
# Builds and returns a query parameter string for the search API
|
24
|
+
#
|
25
|
+
# @param [String] query_string
|
26
|
+
#
|
27
|
+
# @option options [String] :sort
|
28
|
+
# a sort string such as 'name DESC'
|
29
|
+
# @option options [Integer] :rows
|
30
|
+
# how many rows to return
|
31
|
+
# @option options [Integer] :start
|
32
|
+
# the result number to start from
|
33
|
+
#
|
34
|
+
# @example
|
35
|
+
# build_param_string("*:*", rows: 5) #=> "?q=*:*&rows=5"
|
36
|
+
#
|
37
|
+
# @return [String]
|
38
|
+
def build_param_string(query_string, options = {})
|
39
|
+
query = build_query(query_string, options)
|
40
|
+
param = "?q=#{escape(query[:q])}"
|
41
|
+
param += "&sort=#{escape(query[:sort])}" if query[:sort]
|
42
|
+
param += "&start=#{escape(query[:start])}" if query[:start]
|
43
|
+
param += "&rows=#{escape(query[:rows])}" if query[:rows]
|
44
|
+
param
|
45
|
+
end
|
46
|
+
|
23
47
|
# @param [#to_s] index
|
24
48
|
#
|
25
49
|
# @return [String]
|
26
50
|
def query_uri(index)
|
27
51
|
"#{resource_path}/#{index}"
|
28
52
|
end
|
53
|
+
|
54
|
+
private
|
55
|
+
|
56
|
+
def escape(str)
|
57
|
+
str && URI.escape(str.to_s)
|
58
|
+
end
|
29
59
|
end
|
30
60
|
|
31
61
|
set_resource_path "search"
|
@@ -79,20 +109,76 @@ module Ridley
|
|
79
109
|
def run(index, query_string, resources_registry, options = {})
|
80
110
|
query_uri = self.class.query_uri(index)
|
81
111
|
query = self.class.build_query(query_string, options)
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
112
|
+
|
113
|
+
handle_response(index, resources_registry, request(:get, query_uri, query))
|
114
|
+
end
|
115
|
+
|
116
|
+
# Perform a partial search on the Chef server
|
117
|
+
#
|
118
|
+
# @param [#to_sym, #to_s] index
|
119
|
+
# @param [#to_s] query_string
|
120
|
+
# @param [Array] attributes
|
121
|
+
# an array of strings in dotted hash notation representing the attributes to return
|
122
|
+
#
|
123
|
+
# @option options [String] :sort
|
124
|
+
# a sort string such as 'name DESC'
|
125
|
+
# @option options [Integer] :rows
|
126
|
+
# how many rows to return
|
127
|
+
# @option options [Integer] :start
|
128
|
+
# the result number to start from
|
129
|
+
#
|
130
|
+
# @return [Array<ChefObject>, Hash]
|
131
|
+
def partial(index, query_string, attributes, resources_registry, options = {})
|
132
|
+
query_uri = self.class.query_uri(index)
|
133
|
+
param_string = self.class.build_param_string(query_string, options)
|
134
|
+
|
135
|
+
chef_id = chef_id_for_index(index)
|
136
|
+
|
137
|
+
body = Hash.new.tap do |body|
|
138
|
+
body[chef_id] = [ chef_id ] if chef_id
|
139
|
+
attributes.collect { |attr| body[attr] = attr.split('.') }
|
95
140
|
end
|
141
|
+
|
142
|
+
handle_partial(index, resources_registry, request(:post, "#{query_uri}#{param_string}", JSON.generate(body)))
|
96
143
|
end
|
144
|
+
|
145
|
+
private
|
146
|
+
|
147
|
+
def chef_id_for_index(index)
|
148
|
+
chef_id = index.to_sym == :node ? Ridley::NodeObject.chef_id : nil
|
149
|
+
end
|
150
|
+
|
151
|
+
def handle_partial(index, registry, response)
|
152
|
+
chef_id = chef_id_for_index(index)
|
153
|
+
|
154
|
+
case index.to_sym
|
155
|
+
when :node
|
156
|
+
response[:rows].collect do |item|
|
157
|
+
attributes = Hash.new
|
158
|
+
item[:data].each do |key, value|
|
159
|
+
next if key.to_s == chef_id.to_s
|
160
|
+
attributes.deep_merge!(Hash.from_dotted_path(key, value))
|
161
|
+
end
|
162
|
+
registry[:node_resource].new(name: item[:data][chef_id], normal: attributes)
|
163
|
+
end
|
164
|
+
else
|
165
|
+
response[:rows]
|
166
|
+
end
|
167
|
+
end
|
168
|
+
|
169
|
+
def handle_response(index, registry, response)
|
170
|
+
case index.to_sym
|
171
|
+
when :node
|
172
|
+
response[:rows].collect { |row| NodeObject.new(registry[:node_resource], row) }
|
173
|
+
when :role
|
174
|
+
response[:rows].collect { |row| RoleObject.new(registry[:role_resource], row) }
|
175
|
+
when :client
|
176
|
+
response[:rows].collect { |row| ClientObject.new(registry[:client_resource], row) }
|
177
|
+
when :environment
|
178
|
+
response[:rows].collect { |row| EnvironmentObject.new(registry[:environment_resource], row) }
|
179
|
+
else
|
180
|
+
response[:rows]
|
181
|
+
end
|
182
|
+
end
|
97
183
|
end
|
98
184
|
end
|
data/lib/ridley/version.rb
CHANGED
data/ridley.gemspec
CHANGED
@@ -19,6 +19,7 @@ Gem::Specification.new do |s|
|
|
19
19
|
|
20
20
|
s.add_dependency 'addressable'
|
21
21
|
s.add_dependency 'varia_model', '~> 0.1'
|
22
|
+
s.add_dependency 'buff-config', '~> 0.2'
|
22
23
|
s.add_dependency 'buff-extensions', '~> 0.3'
|
23
24
|
s.add_dependency 'buff-shell_out', '~> 0.1'
|
24
25
|
s.add_dependency 'celluloid', '~> 0.14.0'
|
@@ -34,5 +35,5 @@ Gem::Specification.new do |s|
|
|
34
35
|
s.add_dependency 'solve', '>= 0.4.4'
|
35
36
|
s.add_dependency 'winrm', '~> 1.1.0'
|
36
37
|
|
37
|
-
s.add_development_dependency
|
38
|
+
s.add_development_dependency 'buff-ruby_engine', '~> 0.1'
|
38
39
|
end
|
@@ -49,6 +49,44 @@ describe Ridley::SearchResource do
|
|
49
49
|
end
|
50
50
|
end
|
51
51
|
|
52
|
+
describe "::build_param_string" do
|
53
|
+
let(:query) { "*:*" }
|
54
|
+
let(:options) { Hash.new }
|
55
|
+
|
56
|
+
subject { described_class.build_param_string(query, options) }
|
57
|
+
|
58
|
+
it "returns a string containing the query string" do
|
59
|
+
expect(subject).to eq("?q=#{query}")
|
60
|
+
end
|
61
|
+
|
62
|
+
context "when the :start option is given" do
|
63
|
+
let(:start) { 10 }
|
64
|
+
let(:options) { { start: start } }
|
65
|
+
|
66
|
+
it "contains the start query param" do
|
67
|
+
expect(subject).to eq("?q=#{query}&start=#{start}")
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
71
|
+
context "when the :sort option is given" do
|
72
|
+
let(:sort) { "DESC" }
|
73
|
+
let(:options) { { sort: sort } }
|
74
|
+
|
75
|
+
it "contains the sort query param" do
|
76
|
+
expect(subject).to eq("?q=#{query}&sort=#{sort}")
|
77
|
+
end
|
78
|
+
end
|
79
|
+
|
80
|
+
context "when the :rows option is given" do
|
81
|
+
let(:rows) { 20 }
|
82
|
+
let(:options) { { rows: rows } }
|
83
|
+
|
84
|
+
it "contains the rows query param" do
|
85
|
+
expect(subject).to eq("?q=#{query}&rows=#{rows}")
|
86
|
+
end
|
87
|
+
end
|
88
|
+
end
|
89
|
+
|
52
90
|
describe "::query_uri" do
|
53
91
|
it "returns a URI path containing the search resource path and index" do
|
54
92
|
subject.query_uri(:nodes).should eql("search/nodes")
|
data/spec/unit/ridley_spec.rb
CHANGED
@@ -14,5 +14,103 @@ describe Ridley do
|
|
14
14
|
subject.new(config).should eql(client)
|
15
15
|
end
|
16
16
|
end
|
17
|
+
|
18
|
+
describe "from_chef_config" do
|
19
|
+
let(:chef_config) do
|
20
|
+
%(
|
21
|
+
node_name "username"
|
22
|
+
client_key "username.pem"
|
23
|
+
validation_client_name "validator"
|
24
|
+
validation_key "validator.pem"
|
25
|
+
chef_server_url "https://api.opscode.com"
|
26
|
+
cache_options(:path => "~/.chef/checksums")
|
27
|
+
syntax_check_cache_path "/foo/bar"
|
28
|
+
)
|
29
|
+
end
|
30
|
+
|
31
|
+
let(:client) { double('client') }
|
32
|
+
let(:path) { tmp_path.join('config.rb').to_s }
|
33
|
+
|
34
|
+
before do
|
35
|
+
Ridley::Client.stub(:new).and_return(client)
|
36
|
+
File.open(path, 'w') { |f| f.write(chef_config) }
|
37
|
+
end
|
38
|
+
|
39
|
+
it "creates a Ridley connection from the Chef config" do
|
40
|
+
Ridley::Client.should_receive(:new).with({
|
41
|
+
client_key: 'username.pem',
|
42
|
+
client_name: 'username',
|
43
|
+
validator_client: 'validator',
|
44
|
+
validator_path: 'validator.pem',
|
45
|
+
server_url: 'https://api.opscode.com',
|
46
|
+
|
47
|
+
cookbook_copyright: 'YOUR_NAME',
|
48
|
+
cookbook_email: 'YOUR_EMAIL',
|
49
|
+
cookbook_license: 'reserved',
|
50
|
+
|
51
|
+
knife: {},
|
52
|
+
|
53
|
+
syntax_check_cache_path: "/foo/bar",
|
54
|
+
cache_options: { path: "~/.chef/checksums" },
|
55
|
+
}).and_return(nil)
|
56
|
+
|
57
|
+
subject.from_chef_config(path)
|
58
|
+
end
|
59
|
+
|
60
|
+
it "allows the user to override attributes" do
|
61
|
+
Ridley::Client.should_receive(:new).with({
|
62
|
+
client_key: 'bacon.pem',
|
63
|
+
client_name: 'bacon',
|
64
|
+
validator_client: 'validator',
|
65
|
+
validator_path: 'validator.pem',
|
66
|
+
server_url: 'https://api.opscode.com',
|
67
|
+
|
68
|
+
cookbook_copyright: 'YOUR_NAME',
|
69
|
+
cookbook_email: 'YOUR_EMAIL',
|
70
|
+
cookbook_license: 'reserved',
|
71
|
+
|
72
|
+
knife: {},
|
73
|
+
|
74
|
+
syntax_check_cache_path: "/foo/bar",
|
75
|
+
cache_options: { path: "~/.chef/checksums" },
|
76
|
+
})
|
77
|
+
|
78
|
+
subject.from_chef_config(path, client_key: 'bacon.pem', client_name: 'bacon')
|
79
|
+
end
|
80
|
+
|
81
|
+
context "when the config location isn't explicitly specified" do
|
82
|
+
before do
|
83
|
+
dot_chef = tmp_path.join('.chef')
|
84
|
+
knife_rb = dot_chef.join('knife.rb')
|
85
|
+
|
86
|
+
FileUtils.mkdir_p(dot_chef)
|
87
|
+
File.open(knife_rb, 'w') { |f| f.write(chef_config) }
|
88
|
+
end
|
89
|
+
|
90
|
+
it "does a knife.rb search" do
|
91
|
+
Ridley::Client.should_receive(:new).with({
|
92
|
+
client_key: 'username.pem',
|
93
|
+
client_name: 'username',
|
94
|
+
validator_client: 'validator',
|
95
|
+
validator_path: 'validator.pem',
|
96
|
+
server_url: 'https://api.opscode.com',
|
97
|
+
|
98
|
+
cookbook_copyright: 'YOUR_NAME',
|
99
|
+
cookbook_email: 'YOUR_EMAIL',
|
100
|
+
cookbook_license: 'reserved',
|
101
|
+
|
102
|
+
knife: {},
|
103
|
+
|
104
|
+
syntax_check_cache_path: "/foo/bar",
|
105
|
+
cache_options: { path: "~/.chef/checksums" },
|
106
|
+
}).and_return(nil)
|
107
|
+
|
108
|
+
Dir.chdir(tmp_path) do
|
109
|
+
ENV['PWD'] = Dir.pwd
|
110
|
+
subject.from_chef_config
|
111
|
+
end
|
112
|
+
end
|
113
|
+
end
|
114
|
+
end
|
17
115
|
end
|
18
116
|
end
|
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: 1.
|
4
|
+
version: 1.3.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: 2013-
|
12
|
+
date: 2013-07-03 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: addressable
|
@@ -39,6 +39,20 @@ dependencies:
|
|
39
39
|
- - ~>
|
40
40
|
- !ruby/object:Gem::Version
|
41
41
|
version: '0.1'
|
42
|
+
- !ruby/object:Gem::Dependency
|
43
|
+
name: buff-config
|
44
|
+
requirement: !ruby/object:Gem::Requirement
|
45
|
+
requirements:
|
46
|
+
- - ~>
|
47
|
+
- !ruby/object:Gem::Version
|
48
|
+
version: '0.2'
|
49
|
+
type: :runtime
|
50
|
+
prerelease: false
|
51
|
+
version_requirements: !ruby/object:Gem::Requirement
|
52
|
+
requirements:
|
53
|
+
- - ~>
|
54
|
+
- !ruby/object:Gem::Version
|
55
|
+
version: '0.2'
|
42
56
|
- !ruby/object:Gem::Dependency
|
43
57
|
name: buff-extensions
|
44
58
|
requirement: !ruby/object:Gem::Requirement
|
@@ -273,6 +287,7 @@ files:
|
|
273
287
|
- lib/ridley/bootstrap_context/windows.rb
|
274
288
|
- lib/ridley/chef.rb
|
275
289
|
- lib/ridley/chef/chefignore.rb
|
290
|
+
- lib/ridley/chef/config.rb
|
276
291
|
- lib/ridley/chef/cookbook.rb
|
277
292
|
- lib/ridley/chef/cookbook/metadata.rb
|
278
293
|
- lib/ridley/chef/cookbook/syntax_check.rb
|
@@ -418,7 +433,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
418
433
|
version: '0'
|
419
434
|
requirements: []
|
420
435
|
rubyforge_project:
|
421
|
-
rubygems_version: 2.0.
|
436
|
+
rubygems_version: 2.0.3
|
422
437
|
signing_key:
|
423
438
|
specification_version: 4
|
424
439
|
summary: A reliable Chef API client with a clean syntax
|