ridley 1.3.2 → 1.4.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/LICENSE +1 -1
- data/README.md +205 -130
- data/lib/ridley/chef/chefignore.rb +38 -64
- data/lib/ridley/chef/cookbook.rb +11 -4
- data/lib/ridley/resources/cookbook_resource.rb +1 -1
- data/lib/ridley/version.rb +1 -1
- data/ridley.gemspec +2 -1
- data/spec/acceptance/cookbook_resource_spec.rb +2 -2
- data/spec/fixtures/chefignore +3 -8
- data/spec/fixtures/example_cookbook/Guardfile +1 -0
- data/spec/fixtures/example_cookbook/ignores/magic.rb +1 -0
- data/spec/fixtures/example_cookbook/ignores/ok.txt +1 -0
- data/spec/fixtures/example_cookbook/metadata.rb +1 -1
- data/spec/unit/ridley/chef/chefignore_spec.rb +20 -32
- data/spec/unit/ridley/resources/cookbook_resource_spec.rb +28 -1
- metadata +23 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d49b01c05183839d7cef30131ba300c890180655
|
4
|
+
data.tar.gz: 402b0fbdbf265d4f070803bc80833538ec1dbf72
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c00aefbe3246307695bb8dd78c8f97ded171b4e5dc0c7861adfe1f5a8f292558d6ae45d94e37cce0c3a6a8e52892a949e02840d028f7595d24473c6d6a4eca79
|
7
|
+
data.tar.gz: 622d8a1ebf053ead22c1310e46663ec4ee75021b31499198e8cd57dd3b7f2121f7eff6eb6bb8b943c80f79bb4d3c18050a877ad5705f8ffa8562351c2d7b8daa
|
data/LICENSE
CHANGED
data/README.md
CHANGED
@@ -6,37 +6,51 @@
|
|
6
6
|
|
7
7
|
A reliable Chef API client with a clean syntax
|
8
8
|
|
9
|
-
|
9
|
+
Installation
|
10
|
+
------------
|
11
|
+
Add Ridley to your `Gemfile`:
|
10
12
|
|
11
|
-
|
13
|
+
```ruby
|
14
|
+
gem 'ridley'
|
15
|
+
```
|
12
16
|
|
13
|
-
|
17
|
+
And run the `bundle` command to install. Alternatively, you can install the gem directly:
|
18
|
+
|
19
|
+
$ gem install ridley
|
14
20
|
|
15
|
-
|
21
|
+
Usage
|
22
|
+
-----
|
23
|
+
Before you can use Ridley, you must require it in your application:
|
16
24
|
|
17
|
-
|
25
|
+
```ruby
|
26
|
+
require 'ridley'
|
27
|
+
```
|
18
28
|
|
19
|
-
|
29
|
+
### Creating a new Ridley client
|
20
30
|
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
31
|
+
```ruby
|
32
|
+
ridley = Ridley.new(
|
33
|
+
server_url: "https://api.opscode.com/organizations/ridley",
|
34
|
+
client_name: "reset",
|
35
|
+
client_key: "/Users/reset/.chef/reset.pem"
|
36
|
+
)
|
37
|
+
```
|
26
38
|
|
27
39
|
Creating a new instance of Ridley requires the following options:
|
28
40
|
|
29
|
-
|
30
|
-
|
31
|
-
|
41
|
+
- server_url
|
42
|
+
- client_name
|
43
|
+
- client_key
|
32
44
|
|
33
45
|
Ridley exposes a number of functions that return resources which you can use to retrieve or create objects on your Chef server. Here is a simple example of getting a list of all the roles on your Chef server.
|
34
46
|
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
47
|
+
```ruby
|
48
|
+
ridley = Ridley.new(...)
|
49
|
+
ridley.role.all #=> [
|
50
|
+
#<Ridley::RoleObject chef_id:motherbrain_srv ...>,
|
51
|
+
#<Ridley::RoleObject chef_id:motherbrain_proxy ...>
|
52
|
+
]
|
53
|
+
```
|
40
54
|
|
41
55
|
For more information scroll down to the Manipulating Chef Resources section of this README.
|
42
56
|
|
@@ -91,29 +105,35 @@ ridley.role.all #=> [
|
|
91
105
|
|
92
106
|
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.
|
93
107
|
|
94
|
-
|
95
|
-
|
96
|
-
|
108
|
+
```ruby
|
109
|
+
Ridley.open(server_url: "https://api.opscode.com", ...) do |r|
|
110
|
+
r.node.all
|
111
|
+
end
|
112
|
+
```
|
97
113
|
|
98
|
-
|
114
|
+
### Manipulating Chef Resources
|
99
115
|
|
100
|
-
Resources are access by instance functions on a new instance of Ridley::Client
|
116
|
+
Resources are access by instance functions on a new instance of `Ridley::Client`.
|
101
117
|
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
118
|
+
```ruby
|
119
|
+
ridley = Ridley.new(...)
|
120
|
+
ridley.client #=> Ridley::ClientResource
|
121
|
+
ridley.cookbook #=> Ridley::CookbookResource
|
122
|
+
ridley.data_bag #=> Ridley::DataBagResource
|
123
|
+
ridley.environment #=> Ridley::EnvironmentResource
|
124
|
+
ridley.node #=> Ridley::NodeResource
|
125
|
+
ridley.role #=> Ridley::RoleResource
|
126
|
+
ridley.sandbox #=> Ridley::SandboxResource
|
127
|
+
ridley.search #=> Ridley::SearchResource
|
128
|
+
```
|
111
129
|
|
112
130
|
DataBagItems are the only exception to this rule. The DataBagItem resource is accessed from a DataBagObject
|
113
131
|
|
114
|
-
|
115
|
-
|
116
|
-
|
132
|
+
```ruby
|
133
|
+
data_bag = ridley.data_bag.find("my_data")
|
134
|
+
data_bag.item #=> Ridley::DataBagItemResource
|
135
|
+
data_bag.item.find("my_item") #=> Ridley::DataBagItemObject
|
136
|
+
```
|
117
137
|
|
118
138
|
### CRUD
|
119
139
|
|
@@ -125,115 +145,148 @@ A new Chef Object can be created in a three ways
|
|
125
145
|
|
126
146
|
_With the `#create` function and an attribute hash_
|
127
147
|
|
128
|
-
|
129
|
-
|
148
|
+
```ruby
|
149
|
+
ridley = Ridley.new(...)
|
150
|
+
ridley.role.create(name: "reset") #=> #<Ridley::RoleObject: chef_id:reset>
|
151
|
+
```
|
130
152
|
|
131
153
|
_With the `#create` function and an instance of a Chef Object_
|
132
154
|
|
133
|
-
|
134
|
-
|
135
|
-
|
155
|
+
```ruby
|
156
|
+
obj = ridley.role.new
|
157
|
+
obj.name = "reset"
|
158
|
+
ridley.role.create(obj) #=> #<Ridley::RoleObject: chef_id:reset>
|
159
|
+
```
|
136
160
|
|
137
161
|
_With the `#save` function on an instance of a Chef Object_
|
138
162
|
|
139
|
-
|
140
|
-
|
141
|
-
|
163
|
+
```ruby
|
164
|
+
obj = ridley.role.new
|
165
|
+
obj.name = "reset"
|
166
|
+
obj.save #=> #<Ridley::RoleObject: chef_id:reset>
|
167
|
+
```
|
142
168
|
|
143
169
|
Each of these methods produce an identical object on the Chef server. It is up to you on how you'd like to create new resources.
|
144
170
|
|
145
|
-
|
171
|
+
#### Read
|
146
172
|
|
147
173
|
Most resources have two read functions
|
148
174
|
|
149
175
|
- `#all` for listing all the Chef Objects
|
150
176
|
- `#find` for retrieving a specific Chef Object
|
151
177
|
|
152
|
-
|
178
|
+
##### Listing
|
153
179
|
|
154
180
|
If you wanted to get a list of all of the roles on your Chef server
|
155
181
|
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
182
|
+
```ruby
|
183
|
+
ridley = Ridley.new(...)
|
184
|
+
ridley.role.all #=> [
|
185
|
+
#<Ridley::RoleObject chef_id:motherbrain_srv ...>,
|
186
|
+
#<Ridley::RoleObject chef_id:motherbrain_proxy ...>
|
187
|
+
]
|
188
|
+
```
|
162
189
|
|
163
|
-
|
190
|
+
##### Finding
|
164
191
|
|
165
192
|
If you want to retrieve a single role from the Chef server
|
166
193
|
|
167
|
-
|
168
|
-
|
194
|
+
```ruby
|
195
|
+
ridley = Ridley.new(...)
|
196
|
+
ridley.role.find("motherbrain_srv") #=> #<Ridley::RoleObject: chef_id:motherbrain_srv ...>
|
197
|
+
```
|
169
198
|
|
170
199
|
If the role does not exist on the Chef server then `nil` is returned
|
171
200
|
|
172
|
-
|
173
|
-
|
201
|
+
```ruby
|
202
|
+
ridley = Ridley.new(...)
|
203
|
+
ridley.role.find("not_there") #=> nil
|
204
|
+
```
|
174
205
|
|
175
|
-
|
206
|
+
#### Update
|
176
207
|
|
177
208
|
Updating a resource can be expressed in three ways
|
178
209
|
|
179
210
|
_With the `#update` function, the ID of the Object to update, and an attributes hash_
|
180
211
|
|
181
|
-
|
182
|
-
|
183
|
-
|
212
|
+
```ruby
|
213
|
+
ridley = Ridley.new(...)
|
214
|
+
ridley.role.update("motherbrain_srv", description: "testing updates") #=> #<Ridley::RoleObject chef_id:motherbrain_srv, description="testing updates" ...>
|
215
|
+
```
|
184
216
|
|
185
217
|
_With the `#update` function and an instance of a Chef Object_
|
186
218
|
|
187
|
-
|
188
|
-
|
219
|
+
```ruby
|
220
|
+
obj = ridley.role.find("motherbrain_srv")
|
221
|
+
obj.description = "chef object"
|
189
222
|
|
190
|
-
|
223
|
+
ridley.role.update(obj) #=> #<Ridley::RoleObject: chef_id:motherbrain_srv, description="chef object" ...
|
224
|
+
```
|
191
225
|
|
192
226
|
_With the `#save` function on an instance of a Chef Object_
|
193
227
|
|
194
|
-
|
195
|
-
|
196
|
-
|
228
|
+
```ruby
|
229
|
+
obj = ridley.role.find("reset")
|
230
|
+
obj.description = "saving an object"
|
231
|
+
obj.save #=> #<Ridley::RoleObject: chef_id:motherbrain_srv, description="saving an object" ...>
|
232
|
+
```
|
197
233
|
|
198
|
-
|
234
|
+
#### Destroy
|
199
235
|
|
200
236
|
Destroying a resource can be express in three ways
|
201
237
|
|
202
238
|
_With the `#delete` function and the ID of the Object to destroy_
|
203
239
|
|
204
|
-
|
205
|
-
|
240
|
+
```ruby
|
241
|
+
ridley = Ridley.new(...)
|
242
|
+
ridley.role.delete("motherbrain_srv") => #<Ridley::RoleObject: chef_id:motherbrain_srv ...>
|
243
|
+
```
|
206
244
|
|
207
245
|
_With the `#delete` function and a Chef Object_
|
208
246
|
|
209
|
-
|
210
|
-
|
247
|
+
```ruby
|
248
|
+
obj = ridley.role.find("motherbrain_srv")
|
249
|
+
ridley.role.delete(obj) => #<Ridley::RoleObject: chef_id:motherbrain_srv ...>
|
250
|
+
```
|
211
251
|
|
212
252
|
_With the `#destroy` function on an instance of a Chef Object_
|
213
253
|
|
214
|
-
|
215
|
-
|
254
|
+
```ruby
|
255
|
+
obj = conn.role.find("motherbrain_srv")
|
256
|
+
obj.destroy #=> true
|
257
|
+
```
|
258
|
+
|
259
|
+
Client Resource
|
260
|
+
---------------
|
216
261
|
|
217
|
-
## Client Resource
|
218
262
|
### Regenerating a client's private key
|
219
263
|
|
220
264
|
_With the `#regnerate_key` function and the ID of the Client to regenerate_
|
221
265
|
|
222
|
-
|
223
|
-
|
266
|
+
```ruby
|
267
|
+
ridley = Ridley.new(...)
|
268
|
+
ridley.client.regenerate_key("jamie") #=> #<Ridley::ClientObject: chef_id:"jamie", private_key="**HIDDEN***" ...>
|
269
|
+
```
|
224
270
|
|
225
271
|
_With the `#regenerate_key` function on an instance of a Client Object_
|
226
272
|
|
227
|
-
|
228
|
-
|
273
|
+
```ruby
|
274
|
+
obj = ridley.client.find("jamie")
|
275
|
+
obj.regenerate_key #=> #<Ridley::ClientObject: chef_id:"jamie", private_key="**HIDDEN***" ...>
|
276
|
+
```
|
277
|
+
|
278
|
+
Cookbook Resource
|
279
|
+
-----------------
|
229
280
|
|
230
|
-
|
231
|
-
|
281
|
+
Data Bag Resource
|
282
|
+
-----------------
|
232
283
|
|
233
284
|
A data bag is managed exactly the same as any other Chef resource
|
234
285
|
|
235
|
-
|
236
|
-
|
286
|
+
```ruby
|
287
|
+
ridley = Ridley.new(...)
|
288
|
+
ridley.data_bag.create(name: "ridley-test")
|
289
|
+
```
|
237
290
|
|
238
291
|
You can create, delete, update, or retrieve a data bag exactly how you would expect if you read through the
|
239
292
|
Manipulating Chef Resources portion of this document.
|
@@ -242,42 +295,53 @@ Unlike a role, node, client, or environment, a data bag is a container for other
|
|
242
295
|
|
243
296
|
### Creating a Data Bag Item
|
244
297
|
|
245
|
-
|
246
|
-
|
298
|
+
```ruby
|
299
|
+
ridley = Ridley.new(...)
|
300
|
+
data_bag = ridley.data_bag.create(name: "ridley-test")
|
247
301
|
|
248
|
-
|
249
|
-
|
302
|
+
data_bag.item.create(id: "appconfig", host: "reset.local", user: "jamie") #=> #<Ridley::DataBagItemObject: chef_id:appconfig, host="reset.local", user="jamie">
|
303
|
+
```
|
304
|
+
|
305
|
+
Environment Resource
|
306
|
+
--------------------
|
250
307
|
|
251
|
-
## Environment Resource
|
252
|
-
## Node Resource
|
253
308
|
### Setting Attributes
|
254
309
|
|
255
310
|
Setting a default environment attribute is just like setting a node level default attribute
|
256
311
|
|
257
|
-
|
258
|
-
|
259
|
-
|
260
|
-
|
312
|
+
```ruby
|
313
|
+
ridley = Ridley.new(...)
|
314
|
+
production_env = ridley.environment.find("production")
|
315
|
+
production_env.set_default_attribute("my_app.proxy.enabled", false)
|
316
|
+
production_env.save #=> true
|
317
|
+
```
|
261
318
|
|
262
319
|
And the same goes for setting an environment level override attribute
|
263
320
|
|
264
|
-
|
265
|
-
|
321
|
+
```ruby
|
322
|
+
production_env.set_override_attribute("my_app.proxy.enabled", false)
|
323
|
+
production_env.save #=> true
|
324
|
+
```
|
325
|
+
|
326
|
+
Node Resource
|
327
|
+
-------------
|
266
328
|
|
267
329
|
### Bootstrapping Unix nodes
|
268
330
|
|
269
|
-
|
270
|
-
|
271
|
-
|
272
|
-
|
273
|
-
|
274
|
-
|
275
|
-
|
276
|
-
|
277
|
-
|
278
|
-
|
279
|
-
|
280
|
-
|
331
|
+
```ruby
|
332
|
+
ridley = Ridley.new(
|
333
|
+
server_url: "https://api.opscode.com",
|
334
|
+
organization: "vialstudios",
|
335
|
+
validator_client: "vialstudios-validator",
|
336
|
+
validator_path: "/Users/reset/.chef/vialstudios-validator.pem",
|
337
|
+
ssh: {
|
338
|
+
user: "vagrant",
|
339
|
+
password: "vagrant"
|
340
|
+
}
|
341
|
+
)
|
342
|
+
|
343
|
+
ridley.node.bootstrap("33.33.33.10", "33.33.33.11")
|
344
|
+
```
|
281
345
|
|
282
346
|
### Bootstrapping Windows Nodes
|
283
347
|
|
@@ -308,44 +372,55 @@ echo "$PSSessionOption = New-PSSessionOption -OpenTimeout 0 -CancelTimeout 0 -Id
|
|
308
372
|
Verify the PowerShell settings by opening up the PowerShell Console and entering `$PSSessionOption` and ensure those values are set, and that there are no errors output.
|
309
373
|
|
310
374
|
The following links offer some information about configuring a machine's PowerShell settings:
|
311
|
-
|
312
|
-
|
313
|
-
|
375
|
+
- [PowerShell Profiles](http://technet.microsoft.com/en-us/library/ee692764.aspx)
|
376
|
+
- [The $PSSessionOptions Preference Variable](http://technet.microsoft.com/library/hh847796.aspx)
|
377
|
+
- [Creating a new PSSessionOption](http://technet.microsoft.com/en-us/library/hh849703.aspx)
|
314
378
|
|
315
379
|
You may also want to tweak your Windows boxes a bit more ex: turning UAC off, turning off the Windows Firewall.
|
316
380
|
|
317
|
-
|
381
|
+
Role Resource
|
382
|
+
-------------
|
383
|
+
|
318
384
|
### Role Attributes
|
319
385
|
|
320
386
|
Setting role attributes is just like setting node and environment attributes
|
321
387
|
|
322
|
-
|
323
|
-
|
324
|
-
|
325
|
-
|
388
|
+
```ruby
|
389
|
+
ridley = Ridley.new(...)
|
390
|
+
my_app_role = ridley.role.find("my_app")
|
391
|
+
my_app_role.set_default_attribute("my_app.proxy.enabled", false)
|
392
|
+
my_app_role.save #=> true
|
393
|
+
```
|
326
394
|
|
327
395
|
And the same goes for setting an environment level override attribute
|
328
396
|
|
329
|
-
|
330
|
-
|
397
|
+
```ruby
|
398
|
+
my_app_role.set_override_attribute("my_app.proxy.enabled", false)
|
399
|
+
my_app_role.save #=> true
|
400
|
+
```
|
331
401
|
|
332
|
-
|
333
|
-
|
402
|
+
Sandbox Resource
|
403
|
+
----------------
|
334
404
|
|
335
|
-
|
336
|
-
|
337
|
-
ridley.search(:node, "name:ridley-test.local")
|
405
|
+
Search Resource
|
406
|
+
---------------
|
338
407
|
|
339
|
-
|
408
|
+
```ruby
|
409
|
+
ridley = Ridley.new(...)
|
410
|
+
ridley.search(:node)
|
411
|
+
ridley.search(:node, "name:ridley-test.local")
|
412
|
+
```
|
340
413
|
|
341
|
-
|
342
|
-
* role
|
343
|
-
* client
|
344
|
-
* environment
|
414
|
+
Search will return an array of the appropriate Chef Objects if one of the default indices is specified. The indices are
|
345
415
|
|
346
|
-
|
416
|
+
- node
|
417
|
+
- role
|
418
|
+
- client
|
419
|
+
- environment
|
347
420
|
|
348
|
-
|
349
|
-
|
421
|
+
Authors and Contributors
|
422
|
+
------------------------
|
423
|
+
- Jamie Winsor (<jamie@vialstudios.com>)
|
424
|
+
- Kyle Allan (<kallan@riotgames.com>)
|
350
425
|
|
351
426
|
Thank you to all of our [Contributors](https://github.com/RiotGames/ridley/graphs/contributors), testers, and users.
|
@@ -1,76 +1,50 @@
|
|
1
|
-
|
2
|
-
# Borrowed and modified from:
|
3
|
-
# {https://raw.github.com/opscode/chef/62f9b0e3be8e22eef092163c331b7d3f8d350f94/lib/chef/cookbook/chefignore.rb}
|
4
|
-
#
|
5
|
-
# Copyright:: Copyright (c) 2011 Opscode, Inc.
|
6
|
-
#
|
7
|
-
# Licensed under the Apache License, Version 2.0 (the "License");
|
8
|
-
# you may not use this file except in compliance with the License.
|
9
|
-
# You may obtain a copy of the License at
|
10
|
-
#
|
11
|
-
# http://www.apache.org/licenses/LICENSE-2.0
|
12
|
-
#
|
13
|
-
# Unless required by applicable law or agreed to in writing, software
|
14
|
-
# distributed under the License is distributed on an "AS IS" BASIS,
|
15
|
-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
16
|
-
# See the License for the specific language governing permissions and
|
17
|
-
# limitations under the License.
|
18
|
-
class Chefignore
|
19
|
-
class << self
|
20
|
-
# Traverse a path in relative context to find a Chefignore file
|
21
|
-
#
|
22
|
-
# @param [String] path
|
23
|
-
# path to traverse
|
24
|
-
#
|
25
|
-
# @return [String, nil]
|
26
|
-
def find_relative_to(path)
|
27
|
-
[
|
28
|
-
File.join(path, FILENAME),
|
29
|
-
File.join(path, 'cookbooks', FILENAME)
|
30
|
-
].find { |f| File.exists?(f) }
|
31
|
-
end
|
32
|
-
end
|
33
|
-
|
34
|
-
FILENAME = "chefignore".freeze
|
35
|
-
COMMENTS_AND_WHITESPACE = /^\s*(?:#.*)?$/
|
36
|
-
|
37
|
-
attr_reader :ignores
|
38
|
-
|
39
|
-
def initialize(ignore_file_or_repo)
|
40
|
-
@ignore_file = find_ignore_file(ignore_file_or_repo)
|
41
|
-
@ignores = parse_ignore_file
|
42
|
-
end
|
1
|
+
require 'buff/ignore'
|
43
2
|
|
44
|
-
|
45
|
-
|
46
|
-
|
3
|
+
module Ridley::Chef
|
4
|
+
class Chefignore < Buff::Ignore::IgnoreFile
|
5
|
+
include Ridley::Logging
|
6
|
+
|
7
|
+
# The filename of the chefignore
|
8
|
+
#
|
9
|
+
# @return [String]
|
10
|
+
FILENAME = 'chefignore'.freeze
|
11
|
+
|
12
|
+
# Create a new chefignore
|
13
|
+
#
|
14
|
+
# @param [#to_s] path
|
15
|
+
# the path to find a chefignore from (default: `Dir.pwd`)
|
16
|
+
def initialize(path = Dir.pwd)
|
17
|
+
ignore = chefignore(path)
|
18
|
+
|
19
|
+
if ignore
|
20
|
+
log.debug "Using Chefignore at '#{ignore}'"
|
21
|
+
else
|
22
|
+
log.debug "Could not find a Chefignore at '#{path}'"
|
47
23
|
end
|
48
|
-
end
|
49
24
|
|
50
|
-
|
51
|
-
@ignores.any? { |glob| File.fnmatch?(glob, file_name) }
|
25
|
+
super(ignore, base: path)
|
52
26
|
end
|
53
27
|
|
54
28
|
private
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
29
|
+
# Find the chefignore file in the current directory
|
30
|
+
#
|
31
|
+
# @return [String, nil]
|
32
|
+
# the path to the chefignore file or nil if one was not
|
33
|
+
# found
|
34
|
+
def chefignore(path)
|
35
|
+
Pathname.new(path).ascend do |dir|
|
36
|
+
next unless dir.directory?
|
37
|
+
|
38
|
+
[
|
39
|
+
dir.join(FILENAME),
|
40
|
+
dir.join('cookbooks', FILENAME),
|
41
|
+
dir.join('.chef', FILENAME),
|
42
|
+
].each do |possible|
|
43
|
+
return possible.expand_path.to_s if possible.exist?
|
62
44
|
end
|
63
45
|
end
|
64
46
|
|
65
|
-
|
66
|
-
end
|
67
|
-
|
68
|
-
def find_ignore_file(path)
|
69
|
-
if File.basename(path) =~ /#{FILENAME}/
|
70
|
-
path
|
71
|
-
else
|
72
|
-
File.join(path, FILENAME)
|
73
|
-
end
|
47
|
+
return nil
|
74
48
|
end
|
75
49
|
end
|
76
50
|
end
|
data/lib/ridley/chef/cookbook.rb
CHANGED
@@ -96,7 +96,7 @@ module Ridley::Chef
|
|
96
96
|
root_files: Array.new
|
97
97
|
)
|
98
98
|
@frozen = false
|
99
|
-
@chefignore = Ridley::Chef::Chefignore.new(@path)
|
99
|
+
@chefignore = Ridley::Chef::Chefignore.new(@path) rescue nil
|
100
100
|
|
101
101
|
load_files
|
102
102
|
end
|
@@ -210,10 +210,9 @@ module Ridley::Chef
|
|
210
210
|
|
211
211
|
# @return [Array]
|
212
212
|
attr_reader :files
|
213
|
-
# @return [Ridley::Chef::Chefignore]
|
214
|
-
attr_reader :chefignore
|
215
213
|
|
216
|
-
|
214
|
+
# @return [Ridley::Chef::Chefignore, nil]
|
215
|
+
attr_reader :chefignore
|
217
216
|
|
218
217
|
def load_files
|
219
218
|
load_shallow(:recipes, 'recipes', '*.rb')
|
@@ -263,5 +262,13 @@ module Ridley::Chef
|
|
263
262
|
def syntax_checker
|
264
263
|
@syntax_checker ||= Cookbook::SyntaxCheck.new(path.to_s)
|
265
264
|
end
|
265
|
+
|
266
|
+
# Determine if the given file should be ignored by the chefignore
|
267
|
+
#
|
268
|
+
# @return [Boolean]
|
269
|
+
# true if it should be ignored, false otherwise
|
270
|
+
def ignored?(file)
|
271
|
+
!!chefignore && chefignore.ignored?(file)
|
272
|
+
end
|
266
273
|
end
|
267
274
|
end
|
data/lib/ridley/version.rb
CHANGED
data/ridley.gemspec
CHANGED
@@ -3,7 +3,7 @@ require File.expand_path('../lib/ridley/version', __FILE__)
|
|
3
3
|
|
4
4
|
Gem::Specification.new do |s|
|
5
5
|
s.authors = ["Jamie Winsor", "Kyle Allan"]
|
6
|
-
s.email = ["
|
6
|
+
s.email = ["jamie@vialstudios.com", "kallan@riotgames.com"]
|
7
7
|
s.description = %q{A reliable Chef API client with a clean syntax}
|
8
8
|
s.summary = s.description
|
9
9
|
s.homepage = "https://github.com/RiotGames/ridley"
|
@@ -21,6 +21,7 @@ Gem::Specification.new do |s|
|
|
21
21
|
s.add_dependency 'varia_model', '~> 0.1'
|
22
22
|
s.add_dependency 'buff-config', '~> 0.2'
|
23
23
|
s.add_dependency 'buff-extensions', '~> 0.3'
|
24
|
+
s.add_dependency 'buff-ignore', '~> 1.1'
|
24
25
|
s.add_dependency 'buff-shell_out', '~> 0.1'
|
25
26
|
s.add_dependency 'celluloid', '~> 0.14.0'
|
26
27
|
s.add_dependency 'celluloid-io', '~> 0.14.0'
|
@@ -26,7 +26,7 @@ describe "Client API operations", type: "acceptance" do
|
|
26
26
|
describe "uploading a cookbook" do
|
27
27
|
let(:path) { fixtures_path.join("example_cookbook") }
|
28
28
|
|
29
|
-
it "uploads the entire contents of the cookbook in the given path" do
|
29
|
+
it "uploads the entire contents of the cookbook in the given path, applying chefignore" do
|
30
30
|
subject.upload(path)
|
31
31
|
cookbook = subject.find("example_cookbook", "0.1.0")
|
32
32
|
|
@@ -38,7 +38,7 @@ describe "Client API operations", type: "acceptance" do
|
|
38
38
|
cookbook.recipes.should have(1).item
|
39
39
|
cookbook.resources.should have(1).item
|
40
40
|
cookbook.templates.should have(1).item
|
41
|
-
cookbook.root_files.should have(
|
41
|
+
cookbook.root_files.should have(1).items
|
42
42
|
end
|
43
43
|
end
|
44
44
|
|
data/spec/fixtures/chefignore
CHANGED
@@ -0,0 +1 @@
|
|
1
|
+
# This should be ignored by chefignore
|
@@ -0,0 +1 @@
|
|
1
|
+
# I should never see this file
|
@@ -0,0 +1 @@
|
|
1
|
+
This one is okay, though
|
@@ -1,6 +1,6 @@
|
|
1
1
|
name "example_cookbook"
|
2
2
|
maintainer "Jamie Winsor"
|
3
|
-
maintainer_email "
|
3
|
+
maintainer_email "jamie@vialstudios.com"
|
4
4
|
license "Apache 2.0"
|
5
5
|
description "Installs/Configures example_cookbook"
|
6
6
|
long_description IO.read(File.join(File.dirname(__FILE__), "README.md"))
|
@@ -1,40 +1,28 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe Ridley::Chef::Chefignore do
|
4
|
-
describe
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
FileUtils.touch(path.join('chefignore'))
|
13
|
-
subject.find_relative_to(path)
|
14
|
-
end
|
15
|
-
|
16
|
-
it "finds a chefignore file relative to the given path" do
|
17
|
-
FileUtils.mkdir_p(path.join('cookbooks'))
|
18
|
-
FileUtils.touch(path.join('cookbooks', 'chefignore'))
|
19
|
-
subject.find_relative_to(path)
|
20
|
-
end
|
4
|
+
describe '.initialize' do
|
5
|
+
let(:path) { tmp_path.join('chefignore-test') }
|
6
|
+
before { FileUtils.mkdir_p(path) }
|
7
|
+
|
8
|
+
it 'finds the nearest chefignore' do
|
9
|
+
target = path.join('chefignore').to_s
|
10
|
+
FileUtils.touch(target)
|
11
|
+
expect(described_class.new(path).filepath).to eq(target)
|
21
12
|
end
|
22
|
-
end
|
23
|
-
|
24
|
-
subject { described_class.new(File.join(fixtures_path)) }
|
25
13
|
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
subject.remove_ignores_from(file_list).should == %w[recipes/dontignoreme.rb]
|
33
|
-
end
|
14
|
+
it 'finds a chefignore in the `cookbooks` directory' do
|
15
|
+
target = path.join('cookbooks', 'chefignore').to_s
|
16
|
+
FileUtils.mkdir_p(path.join('cookbooks'))
|
17
|
+
FileUtils.touch(target)
|
18
|
+
expect(described_class.new(path).filepath).to eq(target)
|
19
|
+
end
|
34
20
|
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
21
|
+
it 'finds a chefignore in the `.chef` directory' do
|
22
|
+
target = path.join('.chef', 'chefignore').to_s
|
23
|
+
FileUtils.mkdir_p(path.join('.chef'))
|
24
|
+
FileUtils.touch(target)
|
25
|
+
expect(described_class.new(path).filepath).to eq(target)
|
26
|
+
end
|
39
27
|
end
|
40
28
|
end
|
@@ -116,7 +116,34 @@ describe Ridley::CookbookResource do
|
|
116
116
|
end
|
117
117
|
|
118
118
|
describe "#upload" do
|
119
|
-
|
119
|
+
let(:name) { "upload_test" }
|
120
|
+
let(:cookbook_path) { fixtures_path.join('example_cookbook') }
|
121
|
+
let(:sandbox_resource) { double('sandbox_resource') }
|
122
|
+
let(:sandbox) { double('sandbox', upload: nil, commit: nil) }
|
123
|
+
|
124
|
+
before do
|
125
|
+
subject.stub(:sandbox_resource).and_return(sandbox_resource)
|
126
|
+
end
|
127
|
+
|
128
|
+
it 'does not include files that are ignored' do
|
129
|
+
# These are the SHAs for the files. It's not possible to check that
|
130
|
+
# the ignored files weren't uploaded, so we just check that the
|
131
|
+
# non-ignored files are the ONLY thing uploaded
|
132
|
+
sandbox_resource.should_receive(:create).with([
|
133
|
+
"211a3a8798d4acd424af15ff8a2e28a5",
|
134
|
+
"75077ba33d2887cc1746d1ef716bf8b7",
|
135
|
+
"7b1ebd2ff580ca9dc46fb27ec1653bf2",
|
136
|
+
"a39eb80def9804f4b118099697cc2cd2",
|
137
|
+
"b70ba735f3af47e5d6fc71b91775b34c",
|
138
|
+
"cafb6869fca13f5c36f24a60de8fb982",
|
139
|
+
"dbf3a6c4ab68a86172be748aced9f46e",
|
140
|
+
"dc6461b5da25775f3ef6a9cc1f6cff9f",
|
141
|
+
"e77856b411b6dcbb2c76c281091ad922",
|
142
|
+
"e9a2e24281cfbd6be0a6b1af3b6d277e",
|
143
|
+
]).and_return(sandbox)
|
144
|
+
|
145
|
+
subject.upload(cookbook_path, validate: false)
|
146
|
+
end
|
120
147
|
end
|
121
148
|
|
122
149
|
describe "#update" do
|
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.4.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-07-
|
12
|
+
date: 2013-07-19 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: addressable
|
@@ -67,6 +67,20 @@ dependencies:
|
|
67
67
|
- - ~>
|
68
68
|
- !ruby/object:Gem::Version
|
69
69
|
version: '0.3'
|
70
|
+
- !ruby/object:Gem::Dependency
|
71
|
+
name: buff-ignore
|
72
|
+
requirement: !ruby/object:Gem::Requirement
|
73
|
+
requirements:
|
74
|
+
- - ~>
|
75
|
+
- !ruby/object:Gem::Version
|
76
|
+
version: '1.1'
|
77
|
+
type: :runtime
|
78
|
+
prerelease: false
|
79
|
+
version_requirements: !ruby/object:Gem::Requirement
|
80
|
+
requirements:
|
81
|
+
- - ~>
|
82
|
+
- !ruby/object:Gem::Version
|
83
|
+
version: '1.1'
|
70
84
|
- !ruby/object:Gem::Dependency
|
71
85
|
name: buff-shell_out
|
72
86
|
requirement: !ruby/object:Gem::Requirement
|
@@ -265,7 +279,7 @@ dependencies:
|
|
265
279
|
version: '0.1'
|
266
280
|
description: A reliable Chef API client with a clean syntax
|
267
281
|
email:
|
268
|
-
-
|
282
|
+
- jamie@vialstudios.com
|
269
283
|
- kallan@riotgames.com
|
270
284
|
executables: []
|
271
285
|
extensions: []
|
@@ -353,11 +367,14 @@ files:
|
|
353
367
|
- spec/acceptance/search_resource_spec.rb
|
354
368
|
- spec/fixtures/chefignore
|
355
369
|
- spec/fixtures/encrypted_data_bag_secret
|
370
|
+
- spec/fixtures/example_cookbook/Guardfile
|
356
371
|
- spec/fixtures/example_cookbook/README.md
|
357
372
|
- spec/fixtures/example_cookbook/attributes/default.rb
|
358
373
|
- spec/fixtures/example_cookbook/definitions/bad_def.rb
|
359
374
|
- spec/fixtures/example_cookbook/files/default/file.h
|
360
375
|
- spec/fixtures/example_cookbook/files/ubuntu/file.h
|
376
|
+
- spec/fixtures/example_cookbook/ignores/magic.rb
|
377
|
+
- spec/fixtures/example_cookbook/ignores/ok.txt
|
361
378
|
- spec/fixtures/example_cookbook/libraries/my_lib.rb
|
362
379
|
- spec/fixtures/example_cookbook/metadata.rb
|
363
380
|
- spec/fixtures/example_cookbook/providers/defprovider.rb
|
@@ -449,11 +466,14 @@ test_files:
|
|
449
466
|
- spec/acceptance/search_resource_spec.rb
|
450
467
|
- spec/fixtures/chefignore
|
451
468
|
- spec/fixtures/encrypted_data_bag_secret
|
469
|
+
- spec/fixtures/example_cookbook/Guardfile
|
452
470
|
- spec/fixtures/example_cookbook/README.md
|
453
471
|
- spec/fixtures/example_cookbook/attributes/default.rb
|
454
472
|
- spec/fixtures/example_cookbook/definitions/bad_def.rb
|
455
473
|
- spec/fixtures/example_cookbook/files/default/file.h
|
456
474
|
- spec/fixtures/example_cookbook/files/ubuntu/file.h
|
475
|
+
- spec/fixtures/example_cookbook/ignores/magic.rb
|
476
|
+
- spec/fixtures/example_cookbook/ignores/ok.txt
|
457
477
|
- spec/fixtures/example_cookbook/libraries/my_lib.rb
|
458
478
|
- spec/fixtures/example_cookbook/metadata.rb
|
459
479
|
- spec/fixtures/example_cookbook/providers/defprovider.rb
|