chef-zero 1.6 → 1.6.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/lib/chef_zero/endpoints/cookbook_version_endpoint.rb +14 -6
- data/lib/chef_zero/rest_base.rb +1 -1
- data/lib/chef_zero/solr/query/range_query.rb +26 -14
- data/lib/chef_zero/version.rb +1 -1
- data/spec/search_spec.rb +32 -0
- metadata +15 -31
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 41f3262d55e2da6c2b9bf3afb8107fca976797ee
|
4
|
+
data.tar.gz: a5f9e8d5b1bc005a98b7eaad746c380aceec1aa8
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: dc7ad95473bb9fc9fc726d13984f2dd5de6b6ec24640476a1faba8b5845cdccdbf11a61debe62545cff7e5fd9f8cb69acd2fae99a7a11637b2826cc99c5dac2a
|
7
|
+
data.tar.gz: 8dfe749deeec3bf6b52acd96c794beaf2d7d805cc5f8b7fb8c4a7ef74c2ef4af2b22d9907dca6790e7226cbb354dcb37931d2a507ea8cd75dbb2ec35544e3a14
|
@@ -2,6 +2,7 @@ require 'json'
|
|
2
2
|
require 'chef_zero/endpoints/rest_object_endpoint'
|
3
3
|
require 'chef_zero/rest_error_response'
|
4
4
|
require 'chef_zero/data_normalizer'
|
5
|
+
require 'chef_zero/data_store/data_not_found_error'
|
5
6
|
|
6
7
|
module ChefZero
|
7
8
|
module Endpoints
|
@@ -42,7 +43,7 @@ module ChefZero
|
|
42
43
|
if existing_cookbook
|
43
44
|
missing_checksums = get_checksums(existing_cookbook) - get_checksums(request.body)
|
44
45
|
if missing_checksums.size > 0
|
45
|
-
hoover_unused_checksums(missing_checksums)
|
46
|
+
hoover_unused_checksums(missing_checksums, request)
|
46
47
|
end
|
47
48
|
end
|
48
49
|
|
@@ -58,10 +59,12 @@ module ChefZero
|
|
58
59
|
|
59
60
|
response = super(request)
|
60
61
|
cookbook_name = request.rest_path[1]
|
61
|
-
|
62
|
+
if exists_data_dir?(request, [ 'cookbooks', cookbook_name ]) && list_data(request, ['cookbooks', cookbook_name]).size == 0
|
63
|
+
delete_data_dir(request, ['cookbooks', cookbook_name])
|
64
|
+
end
|
62
65
|
|
63
66
|
# Hoover deleted files, if they exist
|
64
|
-
hoover_unused_checksums(get_checksums(deleted_cookbook))
|
67
|
+
hoover_unused_checksums(get_checksums(deleted_cookbook), request)
|
65
68
|
response
|
66
69
|
end
|
67
70
|
|
@@ -81,16 +84,21 @@ module ChefZero
|
|
81
84
|
|
82
85
|
private
|
83
86
|
|
84
|
-
def hoover_unused_checksums(deleted_checksums)
|
87
|
+
def hoover_unused_checksums(deleted_checksums, request)
|
85
88
|
data_store.list(['cookbooks']).each do |cookbook_name|
|
86
89
|
data_store.list(['cookbooks', cookbook_name]).each do |version|
|
87
|
-
cookbook = data_store.get(['cookbooks', cookbook_name, version])
|
90
|
+
cookbook = data_store.get(['cookbooks', cookbook_name, version], request)
|
88
91
|
deleted_checksums = deleted_checksums - get_checksums(cookbook)
|
89
92
|
end
|
90
93
|
end
|
91
94
|
deleted_checksums.each do |checksum|
|
92
95
|
# There can be a race here if multiple cookbooks are uploading.
|
93
|
-
|
96
|
+
# This deals with an exception on delete, but things can still get deleted
|
97
|
+
# that shouldn't be.
|
98
|
+
begin
|
99
|
+
data_store.delete(['file_store', 'checksums', checksum])
|
100
|
+
rescue ChefZero::DataStore::DataNotFoundError
|
101
|
+
end
|
94
102
|
end
|
95
103
|
end
|
96
104
|
|
data/lib/chef_zero/rest_base.rb
CHANGED
@@ -70,7 +70,7 @@ module ChefZero
|
|
70
70
|
def delete_data_dir(request, rest_path, *options)
|
71
71
|
rest_path ||= request.rest_path
|
72
72
|
begin
|
73
|
-
data_store.delete_dir(rest_path)
|
73
|
+
data_store.delete_dir(rest_path, *options)
|
74
74
|
rescue DataStore::DataNotFoundError
|
75
75
|
raise RestErrorResponse.new(404, "Object not found: #{build_uri(request.base_uri, request.rest_path)}")
|
76
76
|
end
|
@@ -10,24 +10,36 @@ module ChefZero
|
|
10
10
|
end
|
11
11
|
|
12
12
|
def to_s
|
13
|
-
"#{@from_inclusive ? '[' : '{'}#{@from} TO #{@to}#{@to_inclusive ? '
|
13
|
+
"#{@from_inclusive ? '[' : '{'}#{@from} TO #{@to}#{@to_inclusive ? ']' : '}'}"
|
14
14
|
end
|
15
15
|
|
16
|
-
def
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
16
|
+
def matches_values?(values)
|
17
|
+
values.any? do |value|
|
18
|
+
unless @from == '*'
|
19
|
+
case @from <=> value
|
20
|
+
when -1
|
21
|
+
return false
|
22
|
+
when 0
|
23
|
+
return false if !@from_inclusive
|
24
|
+
end
|
25
|
+
end
|
26
|
+
unless @to == '*'
|
27
|
+
case value <=> @to
|
28
|
+
when 1
|
29
|
+
return false
|
30
|
+
when 0
|
31
|
+
return false if !@to_inclusive
|
32
|
+
end
|
33
|
+
end
|
34
|
+
return true
|
22
35
|
end
|
23
|
-
case @to <=> value
|
24
|
-
when 1
|
25
|
-
return false
|
26
|
-
when 0
|
27
|
-
return false if !@to_inclusive
|
28
|
-
end
|
29
|
-
return true
|
30
36
|
end
|
37
|
+
|
38
|
+
def matches_doc?(doc)
|
39
|
+
matches_values?(doc[DEFAULT_FIELD])
|
40
|
+
end
|
41
|
+
|
42
|
+
DEFAULT_FIELD = "text"
|
31
43
|
end
|
32
44
|
end
|
33
45
|
end
|
data/lib/chef_zero/version.rb
CHANGED
data/spec/search_spec.rb
ADDED
@@ -0,0 +1,32 @@
|
|
1
|
+
require 'chef_zero/solr/solr_parser'
|
2
|
+
require 'chef_zero/solr/solr_doc'
|
3
|
+
|
4
|
+
describe ChefZero::Solr::SolrParser do
|
5
|
+
let (:all_docs) do
|
6
|
+
docs = []
|
7
|
+
[{'foo' => 'a'},
|
8
|
+
{'foo' => 'd'}].each_with_index do |h, i|
|
9
|
+
docs.push ChefZero::Solr::SolrDoc.new(h, i)
|
10
|
+
end
|
11
|
+
docs
|
12
|
+
end
|
13
|
+
|
14
|
+
def search_for(query)
|
15
|
+
q = ChefZero::Solr::SolrParser.new(query).parse
|
16
|
+
all_docs.select {|doc| q.matches_doc?(doc) }
|
17
|
+
end
|
18
|
+
|
19
|
+
it "handles terms" do
|
20
|
+
search_for('foo:d').size.should eq(1)
|
21
|
+
end
|
22
|
+
|
23
|
+
it "handles ranges" do
|
24
|
+
search_for('foo:[a TO c]').size.should eq(1)
|
25
|
+
end
|
26
|
+
|
27
|
+
it "handles wildcard ranges" do
|
28
|
+
search_for('foo:[* TO c]').size.should eq(1)
|
29
|
+
search_for('foo:[c TO *]').size.should eq(1)
|
30
|
+
search_for('foo:[* TO *]').size.should eq(2)
|
31
|
+
end
|
32
|
+
end
|
metadata
CHANGED
@@ -1,20 +1,18 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: chef-zero
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
5
|
-
prerelease:
|
4
|
+
version: 1.6.1
|
6
5
|
platform: ruby
|
7
6
|
authors:
|
8
7
|
- John Keiser
|
9
8
|
autorequire:
|
10
9
|
bindir: bin
|
11
10
|
cert_chain: []
|
12
|
-
date: 2013-
|
11
|
+
date: 2013-10-11 00:00:00.000000000 Z
|
13
12
|
dependencies:
|
14
13
|
- !ruby/object:Gem::Dependency
|
15
14
|
name: puma
|
16
15
|
requirement: !ruby/object:Gem::Requirement
|
17
|
-
none: false
|
18
16
|
requirements:
|
19
17
|
- - ~>
|
20
18
|
- !ruby/object:Gem::Version
|
@@ -22,7 +20,6 @@ dependencies:
|
|
22
20
|
type: :runtime
|
23
21
|
prerelease: false
|
24
22
|
version_requirements: !ruby/object:Gem::Requirement
|
25
|
-
none: false
|
26
23
|
requirements:
|
27
24
|
- - ~>
|
28
25
|
- !ruby/object:Gem::Version
|
@@ -30,7 +27,6 @@ dependencies:
|
|
30
27
|
- !ruby/object:Gem::Dependency
|
31
28
|
name: mixlib-log
|
32
29
|
requirement: !ruby/object:Gem::Requirement
|
33
|
-
none: false
|
34
30
|
requirements:
|
35
31
|
- - ~>
|
36
32
|
- !ruby/object:Gem::Version
|
@@ -38,7 +34,6 @@ dependencies:
|
|
38
34
|
type: :runtime
|
39
35
|
prerelease: false
|
40
36
|
version_requirements: !ruby/object:Gem::Requirement
|
41
|
-
none: false
|
42
37
|
requirements:
|
43
38
|
- - ~>
|
44
39
|
- !ruby/object:Gem::Version
|
@@ -46,7 +41,6 @@ dependencies:
|
|
46
41
|
- !ruby/object:Gem::Dependency
|
47
42
|
name: hashie
|
48
43
|
requirement: !ruby/object:Gem::Requirement
|
49
|
-
none: false
|
50
44
|
requirements:
|
51
45
|
- - ~>
|
52
46
|
- !ruby/object:Gem::Version
|
@@ -54,7 +48,6 @@ dependencies:
|
|
54
48
|
type: :runtime
|
55
49
|
prerelease: false
|
56
50
|
version_requirements: !ruby/object:Gem::Requirement
|
57
|
-
none: false
|
58
51
|
requirements:
|
59
52
|
- - ~>
|
60
53
|
- !ruby/object:Gem::Version
|
@@ -62,7 +55,6 @@ dependencies:
|
|
62
55
|
- !ruby/object:Gem::Dependency
|
63
56
|
name: moneta
|
64
57
|
requirement: !ruby/object:Gem::Requirement
|
65
|
-
none: false
|
66
58
|
requirements:
|
67
59
|
- - <
|
68
60
|
- !ruby/object:Gem::Version
|
@@ -70,7 +62,6 @@ dependencies:
|
|
70
62
|
type: :runtime
|
71
63
|
prerelease: false
|
72
64
|
version_requirements: !ruby/object:Gem::Requirement
|
73
|
-
none: false
|
74
65
|
requirements:
|
75
66
|
- - <
|
76
67
|
- !ruby/object:Gem::Version
|
@@ -78,49 +69,43 @@ dependencies:
|
|
78
69
|
- !ruby/object:Gem::Dependency
|
79
70
|
name: json
|
80
71
|
requirement: !ruby/object:Gem::Requirement
|
81
|
-
none: false
|
82
72
|
requirements:
|
83
|
-
- -
|
73
|
+
- - '>='
|
84
74
|
- !ruby/object:Gem::Version
|
85
75
|
version: '0'
|
86
76
|
type: :runtime
|
87
77
|
prerelease: false
|
88
78
|
version_requirements: !ruby/object:Gem::Requirement
|
89
|
-
none: false
|
90
79
|
requirements:
|
91
|
-
- -
|
80
|
+
- - '>='
|
92
81
|
- !ruby/object:Gem::Version
|
93
82
|
version: '0'
|
94
83
|
- !ruby/object:Gem::Dependency
|
95
84
|
name: rake
|
96
85
|
requirement: !ruby/object:Gem::Requirement
|
97
|
-
none: false
|
98
86
|
requirements:
|
99
|
-
- -
|
87
|
+
- - '>='
|
100
88
|
- !ruby/object:Gem::Version
|
101
89
|
version: '0'
|
102
90
|
type: :development
|
103
91
|
prerelease: false
|
104
92
|
version_requirements: !ruby/object:Gem::Requirement
|
105
|
-
none: false
|
106
93
|
requirements:
|
107
|
-
- -
|
94
|
+
- - '>='
|
108
95
|
- !ruby/object:Gem::Version
|
109
96
|
version: '0'
|
110
97
|
- !ruby/object:Gem::Dependency
|
111
98
|
name: rspec
|
112
99
|
requirement: !ruby/object:Gem::Requirement
|
113
|
-
none: false
|
114
100
|
requirements:
|
115
|
-
- -
|
101
|
+
- - '>='
|
116
102
|
- !ruby/object:Gem::Version
|
117
103
|
version: '0'
|
118
104
|
type: :development
|
119
105
|
prerelease: false
|
120
106
|
version_requirements: !ruby/object:Gem::Requirement
|
121
|
-
none: false
|
122
107
|
requirements:
|
123
|
-
- -
|
108
|
+
- - '>='
|
124
109
|
- !ruby/object:Gem::Version
|
125
110
|
version: '0'
|
126
111
|
description: Self-contained, easy-setup, fast-start in-memory Chef server for testing
|
@@ -188,34 +173,33 @@ files:
|
|
188
173
|
- lib/chef_zero/version.rb
|
189
174
|
- lib/chef_zero.rb
|
190
175
|
- spec/run.rb
|
176
|
+
- spec/search_spec.rb
|
191
177
|
- spec/support/pedant.rb
|
192
178
|
- spec/support/stickywicket.pem
|
193
|
-
-
|
194
|
-
YmluL2NoZWYtemVybw==
|
179
|
+
- bin/chef-zero
|
195
180
|
homepage: http://www.opscode.com
|
196
181
|
licenses:
|
197
182
|
- Apache 2.0
|
183
|
+
metadata: {}
|
198
184
|
post_install_message:
|
199
185
|
rdoc_options: []
|
200
186
|
require_paths:
|
201
187
|
- lib
|
202
188
|
required_ruby_version: !ruby/object:Gem::Requirement
|
203
|
-
none: false
|
204
189
|
requirements:
|
205
|
-
- -
|
190
|
+
- - '>='
|
206
191
|
- !ruby/object:Gem::Version
|
207
192
|
version: '0'
|
208
193
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
209
|
-
none: false
|
210
194
|
requirements:
|
211
|
-
- -
|
195
|
+
- - '>='
|
212
196
|
- !ruby/object:Gem::Version
|
213
197
|
version: '0'
|
214
198
|
requirements: []
|
215
199
|
rubyforge_project:
|
216
|
-
rubygems_version:
|
200
|
+
rubygems_version: 2.0.3
|
217
201
|
signing_key:
|
218
|
-
specification_version:
|
202
|
+
specification_version: 4
|
219
203
|
summary: Self-contained, easy-setup, fast-start in-memory Chef server for testing
|
220
204
|
and solo setup purposes
|
221
205
|
test_files: []
|