chef 10.34.6 → 11.0.0.beta.0
Sign up to get free protection for your applications and to get access to all the features.
- data/CONTRIBUTING.md +155 -0
- data/README.md +89 -0
- data/Rakefile +4 -12
- data/bin/chef-apply +25 -0
- data/bin/chef-shell +34 -0
- data/bin/shef +6 -5
- data/distro/common/html/chef-client.8.html +4 -4
- data/distro/common/html/chef-expander.8.html +4 -4
- data/distro/common/html/chef-expanderctl.8.html +4 -4
- data/distro/common/html/chef-server-webui.8.html +4 -4
- data/distro/common/html/chef-server.8.html +4 -4
- data/distro/common/html/{shef.1.html → chef-shell.1.html} +49 -46
- data/distro/common/html/chef-solo.8.html +18 -12
- data/distro/common/html/chef-solr.8.html +4 -4
- data/distro/common/html/knife-bootstrap.1.html +4 -4
- data/distro/common/html/knife-client.1.html +4 -4
- data/distro/common/html/knife-configure.1.html +4 -4
- data/distro/common/html/knife-cookbook-site.1.html +4 -4
- data/distro/common/html/knife-cookbook.1.html +10 -7
- data/distro/common/html/knife-data-bag.1.html +10 -7
- data/distro/common/html/knife-environment.1.html +8 -6
- data/distro/common/html/knife-exec.1.html +9 -9
- data/distro/common/html/knife-index.1.html +4 -4
- data/distro/common/html/knife-node.1.html +4 -4
- data/distro/common/html/knife-role.1.html +4 -4
- data/distro/common/html/knife-search.1.html +4 -4
- data/distro/common/html/knife-ssh.1.html +4 -4
- data/distro/common/html/knife-status.1.html +4 -4
- data/distro/common/html/knife-tag.1.html +4 -4
- data/distro/common/html/knife.1.html +8 -13
- data/distro/common/man/man1/{shef.1 → chef-shell.1} +21 -57
- data/distro/common/man/man1/knife-bootstrap.1 +1 -1
- data/distro/common/man/man1/knife-client.1 +1 -1
- data/distro/common/man/man1/knife-configure.1 +1 -1
- data/distro/common/man/man1/knife-cookbook-site.1 +1 -1
- data/distro/common/man/man1/knife-cookbook.1 +15 -2
- data/distro/common/man/man1/knife-data-bag.1 +15 -2
- data/distro/common/man/man1/knife-environment.1 +12 -2
- data/distro/common/man/man1/knife-exec.1 +4 -7
- data/distro/common/man/man1/knife-index.1 +1 -1
- data/distro/common/man/man1/knife-node.1 +1 -1
- data/distro/common/man/man1/knife-role.1 +1 -1
- data/distro/common/man/man1/knife-search.1 +1 -1
- data/distro/common/man/man1/knife-ssh.1 +1 -1
- data/distro/common/man/man1/knife-status.1 +1 -1
- data/distro/common/man/man1/knife-tag.1 +1 -1
- data/distro/common/man/man1/knife.1 +3 -6
- data/distro/common/man/man8/chef-client.8 +1 -1
- data/distro/common/man/man8/chef-expander.8 +1 -1
- data/distro/common/man/man8/chef-expanderctl.8 +1 -1
- data/distro/common/man/man8/chef-server-webui.8 +1 -1
- data/distro/common/man/man8/chef-server.8 +1 -1
- data/distro/common/man/man8/chef-solo.8 +36 -4
- data/distro/common/man/man8/chef-solr.8 +1 -1
- data/distro/common/markdown/man1/{shef.mkd → chef-shell.mkd} +49 -43
- data/distro/common/markdown/man1/knife-exec.mkd +11 -6
- data/distro/common/markdown/man1/knife.mkd +4 -9
- data/distro/debian/etc/default/chef-client +0 -1
- data/distro/debian/etc/init.d/chef-client +2 -2
- data/lib/chef.rb +2 -5
- data/lib/chef/api_client.rb +20 -130
- data/lib/chef/api_client/registration.rb +126 -0
- data/lib/chef/application.rb +71 -14
- data/lib/chef/application/apply.rb +160 -0
- data/lib/chef/application/client.rb +25 -18
- data/lib/chef/application/knife.rb +0 -2
- data/lib/chef/application/solo.rb +23 -8
- data/lib/chef/application/windows_service.rb +5 -2
- data/lib/chef/applications.rb +1 -0
- data/lib/chef/chef_fs.rb +11 -0
- data/lib/chef/chef_fs/command_line.rb +232 -0
- data/lib/chef/chef_fs/file_pattern.rb +312 -0
- data/lib/chef/chef_fs/file_system.rb +358 -0
- data/lib/chef/chef_fs/file_system/base_fs_dir.rb +47 -0
- data/lib/chef/chef_fs/file_system/base_fs_object.rb +121 -0
- data/lib/chef/chef_fs/file_system/chef_repository_file_system_entry.rb +109 -0
- data/{spec/unit/monkey_patches/uri_spec.rb → lib/chef/chef_fs/file_system/chef_repository_file_system_root_dir.rb} +12 -15
- data/lib/chef/chef_fs/file_system/chef_server_root_dir.rb +84 -0
- data/lib/chef/chef_fs/file_system/cookbook_dir.rb +188 -0
- data/lib/chef/chef_fs/file_system/cookbook_file.rb +78 -0
- data/lib/chef/chef_fs/file_system/cookbook_subdir.rb +54 -0
- data/lib/chef/chef_fs/file_system/cookbooks_dir.rb +68 -0
- data/lib/chef/chef_fs/file_system/data_bag_dir.rb +78 -0
- data/lib/chef/chef_fs/file_system/data_bag_item.rb +59 -0
- data/lib/chef/chef_fs/file_system/data_bags_dir.rb +66 -0
- data/lib/chef/chef_fs/file_system/file_system_entry.rb +90 -0
- data/lib/chef/{index_queue.rb → chef_fs/file_system/file_system_error.rb} +14 -12
- data/lib/chef/{resource/whyrun_safe_ruby_block.rb → chef_fs/file_system/file_system_root_dir.rb} +10 -10
- data/lib/chef/chef_fs/file_system/must_delete_recursively_error.rb +31 -0
- data/lib/chef/chef_fs/file_system/nodes_dir.rb +47 -0
- data/lib/chef/{provider/whyrun_safe_ruby_block.rb → chef_fs/file_system/nonexistent_fs_object.rb} +19 -9
- data/lib/chef/chef_fs/file_system/not_found_error.rb +31 -0
- data/lib/chef/chef_fs/file_system/rest_list_dir.rb +84 -0
- data/lib/chef/chef_fs/file_system/rest_list_entry.rb +123 -0
- data/lib/chef/chef_fs/knife.rb +77 -0
- data/lib/chef/chef_fs/path_utils.rb +64 -0
- data/lib/chef/client.rb +44 -21
- data/lib/chef/config.rb +52 -43
- data/lib/chef/cookbook/synchronizer.rb +6 -8
- data/lib/chef/cookbook/syntax_check.rb +61 -14
- data/lib/chef/cookbook_loader.rb +39 -26
- data/lib/chef/cookbook_uploader.rb +17 -19
- data/lib/chef/cookbook_version.rb +3 -302
- data/lib/chef/daemon.rb +3 -18
- data/lib/chef/data_bag.rb +4 -97
- data/lib/chef/data_bag_item.rb +2 -65
- data/lib/chef/digester.rb +73 -0
- data/lib/chef/dsl.rb +6 -0
- data/lib/chef/dsl/data_query.rb +66 -0
- data/lib/chef/dsl/include_attribute.rb +60 -0
- data/lib/chef/dsl/include_recipe.rb +42 -0
- data/lib/chef/dsl/platform_introspection.rb +213 -0
- data/lib/chef/dsl/recipe.rb +84 -0
- data/lib/chef/dsl/registry_helper.rb +59 -0
- data/lib/chef/encrypted_data_bag_item.rb +74 -19
- data/lib/chef/environment.rb +9 -180
- data/lib/chef/exceptions.rb +87 -14
- data/lib/chef/formatters/base.rb +4 -1
- data/lib/chef/formatters/error_inspectors/registration_error_inspector.rb +0 -4
- data/lib/chef/json_compat.rb +1 -97
- data/lib/chef/knife.rb +90 -41
- data/lib/chef/knife/bootstrap/archlinux-gems.erb +2 -2
- data/lib/chef/knife/bootstrap/centos5-gems.erb +2 -2
- data/lib/chef/knife/bootstrap/chef-full.erb +3 -3
- data/lib/chef/knife/bootstrap/fedora13-gems.erb +2 -2
- data/lib/chef/knife/bootstrap/ubuntu10.04-apt.erb +2 -2
- data/lib/chef/knife/bootstrap/ubuntu10.04-gems.erb +2 -2
- data/lib/chef/knife/bootstrap/ubuntu12.04-gems.erb +2 -2
- data/lib/chef/knife/configure.rb +1 -2
- data/lib/chef/knife/cookbook_metadata.rb +1 -0
- data/lib/chef/knife/cookbook_test.rb +3 -2
- data/lib/chef/knife/cookbook_upload.rb +12 -7
- data/lib/chef/knife/core/bootstrap_context.rb +1 -1
- data/lib/chef/knife/core/generic_presenter.rb +26 -13
- data/lib/chef/knife/core/node_editor.rb +36 -16
- data/lib/chef/knife/core/node_presenter.rb +1 -1
- data/lib/chef/knife/core/text_formatter.rb +23 -37
- data/lib/chef/knife/core/ui.rb +15 -9
- data/lib/chef/knife/delete.rb +39 -0
- data/lib/chef/knife/diff.rb +46 -0
- data/lib/chef/knife/download.rb +50 -0
- data/lib/chef/knife/environment_show.rb +7 -0
- data/lib/chef/knife/exec.rb +5 -5
- data/lib/chef/knife/help_topics.rb +1 -1
- data/lib/chef/knife/index_rebuild.rb +91 -7
- data/lib/chef/knife/list.rb +109 -0
- data/lib/chef/knife/raw.rb +108 -0
- data/lib/chef/knife/search.rb +40 -22
- data/lib/chef/knife/show.rb +32 -0
- data/lib/chef/knife/ssh.rb +6 -2
- data/lib/chef/knife/upload.rb +50 -0
- data/lib/chef/mixin/checksum.rb +3 -3
- data/lib/chef/mixin/deep_merge.rb +55 -197
- data/lib/chef/mixin/language.rb +9 -222
- data/lib/chef/mixin/language_include_attribute.rb +6 -38
- data/lib/chef/mixin/language_include_recipe.rb +3 -35
- data/lib/chef/mixin/params_validate.rb +6 -19
- data/lib/chef/mixin/recipe_definition_dsl_core.rb +8 -61
- data/lib/chef/mixin/securable.rb +32 -7
- data/lib/chef/mixin/template.rb +40 -0
- data/lib/chef/mixins.rb +0 -4
- data/lib/chef/monkey_patches/net_http.rb +0 -34
- data/lib/chef/node.rb +133 -309
- data/lib/chef/node/attribute.rb +333 -473
- data/lib/chef/node/attribute_collections.rb +199 -0
- data/lib/chef/node/immutable_collections.rb +186 -0
- data/lib/chef/platform.rb +7 -22
- data/lib/chef/provider.rb +2 -49
- data/lib/chef/provider/breakpoint.rb +6 -6
- data/lib/chef/provider/cookbook_file.rb +5 -33
- data/lib/chef/provider/deploy.rb +2 -1
- data/lib/chef/provider/directory.rb +14 -17
- data/lib/chef/provider/file.rb +19 -52
- data/lib/chef/provider/group.rb +31 -51
- data/lib/chef/provider/group/dscl.rb +13 -53
- data/lib/chef/provider/group/gpasswd.rb +19 -14
- data/lib/chef/provider/group/groupadd.rb +1 -41
- data/lib/chef/provider/group/groupmod.rb +36 -46
- data/lib/chef/provider/group/pw.rb +16 -59
- data/lib/chef/provider/group/suse.rb +13 -16
- data/lib/chef/provider/group/usermod.rb +18 -40
- data/lib/chef/provider/group/windows.rb +6 -13
- data/lib/chef/provider/http_request.rb +25 -42
- data/lib/chef/provider/link.rb +2 -0
- data/lib/chef/provider/lwrp_base.rb +150 -0
- data/lib/chef/provider/package/portage.rb +4 -9
- data/lib/chef/provider/package/rpm.rb +2 -2
- data/lib/chef/provider/package/rubygems.rb +9 -41
- data/lib/chef/provider/package/yum.rb +12 -19
- data/lib/chef/provider/registry_key.rb +156 -0
- data/lib/chef/provider/remote_directory.rb +2 -0
- data/lib/chef/provider/remote_file.rb +21 -12
- data/lib/chef/provider/ruby_block.rb +5 -2
- data/lib/chef/provider/service.rb +15 -0
- data/lib/chef/provider/service/init.rb +9 -7
- data/lib/chef/provider/service/macosx.rb +15 -73
- data/lib/chef/provider/service/simple.rb +1 -1
- data/lib/chef/provider/service/solaris.rb +3 -3
- data/lib/chef/provider/template.rb +22 -25
- data/lib/chef/provider/template_finder.rb +61 -0
- data/lib/chef/provider/user.rb +0 -1
- data/lib/chef/provider/user/dscl.rb +175 -568
- data/lib/chef/provider/user/useradd.rb +30 -47
- data/lib/chef/providers.rb +3 -2
- data/lib/chef/recipe.rb +14 -8
- data/lib/chef/resource.rb +13 -154
- data/lib/chef/resource/group.rb +1 -11
- data/lib/chef/resource/http_request.rb +2 -1
- data/lib/chef/resource/lwrp_base.rb +127 -0
- data/lib/chef/resource/mount.rb +10 -11
- data/lib/chef/resource/registry_key.rb +86 -0
- data/lib/chef/resource/remote_directory.rb +6 -5
- data/lib/chef/resource/remote_file.rb +22 -31
- data/lib/chef/resource/ruby_block.rb +2 -2
- data/lib/chef/resource/service.rb +14 -0
- data/lib/chef/resource/user.rb +0 -18
- data/lib/chef/resource_collection.rb +25 -21
- data/lib/chef/resources.rb +2 -1
- data/lib/chef/rest.rb +50 -131
- data/lib/chef/rest/auth_credentials.rb +4 -20
- data/lib/chef/rest/rest_request.rb +2 -7
- data/lib/chef/role.rb +1 -97
- data/lib/chef/run_context.rb +108 -130
- data/lib/chef/run_context/cookbook_compiler.rb +280 -0
- data/lib/chef/run_list.rb +0 -2
- data/lib/chef/run_list/run_list_expansion.rb +0 -15
- data/lib/chef/run_lock.rb +90 -0
- data/lib/chef/runner.rb +28 -5
- data/lib/chef/sandbox.rb +15 -148
- data/lib/chef/scan_access_control.rb +2 -4
- data/lib/chef/shef/ext.rb +3 -575
- data/lib/chef/{shef.rb → shell.rb} +35 -40
- data/lib/chef/shell/ext.rb +593 -0
- data/lib/chef/{shef → shell}/model_wrapper.rb +3 -3
- data/lib/chef/{shef/shef_rest.rb → shell/shell_rest.rb} +4 -4
- data/lib/chef/{shef/shef_session.rb → shell/shell_session.rb} +17 -15
- data/lib/chef/shell_out.rb +7 -0
- data/lib/chef/util/windows/net_group.rb +1 -5
- data/lib/chef/version.rb +3 -3
- data/lib/chef/win32/api/process.rb +0 -1
- data/lib/chef/win32/handle.rb +1 -8
- data/lib/chef/win32/registry.rb +371 -0
- data/spec/data/big_json.json +1 -2
- data/spec/data/big_json_plus_one.json +1 -2
- data/spec/data/cookbooks/openldap/attributes/default.rb +10 -9
- data/spec/data/cookbooks/openldap/attributes/smokey.rb +1 -1
- data/spec/data/lwrp/providers/inline_compiler.rb +26 -0
- data/spec/data/nodes/default.rb +3 -3
- data/spec/data/nodes/test.example.com.rb +3 -3
- data/spec/data/nodes/test.rb +3 -3
- data/spec/data/partial_one.erb +1 -0
- data/spec/data/run_context/cookbooks/circular-dep1/attributes/default.rb +4 -0
- data/spec/data/run_context/cookbooks/circular-dep1/definitions/circular_dep1_res.rb +1 -0
- data/spec/data/run_context/cookbooks/circular-dep1/libraries/lib.rb +2 -0
- data/spec/data/run_context/cookbooks/circular-dep1/metadata.rb +2 -0
- data/spec/data/run_context/cookbooks/circular-dep1/providers/provider.rb +1 -0
- data/spec/data/{knife-home/.chef/plugins/knife/example_home_subcommand.rb → run_context/cookbooks/circular-dep1/recipes/default.rb} +0 -0
- data/spec/data/run_context/cookbooks/circular-dep1/resources/resource.rb +1 -0
- data/spec/data/run_context/cookbooks/circular-dep2/attributes/default.rb +3 -0
- data/spec/data/run_context/cookbooks/circular-dep2/definitions/circular_dep2_res.rb +1 -0
- data/spec/data/run_context/cookbooks/circular-dep2/libraries/lib.rb +2 -0
- data/spec/data/run_context/cookbooks/circular-dep2/metadata.rb +2 -0
- data/spec/data/run_context/cookbooks/circular-dep2/providers/provider.rb +1 -0
- data/spec/data/{lwrp_const_scoping/resources/conflict.rb → run_context/cookbooks/circular-dep2/recipes/default.rb} +0 -0
- data/spec/data/run_context/cookbooks/circular-dep2/resources/resource.rb +1 -0
- data/spec/data/run_context/cookbooks/dependency1/attributes/aa_first.rb +2 -0
- data/spec/data/run_context/cookbooks/dependency1/attributes/default.rb +2 -0
- data/spec/data/run_context/cookbooks/dependency1/attributes/zz_last.rb +3 -0
- data/spec/data/run_context/cookbooks/dependency1/definitions/dependency1_res.rb +1 -0
- data/spec/data/run_context/cookbooks/dependency1/libraries/lib.rb +2 -0
- data/spec/data/run_context/cookbooks/dependency1/providers/provider.rb +1 -0
- data/spec/data/run_context/cookbooks/dependency1/recipes/default.rb +0 -0
- data/spec/data/run_context/cookbooks/dependency1/resources/resource.rb +1 -0
- data/spec/data/run_context/cookbooks/dependency2/attributes/default.rb +3 -0
- data/spec/data/run_context/cookbooks/dependency2/definitions/dependency2_res.rb +1 -0
- data/spec/data/run_context/cookbooks/dependency2/libraries/lib.rb +2 -0
- data/spec/data/run_context/cookbooks/dependency2/providers/provider.rb +1 -0
- data/spec/data/run_context/cookbooks/dependency2/recipes/default.rb +0 -0
- data/spec/data/run_context/cookbooks/dependency2/resources/resource.rb +1 -0
- data/spec/data/run_context/cookbooks/no-default-attr/attributes/server.rb +3 -0
- data/spec/data/run_context/cookbooks/no-default-attr/definitions/no_default-attr_res.rb +1 -0
- data/spec/data/run_context/cookbooks/no-default-attr/providers/provider.rb +1 -0
- data/spec/data/run_context/cookbooks/no-default-attr/recipes/default.rb +0 -0
- data/spec/data/run_context/cookbooks/no-default-attr/resources/resource.rb +1 -0
- data/spec/data/run_context/cookbooks/test-with-circular-deps/attributes/default.rb +3 -0
- data/spec/data/run_context/cookbooks/test-with-circular-deps/definitions/test_with-circular-deps_res.rb +1 -0
- data/spec/data/run_context/cookbooks/test-with-circular-deps/libraries/lib.rb +2 -0
- data/spec/data/run_context/cookbooks/test-with-circular-deps/metadata.rb +2 -0
- data/spec/data/run_context/cookbooks/test-with-circular-deps/providers/provider.rb +1 -0
- data/spec/data/run_context/cookbooks/test-with-circular-deps/recipes/default.rb +0 -0
- data/spec/data/run_context/cookbooks/test-with-circular-deps/resources/resource.rb +1 -0
- data/spec/data/run_context/cookbooks/test-with-deps/attributes/default.rb +3 -0
- data/spec/data/run_context/cookbooks/test-with-deps/definitions/test_with-deps_res.rb +1 -0
- data/spec/data/run_context/cookbooks/test-with-deps/libraries/lib.rb +1 -0
- data/spec/data/run_context/cookbooks/test-with-deps/metadata.rb +3 -0
- data/spec/data/run_context/cookbooks/test-with-deps/providers/provider.rb +1 -0
- data/spec/data/run_context/cookbooks/test-with-deps/recipes/default.rb +0 -0
- data/spec/data/run_context/cookbooks/test-with-deps/recipes/server.rb +0 -0
- data/spec/data/run_context/cookbooks/test-with-deps/resources/resource.rb +1 -0
- data/spec/data/run_context/cookbooks/test/attributes/default.rb +0 -0
- data/spec/data/run_context/cookbooks/test/attributes/george.rb +1 -1
- data/spec/data/run_context/cookbooks/test/definitions/test_res.rb +1 -0
- data/spec/data/run_context/cookbooks/test/providers/provider.rb +1 -0
- data/spec/data/run_context/cookbooks/test/resources/resource.rb +1 -0
- data/spec/data/shef-config.rb +7 -0
- data/spec/functional/dsl/registry_helper_spec.rb +63 -0
- data/spec/functional/knife/cookbook_delete_spec.rb +1 -1
- data/spec/functional/knife/exec_spec.rb +2 -2
- data/spec/functional/knife/ssh_spec.rb +5 -1
- data/spec/functional/resource/cookbook_file_spec.rb +7 -19
- data/spec/functional/resource/directory_spec.rb +4 -0
- data/spec/functional/resource/file_spec.rb +56 -22
- data/spec/functional/resource/link_spec.rb +2 -0
- data/spec/functional/resource/registry_spec.rb +576 -0
- data/spec/functional/resource/remote_directory_spec.rb +142 -36
- data/spec/functional/resource/remote_file_spec.rb +18 -0
- data/spec/functional/resource/template_spec.rb +23 -2
- data/spec/functional/run_lock_spec.rb +106 -0
- data/spec/functional/shell_spec.rb +100 -0
- data/spec/functional/win32/registry_helper_spec.rb +632 -0
- data/spec/spec_helper.rb +5 -29
- data/spec/stress/win32/security_spec.rb +1 -1
- data/spec/support/chef_helpers.rb +0 -2
- data/spec/support/platform_helpers.rb +8 -15
- data/spec/support/shared/functional/directory_resource.rb +84 -22
- data/spec/support/shared/functional/file_resource.rb +169 -71
- data/spec/support/shared/functional/securable_resource.rb +143 -119
- data/spec/support/shared/functional/securable_resource_with_reporting.rb +375 -0
- data/spec/support/shared/unit/file_system_support.rb +110 -0
- data/spec/support/shared/unit/platform_introspector.rb +162 -0
- data/spec/unit/api_client/registration_spec.rb +175 -0
- data/spec/unit/api_client_spec.rb +78 -156
- data/spec/unit/application/apply.rb +84 -0
- data/spec/unit/application/client_spec.rb +1 -37
- data/spec/unit/application/knife_spec.rb +5 -0
- data/spec/unit/application_spec.rb +57 -2
- data/spec/unit/checksum/storage/filesystem_spec.rb +1 -1
- data/spec/unit/chef_fs/diff_spec.rb +328 -0
- data/spec/unit/chef_fs/file_pattern_spec.rb +526 -0
- data/spec/unit/chef_fs/file_system/chef_server_root_dir_spec.rb +237 -0
- data/spec/unit/chef_fs/file_system/cookbooks_dir_spec.rb +568 -0
- data/spec/unit/chef_fs/file_system/data_bags_dir_spec.rb +220 -0
- data/spec/unit/chef_fs/file_system_spec.rb +136 -0
- data/spec/unit/client_spec.rb +124 -33
- data/spec/unit/config_spec.rb +46 -13
- data/spec/unit/cookbook/synchronizer_spec.rb +1 -49
- data/spec/unit/cookbook/syntax_check_spec.rb +48 -109
- data/spec/unit/cookbook_loader_spec.rb +153 -91
- data/spec/unit/cookbook_manifest_spec.rb +81 -81
- data/spec/unit/cookbook_spec.rb +3 -20
- data/spec/unit/cookbook_version_spec.rb +23 -122
- data/spec/unit/daemon_spec.rb +3 -24
- data/spec/unit/data_bag_spec.rb +6 -4
- data/spec/unit/digester_spec.rb +50 -0
- data/spec/unit/dsl/data_query_spec.rb +66 -0
- data/spec/unit/dsl/platform_introspection_spec.rb +130 -0
- data/spec/unit/dsl/regsitry_helper_spec.rb +55 -0
- data/spec/unit/encrypted_data_bag_item_spec.rb +50 -105
- data/spec/unit/environment_spec.rb +0 -130
- data/spec/unit/exceptions_spec.rb +2 -3
- data/spec/unit/formatters/error_inspectors/resource_failure_inspector_spec.rb +3 -3
- data/spec/unit/json_compat_spec.rb +15 -7
- data/spec/unit/knife/bootstrap_spec.rb +2 -0
- data/spec/unit/knife/configure_spec.rb +20 -14
- data/spec/unit/knife/cookbook_metadata_spec.rb +11 -4
- data/spec/unit/knife/cookbook_test_spec.rb +1 -0
- data/spec/unit/knife/cookbook_upload_spec.rb +43 -8
- data/spec/unit/knife/core/bootstrap_context_spec.rb +1 -1
- data/spec/unit/knife/core/ui_spec.rb +156 -125
- data/spec/unit/knife/data_bag_create_spec.rb +9 -0
- data/spec/unit/knife/data_bag_edit_spec.rb +1 -4
- data/spec/unit/knife/data_bag_from_file_spec.rb +4 -6
- data/spec/unit/knife/data_bag_show_spec.rb +11 -4
- data/spec/unit/knife/index_rebuild_spec.rb +96 -33
- data/spec/unit/knife/knife_help.rb +7 -7
- data/spec/unit/knife/node_edit_spec.rb +6 -33
- data/spec/unit/knife/node_run_list_remove_spec.rb +2 -1
- data/spec/unit/knife/ssh_spec.rb +12 -15
- data/spec/unit/knife/status_spec.rb +2 -2
- data/spec/unit/knife_spec.rb +53 -0
- data/spec/unit/lwrp_spec.rb +59 -42
- data/spec/unit/mixin/checksum_spec.rb +2 -2
- data/spec/unit/mixin/deep_merge_spec.rb +101 -799
- data/spec/unit/mixin/enforce_ownership_and_permissions_spec.rb +6 -1
- data/spec/unit/mixin/params_validate_spec.rb +4 -37
- data/spec/unit/mixin/securable_spec.rb +5 -3
- data/spec/unit/mixin/template_spec.rb +119 -0
- data/spec/unit/node/attribute_spec.rb +195 -173
- data/spec/unit/node/immutable_collections_spec.rb +139 -0
- data/spec/unit/node_spec.rb +366 -370
- data/spec/unit/platform_spec.rb +9 -10
- data/spec/unit/provider/breakpoint_spec.rb +8 -8
- data/spec/unit/provider/cookbook_file_spec.rb +4 -8
- data/spec/unit/provider/directory_spec.rb +96 -64
- data/spec/unit/provider/env_spec.rb +2 -2
- data/spec/unit/provider/file_spec.rb +48 -39
- data/spec/unit/provider/group/dscl_spec.rb +0 -36
- data/spec/unit/provider/group/gpasswd_spec.rb +9 -16
- data/spec/unit/provider/group/groupadd_spec.rb +4 -3
- data/spec/unit/provider/group/groupmod_spec.rb +1 -0
- data/spec/unit/provider/group/pw_spec.rb +15 -12
- data/spec/unit/provider/group/usermod_spec.rb +6 -21
- data/spec/unit/provider/group/windows_spec.rb +8 -0
- data/spec/unit/provider/group_spec.rb +6 -28
- data/spec/unit/provider/http_request_spec.rb +28 -69
- data/spec/unit/provider/ifconfig_spec.rb +2 -2
- data/spec/unit/provider/ohai_spec.rb +4 -4
- data/spec/unit/provider/package/apt_spec.rb +0 -1
- data/spec/unit/provider/package/ips_spec.rb +0 -1
- data/spec/unit/provider/package/portage_spec.rb +0 -44
- data/spec/unit/provider/package/rpm_spec.rb +0 -12
- data/spec/unit/provider/package/rubygems_spec.rb +1 -44
- data/spec/unit/provider/package/yum_spec.rb +39 -36
- data/spec/unit/provider/package_spec.rb +7 -5
- data/spec/unit/provider/registry_key_spec.rb +269 -0
- data/spec/unit/provider/remote_directory_spec.rb +7 -3
- data/spec/unit/provider/remote_file_spec.rb +36 -0
- data/spec/unit/provider/route_spec.rb +4 -3
- data/spec/unit/provider/ruby_block_spec.rb +8 -0
- data/spec/unit/provider/service/arch_service_spec.rb +5 -5
- data/spec/unit/provider/service/debian_service_spec.rb +1 -1
- data/spec/unit/provider/service/freebsd_service_spec.rb +5 -5
- data/spec/unit/provider/service/init_service_spec.rb +27 -4
- data/spec/unit/provider/service/insserv_service_spec.rb +1 -1
- data/spec/unit/provider/service/invokercd_service_spec.rb +4 -4
- data/spec/unit/provider/service/macosx_spec.rb +11 -66
- data/spec/unit/provider/service/redhat_spec.rb +1 -1
- data/spec/unit/provider/service/simple_service_spec.rb +3 -3
- data/spec/unit/provider/service/upstart_service_spec.rb +9 -9
- data/spec/unit/provider/subversion_spec.rb +1 -1
- data/spec/unit/provider/template_spec.rb +35 -11
- data/spec/unit/provider/user/dscl_spec.rb +285 -681
- data/spec/unit/provider/user/useradd_spec.rb +1 -22
- data/spec/unit/provider/user_spec.rb +1 -1
- data/spec/unit/recipe_spec.rb +10 -8
- data/spec/unit/registry_helper_spec.rb +374 -0
- data/spec/unit/resource/mount_spec.rb +0 -11
- data/spec/unit/resource/registry_key_spec.rb +171 -0
- data/spec/unit/resource/remote_file_spec.rb +21 -23
- data/spec/unit/resource/ruby_block_spec.rb +7 -3
- data/spec/unit/resource/service_spec.rb +11 -0
- data/spec/unit/resource_spec.rb +4 -19
- data/spec/unit/rest/auth_credentials_spec.rb +2 -19
- data/spec/unit/rest_spec.rb +130 -284
- data/spec/unit/run_context/cookbook_compiler_spec.rb +181 -0
- data/spec/unit/run_context_spec.rb +18 -4
- data/spec/unit/run_list_spec.rb +0 -209
- data/spec/unit/run_lock_spec.rb +37 -0
- data/spec/unit/runner_spec.rb +101 -2
- data/spec/unit/scan_access_control_spec.rb +4 -4
- data/spec/unit/{shef → shell}/model_wrapper_spec.rb +5 -5
- data/spec/unit/{shef/shef_ext_spec.rb → shell/shell_ext_spec.rb} +21 -21
- data/spec/unit/{shef/shef_session_spec.rb → shell/shell_session_spec.rb} +14 -69
- data/spec/unit/shell_out_spec.rb +18 -0
- data/spec/unit/{shef_spec.rb → shell_spec.rb} +20 -20
- metadata +275 -234
- checksums.yaml +0 -15
- data/README.rdoc +0 -177
- data/distro/common/html/knife-recipe.1.html +0 -92
- data/lib/chef/certificate.rb +0 -161
- data/lib/chef/checksum.rb +0 -167
- data/lib/chef/checksum_cache.rb +0 -190
- data/lib/chef/cookbook_version_selector.rb +0 -168
- data/lib/chef/couchdb.rb +0 -246
- data/lib/chef/index_queue/amqp_client.rb +0 -116
- data/lib/chef/index_queue/consumer.rb +0 -76
- data/lib/chef/index_queue/indexable.rb +0 -109
- data/lib/chef/knife/bootstrap/ubuntu12.10-gems.erb +0 -60
- data/lib/chef/monkey_patches/moneta.rb +0 -50
- data/lib/chef/monkey_patches/uri.rb +0 -70
- data/lib/chef/openid_registration.rb +0 -187
- data/lib/chef/provider/user/solaris.rb +0 -90
- data/lib/chef/solr_query.rb +0 -187
- data/lib/chef/solr_query/lucene.treetop +0 -150
- data/lib/chef/solr_query/lucene_nodes.rb +0 -285
- data/lib/chef/solr_query/query_transform.rb +0 -65
- data/lib/chef/solr_query/solr_http_request.rb +0 -132
- data/lib/chef/webui_user.rb +0 -231
- data/spec/data/cookbooks/openldap/files/default/.dotfile +0 -1
- data/spec/data/cookbooks/openldap/files/default/.ssh/id_rsa +0 -1
- data/spec/data/cookbooks/openldap/files/default/remotedir/.a_dotdir/.a_dotfile_in_a_dotdir +0 -1
- data/spec/data/cookbooks/openldap/files/default/remotedir/remotesubdir/.a_dotfile +0 -1
- data/spec/data/mac_users/10.7-8.plist.xml +0 -559
- data/spec/data/mac_users/10.7-8.shadow.xml +0 -11
- data/spec/data/mac_users/10.7.plist.xml +0 -559
- data/spec/data/mac_users/10.7.shadow.xml +0 -11
- data/spec/data/mac_users/10.8.plist.xml +0 -559
- data/spec/data/mac_users/10.8.shadow.xml +0 -21
- data/spec/data/mac_users/10.9.plist.xml +0 -560
- data/spec/data/mac_users/10.9.shadow.xml +0 -21
- data/spec/functional/resource/base.rb +0 -40
- data/spec/functional/resource/group_spec.rb +0 -343
- data/spec/functional/resource/user/dscl_spec.rb +0 -199
- data/spec/unit/certificate_spec.rb +0 -76
- data/spec/unit/checksum_cache_spec.rb +0 -209
- data/spec/unit/checksum_spec.rb +0 -94
- data/spec/unit/couchdb_spec.rb +0 -274
- data/spec/unit/index_queue_spec.rb +0 -391
- data/spec/unit/mixin/language_spec.rb +0 -305
- data/spec/unit/openid_registration_spec.rb +0 -153
- data/spec/unit/provider/user/solaris_spec.rb +0 -414
- data/spec/unit/provider/whyrun_safe_ruby_block_spec.rb +0 -47
- data/spec/unit/solr_query/query_transform_spec.rb +0 -454
- data/spec/unit/solr_query/solr_http_request_spec.rb +0 -244
- data/spec/unit/solr_query_spec.rb +0 -203
- data/spec/unit/webui_user_spec.rb +0 -238
data/spec/unit/config_spec.rb
CHANGED
@@ -50,7 +50,7 @@ describe Chef::Config do
|
|
50
50
|
before do
|
51
51
|
Chef::Config.chef_server_url = "https://junglist.gen.nz"
|
52
52
|
end
|
53
|
-
|
53
|
+
|
54
54
|
it_behaves_like "server URL"
|
55
55
|
end
|
56
56
|
|
@@ -58,10 +58,54 @@ describe Chef::Config do
|
|
58
58
|
before do
|
59
59
|
Chef::Config.chef_server_url = " https://junglist.gen.nz"
|
60
60
|
end
|
61
|
-
|
61
|
+
|
62
62
|
it_behaves_like "server URL"
|
63
63
|
end
|
64
64
|
|
65
|
+
describe "when configuring formatters" do
|
66
|
+
# if TTY and not(force-logger)
|
67
|
+
# formatter = configured formatter or default formatter
|
68
|
+
# formatter goes to STDOUT/ERR
|
69
|
+
# if log file is writeable
|
70
|
+
# log level is configured level or info
|
71
|
+
# log location is file
|
72
|
+
# else
|
73
|
+
# log level is warn
|
74
|
+
# log location is STDERR
|
75
|
+
# end
|
76
|
+
# elsif not(TTY) and force formatter
|
77
|
+
# formatter = configured formatter or default formatter
|
78
|
+
# if log_location specified
|
79
|
+
# formatter goes to log_location
|
80
|
+
# else
|
81
|
+
# formatter goes to STDOUT/ERR
|
82
|
+
# end
|
83
|
+
# else
|
84
|
+
# formatter = "null"
|
85
|
+
# log_location = configured-value or defualt
|
86
|
+
# log_level = info or defualt
|
87
|
+
# end
|
88
|
+
#
|
89
|
+
before do
|
90
|
+
@config_class = Class.new(Chef::Config)
|
91
|
+
end
|
92
|
+
|
93
|
+
it "has an empty list of formatters by default" do
|
94
|
+
@config_class.formatters.should == []
|
95
|
+
end
|
96
|
+
|
97
|
+
it "configures a formatter with a short name" do
|
98
|
+
@config_class.add_formatter(:doc)
|
99
|
+
@config_class.formatters.should == [[:doc, nil]]
|
100
|
+
end
|
101
|
+
|
102
|
+
it "configures a formatter with a file output" do
|
103
|
+
@config_class.add_formatter(:doc, "/var/log/formatter.log")
|
104
|
+
@config_class.formatters.should == [[:doc, "/var/log/formatter.log"]]
|
105
|
+
end
|
106
|
+
|
107
|
+
end
|
108
|
+
|
65
109
|
context "when the url is a frozen string" do
|
66
110
|
before do
|
67
111
|
Chef::Config.chef_server_url = " https://junglist.gen.nz".freeze
|
@@ -217,17 +261,6 @@ describe Chef::Config do
|
|
217
261
|
end
|
218
262
|
end
|
219
263
|
|
220
|
-
describe "Chef::Config[:event_handlers]" do
|
221
|
-
it "sets a event_handlers to an empty array by default" do
|
222
|
-
Chef::Config[:event_handlers].should eq([])
|
223
|
-
end
|
224
|
-
it "should be able to add custom handlers" do
|
225
|
-
o = Object.new
|
226
|
-
Chef::Config[:event_handlers] << o
|
227
|
-
Chef::Config[:event_handlers].should be_include(o)
|
228
|
-
end
|
229
|
-
end
|
230
|
-
|
231
264
|
after(:each) do
|
232
265
|
Chef::Config.configuration = @original_config
|
233
266
|
end
|
@@ -63,7 +63,6 @@ describe Chef::CookbookSynchronizer do
|
|
63
63
|
"checksum" => "abc456" }
|
64
64
|
@cookbook_a_manifest["attributes"] = [ @cookbook_a_default_attrs ]
|
65
65
|
@cookbook_a_manifest["templates"] = [{"path" => "templates/default/apache2.conf.erb", "url" => "http://chef.example.com/ffffff"}]
|
66
|
-
@cookbook_a_manifest["files"] = [{"path" => "files/default/megaman.conf", "url" => "http://chef.example.com/megaman.conf"}]
|
67
66
|
@cookbook_a.manifest = @cookbook_a_manifest
|
68
67
|
@cookbook_manifest["cookbook_a"] = @cookbook_a
|
69
68
|
|
@@ -103,7 +102,7 @@ describe Chef::CookbookSynchronizer do
|
|
103
102
|
before do
|
104
103
|
# Would rather not stub out methods on the test subject, but setting up
|
105
104
|
# the state is a PITA and tests for this behavior are above.
|
106
|
-
@synchronizer.
|
105
|
+
@synchronizer.should_receive(:clear_obsoleted_cookbooks)
|
107
106
|
|
108
107
|
@server_api = mock("Chef::REST (mock)")
|
109
108
|
@file_cache = mock("Chef::FileCache (mock)")
|
@@ -163,53 +162,6 @@ describe Chef::CookbookSynchronizer do
|
|
163
162
|
@synchronizer.sync_cookbooks
|
164
163
|
end
|
165
164
|
|
166
|
-
context "Chef::Config[:no_lazy_load] is true" do
|
167
|
-
before do
|
168
|
-
Chef::Config[:no_lazy_load] = true
|
169
|
-
@synchronizer = Chef::CookbookSynchronizer.new(@cookbook_manifest, @events)
|
170
|
-
@synchronizer.stub!(:server_api).and_return(@server_api)
|
171
|
-
@synchronizer.stub!(:cache).and_return(@file_cache)
|
172
|
-
@synchronizer.stub!(:clear_obsoleted_cookbooks)
|
173
|
-
|
174
|
-
@cookbook_a_file_default_tempfile = mock("Tempfile for cookbook_a megaman.conf file",
|
175
|
-
:path => "/tmp/cookbook_a_file_default_tempfile")
|
176
|
-
@cookbook_a_template_default_tempfile = mock("Tempfile for cookbook_a apache.conf.erb template",
|
177
|
-
:path => "/tmp/cookbook_a_template_default_tempfile")
|
178
|
-
end
|
179
|
-
|
180
|
-
after do
|
181
|
-
Chef::Config[:no_lazy_load] = false
|
182
|
-
end
|
183
|
-
|
184
|
-
it "fetches templates and cookbook files" do
|
185
|
-
@file_cache.should_receive(:has_key?).
|
186
|
-
with("cookbooks/cookbook_a/files/default/megaman.conf").
|
187
|
-
and_return(false)
|
188
|
-
@file_cache.should_receive(:has_key?).
|
189
|
-
with("cookbooks/cookbook_a/templates/default/apache2.conf.erb").
|
190
|
-
and_return(false)
|
191
|
-
|
192
|
-
@server_api.should_receive(:get_rest).
|
193
|
-
with('http://chef.example.com/megaman.conf', true).
|
194
|
-
and_return(@cookbook_a_file_default_tempfile)
|
195
|
-
@file_cache.should_receive(:move_to).
|
196
|
-
with("/tmp/cookbook_a_file_default_tempfile", "cookbooks/cookbook_a/files/default/megaman.conf")
|
197
|
-
@file_cache.should_receive(:load).
|
198
|
-
with("cookbooks/cookbook_a/files/default/megaman.conf", false).
|
199
|
-
and_return("/file-cache/cookbooks/cookbook_a/default/megaman.conf")
|
200
|
-
|
201
|
-
@server_api.should_receive(:get_rest).
|
202
|
-
with('http://chef.example.com/ffffff', true).
|
203
|
-
and_return(@cookbook_a_template_default_tempfile)
|
204
|
-
@file_cache.should_receive(:move_to).
|
205
|
-
with("/tmp/cookbook_a_template_default_tempfile", "cookbooks/cookbook_a/templates/default/apache2.conf.erb")
|
206
|
-
@file_cache.should_receive(:load).
|
207
|
-
with("cookbooks/cookbook_a/templates/default/apache2.conf.erb", false).
|
208
|
-
and_return("/file-cache/cookbooks/cookbook_a/templates/default/apache2.conf.erb")
|
209
|
-
|
210
|
-
@synchronizer.sync_cookbooks
|
211
|
-
end
|
212
|
-
end
|
213
165
|
end
|
214
166
|
|
215
167
|
context "when the cache contains outdated files" do
|
@@ -16,175 +16,114 @@
|
|
16
16
|
# limitations under the License.
|
17
17
|
#
|
18
18
|
|
19
|
-
###################################################
|
20
|
-
# OLD:
|
21
|
-
###################################################
|
22
|
-
# def test_ruby(cookbook_dir)
|
23
|
-
# cache = Chef::ChecksumCache.instance
|
24
|
-
# Dir[File.join(cookbook_dir, '**', '*.rb')].each do |ruby_file|
|
25
|
-
# key = cache.generate_key(ruby_file, "chef-test")
|
26
|
-
# fstat = File.stat(ruby_file)
|
27
|
-
#
|
28
|
-
# if cache.lookup_checksum(key, fstat)
|
29
|
-
# Chef::Log.info("No change in checksum of #{ruby_file}")
|
30
|
-
# else
|
31
|
-
# Chef::Log.info("Testing #{ruby_file} for syntax errors...")
|
32
|
-
# Chef::Mixin::Command.run_command(:command => "ruby -c #{ruby_file}", :output_on_failure => true)
|
33
|
-
# cache.generate_checksum(key, ruby_file, fstat)
|
34
|
-
# end
|
35
|
-
# end
|
36
|
-
# end
|
37
|
-
#
|
38
|
-
#def test_templates(cookbook_dir)
|
39
|
-
# cache = Chef::ChecksumCache.instance
|
40
|
-
# Dir[File.join(cookbook_dir, '**', '*.erb')].each do |erb_file|
|
41
|
-
# key = cache.generate_key(erb_file, "chef-test")
|
42
|
-
# fstat = File.stat(erb_file)
|
43
|
-
#
|
44
|
-
# if cache.lookup_checksum(key, fstat)
|
45
|
-
# Chef::Log.info("No change in checksum of #{erb_file}")
|
46
|
-
# else
|
47
|
-
# Chef::Log.info("Testing template #{erb_file} for syntax errors...")
|
48
|
-
# Chef::Mixin::Command.run_command(:command => "sh -c 'erubis -x #{erb_file} | ruby -c'", :output_on_failure => true)
|
49
|
-
# cache.generate_checksum(key, erb_file, fstat)
|
50
|
-
# end
|
51
|
-
# end
|
52
|
-
#end
|
53
|
-
#
|
54
|
-
|
55
|
-
###################################################
|
56
|
-
# NEW:
|
57
|
-
###################################################
|
58
|
-
# def test_template_file(cookbook_dir, erb_file)
|
59
|
-
# Chef::Log.debug("Testing template #{erb_file} for syntax errors...")
|
60
|
-
# result = shell_out("sh -c 'erubis -x #{erb_file} | ruby -c'")
|
61
|
-
# result.error!
|
62
|
-
# rescue Mixlib::ShellOut::ShellCommandFailed
|
63
|
-
# file_relative_path = erb_file[/^#{Regexp.escape(cookbook_dir+File::Separator)}(.*)/, 1]
|
64
|
-
# Chef::Log.fatal("Erb template #{file_relative_path} has a syntax error:")
|
65
|
-
# result.stderr.each_line { |l| Chef::Log.fatal(l.chomp) }
|
66
|
-
# exit(1)
|
67
|
-
# end
|
68
|
-
#
|
69
|
-
# def test_ruby_file(cookbook_dir, ruby_file)
|
70
|
-
# Chef::Log.debug("Testing #{ruby_file} for syntax errors...")
|
71
|
-
# result = shell_out("ruby -c #{ruby_file}")
|
72
|
-
# result.error!
|
73
|
-
# rescue Mixlib::ShellOut::ShellCommandFailed
|
74
|
-
# file_relative_path = ruby_file[/^#{Regexp.escape(cookbook_dir+File::Separator)}(.*)/, 1]
|
75
|
-
# Chef::Log.fatal("Cookbook file #{file_relative_path} has a syntax error:")
|
76
|
-
# result.stderr.each_line { |l| Chef::Log.fatal(l.chomp) }
|
77
|
-
# exit(1)
|
78
|
-
# end
|
79
|
-
#
|
80
|
-
|
81
19
|
require 'spec_helper'
|
82
20
|
require "chef/cookbook/syntax_check"
|
83
21
|
|
84
22
|
describe Chef::Cookbook::SyntaxCheck do
|
23
|
+
|
24
|
+
let(:cookbook_path) { File.join(CHEF_SPEC_DATA, 'cookbooks', 'openldap') }
|
25
|
+
let(:syntax_check) { Chef::Cookbook::SyntaxCheck.new(cookbook_path) }
|
26
|
+
|
85
27
|
before do
|
86
28
|
Chef::Log.logger = Logger.new(StringIO.new)
|
29
|
+
Chef::Log.level = :warn # suppress "Syntax OK" messages
|
87
30
|
|
88
|
-
@cookbook_path = File.join(CHEF_SPEC_DATA, 'cookbooks', 'openldap')
|
89
31
|
|
90
|
-
@attr_files = %w{default.rb smokey.rb}.map { |f| File.join(
|
91
|
-
@defn_files = %w{client.rb server.rb}.map { |f| File.join(
|
92
|
-
@recipes = %w{default.rb gigantor.rb one.rb}.map { |f| File.join(
|
32
|
+
@attr_files = %w{default.rb smokey.rb}.map { |f| File.join(cookbook_path, 'attributes', f) }
|
33
|
+
@defn_files = %w{client.rb server.rb}.map { |f| File.join(cookbook_path, 'definitions', f)}
|
34
|
+
@recipes = %w{default.rb gigantor.rb one.rb}.map { |f| File.join(cookbook_path, 'recipes', f) }
|
93
35
|
@ruby_files = @attr_files + @defn_files + @recipes
|
94
36
|
|
95
|
-
@template_files = %w{openldap_stuff.conf.erb openldap_variable_stuff.conf.erb test.erb}.map { |f| File.join(
|
37
|
+
@template_files = %w{openldap_stuff.conf.erb openldap_variable_stuff.conf.erb test.erb}.map { |f| File.join(cookbook_path, 'templates', 'default', f)}
|
96
38
|
|
97
|
-
@syntax_check = Chef::Cookbook::SyntaxCheck.new(@cookbook_path)
|
98
39
|
end
|
99
40
|
|
100
41
|
it "creates a syntax checker given the cookbook name when Chef::Config.cookbook_path is set" do
|
101
|
-
Chef::Config[:cookbook_path] = File.dirname(
|
42
|
+
Chef::Config[:cookbook_path] = File.dirname(cookbook_path)
|
102
43
|
syntax_check = Chef::Cookbook::SyntaxCheck.for_cookbook(:openldap)
|
103
|
-
syntax_check.cookbook_path.should ==
|
44
|
+
syntax_check.cookbook_path.should == cookbook_path
|
104
45
|
end
|
105
46
|
|
106
47
|
describe "when first created" do
|
107
48
|
it "has the path to the cookbook to syntax check" do
|
108
|
-
|
109
|
-
end
|
110
|
-
|
111
|
-
it "has access to the checksum cache" do
|
112
|
-
@syntax_check.cache.should equal(Chef::ChecksumCache.instance)
|
49
|
+
syntax_check.cookbook_path.should == cookbook_path
|
113
50
|
end
|
114
51
|
|
115
52
|
it "lists the ruby files in the cookbook" do
|
116
|
-
|
53
|
+
syntax_check.ruby_files.sort.should == @ruby_files.sort
|
117
54
|
end
|
118
55
|
|
119
56
|
it "lists the erb templates in the cookbook" do
|
120
|
-
|
57
|
+
syntax_check.template_files.sort.should == @template_files.sort
|
121
58
|
end
|
122
59
|
|
123
60
|
end
|
124
61
|
|
125
62
|
describe "when validating cookbooks" do
|
63
|
+
let(:cache_path) { Dir.mktmpdir }
|
64
|
+
|
126
65
|
before do
|
127
|
-
Chef::Config[:
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
66
|
+
Chef::Config[:syntax_check_cache_path] = cache_path
|
67
|
+
end
|
68
|
+
|
69
|
+
after do
|
70
|
+
FileUtils.rm_rf(cache_path) if File.exist?(cache_path)
|
71
|
+
Chef::Config[:syntax_check_cache_path] = nil
|
133
72
|
end
|
134
73
|
|
135
74
|
describe "and the files have not been syntax checked previously" do
|
136
75
|
it "shows that all ruby files require a syntax check" do
|
137
|
-
|
76
|
+
syntax_check.untested_ruby_files.sort.should == @ruby_files.sort
|
138
77
|
end
|
139
78
|
|
140
79
|
it "shows that all template files require a syntax check" do
|
141
|
-
|
80
|
+
syntax_check.untested_template_files.sort.should == @template_files.sort
|
142
81
|
end
|
143
82
|
|
144
83
|
it "removes a ruby file from the list of untested files after it is marked as validated" do
|
145
|
-
recipe = File.join(
|
146
|
-
|
147
|
-
|
84
|
+
recipe = File.join(cookbook_path, 'recipes', 'default.rb')
|
85
|
+
syntax_check.validated(recipe)
|
86
|
+
syntax_check.untested_ruby_files.should_not include(recipe)
|
148
87
|
end
|
149
88
|
|
150
89
|
it "removes a template file from the list of untested files after it is marked as validated" do
|
151
|
-
template = File.join(
|
152
|
-
|
153
|
-
|
90
|
+
template = File.join(cookbook_path, 'templates', 'default', 'test.erb')
|
91
|
+
syntax_check.validated(template)
|
92
|
+
syntax_check.untested_template_files.should_not include(template)
|
154
93
|
end
|
155
94
|
|
156
95
|
it "validates all ruby files" do
|
157
|
-
|
158
|
-
|
96
|
+
syntax_check.validate_ruby_files.should be_true
|
97
|
+
syntax_check.untested_ruby_files.should be_empty
|
159
98
|
end
|
160
99
|
|
161
100
|
it "validates all templates" do
|
162
|
-
|
163
|
-
|
101
|
+
syntax_check.validate_templates.should be_true
|
102
|
+
syntax_check.untested_template_files.should be_empty
|
164
103
|
end
|
165
104
|
|
166
105
|
describe "and a file has a syntax error" do
|
167
106
|
before do
|
168
|
-
|
169
|
-
|
107
|
+
cookbook_path = File.join(CHEF_SPEC_DATA, 'cookbooks', 'borken')
|
108
|
+
syntax_check.cookbook_path.replace(cookbook_path)
|
170
109
|
end
|
171
110
|
|
172
111
|
it "it indicates that a ruby file has a syntax error" do
|
173
|
-
|
112
|
+
syntax_check.validate_ruby_files.should be_false
|
174
113
|
end
|
175
114
|
|
176
115
|
it "does not remove the invalid file from the list of untested files" do
|
177
|
-
|
178
|
-
lambda {
|
116
|
+
syntax_check.untested_ruby_files.should include(File.join(cookbook_path, 'recipes', 'default.rb'))
|
117
|
+
lambda { syntax_check.validate_ruby_files }.should_not change(syntax_check, :untested_ruby_files)
|
179
118
|
end
|
180
119
|
|
181
120
|
it "indicates that a template file has a syntax error" do
|
182
|
-
|
121
|
+
syntax_check.validate_templates.should be_false
|
183
122
|
end
|
184
123
|
|
185
124
|
it "does not remove the invalid template from the list of untested templates" do
|
186
|
-
|
187
|
-
lambda {
|
125
|
+
syntax_check.untested_template_files.should include(File.join(cookbook_path, 'templates', 'default', 'borken.erb'))
|
126
|
+
lambda {syntax_check.validate_templates}.should_not change(syntax_check, :untested_template_files)
|
188
127
|
end
|
189
128
|
|
190
129
|
end
|
@@ -193,18 +132,18 @@ describe Chef::Cookbook::SyntaxCheck do
|
|
193
132
|
|
194
133
|
describe "and the files have been syntax checked previously" do
|
195
134
|
before do
|
196
|
-
|
197
|
-
|
135
|
+
syntax_check.untested_ruby_files.each { |f| syntax_check.validated(f) }
|
136
|
+
syntax_check.untested_template_files.each { |f| syntax_check.validated(f) }
|
198
137
|
end
|
199
138
|
|
200
139
|
it "does not syntax check ruby files" do
|
201
|
-
|
202
|
-
|
140
|
+
syntax_check.should_not_receive(:shell_out)
|
141
|
+
syntax_check.validate_ruby_files.should be_true
|
203
142
|
end
|
204
143
|
|
205
144
|
it "does not syntax check templates" do
|
206
|
-
|
207
|
-
|
145
|
+
syntax_check.should_not_receive(:shell_out)
|
146
|
+
syntax_check.validate_templates.should be_true
|
208
147
|
end
|
209
148
|
end
|
210
149
|
end
|
@@ -25,121 +25,183 @@ describe Chef::CookbookLoader do
|
|
25
25
|
@cookbook_loader = Chef::CookbookLoader.new(@repo_paths)
|
26
26
|
end
|
27
27
|
|
28
|
-
describe "
|
29
|
-
|
30
|
-
@cookbook_loader
|
28
|
+
describe "loading all cookbooks" do
|
29
|
+
before(:each) do
|
30
|
+
@cookbook_loader.load_cookbooks
|
31
31
|
end
|
32
32
|
|
33
|
+
describe "[]" do
|
34
|
+
it "should return cookbook objects with []" do
|
35
|
+
@cookbook_loader[:openldap].should be_a_kind_of(Chef::CookbookVersion)
|
36
|
+
end
|
33
37
|
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
it "should allow you to look up available cookbooks with [] and a symbol" do
|
39
|
-
@cookbook_loader[:openldap].name.should eql(:openldap)
|
40
|
-
end
|
38
|
+
it "should raise an exception if it cannot find a cookbook with []" do
|
39
|
+
lambda { @cookbook_loader[:monkeypoop] }.should raise_error(Chef::Exceptions::CookbookNotFoundInRepo)
|
40
|
+
end
|
41
41
|
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
end
|
42
|
+
it "should allow you to look up available cookbooks with [] and a symbol" do
|
43
|
+
@cookbook_loader[:openldap].name.should eql(:openldap)
|
44
|
+
end
|
46
45
|
|
47
|
-
|
48
|
-
|
49
|
-
seen = Hash.new
|
50
|
-
@cookbook_loader.each do |cookbook_name, cookbook|
|
51
|
-
seen[cookbook_name] = true
|
46
|
+
it "should allow you to look up available cookbooks with [] and a string" do
|
47
|
+
@cookbook_loader["openldap"].name.should eql(:openldap)
|
52
48
|
end
|
53
|
-
seen.should have_key("openldap")
|
54
|
-
seen.should have_key("apache2")
|
55
49
|
end
|
56
50
|
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
51
|
+
describe "each" do
|
52
|
+
it "should allow you to iterate over cookbooks with each" do
|
53
|
+
seen = Hash.new
|
54
|
+
@cookbook_loader.each do |cookbook_name, cookbook|
|
55
|
+
seen[cookbook_name] = true
|
56
|
+
end
|
57
|
+
seen.should have_key("openldap")
|
58
|
+
seen.should have_key("apache2")
|
61
59
|
end
|
62
|
-
seen[0].should == "angrybash"
|
63
|
-
seen[1].should == "apache2"
|
64
|
-
seen[2].should == "borken"
|
65
|
-
seen[3].should == "java"
|
66
|
-
seen[4].should == "openldap"
|
67
|
-
end
|
68
|
-
end
|
69
60
|
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
61
|
+
it "should iterate in alphabetical order" do
|
62
|
+
seen = Array.new
|
63
|
+
@cookbook_loader.each do |cookbook_name, cookbook|
|
64
|
+
seen << cookbook_name
|
65
|
+
end
|
66
|
+
seen[0].should == "angrybash"
|
67
|
+
seen[1].should == "apache2"
|
68
|
+
seen[2].should == "borken"
|
69
|
+
seen[3].should == "java"
|
70
|
+
seen[4].should == "openldap"
|
71
|
+
end
|
76
72
|
end
|
73
|
+
|
74
|
+
describe "load_cookbooks" do
|
75
|
+
it "should find all the cookbooks in the cookbook path" do
|
76
|
+
Chef::Config.cookbook_path << File.expand_path(File.join(CHEF_SPEC_DATA, "hidden-cookbooks"))
|
77
|
+
@cookbook_loader.load_cookbooks
|
78
|
+
@cookbook_loader.should have_key(:openldap)
|
79
|
+
@cookbook_loader.should have_key(:apache2)
|
80
|
+
end
|
81
|
+
|
82
|
+
it "should allow you to override an attribute file via cookbook_path" do
|
83
|
+
@cookbook_loader[:openldap].attribute_filenames.detect { |f|
|
84
|
+
f =~ /cookbooks\/openldap\/attributes\/default.rb/
|
85
|
+
}.should_not eql(nil)
|
86
|
+
@cookbook_loader[:openldap].attribute_filenames.detect { |f|
|
87
|
+
f =~ /kitchen\/openldap\/attributes\/default.rb/
|
88
|
+
}.should eql(nil)
|
89
|
+
end
|
90
|
+
|
91
|
+
it "should load different attribute files from deeper paths" do
|
92
|
+
@cookbook_loader[:openldap].attribute_filenames.detect { |f|
|
93
|
+
f =~ /kitchen\/openldap\/attributes\/robinson.rb/
|
94
|
+
}.should_not eql(nil)
|
95
|
+
end
|
96
|
+
|
97
|
+
it "should allow you to override a definition file via cookbook_path" do
|
98
|
+
@cookbook_loader[:openldap].definition_filenames.detect { |f|
|
99
|
+
f =~ /cookbooks\/openldap\/definitions\/client.rb/
|
100
|
+
}.should_not eql(nil)
|
101
|
+
@cookbook_loader[:openldap].definition_filenames.detect { |f|
|
102
|
+
f =~ /kitchen\/openldap\/definitions\/client.rb/
|
103
|
+
}.should eql(nil)
|
104
|
+
end
|
105
|
+
|
106
|
+
it "should load definition files from deeper paths" do
|
107
|
+
@cookbook_loader[:openldap].definition_filenames.detect { |f|
|
108
|
+
f =~ /kitchen\/openldap\/definitions\/drewbarrymore.rb/
|
109
|
+
}.should_not eql(nil)
|
110
|
+
end
|
111
|
+
|
112
|
+
it "should allow you to override a recipe file via cookbook_path" do
|
113
|
+
@cookbook_loader[:openldap].recipe_filenames.detect { |f|
|
114
|
+
f =~ /cookbooks\/openldap\/recipes\/gigantor.rb/
|
115
|
+
}.should_not eql(nil)
|
116
|
+
@cookbook_loader[:openldap].recipe_filenames.detect { |f|
|
117
|
+
f =~ /kitchen\/openldap\/recipes\/gigantor.rb/
|
118
|
+
}.should eql(nil)
|
119
|
+
end
|
120
|
+
|
121
|
+
it "should load recipe files from deeper paths" do
|
122
|
+
@cookbook_loader[:openldap].recipe_filenames.detect { |f|
|
123
|
+
f =~ /kitchen\/openldap\/recipes\/woot.rb/
|
124
|
+
}.should_not eql(nil)
|
125
|
+
end
|
126
|
+
|
127
|
+
it "should allow you to have an 'ignore' file, which skips loading files in later cookbooks" do
|
128
|
+
@cookbook_loader[:openldap].recipe_filenames.detect { |f|
|
129
|
+
f =~ /kitchen\/openldap\/recipes\/ignoreme.rb/
|
130
|
+
}.should eql(nil)
|
131
|
+
end
|
132
|
+
|
133
|
+
it "should find files that start with a ." do
|
134
|
+
@cookbook_loader[:openldap].file_filenames.detect { |f|
|
135
|
+
f =~ /\.dotfile$/
|
136
|
+
}.should =~ /\.dotfile$/
|
137
|
+
@cookbook_loader[:openldap].file_filenames.detect { |f|
|
138
|
+
f =~ /\.ssh\/id_rsa$/
|
139
|
+
}.should =~ /\.ssh\/id_rsa$/
|
140
|
+
end
|
141
|
+
|
142
|
+
it "should load the metadata for the cookbook" do
|
143
|
+
@cookbook_loader.metadata[:openldap].name.should == :openldap
|
144
|
+
@cookbook_loader.metadata[:openldap].should be_a_kind_of(Chef::Cookbook::Metadata)
|
145
|
+
end
|
77
146
|
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
147
|
+
it "should check each cookbook directory only once (CHEF-3487)" do
|
148
|
+
cookbooks = []
|
149
|
+
@repo_paths.each do |repo_path|
|
150
|
+
cookbooks |= Dir[File.join(repo_path, "*")]
|
151
|
+
end
|
152
|
+
cookbooks.each do |cookbook|
|
153
|
+
File.should_receive(:directory?).with(cookbook).once;
|
154
|
+
end
|
155
|
+
@cookbook_loader.load_cookbooks
|
156
|
+
end
|
157
|
+
end # load_cookbooks
|
86
158
|
|
87
|
-
|
88
|
-
@cookbook_loader[:openldap].attribute_filenames.detect { |f|
|
89
|
-
f =~ /kitchen\/openldap\/attributes\/robinson.rb/
|
90
|
-
}.should_not eql(nil)
|
91
|
-
end
|
159
|
+
end # loading all cookbooks
|
92
160
|
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
@cookbook_loader[:openldap].definition_filenames.detect { |f|
|
98
|
-
f =~ /kitchen\/openldap\/definitions\/client.rb/
|
99
|
-
}.should eql(nil)
|
161
|
+
describe "loading only one cookbook" do
|
162
|
+
before(:each) do
|
163
|
+
@cookbook_loader = Chef::CookbookLoader.new(@repo_paths)
|
164
|
+
@cookbook_loader.load_cookbook("openldap")
|
100
165
|
end
|
101
166
|
|
102
|
-
it "should
|
103
|
-
|
104
|
-
|
105
|
-
|
167
|
+
it "should have loaded the correct cookbook" do
|
168
|
+
seen = Hash.new
|
169
|
+
@cookbook_loader.each do |cookbook_name, cookbook|
|
170
|
+
seen[cookbook_name] = true
|
171
|
+
end
|
172
|
+
seen.should have_key("openldap")
|
106
173
|
end
|
107
174
|
|
108
|
-
it "should
|
109
|
-
@cookbook_loader
|
110
|
-
|
111
|
-
}.should_not eql(nil)
|
112
|
-
@cookbook_loader[:openldap].recipe_filenames.detect { |f|
|
113
|
-
f =~ /kitchen\/openldap\/recipes\/gigantor.rb/
|
114
|
-
}.should eql(nil)
|
175
|
+
it "should not load the cookbook again when accessed" do
|
176
|
+
@cookbook_loader.should_not_receive('load_cookbook')
|
177
|
+
@cookbook_loader["openldap"]
|
115
178
|
end
|
116
179
|
|
117
|
-
it "should load
|
118
|
-
|
119
|
-
|
120
|
-
|
180
|
+
it "should not load the other cookbooks" do
|
181
|
+
seen = Hash.new
|
182
|
+
@cookbook_loader.each do |cookbook_name, cookbook|
|
183
|
+
seen[cookbook_name] = true
|
184
|
+
end
|
185
|
+
seen.should_not have_key("apache2")
|
121
186
|
end
|
122
187
|
|
123
|
-
it "should
|
124
|
-
@cookbook_loader[
|
125
|
-
f =~ /kitchen\/openldap\/recipes\/ignoreme.rb/
|
126
|
-
}.should eql(nil)
|
188
|
+
it "should load another cookbook lazily with []" do
|
189
|
+
@cookbook_loader["apache2"].should be_a_kind_of(Chef::CookbookVersion)
|
127
190
|
end
|
128
191
|
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
@cookbook_loader[:openldap].file_filenames.detect { |f|
|
134
|
-
f =~ /\.ssh\/id_rsa$/
|
135
|
-
}.should =~ /\.ssh\/id_rsa$/
|
136
|
-
end
|
192
|
+
describe "loading all cookbooks after loading only one cookbook" do
|
193
|
+
before(:each) do
|
194
|
+
@cookbook_loader.load_cookbooks
|
195
|
+
end
|
137
196
|
|
138
|
-
|
139
|
-
|
140
|
-
|
197
|
+
it "should load all cookbooks" do
|
198
|
+
seen = Hash.new
|
199
|
+
@cookbook_loader.each do |cookbook_name, cookbook|
|
200
|
+
seen[cookbook_name] = true
|
201
|
+
end
|
202
|
+
seen.should have_key("openldap")
|
203
|
+
seen.should have_key("apache2")
|
204
|
+
end
|
141
205
|
end
|
142
|
-
|
143
|
-
end
|
144
|
-
|
206
|
+
end # loading only one cookbook
|
145
207
|
end
|