ridley 2.2.0 → 2.3.0
Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f571021ed99ad605622448d1f79edcb954abfafa
|
4
|
+
data.tar.gz: 3549b22251eba2ecf03e1829531e90d6d32dc50e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 83ab54c5ef8ceb4128a6d12d1e6c741b9126b9e13fdc84b5a2cf68cc4eb76047e2bb77a3d28c8c4a3b3803d5ab970fa40b8494c260b552e1d0c60c38f748d71d
|
7
|
+
data.tar.gz: e9662d26e3d80e53f6ee3e710f2cc089f8bfe07c6d32d23d3e337ebdf4bf438e45bf35d435b22c54da6e5b34c25b5e3f8cd2a5d0a5ecc23045526022d892619d
|
data/lib/ridley/chef/cookbook.rb
CHANGED
@@ -84,21 +84,10 @@ module Ridley::Chef
|
|
84
84
|
@cookbook_name = name
|
85
85
|
@path = Pathname.new(path)
|
86
86
|
@metadata = metadata
|
87
|
-
@files = Array.new
|
88
|
-
@manifest = Hashie::Mash.new(
|
89
|
-
recipes: Array.new,
|
90
|
-
definitions: Array.new,
|
91
|
-
libraries: Array.new,
|
92
|
-
attributes: Array.new,
|
93
|
-
files: Array.new,
|
94
|
-
templates: Array.new,
|
95
|
-
resources: Array.new,
|
96
|
-
providers: Array.new,
|
97
|
-
root_files: Array.new
|
98
|
-
)
|
99
87
|
@frozen = false
|
100
88
|
@chefignore = Ridley::Chef::Chefignore.new(@path) rescue nil
|
101
89
|
|
90
|
+
clear_files
|
102
91
|
load_files
|
103
92
|
end
|
104
93
|
|
@@ -123,10 +112,16 @@ module Ridley::Chef
|
|
123
112
|
#
|
124
113
|
# @param [String] out
|
125
114
|
# directory to output compiled metadata to
|
115
|
+
#
|
116
|
+
# @return [String]
|
117
|
+
# path to the compiled metadata
|
126
118
|
def compile_metadata(out = self.path)
|
127
|
-
File.
|
119
|
+
filepath = File.join(out, Metadata::COMPILED_FILE_NAME)
|
120
|
+
File.open(filepath, "w+") do |f|
|
128
121
|
f.write(metadata.to_json)
|
129
122
|
end
|
123
|
+
|
124
|
+
filepath
|
130
125
|
end
|
131
126
|
|
132
127
|
# Returns true if the cookbook instance has a compiled metadata file and false if it
|
@@ -190,6 +185,7 @@ module Ridley::Chef
|
|
190
185
|
|
191
186
|
# Reload the cookbook from the files located on disk at `#path`.
|
192
187
|
def reload
|
188
|
+
clear_files
|
193
189
|
load_files
|
194
190
|
end
|
195
191
|
|
@@ -239,6 +235,21 @@ module Ridley::Chef
|
|
239
235
|
# @return [Ridley::Chef::Chefignore, nil]
|
240
236
|
attr_reader :chefignore
|
241
237
|
|
238
|
+
def clear_files
|
239
|
+
@files = Array.new
|
240
|
+
@manifest = Hashie::Mash.new(
|
241
|
+
recipes: Array.new,
|
242
|
+
definitions: Array.new,
|
243
|
+
libraries: Array.new,
|
244
|
+
attributes: Array.new,
|
245
|
+
files: Array.new,
|
246
|
+
templates: Array.new,
|
247
|
+
resources: Array.new,
|
248
|
+
providers: Array.new,
|
249
|
+
root_files: Array.new
|
250
|
+
)
|
251
|
+
end
|
252
|
+
|
242
253
|
def load_files
|
243
254
|
load_shallow(:recipes, 'recipes', '*.rb')
|
244
255
|
load_shallow(:definitions, 'definitions', '*.rb')
|
@@ -186,8 +186,8 @@ module Ridley
|
|
186
186
|
#
|
187
187
|
# @return [Hash]
|
188
188
|
def upload(path, options = {})
|
189
|
-
options
|
190
|
-
cookbook
|
189
|
+
options = options.reverse_merge(validate: true, force: false, freeze: false)
|
190
|
+
cookbook = Ridley::Chef::Cookbook.from_path(path, options.slice(:name))
|
191
191
|
|
192
192
|
unless (existing = find(cookbook.cookbook_name, cookbook.version)).nil?
|
193
193
|
if existing.frozen? && options[:force] == false
|
@@ -201,12 +201,38 @@ module Ridley
|
|
201
201
|
cookbook.validate
|
202
202
|
end
|
203
203
|
|
204
|
+
# Compile metadata on upload if it hasn't been compiled already
|
205
|
+
unless cookbook.compiled_metadata?
|
206
|
+
compiled_metadata = cookbook.compile_metadata
|
207
|
+
cookbook.reload
|
208
|
+
end
|
209
|
+
|
210
|
+
# Skip uploading the raw metadata (metadata.rb). The raw metadata is unecessary for the
|
211
|
+
# client, and this is required until compiled metadata (metadata.json) takes precedence over
|
212
|
+
# raw metadata in the Chef-Client.
|
213
|
+
#
|
214
|
+
# We can change back to including the raw metadata in the future after this has been fixed or
|
215
|
+
# just remove these comments. There is no circumstance that I can currently think of where
|
216
|
+
# raw metadata should ever be read by the client.
|
217
|
+
#
|
218
|
+
# - Jamie
|
219
|
+
#
|
220
|
+
# See the following tickets for more information:
|
221
|
+
# * https://tickets.opscode.com/browse/CHEF-4811
|
222
|
+
# * https://tickets.opscode.com/browse/CHEF-4810
|
223
|
+
cookbook.manifest[:root_files].reject! do |file|
|
224
|
+
File.basename(file[:name]).downcase == Ridley::Chef::Cookbook::Metadata::RAW_FILE_NAME
|
225
|
+
end
|
226
|
+
|
204
227
|
checksums = cookbook.checksums.dup
|
205
228
|
sandbox = sandbox_resource.create(checksums.keys.sort)
|
206
229
|
|
207
230
|
sandbox.upload(checksums)
|
208
231
|
sandbox.commit
|
209
232
|
update(cookbook, options.slice(:force, :freeze))
|
233
|
+
ensure
|
234
|
+
# Destroy the compiled metadata only if it was created
|
235
|
+
File.delete(compiled_metadata) unless compiled_metadata.nil?
|
210
236
|
end
|
211
237
|
|
212
238
|
# Return a list of versions for the given cookbook present on the remote Chef server
|
data/lib/ridley/version.rb
CHANGED
@@ -18,7 +18,7 @@ describe "Client API operations", type: "acceptance" do
|
|
18
18
|
before { subject.download(name, version, destination) }
|
19
19
|
|
20
20
|
it "downloads the cookbook to the destination" do
|
21
|
-
expect(File.exist?(destination.join("metadata.
|
21
|
+
expect(File.exist?(destination.join("metadata.json"))).to be_true
|
22
22
|
end
|
23
23
|
end
|
24
24
|
end
|
@@ -40,6 +40,14 @@ describe "Client API operations", type: "acceptance" do
|
|
40
40
|
cookbook.templates.should have(1).item
|
41
41
|
cookbook.root_files.should have(1).items
|
42
42
|
end
|
43
|
+
|
44
|
+
it "does not contain a raw metadata.rb but does contain a compiled metadata.json" do
|
45
|
+
subject.upload(path)
|
46
|
+
cookbook = subject.find("example_cookbook", "0.1.0")
|
47
|
+
|
48
|
+
expect(cookbook.root_files.any? { |f| f[:name] == "metadata.json" }).to be_true
|
49
|
+
expect(cookbook.root_files.any? { |f| f[:name] == "metadata.rb" }).to be_false
|
50
|
+
end
|
43
51
|
end
|
44
52
|
|
45
53
|
describe "listing cookbooks" do
|
@@ -133,6 +133,7 @@ describe Ridley::CookbookResource do
|
|
133
133
|
"211a3a8798d4acd424af15ff8a2e28a5",
|
134
134
|
"75077ba33d2887cc1746d1ef716bf8b7",
|
135
135
|
"7b1ebd2ff580ca9dc46fb27ec1653bf2",
|
136
|
+
"83128904bdb43eeeef131535c4a2ce8e",
|
136
137
|
"a39eb80def9804f4b118099697cc2cd2",
|
137
138
|
"b70ba735f3af47e5d6fc71b91775b34c",
|
138
139
|
"cafb6869fca13f5c36f24a60de8fb982",
|