chef 12.0.0.alpha.0 → 12.0.0.alpha.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CONTRIBUTING.md +3 -5
- data/lib/chef/api_client.rb +1 -1
- data/lib/chef/application.rb +16 -8
- data/lib/chef/chef_fs/chef_fs_data_store.rb +1 -1
- data/lib/chef/chef_fs/command_line.rb +1 -1
- data/lib/chef/chef_fs/file_system.rb +1 -1
- data/lib/chef/chef_fs/file_system/acl_entry.rb +1 -1
- data/lib/chef/chef_fs/file_system/chef_repository_file_system_entry.rb +3 -3
- data/lib/chef/chef_fs/file_system/cookbook_file.rb +2 -2
- data/lib/chef/chef_fs/file_system/rest_list_dir.rb +2 -2
- data/lib/chef/chef_fs/file_system/rest_list_entry.rb +4 -4
- data/lib/chef/config.rb +6 -5
- data/lib/chef/config_fetcher.rb +1 -1
- data/lib/chef/cookbook/cookbook_version_loader.rb +126 -43
- data/lib/chef/cookbook/metadata.rb +102 -53
- data/lib/chef/cookbook/syntax_check.rb +1 -1
- data/lib/chef/cookbook_loader.rb +62 -14
- data/lib/chef/cookbook_site_streaming_uploader.rb +12 -1
- data/lib/chef/cookbook_version.rb +13 -4
- data/lib/chef/data_bag.rb +28 -15
- data/lib/chef/data_bag_item.rb +5 -7
- data/lib/chef/digester.rb +5 -9
- data/lib/chef/dsl/recipe.rb +14 -0
- data/lib/chef/encrypted_data_bag_item.rb +1 -0
- data/lib/chef/encrypted_data_bag_item/assertions.rb +57 -0
- data/lib/chef/encrypted_data_bag_item/decryptor.rb +52 -28
- data/lib/chef/encrypted_data_bag_item/encrypted_data_bag_item_assertions.rb +37 -0
- data/lib/chef/encrypted_data_bag_item/encryption_failure.rb +22 -0
- data/lib/chef/encrypted_data_bag_item/encryptor.rb +79 -8
- data/lib/chef/environment.rb +1 -3
- data/lib/chef/exceptions.rb +18 -3
- data/lib/chef/formatters/base.rb +7 -0
- data/lib/chef/formatters/error_inspectors/cookbook_resolve_error_inspector.rb +1 -1
- data/lib/chef/handler/json_file.rb +0 -1
- data/lib/chef/http/json_output.rb +1 -1
- data/lib/chef/json_compat.rb +24 -6
- data/lib/chef/knife/bootstrap.rb +2 -2
- data/lib/chef/knife/client_delete.rb +1 -1
- data/lib/chef/knife/cookbook_site_download.rb +1 -1
- data/lib/chef/knife/cookbook_site_list.rb +1 -1
- data/lib/chef/knife/cookbook_site_search.rb +1 -1
- data/lib/chef/knife/cookbook_site_share.rb +2 -2
- data/lib/chef/knife/cookbook_site_show.rb +3 -3
- data/lib/chef/knife/cookbook_site_unshare.rb +1 -1
- data/lib/chef/knife/core/node_editor.rb +2 -3
- data/lib/chef/knife/core/ui.rb +2 -2
- data/lib/chef/knife/deps.rb +2 -3
- data/lib/chef/mixin/shell_out.rb +1 -1
- data/lib/chef/mixin/windows_architecture_helper.rb +1 -0
- data/lib/chef/node.rb +1 -2
- data/lib/chef/platform/provider_mapping.rb +33 -6
- data/lib/chef/provider.rb +0 -2
- data/lib/chef/provider/cookbook_file/content.rb +1 -1
- data/lib/chef/provider/cron.rb +11 -0
- data/lib/chef/provider/deploy.rb +3 -2
- data/lib/chef/provider/deploy/revision.rb +2 -2
- data/lib/chef/provider/env.rb +1 -1
- data/lib/chef/provider/env/windows.rb +5 -9
- data/lib/chef/provider/file.rb +84 -33
- data/lib/chef/provider/git.rb +2 -1
- data/lib/chef/provider/group/aix.rb +17 -2
- data/lib/chef/provider/group/dscl.rb +27 -9
- data/lib/chef/provider/group/pw.rb +8 -1
- data/lib/chef/provider/http_request.rb +4 -4
- data/lib/chef/provider/log.rb +4 -14
- data/lib/chef/provider/mount/mount.rb +2 -2
- data/lib/chef/provider/package/ips.rb +17 -23
- data/lib/chef/provider/package/paludis.rb +2 -2
- data/lib/chef/provider/package/rpm.rb +2 -2
- data/lib/chef/provider/package/rubygems.rb +2 -0
- data/lib/chef/provider/package/yum.rb +2 -0
- data/lib/chef/provider/package/zypper.rb +1 -1
- data/lib/chef/provider/remote_file/cache_control_data.rb +2 -2
- data/lib/chef/provider/service/windows.rb +87 -21
- data/lib/chef/provider/user/aix.rb +95 -0
- data/lib/chef/provider/user/dscl.rb +544 -156
- data/lib/chef/provider/user/useradd.rb +1 -0
- data/lib/chef/providers.rb +1 -0
- data/lib/chef/resource.rb +4 -3
- data/lib/chef/resource/freebsd_package.rb +10 -2
- data/lib/chef/resource/paludis_package.rb +1 -0
- data/lib/chef/resource/scm.rb +10 -0
- data/lib/chef/resource/user.rb +27 -0
- data/lib/chef/resource/windows_service.rb +53 -0
- data/lib/chef/resource_collection.rb +23 -12
- data/lib/chef/resource_reporter.rb +10 -10
- data/lib/chef/resources.rb +1 -0
- data/lib/chef/role.rb +3 -3
- data/lib/chef/run_list.rb +6 -3
- data/lib/chef/user.rb +1 -1
- data/lib/chef/util/diff.rb +1 -2
- data/lib/chef/version.rb +1 -1
- data/lib/chef/version_constraint.rb +4 -4
- data/spec/data/cookbooks/angrybash/metadata.rb +2 -0
- data/spec/data/cookbooks/apache2/metadata.rb +2 -0
- data/spec/data/cookbooks/borken/metadata.rb +2 -0
- data/spec/data/cookbooks/ignorken/metadata.rb +2 -0
- data/spec/data/cookbooks/java/metadata.rb +2 -0
- data/spec/data/cookbooks/name-mismatch-versionnumber/README.md +4 -0
- data/spec/data/cookbooks/name-mismatch-versionnumber/metadata.rb +8 -0
- data/spec/data/cookbooks/name-mismatch-versionnumber/recipes/default.rb +8 -0
- data/spec/data/cookbooks/openldap/files/default/remotedir/not_a_template.erb +2 -0
- data/spec/data/cookbooks/preseed/metadata.rb +2 -0
- data/spec/data/incomplete-metadata-chef-repo/incomplete-metadata/README.md +4 -0
- data/spec/data/incomplete-metadata-chef-repo/incomplete-metadata/metadata.rb +13 -0
- data/spec/data/incomplete-metadata-chef-repo/incomplete-metadata/recipes/default.rb +8 -0
- data/spec/data/invalid-metadata-chef-repo/invalid-metadata/README.md +4 -0
- data/spec/data/invalid-metadata-chef-repo/invalid-metadata/metadata.rb +10 -0
- data/spec/data/invalid-metadata-chef-repo/invalid-metadata/recipes/default.rb +8 -0
- data/spec/data/mac_users/10.7-8.plist.xml +559 -0
- data/spec/data/mac_users/10.7-8.shadow.xml +11 -0
- data/spec/data/mac_users/10.7.plist.xml +559 -0
- data/spec/data/mac_users/10.7.shadow.xml +11 -0
- data/spec/data/mac_users/10.8.plist.xml +559 -0
- data/spec/data/mac_users/10.8.shadow.xml +21 -0
- data/spec/data/mac_users/10.9.plist.xml +560 -0
- data/spec/data/mac_users/10.9.shadow.xml +21 -0
- data/spec/data/object_loader/environments/test.json +2 -0
- data/spec/data/object_loader/environments/test_json_class.json +2 -0
- data/spec/data/object_loader/nodes/test.json +2 -0
- data/spec/data/object_loader/nodes/test_json_class.json +2 -0
- data/spec/data/object_loader/roles/test.json +2 -0
- data/spec/data/object_loader/roles/test_json_class.json +2 -0
- data/spec/functional/resource/bff_spec.rb +1 -1
- data/spec/functional/resource/cron_spec.rb +20 -1
- data/spec/functional/resource/env_spec.rb +137 -0
- data/spec/functional/resource/group_spec.rb +7 -5
- data/spec/functional/resource/remote_file_spec.rb +12 -1
- data/spec/functional/resource/user/dscl_spec.rb +198 -0
- data/spec/functional/resource/{user_spec.rb → user/useradd_spec.rb} +175 -37
- data/spec/integration/client/client_spec.rb +6 -4
- data/spec/integration/client/ipv6_spec.rb +16 -14
- data/spec/integration/knife/chef_fs_data_store_spec.rb +57 -46
- data/spec/integration/knife/chef_repo_path_spec.rb +105 -78
- data/spec/integration/knife/chef_repository_file_system_spec.rb +100 -84
- data/spec/integration/knife/chefignore_spec.rb +76 -46
- data/spec/integration/knife/common_options_spec.rb +16 -21
- data/spec/integration/knife/cookbook_api_ipv6_spec.rb +3 -3
- data/spec/integration/knife/delete_spec.rb +66 -46
- data/spec/integration/knife/deps_spec.rb +145 -94
- data/spec/integration/knife/diff_spec.rb +176 -110
- data/spec/integration/knife/download_spec.rb +229 -133
- data/spec/integration/knife/list_spec.rb +62 -54
- data/spec/integration/knife/raw_spec.rb +24 -9
- data/spec/integration/knife/redirection_spec.rb +2 -2
- data/spec/integration/knife/serve_spec.rb +2 -2
- data/spec/integration/knife/show_spec.rb +32 -26
- data/spec/integration/knife/upload_spec.rb +308 -165
- data/spec/integration/recipes/lwrp_inline_resources_spec.rb +10 -8
- data/spec/integration/solo/solo_spec.rb +22 -11
- data/spec/spec_helper.rb +3 -0
- data/spec/support/lib/chef/resource/zen_follower.rb +46 -0
- data/spec/support/platform_helpers.rb +12 -0
- data/spec/support/shared/functional/file_resource.rb +10 -0
- data/spec/support/shared/integration/chef_zero_support.rb +130 -0
- data/spec/support/shared/integration/integration_helper.rb +100 -98
- data/spec/support/shared/integration/knife_support.rb +0 -1
- data/spec/support/shared/unit/provider/file.rb +6 -4
- data/spec/support/shared/unit/provider/useradd_based_user_provider.rb +10 -1
- data/spec/unit/api_client/registration_spec.rb +83 -74
- data/spec/unit/application_spec.rb +32 -9
- data/spec/unit/cookbook/cookbook_version_loader_spec.rb +179 -0
- data/spec/unit/cookbook/metadata_spec.rb +190 -150
- data/spec/unit/cookbook/syntax_check_spec.rb +3 -2
- data/spec/unit/cookbook_loader_spec.rb +114 -53
- data/spec/unit/{cookbook_site_streaming_uploader.rb → cookbook_site_streaming_uploader_spec.rb} +21 -1
- data/spec/unit/data_bag_spec.rb +88 -13
- data/spec/unit/deprecation_spec.rb +1 -2
- data/spec/unit/encrypted_data_bag_item_spec.rb +145 -9
- data/spec/unit/environment_spec.rb +1 -1
- data/spec/unit/formatters/base_spec.rb +48 -0
- data/spec/unit/json_compat_spec.rb +48 -17
- data/spec/unit/knife/client_delete_spec.rb +4 -4
- data/spec/unit/knife/client_show_spec.rb +15 -5
- data/spec/unit/knife/cookbook_site_download_spec.rb +1 -1
- data/spec/unit/knife/cookbook_site_share_spec.rb +3 -3
- data/spec/unit/knife/data_bag_from_file_spec.rb +0 -2
- data/spec/unit/knife/data_bag_show_spec.rb +23 -14
- data/spec/unit/knife/node_show_spec.rb +32 -15
- data/spec/unit/knife/role_show_spec.rb +59 -0
- data/spec/unit/platform_spec.rb +10 -0
- data/spec/unit/provider/deploy_spec.rb +4 -0
- data/spec/unit/provider/env_spec.rb +19 -0
- data/spec/unit/provider/git_spec.rb +22 -2
- data/spec/unit/provider/group/dscl_spec.rb +38 -1
- data/spec/unit/provider/group/pw_spec.rb +2 -2
- data/spec/unit/provider/http_request_spec.rb +8 -8
- data/spec/unit/provider/log_spec.rb +33 -53
- data/spec/unit/provider/mount/mount_spec.rb +12 -3
- data/spec/unit/provider/package/ips_spec.rb +96 -63
- data/spec/unit/provider/package/paludis_spec.rb +5 -5
- data/spec/unit/provider/package/rpm_spec.rb +12 -0
- data/spec/unit/provider/package/zypper_spec.rb +28 -16
- data/spec/unit/provider/service/windows_spec.rb +77 -17
- data/spec/unit/provider/user/dscl_spec.rb +659 -264
- data/spec/unit/provider/user/useradd_spec.rb +1 -0
- data/spec/unit/recipe_spec.rb +41 -0
- data/spec/unit/resource/scm_spec.rb +11 -0
- data/spec/unit/resource/user_spec.rb +4 -0
- data/spec/unit/resource/windows_service_spec.rb +46 -0
- data/spec/unit/resource_collection_spec.rb +33 -0
- data/spec/unit/resource_reporter_spec.rb +48 -0
- data/spec/unit/resource_spec.rb +9 -2
- data/spec/unit/role_spec.rb +6 -0
- data/spec/unit/version_constraint_spec.rb +28 -0
- metadata +61 -4
@@ -18,12 +18,14 @@
|
|
18
18
|
# limitations under the License.
|
19
19
|
#
|
20
20
|
|
21
|
+
require 'chef/exceptions'
|
21
22
|
require 'chef/mash'
|
22
23
|
require 'chef/mixin/from_file'
|
23
24
|
require 'chef/mixin/params_validate'
|
24
25
|
require 'chef/log'
|
25
26
|
require 'chef/version_class'
|
26
27
|
require 'chef/version_constraint'
|
28
|
+
require 'chef/json_compat'
|
27
29
|
|
28
30
|
class Chef
|
29
31
|
class Cookbook
|
@@ -66,18 +68,17 @@ class Chef
|
|
66
68
|
include Chef::Mixin::ParamsValidate
|
67
69
|
include Chef::Mixin::FromFile
|
68
70
|
|
69
|
-
attr_reader
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
:version
|
71
|
+
attr_reader :platforms
|
72
|
+
attr_reader :dependencies
|
73
|
+
attr_reader :recommendations
|
74
|
+
attr_reader :suggestions
|
75
|
+
attr_reader :conflicting
|
76
|
+
attr_reader :providing
|
77
|
+
attr_reader :replacing
|
78
|
+
attr_reader :attributes
|
79
|
+
attr_reader :groupings
|
80
|
+
attr_reader :recipes
|
81
|
+
attr_reader :version
|
81
82
|
|
82
83
|
# Builds a new Chef::Cookbook::Metadata object.
|
83
84
|
#
|
@@ -89,14 +90,16 @@ class Chef
|
|
89
90
|
#
|
90
91
|
# === Returns
|
91
92
|
# metadata<Chef::Cookbook::Metadata>
|
92
|
-
def initialize
|
93
|
-
@
|
94
|
-
|
95
|
-
@
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
93
|
+
def initialize
|
94
|
+
@name = nil
|
95
|
+
|
96
|
+
@description = ''
|
97
|
+
@long_description = ''
|
98
|
+
@license = 'All rights reserved'
|
99
|
+
|
100
|
+
@maintainer = nil
|
101
|
+
@maintainer_email = nil
|
102
|
+
|
100
103
|
@platforms = Mash.new
|
101
104
|
@dependencies = Mash.new
|
102
105
|
@recommendations = Mash.new
|
@@ -107,15 +110,9 @@ class Chef
|
|
107
110
|
@attributes = Mash.new
|
108
111
|
@groupings = Mash.new
|
109
112
|
@recipes = Mash.new
|
110
|
-
@version = Version.new
|
111
|
-
|
112
|
-
|
113
|
-
e = self.name.to_s if e =~ /::default$/
|
114
|
-
r[e] ||= ""
|
115
|
-
self.provides e
|
116
|
-
r
|
117
|
-
end
|
118
|
-
end
|
113
|
+
@version = Version.new("0.0.0")
|
114
|
+
|
115
|
+
@errors = []
|
119
116
|
end
|
120
117
|
|
121
118
|
def ==(other)
|
@@ -124,6 +121,32 @@ class Chef
|
|
124
121
|
end
|
125
122
|
end
|
126
123
|
|
124
|
+
# Whether this metadata is valid. In order to be valid, all required
|
125
|
+
# fields must be set. Chef's validation implementation checks the content
|
126
|
+
# of a given field when setting (and raises an error if the content does
|
127
|
+
# not meet the criteria), so the content of the fields is not considered
|
128
|
+
# when checking validity.
|
129
|
+
#
|
130
|
+
# === Returns
|
131
|
+
# valid<Boolean>:: Whether this metadata object is valid
|
132
|
+
def valid?
|
133
|
+
run_validation
|
134
|
+
@errors.empty?
|
135
|
+
end
|
136
|
+
|
137
|
+
# A list of validation errors for this metadata object. See #valid? for
|
138
|
+
# comments about the validation criteria.
|
139
|
+
#
|
140
|
+
# If there are any validation errors, one or more error strings will be
|
141
|
+
# returned. Otherwise an empty array is returned.
|
142
|
+
#
|
143
|
+
# === Returns
|
144
|
+
# error messages<Array>:: Whether this metadata object is valid
|
145
|
+
def errors
|
146
|
+
run_validation
|
147
|
+
@errors
|
148
|
+
end
|
149
|
+
|
127
150
|
# Sets the cookbooks maintainer, or returns it.
|
128
151
|
#
|
129
152
|
# === Parameters
|
@@ -242,8 +265,8 @@ class Chef
|
|
242
265
|
# versions<Array>:: Returns the list of versions for the platform
|
243
266
|
def supports(platform, *version_args)
|
244
267
|
version = new_args_format(:supports, platform, version_args)
|
245
|
-
|
246
|
-
@platforms[platform] =
|
268
|
+
constraint = validate_version_constraint(:supports, platform, version)
|
269
|
+
@platforms[platform] = constraint.to_s
|
247
270
|
@platforms[platform]
|
248
271
|
end
|
249
272
|
|
@@ -259,8 +282,8 @@ class Chef
|
|
259
282
|
# versions<Array>:: Returns the list of versions for the platform
|
260
283
|
def depends(cookbook, *version_args)
|
261
284
|
version = new_args_format(:depends, cookbook, version_args)
|
262
|
-
|
263
|
-
@dependencies[cookbook] =
|
285
|
+
constraint = validate_version_constraint(:depends, cookbook, version)
|
286
|
+
@dependencies[cookbook] = constraint.to_s
|
264
287
|
@dependencies[cookbook]
|
265
288
|
end
|
266
289
|
|
@@ -276,8 +299,8 @@ class Chef
|
|
276
299
|
# versions<Array>:: Returns the list of versions for the platform
|
277
300
|
def recommends(cookbook, *version_args)
|
278
301
|
version = new_args_format(:recommends, cookbook, version_args)
|
279
|
-
|
280
|
-
@recommendations[cookbook] =
|
302
|
+
constraint = validate_version_constraint(:recommends, cookbook, version)
|
303
|
+
@recommendations[cookbook] = constraint.to_s
|
281
304
|
@recommendations[cookbook]
|
282
305
|
end
|
283
306
|
|
@@ -293,8 +316,8 @@ class Chef
|
|
293
316
|
# versions<Array>:: Returns the list of versions for the platform
|
294
317
|
def suggests(cookbook, *version_args)
|
295
318
|
version = new_args_format(:suggests, cookbook, version_args)
|
296
|
-
|
297
|
-
@suggestions[cookbook] =
|
319
|
+
constraint = validate_version_constraint(:suggests, cookbook, version)
|
320
|
+
@suggestions[cookbook] = constraint.to_s
|
298
321
|
@suggestions[cookbook]
|
299
322
|
end
|
300
323
|
|
@@ -310,8 +333,8 @@ class Chef
|
|
310
333
|
# versions<Array>:: Returns the list of versions for the platform
|
311
334
|
def conflicts(cookbook, *version_args)
|
312
335
|
version = new_args_format(:conflicts, cookbook, version_args)
|
313
|
-
|
314
|
-
@conflicting[cookbook] =
|
336
|
+
constraint = validate_version_constraint(:conflicts, cookbook, version)
|
337
|
+
@conflicting[cookbook] = constraint.to_s
|
315
338
|
@conflicting[cookbook]
|
316
339
|
end
|
317
340
|
|
@@ -331,8 +354,8 @@ class Chef
|
|
331
354
|
# versions<Array>:: Returns the list of versions for the platform
|
332
355
|
def provides(cookbook, *version_args)
|
333
356
|
version = new_args_format(:provides, cookbook, version_args)
|
334
|
-
|
335
|
-
@providing[cookbook] =
|
357
|
+
constraint = validate_version_constraint(:provides, cookbook, version)
|
358
|
+
@providing[cookbook] = constraint.to_s
|
336
359
|
@providing[cookbook]
|
337
360
|
end
|
338
361
|
|
@@ -347,8 +370,8 @@ class Chef
|
|
347
370
|
# versions<Array>:: Returns the list of versions for the platform
|
348
371
|
def replaces(cookbook, *version_args)
|
349
372
|
version = new_args_format(:replaces, cookbook, version_args)
|
350
|
-
|
351
|
-
@replacing[cookbook] =
|
373
|
+
constraint = validate_version_constraint(:replaces, cookbook, version)
|
374
|
+
@replacing[cookbook] = constraint.to_s
|
352
375
|
@replacing[cookbook]
|
353
376
|
end
|
354
377
|
|
@@ -364,6 +387,32 @@ class Chef
|
|
364
387
|
@recipes[name] = description
|
365
388
|
end
|
366
389
|
|
390
|
+
# Sets the cookbook's recipes to the list of recipes in the given
|
391
|
+
# +cookbook+. Any recipe that already has a description (if set by the
|
392
|
+
# #recipe method) will not be updated.
|
393
|
+
#
|
394
|
+
# === Parameters
|
395
|
+
# cookbook<CookbookVersion>:: CookbookVersion object representing the cookbook
|
396
|
+
# description<String>:: The description of the recipe
|
397
|
+
#
|
398
|
+
# === Returns
|
399
|
+
# recipe_unqualified_names<Array>:: An array of the recipe names given by the cookbook
|
400
|
+
def recipes_from_cookbook_version(cookbook)
|
401
|
+
cookbook.fully_qualified_recipe_names.map do |recipe_name|
|
402
|
+
unqualified_name =
|
403
|
+
if recipe_name =~ /::default$/
|
404
|
+
self.name.to_s
|
405
|
+
else
|
406
|
+
recipe_name
|
407
|
+
end
|
408
|
+
|
409
|
+
@recipes[unqualified_name] ||= ""
|
410
|
+
provides(unqualified_name)
|
411
|
+
|
412
|
+
unqualified_name
|
413
|
+
end
|
414
|
+
end
|
415
|
+
|
367
416
|
# Adds an attribute )hat a user needs to configure for this cookbook. Takes
|
368
417
|
# a name (with the / notation for a nested attribute), followed by any of
|
369
418
|
# these options
|
@@ -441,7 +490,7 @@ class Chef
|
|
441
490
|
end
|
442
491
|
|
443
492
|
def to_json(*a)
|
444
|
-
|
493
|
+
Chef::JSONCompat.to_json(to_hash, *a)
|
445
494
|
end
|
446
495
|
|
447
496
|
def self.from_hash(o)
|
@@ -479,9 +528,9 @@ class Chef
|
|
479
528
|
def self.validate_json(json_str)
|
480
529
|
o = Chef::JSONCompat.from_json(json_str)
|
481
530
|
metadata = new()
|
482
|
-
VERSION_CONSTRAINTS.each do |
|
483
|
-
if
|
484
|
-
|
531
|
+
VERSION_CONSTRAINTS.each do |dependency_type, hash_key|
|
532
|
+
if dependency_group = o[hash_key]
|
533
|
+
dependency_group.each do |cb_name, constraints|
|
485
534
|
metadata.send(method_name, cb_name, *Array(constraints))
|
486
535
|
end
|
487
536
|
end
|
@@ -496,6 +545,12 @@ class Chef
|
|
496
545
|
|
497
546
|
private
|
498
547
|
|
548
|
+
def run_validation
|
549
|
+
if name.nil?
|
550
|
+
@errors = ["The `name' attribute is required in cookbook metadata"]
|
551
|
+
end
|
552
|
+
end
|
553
|
+
|
499
554
|
def new_args_format(caller_name, dep_name, version_constraints)
|
500
555
|
if version_constraints.empty?
|
501
556
|
">= 0.0.0"
|
@@ -533,11 +588,6 @@ INVALID
|
|
533
588
|
raise Exceptions::InvalidVersionConstraint, msg
|
534
589
|
end
|
535
590
|
|
536
|
-
def normalize_version_constraint(caller_name, dep_name, constraint_str)
|
537
|
-
version_constraint = validate_version_constraint(caller_name, dep_name, constraint_str)
|
538
|
-
"#{version_constraint.op} #{version_constraint.raw_version}"
|
539
|
-
end
|
540
|
-
|
541
591
|
# Verify that the given array is an array of strings
|
542
592
|
#
|
543
593
|
# Raise an exception if the members of the array are not Strings
|
@@ -656,6 +706,5 @@ INVALID
|
|
656
706
|
end
|
657
707
|
end
|
658
708
|
|
659
|
-
|
660
709
|
end
|
661
710
|
end
|
data/lib/chef/cookbook_loader.rb
CHANGED
@@ -50,6 +50,9 @@ class Chef
|
|
50
50
|
repo_path = File.expand_path(repo_path)
|
51
51
|
end
|
52
52
|
|
53
|
+
@preloaded_cookbooks = false
|
54
|
+
@loaders_by_name = {}
|
55
|
+
|
53
56
|
# Used to track which cookbooks appear in multiple places in the cookbook repos
|
54
57
|
# and are merged in to a single cookbook by file shadowing. This behavior is
|
55
58
|
# deprecated, so users of this class may issue warnings to the user by checking
|
@@ -64,25 +67,25 @@ class Chef
|
|
64
67
|
end
|
65
68
|
|
66
69
|
def load_cookbooks
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
end
|
70
|
+
preload_cookbooks
|
71
|
+
@loaders_by_name.each do |cookbook_name, _loaders|
|
72
|
+
load_cookbook(cookbook_name)
|
71
73
|
end
|
72
74
|
@cookbooks_by_name
|
73
75
|
end
|
74
76
|
|
75
|
-
def load_cookbook(cookbook_name
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
loader
|
82
|
-
|
77
|
+
def load_cookbook(cookbook_name)
|
78
|
+
preload_cookbooks
|
79
|
+
|
80
|
+
return nil unless @loaders_by_name.key?(cookbook_name.to_s)
|
81
|
+
|
82
|
+
cookbook_loaders_for(cookbook_name).each do |loader|
|
83
|
+
loader.load
|
84
|
+
|
83
85
|
next if loader.empty?
|
84
|
-
|
85
|
-
@cookbooks_paths[cookbook_name] << cookbook_path # for deprecation warnings
|
86
|
+
|
87
|
+
@cookbooks_paths[cookbook_name] << loader.cookbook_path # for deprecation warnings
|
88
|
+
|
86
89
|
if @loaded_cookbooks.key?(cookbook_name)
|
87
90
|
@merged_cookbooks << cookbook_name # for deprecation warnings
|
88
91
|
@loaded_cookbooks[cookbook_name].merge!(loader)
|
@@ -130,5 +133,50 @@ class Chef
|
|
130
133
|
end
|
131
134
|
alias :cookbooks :values
|
132
135
|
|
136
|
+
private
|
137
|
+
|
138
|
+
def preload_cookbooks
|
139
|
+
return false if @preloaded_cookbooks
|
140
|
+
|
141
|
+
all_directories_in_repo_paths.each do |cookbook_path|
|
142
|
+
preload_cookbook(cookbook_path)
|
143
|
+
end
|
144
|
+
@preloaded_cookbooks = true
|
145
|
+
true
|
146
|
+
end
|
147
|
+
|
148
|
+
def preload_cookbook(cookbook_path)
|
149
|
+
repo_path = File.dirname(cookbook_path)
|
150
|
+
@chefignores[repo_path] ||= Cookbook::Chefignore.new(repo_path)
|
151
|
+
loader = Cookbook::CookbookVersionLoader.new(cookbook_path, @chefignores[repo_path])
|
152
|
+
add_cookbook_loader(loader)
|
153
|
+
end
|
154
|
+
|
155
|
+
def all_directories_in_repo_paths
|
156
|
+
@all_directories_in_repo_paths ||=
|
157
|
+
all_files_in_repo_paths.select { |path| File.directory?(path) }
|
158
|
+
end
|
159
|
+
|
160
|
+
def all_files_in_repo_paths
|
161
|
+
@all_files_in_repo_paths ||=
|
162
|
+
begin
|
163
|
+
@repo_paths.inject([]) do |all_children, repo_path|
|
164
|
+
all_children += Dir[File.join(repo_path, "*")]
|
165
|
+
end
|
166
|
+
end
|
167
|
+
end
|
168
|
+
|
169
|
+
def add_cookbook_loader(loader)
|
170
|
+
cookbook_name = loader.cookbook_name
|
171
|
+
|
172
|
+
@loaders_by_name[cookbook_name.to_s] ||= []
|
173
|
+
@loaders_by_name[cookbook_name.to_s] << loader
|
174
|
+
loader
|
175
|
+
end
|
176
|
+
|
177
|
+
def cookbook_loaders_for(cookbook_name)
|
178
|
+
@loaders_by_name[cookbook_name.to_s]
|
179
|
+
end
|
180
|
+
|
133
181
|
end
|
134
182
|
end
|
@@ -143,7 +143,7 @@ class Chef
|
|
143
143
|
http = Net::HTTP.new(url.host, url.port)
|
144
144
|
if url.scheme == "https"
|
145
145
|
http.use_ssl = true
|
146
|
-
http.verify_mode =
|
146
|
+
http.verify_mode = verify_mode
|
147
147
|
end
|
148
148
|
res = http.request(req)
|
149
149
|
#res = http.start {|http_proc| http_proc.request(req) }
|
@@ -165,6 +165,17 @@ class Chef
|
|
165
165
|
res
|
166
166
|
end
|
167
167
|
|
168
|
+
private
|
169
|
+
|
170
|
+
def verify_mode
|
171
|
+
verify_mode = Chef::Config[:ssl_verify_mode]
|
172
|
+
if verify_mode == :verify_none
|
173
|
+
OpenSSL::SSL::VERIFY_NONE
|
174
|
+
elsif verify_mode == :verify_peer
|
175
|
+
OpenSSL::SSL::VERIFY_PEER
|
176
|
+
end
|
177
|
+
end
|
178
|
+
|
168
179
|
end
|
169
180
|
|
170
181
|
class StreamPart
|
@@ -51,10 +51,14 @@ class Chef
|
|
51
51
|
attr_accessor :provider_filenames
|
52
52
|
attr_accessor :root_filenames
|
53
53
|
attr_accessor :name
|
54
|
-
attr_accessor :metadata
|
55
54
|
attr_accessor :metadata_filenames
|
56
55
|
attr_accessor :status
|
57
56
|
|
57
|
+
# A Chef::Cookbook::Metadata object. It has a setter that fixes up the
|
58
|
+
# metadata to add descriptions of the recipes contained in this
|
59
|
+
# CookbookVersion.
|
60
|
+
attr_reader :metadata
|
61
|
+
|
58
62
|
# attribute_filenames also has a setter that has non-default
|
59
63
|
# functionality.
|
60
64
|
attr_reader :attribute_filenames
|
@@ -195,6 +199,12 @@ class Chef
|
|
195
199
|
attribute_filenames
|
196
200
|
end
|
197
201
|
|
202
|
+
def metadata=(metadata)
|
203
|
+
@metadata = metadata
|
204
|
+
@metadata.recipes_from_cookbook_version(self)
|
205
|
+
@metadata
|
206
|
+
end
|
207
|
+
|
198
208
|
## BACKCOMPAT/DEPRECATED - Remove these and fix breakage before release [DAN - 5/20/2010]##
|
199
209
|
alias :attribute_files :attribute_filenames
|
200
210
|
alias :attribute_files= :attribute_filenames=
|
@@ -405,7 +415,6 @@ class Chef
|
|
405
415
|
records_by_pref[best_pref]
|
406
416
|
end
|
407
417
|
|
408
|
-
|
409
418
|
# Given a node, segment and path (filename or directory name),
|
410
419
|
# return the priority-ordered list of preference locations to
|
411
420
|
# look.
|
@@ -458,9 +467,9 @@ class Chef
|
|
458
467
|
end
|
459
468
|
|
460
469
|
def to_json(*a)
|
461
|
-
result =
|
470
|
+
result = to_hash
|
462
471
|
result['json_class'] = self.class.name
|
463
|
-
|
472
|
+
Chef::JSONCompat.to_json(result, *a)
|
464
473
|
end
|
465
474
|
|
466
475
|
def self.json_create(o)
|