summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChef Expeditor <chef-ci@chef.io>2021-03-11 17:45:48 +0000
committerMarc A. Paradise <marc.paradise@gmail.com>2021-03-31 13:52:49 -0400
commit01c6a9e1753bd4b2166efe747151ba8700ebc0f5 (patch)
tree55f16085d89859139211bf6d2b8fd2dbcf4633b0
parent497dd4af19ea7dff9a72d704a1de8e9be36b2996 (diff)
downloadchef-01c6a9e1753bd4b2166efe747151ba8700ebc0f5.tar.gz
Move knife to its own gem
This moves knife into /knife, in the same way that chef-utils and chef-config are separated. NOTES: == File History == If you see this message as the first message in the history of an knife file, you can see the complete history by using 'git log --follow', 'git config log.follow true' to make it the default behavior in this repository, or 'git config --globa log.follow true' to make it the global default. == API Changes == At the API level, there is one breaking change: CookbookSiteStreamingUploader has been moved out of chef and into knife/core. There were a combination of reasons we chose this path: - CookbookSiteStreamingUploader (CSSU) is only used within Knife. - CookbookSiteStreamingUploader (CSSU) references the command Chef::Knife::CookbookMetadata in order to generate a metadata file for the cookbook to upload - Chef::Knife::CookbookMetadata is no longer available to Chef:: because Knife has been moved to its own gem. Knife gem depends on the Chef gem, so Chef can't depend on something in Knife. A search for usage in related projects (berks, chef-cli) and the Internet at large shows that there are no known external consumers of CSSU. For now, we'll move this class into Knife::Core, as it's going to be faster than splitting off the metadata generation and time is a concern. If we find that we need the metadata generation in chef/ proper, we should evaluate decoupling that functionality from Knife::CookbookMetadata and exposing it via something like `Chef::Cookbook::Metadata#from_cookbook_files` == spec changes == The specs are kept in their existing locations, though we have separated out a `knife_spec_helper` so that we can ensure knife is not directly accessing chef requires; and chef is relying on knife's at all. We also now clear gem paths with each test, to force gem state to reset. This works around a problem where a combination of tests is corrupting the internal Gem state, causing failures in rubygems_spec. See branch `mp/broken-gems` for many more details around findings so far. Signed-off-by: Marc A. Paradise <marc.paradise@gmail.com>
-rw-r--r--.expeditor/config.yml1
-rwxr-xr-x.expeditor/update_version.sh5
-rw-r--r--chef.gemspec6
-rw-r--r--habitat/tests/spec.ps12
-rw-r--r--habitat/tests/test.pester.ps17
-rwxr-xr-xhabitat/tests/test.sh4
-rw-r--r--kitchen-tests/Gemfile3
-rw-r--r--knife/Gemfile29
-rw-r--r--knife/LICENSE201
-rw-r--r--knife/Rakefile38
-rwxr-xr-xknife/bin/knife24
-rw-r--r--knife/knife.gemspec65
-rw-r--r--knife/lib/chef/application/knife.rb (renamed from lib/chef/application/knife.rb)2
-rw-r--r--knife/lib/chef/chef_fs/knife.rb (renamed from lib/chef/chef_fs/knife.rb)10
-rw-r--r--knife/lib/chef/knife.rb (renamed from lib/chef/knife.rb)27
-rw-r--r--knife/lib/chef/knife/acl_add.rb (renamed from lib/chef/knife/acl_add.rb)0
-rw-r--r--knife/lib/chef/knife/acl_base.rb (renamed from lib/chef/knife/acl_base.rb)0
-rw-r--r--knife/lib/chef/knife/acl_bulk_add.rb (renamed from lib/chef/knife/acl_bulk_add.rb)0
-rw-r--r--knife/lib/chef/knife/acl_bulk_remove.rb (renamed from lib/chef/knife/acl_bulk_remove.rb)0
-rw-r--r--knife/lib/chef/knife/acl_remove.rb (renamed from lib/chef/knife/acl_remove.rb)0
-rw-r--r--knife/lib/chef/knife/acl_show.rb (renamed from lib/chef/knife/acl_show.rb)0
-rw-r--r--knife/lib/chef/knife/bootstrap.rb (renamed from lib/chef/knife/bootstrap.rb)7
-rw-r--r--knife/lib/chef/knife/bootstrap/chef_vault_handler.rb (renamed from lib/chef/knife/bootstrap/chef_vault_handler.rb)0
-rw-r--r--knife/lib/chef/knife/bootstrap/client_builder.rb (renamed from lib/chef/knife/bootstrap/client_builder.rb)8
-rw-r--r--knife/lib/chef/knife/bootstrap/templates/README.md (renamed from lib/chef/knife/bootstrap/templates/README.md)0
-rw-r--r--knife/lib/chef/knife/bootstrap/templates/chef-full.erb (renamed from lib/chef/knife/bootstrap/templates/chef-full.erb)0
-rw-r--r--knife/lib/chef/knife/bootstrap/templates/windows-chef-client-msi.erb (renamed from lib/chef/knife/bootstrap/templates/windows-chef-client-msi.erb)0
-rw-r--r--knife/lib/chef/knife/bootstrap/train_connector.rb (renamed from lib/chef/knife/bootstrap/train_connector.rb)0
-rw-r--r--knife/lib/chef/knife/client_bulk_delete.rb (renamed from lib/chef/knife/client_bulk_delete.rb)2
-rw-r--r--knife/lib/chef/knife/client_create.rb (renamed from lib/chef/knife/client_create.rb)2
-rw-r--r--knife/lib/chef/knife/client_delete.rb (renamed from lib/chef/knife/client_delete.rb)2
-rw-r--r--knife/lib/chef/knife/client_edit.rb (renamed from lib/chef/knife/client_edit.rb)2
-rw-r--r--knife/lib/chef/knife/client_key_create.rb (renamed from lib/chef/knife/client_key_create.rb)0
-rw-r--r--knife/lib/chef/knife/client_key_delete.rb (renamed from lib/chef/knife/client_key_delete.rb)0
-rw-r--r--knife/lib/chef/knife/client_key_edit.rb (renamed from lib/chef/knife/client_key_edit.rb)0
-rw-r--r--knife/lib/chef/knife/client_key_list.rb (renamed from lib/chef/knife/client_key_list.rb)0
-rw-r--r--knife/lib/chef/knife/client_key_show.rb (renamed from lib/chef/knife/client_key_show.rb)0
-rw-r--r--knife/lib/chef/knife/client_list.rb (renamed from lib/chef/knife/client_list.rb)2
-rw-r--r--knife/lib/chef/knife/client_reregister.rb (renamed from lib/chef/knife/client_reregister.rb)2
-rw-r--r--knife/lib/chef/knife/client_show.rb (renamed from lib/chef/knife/client_show.rb)2
-rw-r--r--knife/lib/chef/knife/config_get.rb (renamed from lib/chef/knife/config_get.rb)0
-rw-r--r--knife/lib/chef/knife/config_get_profile.rb (renamed from lib/chef/knife/config_get_profile.rb)0
-rw-r--r--knife/lib/chef/knife/config_list.rb (renamed from lib/chef/knife/config_list.rb)2
-rw-r--r--knife/lib/chef/knife/config_list_profiles.rb (renamed from lib/chef/knife/config_list_profiles.rb)0
-rw-r--r--knife/lib/chef/knife/config_show.rb (renamed from lib/chef/knife/config_show.rb)0
-rw-r--r--knife/lib/chef/knife/config_use.rb (renamed from lib/chef/knife/config_use.rb)0
-rw-r--r--knife/lib/chef/knife/config_use_profile.rb (renamed from lib/chef/knife/config_use_profile.rb)0
-rw-r--r--knife/lib/chef/knife/configure.rb (renamed from lib/chef/knife/configure.rb)6
-rw-r--r--knife/lib/chef/knife/configure_client.rb (renamed from lib/chef/knife/configure_client.rb)0
-rw-r--r--knife/lib/chef/knife/cookbook_bulk_delete.rb (renamed from lib/chef/knife/cookbook_bulk_delete.rb)2
-rw-r--r--knife/lib/chef/knife/cookbook_delete.rb (renamed from lib/chef/knife/cookbook_delete.rb)2
-rw-r--r--knife/lib/chef/knife/cookbook_download.rb (renamed from lib/chef/knife/cookbook_download.rb)2
-rw-r--r--knife/lib/chef/knife/cookbook_list.rb (renamed from lib/chef/knife/cookbook_list.rb)0
-rw-r--r--knife/lib/chef/knife/cookbook_metadata.rb (renamed from lib/chef/knife/cookbook_metadata.rb)4
-rw-r--r--knife/lib/chef/knife/cookbook_metadata_from_file.rb (renamed from lib/chef/knife/cookbook_metadata_from_file.rb)2
-rw-r--r--knife/lib/chef/knife/cookbook_show.rb (renamed from lib/chef/knife/cookbook_show.rb)4
-rw-r--r--knife/lib/chef/knife/cookbook_upload.rb (renamed from lib/chef/knife/cookbook_upload.rb)8
-rw-r--r--knife/lib/chef/knife/core/bootstrap_context.rb (renamed from lib/chef/knife/core/bootstrap_context.rb)6
-rw-r--r--knife/lib/chef/knife/core/cookbook_scm_repo.rb (renamed from lib/chef/knife/core/cookbook_scm_repo.rb)2
-rw-r--r--knife/lib/chef/knife/core/cookbook_site_streaming_uploader.rb249
-rw-r--r--knife/lib/chef/knife/core/formatting_options.rb (renamed from lib/chef/knife/core/formatting_options.rb)0
-rw-r--r--knife/lib/chef/knife/core/gem_glob_loader.rb (renamed from lib/chef/knife/core/gem_glob_loader.rb)28
-rw-r--r--knife/lib/chef/knife/core/generic_presenter.rb (renamed from lib/chef/knife/core/generic_presenter.rb)0
-rw-r--r--knife/lib/chef/knife/core/hashed_command_loader.rb (renamed from lib/chef/knife/core/hashed_command_loader.rb)2
-rw-r--r--knife/lib/chef/knife/core/node_editor.rb (renamed from lib/chef/knife/core/node_editor.rb)4
-rw-r--r--knife/lib/chef/knife/core/node_presenter.rb (renamed from lib/chef/knife/core/node_presenter.rb)0
-rw-r--r--knife/lib/chef/knife/core/object_loader.rb (renamed from lib/chef/knife/core/object_loader.rb)9
-rw-r--r--knife/lib/chef/knife/core/status_presenter.rb (renamed from lib/chef/knife/core/status_presenter.rb)0
-rw-r--r--knife/lib/chef/knife/core/subcommand_loader.rb (renamed from lib/chef/knife/core/subcommand_loader.rb)23
-rw-r--r--knife/lib/chef/knife/core/text_formatter.rb (renamed from lib/chef/knife/core/text_formatter.rb)0
-rw-r--r--knife/lib/chef/knife/core/ui.rb (renamed from lib/chef/knife/core/ui.rb)2
-rw-r--r--knife/lib/chef/knife/core/windows_bootstrap_context.rb (renamed from lib/chef/knife/core/windows_bootstrap_context.rb)4
-rw-r--r--knife/lib/chef/knife/data_bag_create.rb (renamed from lib/chef/knife/data_bag_create.rb)4
-rw-r--r--knife/lib/chef/knife/data_bag_delete.rb (renamed from lib/chef/knife/data_bag_delete.rb)2
-rw-r--r--knife/lib/chef/knife/data_bag_edit.rb (renamed from lib/chef/knife/data_bag_edit.rb)4
-rw-r--r--knife/lib/chef/knife/data_bag_from_file.rb (renamed from lib/chef/knife/data_bag_from_file.rb)12
-rw-r--r--knife/lib/chef/knife/data_bag_list.rb (renamed from lib/chef/knife/data_bag_list.rb)2
-rw-r--r--knife/lib/chef/knife/data_bag_secret_options.rb (renamed from lib/chef/knife/data_bag_secret_options.rb)6
-rw-r--r--knife/lib/chef/knife/data_bag_show.rb (renamed from lib/chef/knife/data_bag_show.rb)4
-rw-r--r--knife/lib/chef/knife/delete.rb (renamed from lib/chef/knife/delete.rb)2
-rw-r--r--knife/lib/chef/knife/deps.rb (renamed from lib/chef/knife/deps.rb)6
-rw-r--r--knife/lib/chef/knife/diff.rb (renamed from lib/chef/knife/diff.rb)2
-rw-r--r--knife/lib/chef/knife/download.rb (renamed from lib/chef/knife/download.rb)2
-rw-r--r--knife/lib/chef/knife/edit.rb (renamed from lib/chef/knife/edit.rb)4
-rw-r--r--knife/lib/chef/knife/environment_compare.rb (renamed from lib/chef/knife/environment_compare.rb)2
-rw-r--r--knife/lib/chef/knife/environment_create.rb (renamed from lib/chef/knife/environment_create.rb)2
-rw-r--r--knife/lib/chef/knife/environment_delete.rb (renamed from lib/chef/knife/environment_delete.rb)2
-rw-r--r--knife/lib/chef/knife/environment_edit.rb (renamed from lib/chef/knife/environment_edit.rb)2
-rw-r--r--knife/lib/chef/knife/environment_from_file.rb (renamed from lib/chef/knife/environment_from_file.rb)2
-rw-r--r--knife/lib/chef/knife/environment_list.rb (renamed from lib/chef/knife/environment_list.rb)2
-rw-r--r--knife/lib/chef/knife/environment_show.rb (renamed from lib/chef/knife/environment_show.rb)2
-rw-r--r--knife/lib/chef/knife/exec.rb (renamed from lib/chef/knife/exec.rb)6
-rw-r--r--knife/lib/chef/knife/group_add.rb (renamed from lib/chef/knife/group_add.rb)0
-rw-r--r--knife/lib/chef/knife/group_create.rb (renamed from lib/chef/knife/group_create.rb)0
-rw-r--r--knife/lib/chef/knife/group_destroy.rb (renamed from lib/chef/knife/group_destroy.rb)0
-rw-r--r--knife/lib/chef/knife/group_list.rb (renamed from lib/chef/knife/group_list.rb)0
-rw-r--r--knife/lib/chef/knife/group_remove.rb (renamed from lib/chef/knife/group_remove.rb)0
-rw-r--r--knife/lib/chef/knife/group_show.rb (renamed from lib/chef/knife/group_show.rb)0
-rw-r--r--knife/lib/chef/knife/key_create.rb (renamed from lib/chef/knife/key_create.rb)6
-rw-r--r--knife/lib/chef/knife/key_create_base.rb (renamed from lib/chef/knife/key_create_base.rb)0
-rw-r--r--knife/lib/chef/knife/key_delete.rb (renamed from lib/chef/knife/key_delete.rb)2
-rw-r--r--knife/lib/chef/knife/key_edit.rb (renamed from lib/chef/knife/key_edit.rb)6
-rw-r--r--knife/lib/chef/knife/key_edit_base.rb (renamed from lib/chef/knife/key_edit_base.rb)0
-rw-r--r--knife/lib/chef/knife/key_list.rb (renamed from lib/chef/knife/key_list.rb)6
-rw-r--r--knife/lib/chef/knife/key_list_base.rb (renamed from lib/chef/knife/key_list_base.rb)0
-rw-r--r--knife/lib/chef/knife/key_show.rb (renamed from lib/chef/knife/key_show.rb)6
-rw-r--r--knife/lib/chef/knife/list.rb (renamed from lib/chef/knife/list.rb)2
-rw-r--r--knife/lib/chef/knife/node_bulk_delete.rb (renamed from lib/chef/knife/node_bulk_delete.rb)4
-rw-r--r--knife/lib/chef/knife/node_create.rb (renamed from lib/chef/knife/node_create.rb)4
-rw-r--r--knife/lib/chef/knife/node_delete.rb (renamed from lib/chef/knife/node_delete.rb)4
-rw-r--r--knife/lib/chef/knife/node_edit.rb (renamed from lib/chef/knife/node_edit.rb)4
-rw-r--r--knife/lib/chef/knife/node_environment_set.rb (renamed from lib/chef/knife/node_environment_set.rb)2
-rw-r--r--knife/lib/chef/knife/node_from_file.rb (renamed from lib/chef/knife/node_from_file.rb)4
-rw-r--r--knife/lib/chef/knife/node_list.rb (renamed from lib/chef/knife/node_list.rb)4
-rw-r--r--knife/lib/chef/knife/node_policy_set.rb (renamed from lib/chef/knife/node_policy_set.rb)4
-rw-r--r--knife/lib/chef/knife/node_run_list_add.rb (renamed from lib/chef/knife/node_run_list_add.rb)4
-rw-r--r--knife/lib/chef/knife/node_run_list_remove.rb (renamed from lib/chef/knife/node_run_list_remove.rb)4
-rw-r--r--knife/lib/chef/knife/node_run_list_set.rb (renamed from lib/chef/knife/node_run_list_set.rb)4
-rw-r--r--knife/lib/chef/knife/node_show.rb (renamed from lib/chef/knife/node_show.rb)4
-rw-r--r--knife/lib/chef/knife/null.rb (renamed from lib/chef/knife/null.rb)0
-rw-r--r--knife/lib/chef/knife/org_create.rb (renamed from lib/chef/knife/org_create.rb)2
-rw-r--r--knife/lib/chef/knife/org_delete.rb (renamed from lib/chef/knife/org_delete.rb)0
-rw-r--r--knife/lib/chef/knife/org_edit.rb (renamed from lib/chef/knife/org_edit.rb)0
-rw-r--r--knife/lib/chef/knife/org_list.rb (renamed from lib/chef/knife/org_list.rb)0
-rw-r--r--knife/lib/chef/knife/org_show.rb (renamed from lib/chef/knife/org_show.rb)0
-rw-r--r--knife/lib/chef/knife/org_user_add.rb (renamed from lib/chef/knife/org_user_add.rb)0
-rw-r--r--knife/lib/chef/knife/org_user_remove.rb (renamed from lib/chef/knife/org_user_remove.rb)4
-rw-r--r--knife/lib/chef/knife/raw.rb (renamed from lib/chef/knife/raw.rb)14
-rw-r--r--knife/lib/chef/knife/recipe_list.rb (renamed from lib/chef/knife/recipe_list.rb)0
-rw-r--r--knife/lib/chef/knife/rehash.rb (renamed from lib/chef/knife/rehash.rb)0
-rw-r--r--knife/lib/chef/knife/role_bulk_delete.rb (renamed from lib/chef/knife/role_bulk_delete.rb)4
-rw-r--r--knife/lib/chef/knife/role_create.rb (renamed from lib/chef/knife/role_create.rb)4
-rw-r--r--knife/lib/chef/knife/role_delete.rb (renamed from lib/chef/knife/role_delete.rb)4
-rw-r--r--knife/lib/chef/knife/role_edit.rb (renamed from lib/chef/knife/role_edit.rb)4
-rw-r--r--knife/lib/chef/knife/role_env_run_list_add.rb (renamed from lib/chef/knife/role_env_run_list_add.rb)4
-rw-r--r--knife/lib/chef/knife/role_env_run_list_clear.rb (renamed from lib/chef/knife/role_env_run_list_clear.rb)4
-rw-r--r--knife/lib/chef/knife/role_env_run_list_remove.rb (renamed from lib/chef/knife/role_env_run_list_remove.rb)4
-rw-r--r--knife/lib/chef/knife/role_env_run_list_replace.rb (renamed from lib/chef/knife/role_env_run_list_replace.rb)4
-rw-r--r--knife/lib/chef/knife/role_env_run_list_set.rb (renamed from lib/chef/knife/role_env_run_list_set.rb)4
-rw-r--r--knife/lib/chef/knife/role_from_file.rb (renamed from lib/chef/knife/role_from_file.rb)4
-rw-r--r--knife/lib/chef/knife/role_list.rb (renamed from lib/chef/knife/role_list.rb)4
-rw-r--r--knife/lib/chef/knife/role_run_list_add.rb (renamed from lib/chef/knife/role_run_list_add.rb)4
-rw-r--r--knife/lib/chef/knife/role_run_list_clear.rb (renamed from lib/chef/knife/role_run_list_clear.rb)4
-rw-r--r--knife/lib/chef/knife/role_run_list_remove.rb (renamed from lib/chef/knife/role_run_list_remove.rb)2
-rw-r--r--knife/lib/chef/knife/role_run_list_replace.rb (renamed from lib/chef/knife/role_run_list_replace.rb)4
-rw-r--r--knife/lib/chef/knife/role_run_list_set.rb (renamed from lib/chef/knife/role_run_list_set.rb)2
-rw-r--r--knife/lib/chef/knife/role_show.rb (renamed from lib/chef/knife/role_show.rb)2
-rw-r--r--knife/lib/chef/knife/search.rb (renamed from lib/chef/knife/search.rb)8
-rw-r--r--knife/lib/chef/knife/serve.rb (renamed from lib/chef/knife/serve.rb)2
-rw-r--r--knife/lib/chef/knife/show.rb (renamed from lib/chef/knife/show.rb)4
-rw-r--r--knife/lib/chef/knife/ssh.rb (renamed from lib/chef/knife/ssh.rb)10
-rw-r--r--knife/lib/chef/knife/ssl_check.rb (renamed from lib/chef/knife/ssl_check.rb)6
-rw-r--r--knife/lib/chef/knife/ssl_fetch.rb (renamed from lib/chef/knife/ssl_fetch.rb)5
-rw-r--r--knife/lib/chef/knife/status.rb (renamed from lib/chef/knife/status.rb)2
-rw-r--r--knife/lib/chef/knife/supermarket_download.rb (renamed from lib/chef/knife/supermarket_download.rb)0
-rw-r--r--knife/lib/chef/knife/supermarket_install.rb (renamed from lib/chef/knife/supermarket_install.rb)4
-rw-r--r--knife/lib/chef/knife/supermarket_list.rb (renamed from lib/chef/knife/supermarket_list.rb)0
-rw-r--r--knife/lib/chef/knife/supermarket_search.rb (renamed from lib/chef/knife/supermarket_search.rb)0
-rw-r--r--knife/lib/chef/knife/supermarket_share.rb (renamed from lib/chef/knife/supermarket_share.rb)12
-rw-r--r--knife/lib/chef/knife/supermarket_show.rb (renamed from lib/chef/knife/supermarket_show.rb)0
-rw-r--r--knife/lib/chef/knife/supermarket_unshare.rb (renamed from lib/chef/knife/supermarket_unshare.rb)2
-rw-r--r--knife/lib/chef/knife/tag_create.rb (renamed from lib/chef/knife/tag_create.rb)2
-rw-r--r--knife/lib/chef/knife/tag_delete.rb (renamed from lib/chef/knife/tag_delete.rb)2
-rw-r--r--knife/lib/chef/knife/tag_list.rb (renamed from lib/chef/knife/tag_list.rb)2
-rw-r--r--knife/lib/chef/knife/upload.rb (renamed from lib/chef/knife/upload.rb)2
-rw-r--r--knife/lib/chef/knife/user_create.rb (renamed from lib/chef/knife/user_create.rb)2
-rw-r--r--knife/lib/chef/knife/user_delete.rb (renamed from lib/chef/knife/user_delete.rb)2
-rw-r--r--knife/lib/chef/knife/user_dissociate.rb (renamed from lib/chef/knife/user_dissociate.rb)0
-rw-r--r--knife/lib/chef/knife/user_edit.rb (renamed from lib/chef/knife/user_edit.rb)0
-rw-r--r--knife/lib/chef/knife/user_invite_add.rb (renamed from lib/chef/knife/user_invite_add.rb)0
-rw-r--r--knife/lib/chef/knife/user_invite_list.rb (renamed from lib/chef/knife/user_invite_list.rb)0
-rw-r--r--knife/lib/chef/knife/user_invite_rescind.rb (renamed from lib/chef/knife/user_invite_rescind.rb)0
-rw-r--r--knife/lib/chef/knife/user_key_create.rb (renamed from lib/chef/knife/user_key_create.rb)0
-rw-r--r--knife/lib/chef/knife/user_key_delete.rb (renamed from lib/chef/knife/user_key_delete.rb)0
-rw-r--r--knife/lib/chef/knife/user_key_edit.rb (renamed from lib/chef/knife/user_key_edit.rb)0
-rw-r--r--knife/lib/chef/knife/user_key_list.rb (renamed from lib/chef/knife/user_key_list.rb)0
-rw-r--r--knife/lib/chef/knife/user_key_show.rb (renamed from lib/chef/knife/user_key_show.rb)0
-rw-r--r--knife/lib/chef/knife/user_list.rb (renamed from lib/chef/knife/user_list.rb)9
-rw-r--r--knife/lib/chef/knife/user_password.rb (renamed from lib/chef/knife/user_password.rb)0
-rw-r--r--knife/lib/chef/knife/user_reregister.rb (renamed from lib/chef/knife/user_reregister.rb)2
-rw-r--r--knife/lib/chef/knife/user_show.rb (renamed from lib/chef/knife/user_show.rb)0
-rw-r--r--knife/lib/chef/knife/version.rb24
-rw-r--r--knife/lib/chef/knife/xargs.rb (renamed from lib/chef/knife/xargs.rb)4
-rw-r--r--knife/lib/chef/knife/yaml_convert.rb (renamed from lib/chef/knife/yaml_convert.rb)0
-rw-r--r--lib/chef/applications.rb1
-rw-r--r--lib/chef/cookbook_site_streaming_uploader.rb244
-rw-r--r--lib/chef/cookbook_uploader.rb1
-rw-r--r--spec/functional/knife/configure_spec.rb2
-rw-r--r--spec/functional/knife/cookbook_delete_spec.rb2
-rw-r--r--spec/functional/knife/exec_spec.rb2
-rw-r--r--spec/functional/knife/rehash_spec.rb2
-rw-r--r--spec/functional/knife/ssh_spec.rb2
-rw-r--r--spec/functional/knife/version_spec.rb26
-rw-r--r--spec/functional/version_spec.rb2
-rw-r--r--spec/integration/knife/chef_fs_data_store_spec.rb2
-rw-r--r--spec/integration/knife/chef_repo_path_spec.rb2
-rw-r--r--spec/integration/knife/chef_repository_file_system_spec.rb2
-rw-r--r--spec/integration/knife/chefignore_spec.rb2
-rw-r--r--spec/integration/knife/client_bulk_delete_spec.rb2
-rw-r--r--spec/integration/knife/client_create_spec.rb2
-rw-r--r--spec/integration/knife/client_delete_spec.rb2
-rw-r--r--spec/integration/knife/client_key_create_spec.rb2
-rw-r--r--spec/integration/knife/client_key_delete_spec.rb2
-rw-r--r--spec/integration/knife/client_key_list_spec.rb2
-rw-r--r--spec/integration/knife/client_key_show_spec.rb2
-rw-r--r--spec/integration/knife/client_list_spec.rb2
-rw-r--r--spec/integration/knife/client_show_spec.rb2
-rw-r--r--spec/integration/knife/common_options_spec.rb2
-rw-r--r--spec/integration/knife/config_list_spec.rb2
-rw-r--r--spec/integration/knife/config_show_spec.rb2
-rw-r--r--spec/integration/knife/config_use_spec.rb2
-rw-r--r--spec/integration/knife/cookbook_api_ipv6_spec.rb6
-rw-r--r--spec/integration/knife/cookbook_bulk_delete_spec.rb2
-rw-r--r--spec/integration/knife/cookbook_download_spec.rb2
-rw-r--r--spec/integration/knife/cookbook_list_spec.rb2
-rw-r--r--spec/integration/knife/cookbook_show_spec.rb2
-rw-r--r--spec/integration/knife/cookbook_upload_spec.rb2
-rw-r--r--spec/integration/knife/data_bag_create_spec.rb2
-rw-r--r--spec/integration/knife/data_bag_delete_spec.rb2
-rw-r--r--spec/integration/knife/data_bag_edit_spec.rb2
-rw-r--r--spec/integration/knife/data_bag_from_file_spec.rb2
-rw-r--r--spec/integration/knife/data_bag_list_spec.rb2
-rw-r--r--spec/integration/knife/data_bag_show_spec.rb2
-rw-r--r--spec/integration/knife/delete_spec.rb2
-rw-r--r--spec/integration/knife/deps_spec.rb2
-rw-r--r--spec/integration/knife/diff_spec.rb2
-rw-r--r--spec/integration/knife/download_spec.rb2
-rw-r--r--spec/integration/knife/environment_compare_spec.rb2
-rw-r--r--spec/integration/knife/environment_create_spec.rb2
-rw-r--r--spec/integration/knife/environment_delete_spec.rb2
-rw-r--r--spec/integration/knife/environment_from_file_spec.rb2
-rw-r--r--spec/integration/knife/environment_list_spec.rb2
-rw-r--r--spec/integration/knife/environment_show_spec.rb2
-rw-r--r--spec/integration/knife/list_spec.rb2
-rw-r--r--spec/integration/knife/node_bulk_delete_spec.rb2
-rw-r--r--spec/integration/knife/node_create_spec.rb2
-rw-r--r--spec/integration/knife/node_delete_spec.rb2
-rw-r--r--spec/integration/knife/node_environment_set_spec.rb2
-rw-r--r--spec/integration/knife/node_from_file_spec.rb2
-rw-r--r--spec/integration/knife/node_list_spec.rb2
-rw-r--r--spec/integration/knife/node_run_list_add_spec.rb2
-rw-r--r--spec/integration/knife/node_run_list_remove_spec.rb2
-rw-r--r--spec/integration/knife/node_run_list_set_spec.rb2
-rw-r--r--spec/integration/knife/node_show_spec.rb2
-rw-r--r--spec/integration/knife/raw_spec.rb2
-rw-r--r--spec/integration/knife/redirection_spec.rb2
-rw-r--r--spec/integration/knife/role_bulk_delete_spec.rb2
-rw-r--r--spec/integration/knife/role_create_spec.rb2
-rw-r--r--spec/integration/knife/role_delete_spec.rb2
-rw-r--r--spec/integration/knife/role_from_file_spec.rb2
-rw-r--r--spec/integration/knife/role_list_spec.rb2
-rw-r--r--spec/integration/knife/role_show_spec.rb2
-rw-r--r--spec/integration/knife/search_node_spec.rb2
-rw-r--r--spec/integration/knife/show_spec.rb2
-rw-r--r--spec/integration/knife/upload_spec.rb2
-rw-r--r--spec/knife_spec_helper.rb245
-rw-r--r--spec/spec_helper.rb15
-rw-r--r--spec/support/lib/chef/resource/with_state.rb1
-rw-r--r--spec/support/lib/chef/resource/zen_follower.rb1
-rw-r--r--spec/support/lib/chef/resource/zen_master.rb1
-rw-r--r--spec/support/platform_helpers.rb2
-rw-r--r--spec/support/shared/integration/integration_helper.rb1
-rw-r--r--spec/unit/application/knife_spec.rb2
-rw-r--r--spec/unit/knife/bootstrap/chef_vault_handler_spec.rb2
-rw-r--r--spec/unit/knife/bootstrap/client_builder_spec.rb2
-rw-r--r--spec/unit/knife/bootstrap/train_connector_spec.rb2
-rw-r--r--spec/unit/knife/bootstrap_spec.rb4
-rw-r--r--spec/unit/knife/client_bulk_delete_spec.rb2
-rw-r--r--spec/unit/knife/client_create_spec.rb2
-rw-r--r--spec/unit/knife/client_delete_spec.rb2
-rw-r--r--spec/unit/knife/client_edit_spec.rb2
-rw-r--r--spec/unit/knife/client_list_spec.rb2
-rw-r--r--spec/unit/knife/client_reregister_spec.rb2
-rw-r--r--spec/unit/knife/client_show_spec.rb2
-rw-r--r--spec/unit/knife/configure_client_spec.rb2
-rw-r--r--spec/unit/knife/configure_spec.rb2
-rw-r--r--spec/unit/knife/cookbook_bulk_delete_spec.rb2
-rw-r--r--spec/unit/knife/cookbook_delete_spec.rb2
-rw-r--r--spec/unit/knife/cookbook_download_spec.rb2
-rw-r--r--spec/unit/knife/cookbook_list_spec.rb2
-rw-r--r--spec/unit/knife/cookbook_metadata_from_file_spec.rb2
-rw-r--r--spec/unit/knife/cookbook_metadata_spec.rb2
-rw-r--r--spec/unit/knife/cookbook_show_spec.rb2
-rw-r--r--spec/unit/knife/cookbook_upload_spec.rb2
-rw-r--r--spec/unit/knife/core/bootstrap_context_spec.rb2
-rw-r--r--spec/unit/knife/core/cookbook_scm_repo_spec.rb2
-rw-r--r--spec/unit/knife/core/cookbook_site_streaming_uploader_spec.rb (renamed from spec/unit/cookbook_site_streaming_uploader_spec.rb)42
-rw-r--r--spec/unit/knife/core/gem_glob_loader_spec.rb39
-rw-r--r--spec/unit/knife/core/hashed_command_loader_spec.rb2
-rw-r--r--spec/unit/knife/core/node_editor_spec.rb2
-rw-r--r--spec/unit/knife/core/object_loader_spec.rb2
-rw-r--r--spec/unit/knife/core/status_presenter_spec.rb2
-rw-r--r--spec/unit/knife/core/subcommand_loader_spec.rb2
-rw-r--r--spec/unit/knife/core/ui_spec.rb2
-rw-r--r--spec/unit/knife/core/windows_bootstrap_context_spec.rb2
-rw-r--r--spec/unit/knife/data_bag_create_spec.rb2
-rw-r--r--spec/unit/knife/data_bag_edit_spec.rb2
-rw-r--r--spec/unit/knife/data_bag_from_file_spec.rb2
-rw-r--r--spec/unit/knife/data_bag_secret_options_spec.rb2
-rw-r--r--spec/unit/knife/data_bag_show_spec.rb2
-rw-r--r--spec/unit/knife/environment_compare_spec.rb2
-rw-r--r--spec/unit/knife/environment_create_spec.rb2
-rw-r--r--spec/unit/knife/environment_delete_spec.rb2
-rw-r--r--spec/unit/knife/environment_edit_spec.rb2
-rw-r--r--spec/unit/knife/environment_from_file_spec.rb2
-rw-r--r--spec/unit/knife/environment_list_spec.rb2
-rw-r--r--spec/unit/knife/environment_show_spec.rb2
-rw-r--r--spec/unit/knife/key_create_spec.rb2
-rw-r--r--spec/unit/knife/key_delete_spec.rb2
-rw-r--r--spec/unit/knife/key_edit_spec.rb2
-rw-r--r--spec/unit/knife/key_helper.rb2
-rw-r--r--spec/unit/knife/key_list_spec.rb2
-rw-r--r--spec/unit/knife/key_show_spec.rb2
-rw-r--r--spec/unit/knife/node_bulk_delete_spec.rb2
-rw-r--r--spec/unit/knife/node_delete_spec.rb2
-rw-r--r--spec/unit/knife/node_edit_spec.rb2
-rw-r--r--spec/unit/knife/node_environment_set_spec.rb2
-rw-r--r--spec/unit/knife/node_from_file_spec.rb2
-rw-r--r--spec/unit/knife/node_list_spec.rb2
-rw-r--r--spec/unit/knife/node_policy_set_spec.rb2
-rw-r--r--spec/unit/knife/node_run_list_add_spec.rb2
-rw-r--r--spec/unit/knife/node_run_list_remove_spec.rb2
-rw-r--r--spec/unit/knife/node_run_list_set_spec.rb2
-rw-r--r--spec/unit/knife/node_show_spec.rb2
-rw-r--r--spec/unit/knife/org_create_spec.rb2
-rw-r--r--spec/unit/knife/org_delete_spec.rb2
-rw-r--r--spec/unit/knife/org_edit_spec.rb2
-rw-r--r--spec/unit/knife/org_list_spec.rb2
-rw-r--r--spec/unit/knife/org_show_spec.rb2
-rw-r--r--spec/unit/knife/org_user_add_spec.rb2
-rw-r--r--spec/unit/knife/raw_spec.rb2
-rw-r--r--spec/unit/knife/role_bulk_delete_spec.rb2
-rw-r--r--spec/unit/knife/role_create_spec.rb2
-rw-r--r--spec/unit/knife/role_delete_spec.rb2
-rw-r--r--spec/unit/knife/role_edit_spec.rb2
-rw-r--r--spec/unit/knife/role_env_run_list_add_spec.rb2
-rw-r--r--spec/unit/knife/role_env_run_list_clear_spec.rb2
-rw-r--r--spec/unit/knife/role_env_run_list_remove_spec.rb2
-rw-r--r--spec/unit/knife/role_env_run_list_replace_spec.rb2
-rw-r--r--spec/unit/knife/role_env_run_list_set_spec.rb2
-rw-r--r--spec/unit/knife/role_from_file_spec.rb2
-rw-r--r--spec/unit/knife/role_list_spec.rb2
-rw-r--r--spec/unit/knife/role_run_list_add_spec.rb2
-rw-r--r--spec/unit/knife/role_run_list_clear_spec.rb2
-rw-r--r--spec/unit/knife/role_run_list_remove_spec.rb2
-rw-r--r--spec/unit/knife/role_run_list_replace_spec.rb2
-rw-r--r--spec/unit/knife/role_run_list_set_spec.rb2
-rw-r--r--spec/unit/knife/role_show_spec.rb2
-rw-r--r--spec/unit/knife/ssh_spec.rb2
-rw-r--r--spec/unit/knife/ssl_check_spec.rb2
-rw-r--r--spec/unit/knife/ssl_fetch_spec.rb2
-rw-r--r--spec/unit/knife/status_spec.rb2
-rw-r--r--spec/unit/knife/supermarket_download_spec.rb2
-rw-r--r--spec/unit/knife/supermarket_install_spec.rb3
-rw-r--r--spec/unit/knife/supermarket_list_spec.rb2
-rw-r--r--spec/unit/knife/supermarket_search_spec.rb2
-rw-r--r--spec/unit/knife/supermarket_share_spec.rb12
-rw-r--r--spec/unit/knife/supermarket_unshare_spec.rb2
-rw-r--r--spec/unit/knife/tag_create_spec.rb2
-rw-r--r--spec/unit/knife/tag_delete_spec.rb2
-rw-r--r--spec/unit/knife/tag_list_spec.rb2
-rw-r--r--spec/unit/knife/user_create_spec.rb2
-rw-r--r--spec/unit/knife/user_delete_spec.rb2
-rw-r--r--spec/unit/knife/user_edit_spec.rb2
-rw-r--r--spec/unit/knife/user_list_spec.rb2
-rw-r--r--spec/unit/knife/user_password_spec.rb2
-rw-r--r--spec/unit/knife/user_reregister_spec.rb2
-rw-r--r--spec/unit/knife/user_show_spec.rb2
-rw-r--r--spec/unit/knife_spec.rb2
-rw-r--r--spec/unit/provider/service/arch_service_spec.rb1
-rw-r--r--spec/unit/provider/service/debian_service_spec.rb1
-rw-r--r--tasks/rspec.rb22
372 files changed, 1431 insertions, 719 deletions
diff --git a/.expeditor/config.yml b/.expeditor/config.yml
index f87694b89e..c166cd525e 100644
--- a/.expeditor/config.yml
+++ b/.expeditor/config.yml
@@ -16,6 +16,7 @@ rubygems:
- chef-config
- chef-bin
- chef-utils
+ - knife
pipelines:
- verify:
diff --git a/.expeditor/update_version.sh b/.expeditor/update_version.sh
index 2a75c4b2f9..a6a2c6461d 100755
--- a/.expeditor/update_version.sh
+++ b/.expeditor/update_version.sh
@@ -16,10 +16,15 @@ VERSION=$(cat VERSION)
sed -i -r "s/^(\s*)VERSION = \".+\"/\1VERSION = \"${VERSION}\"/" chef-config/lib/chef-config/version.rb
sed -i -r "s/^(\s*)VERSION = \".+\"/\1VERSION = \"${VERSION}\"/" chef-bin/lib/chef-bin/version.rb
sed -i -r "s/^(\s*)VERSION = \".+\"/\1VERSION = \"${VERSION}\"/" chef-utils/lib/chef-utils/version.rb
+sed -i -r "s/^(\s*)VERSION = \".+\"/\1VERSION = \"${VERSION}\"/" knife/lib/chef/knife/version.rb
sed -i -r "s/VersionString\.new\(\".+\"\)/VersionString.new(\"${VERSION}\")/" lib/chef/version.rb
# Update the version inside Gemfile.lock
bundle update chef chef-config chef-utils --jobs=7 --conservative
+# Same for knife.
+cd knife
+bundle update chef chef-config chef-utils --jobs=7 --conservative
+
# Once Expeditor finishes executing this script, it will commit the changes and push
# the commit as a new tag corresponding to the value in the VERSION file.
diff --git a/chef.gemspec b/chef.gemspec
index a5e2b5a8dd..b410ea6d44 100644
--- a/chef.gemspec
+++ b/chef.gemspec
@@ -65,11 +65,13 @@ Gem::Specification.new do |s|
s.add_dependency "proxifier", "~> 1.0"
s.bindir = "bin"
- s.executables = %w{ knife }
+ s.executables = %w{ }
s.require_paths = %w{ lib }
s.files = %w{Gemfile Rakefile LICENSE README.md} +
- Dir.glob("{lib,spec}/**/*", File::FNM_DOTMATCH).reject { |f| File.directory?(f) } +
+ Dir.glob("{lib,spec}/**/*", File::FNM_DOTMATCH).reject do |f|
+ File.directory?(f) || File.path(f).match(/knife*/)
+ end +
Dir.glob("*.gemspec") +
Dir.glob("tasks/rspec.rb")
diff --git a/habitat/tests/spec.ps1 b/habitat/tests/spec.ps1
index 34b3a07beb..0754d31727 100644
--- a/habitat/tests/spec.ps1
+++ b/habitat/tests/spec.ps1
@@ -18,7 +18,7 @@ try {
SETX GEM_PATH $($gemPath.Split("=")[1]) /m
hab pkg binlink --force $PackageIdentifier
- /hab/bin/rspec --tag ~executables --tag ~choco_installed spec/functional
+ /hab/bin/rspec --tag ~executables --tag ~choco_installed --pattern 'spec/functional/**/*_spec.rb' --exclude-pattern 'spec/functional/knife/**/*.rb'
if (-not $?) { throw "functional testing failed"}
} finally {
Pop-Location
diff --git a/habitat/tests/test.pester.ps1 b/habitat/tests/test.pester.ps1
index 56f31e9a2f..c8cf993e2f 100644
--- a/habitat/tests/test.pester.ps1
+++ b/habitat/tests/test.pester.ps1
@@ -52,13 +52,6 @@ Describe "chef-infra-client" {
}
}
- Context "knife" {
- It "is an executable" {
- hab pkg exec $PackageIdentifier knife.bat --version
- $? | Should be $true
- }
- }
-
Context "chef-solo" {
It "is an executable" {
hab pkg exec $PackageIdentifier chef-solo.bat --version
diff --git a/habitat/tests/test.sh b/habitat/tests/test.sh
index c28ab8b2cf..655e8db2d8 100755
--- a/habitat/tests/test.sh
+++ b/habitat/tests/test.sh
@@ -28,10 +28,10 @@ echo "--- :mag_right: Testing ${pkg_ident} executables"
actual_version=$(hab pkg exec "${pkg_ident}" chef-client -- --version | sed 's/.*: //')
[[ "$package_version" = "$actual_version" ]] || error "chef-client is not the expected version. Expected '$package_version', got '$actual_version'"
-for executable in 'chef-client' 'ohai' 'chef-shell' 'chef-apply' 'knife' 'chef-solo'; do
+for executable in 'chef-client' 'ohai' 'chef-shell' 'chef-apply' 'chef-solo'; do
echo -en "\t$executable = "
hab pkg exec "${pkg_ident}" "${executable}" -- --version || error "${executable} failed to execute properly"
done
echo "--- :mag_right: Testing ${pkg_ident} functionality"
-hab pkg exec "${pkg_ident}" rspec --tag ~executables spec/functional || error 'failures during rspec tests'
+hab pkg exec "${pkg_ident}" rspec --tag ~executables --pattern 'spec/functional/**/*_spec.rb' --exclude-pattern 'spec/functional/knife/**/*.rb' || error 'failures during rspec tests'
diff --git a/kitchen-tests/Gemfile b/kitchen-tests/Gemfile
index adaaceaf9e..19f6e7d93e 100644
--- a/kitchen-tests/Gemfile
+++ b/kitchen-tests/Gemfile
@@ -2,9 +2,10 @@ source "https://rubygems.org"
gem "rake" # required to build some native extensions
gem "chef", path: ".."
+gem "knife", path: "../knife"
gem "ohai", git: "https://github.com/chef/ohai.git", branch: "master" # avoids failures when we bump chef major
gem "berkshelf", git: "https://github.com/berkshelf/berkshelf.git", branch: "master"
gem "kitchen-dokken", ">= 2.0"
gem "kitchen-inspec", git: "https://github.com/chef/kitchen-inspec.git", branch: "master"
gem "inspec"
-gem "test-kitchen", git: "https://github.com/test-kitchen/test-kitchen.git", branch: "master" \ No newline at end of file
+gem "test-kitchen", git: "https://github.com/test-kitchen/test-kitchen.git", branch: "master"
diff --git a/knife/Gemfile b/knife/Gemfile
new file mode 100644
index 0000000000..57c6a52f93
--- /dev/null
+++ b/knife/Gemfile
@@ -0,0 +1,29 @@
+source "https://rubygems.org"
+
+group(:development, :test) do
+ gem "cheffish", ">= 14" # testing only , but why didn't this need to explicit in chef?
+ gem "webmock" # testing only
+ gem "rake"
+ gem "rspec"
+ gem "chef-bin", path: "../chef-bin"
+end
+
+group(:ruby_prof) do
+ # ruby-prof 1.3.0 does not compile on our centos6 builders/kitchen testers
+ gem "ruby-prof", "< 1.3.0"
+end
+
+group(:omnibus_package, :pry) do
+ gem "pry"
+ gem "pry-byebug"
+ gem "pry-stack_explorer"
+end
+
+group(:chefstyle) do
+ gem "chefstyle", git: "https://github.com/chef/chefstyle.git", branch: "master"
+end
+
+gem "ohai", git: "https://github.com/chef/ohai.git", branch: "master"
+gem "chef", path: ".."
+gem "chef-utils", path: File.expand_path("../chef-utils", __dir__) if File.exist?(File.expand_path("../chef-utils", __dir__))
+gem "chef-config", path: File.expand_path("../chef-config", __dir__) if File.exist?(File.expand_path("../chef-config", __dir__))
diff --git a/knife/LICENSE b/knife/LICENSE
new file mode 100644
index 0000000000..11069edd79
--- /dev/null
+++ b/knife/LICENSE
@@ -0,0 +1,201 @@
+ Apache License
+ Version 2.0, January 2004
+ http://www.apache.org/licenses/
+
+TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+1. Definitions.
+
+ "License" shall mean the terms and conditions for use, reproduction,
+ and distribution as defined by Sections 1 through 9 of this document.
+
+ "Licensor" shall mean the copyright owner or entity authorized by
+ the copyright owner that is granting the License.
+
+ "Legal Entity" shall mean the union of the acting entity and all
+ other entities that control, are controlled by, or are under common
+ control with that entity. For the purposes of this definition,
+ "control" means (i) the power, direct or indirect, to cause the
+ direction or management of such entity, whether by contract or
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ outstanding shares, or (iii) beneficial ownership of such entity.
+
+ "You" (or "Your") shall mean an individual or Legal Entity
+ exercising permissions granted by this License.
+
+ "Source" form shall mean the preferred form for making modifications,
+ including but not limited to software source code, documentation
+ source, and configuration files.
+
+ "Object" form shall mean any form resulting from mechanical
+ transformation or translation of a Source form, including but
+ not limited to compiled object code, generated documentation,
+ and conversions to other media types.
+
+ "Work" shall mean the work of authorship, whether in Source or
+ Object form, made available under the License, as indicated by a
+ copyright notice that is included in or attached to the work
+ (an example is provided in the Appendix below).
+
+ "Derivative Works" shall mean any work, whether in Source or Object
+ form, that is based on (or derived from) the Work and for which the
+ editorial revisions, annotations, elaborations, or other modifications
+ represent, as a whole, an original work of authorship. For the purposes
+ of this License, Derivative Works shall not include works that remain
+ separable from, or merely link (or bind by name) to the interfaces of,
+ the Work and Derivative Works thereof.
+
+ "Contribution" shall mean any work of authorship, including
+ the original version of the Work and any modifications or additions
+ to that Work or Derivative Works thereof, that is intentionally
+ submitted to Licensor for inclusion in the Work by the copyright owner
+ or by an individual or Legal Entity authorized to submit on behalf of
+ the copyright owner. For the purposes of this definition, "submitted"
+ means any form of electronic, verbal, or written communication sent
+ to the Licensor or its representatives, including but not limited to
+ communication on electronic mailing lists, source code control systems,
+ and issue tracking systems that are managed by, or on behalf of, the
+ Licensor for the purpose of discussing and improving the Work, but
+ excluding communication that is conspicuously marked or otherwise
+ designated in writing by the copyright owner as "Not a Contribution."
+
+ "Contributor" shall mean Licensor and any individual or Legal Entity
+ on behalf of whom a Contribution has been received by Licensor and
+ subsequently incorporated within the Work.
+
+2. Grant of Copyright License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ copyright license to reproduce, prepare Derivative Works of,
+ publicly display, publicly perform, sublicense, and distribute the
+ Work and such Derivative Works in Source or Object form.
+
+3. Grant of Patent License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ (except as stated in this section) patent license to make, have made,
+ use, offer to sell, sell, import, and otherwise transfer the Work,
+ where such license applies only to those patent claims licensable
+ by such Contributor that are necessarily infringed by their
+ Contribution(s) alone or by combination of their Contribution(s)
+ with the Work to which such Contribution(s) was submitted. If You
+ institute patent litigation against any entity (including a
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
+ or a Contribution incorporated within the Work constitutes direct
+ or contributory patent infringement, then any patent licenses
+ granted to You under this License for that Work shall terminate
+ as of the date such litigation is filed.
+
+4. Redistribution. You may reproduce and distribute copies of the
+ Work or Derivative Works thereof in any medium, with or without
+ modifications, and in Source or Object form, provided that You
+ meet the following conditions:
+
+ (a) You must give any other recipients of the Work or
+ Derivative Works a copy of this License; and
+
+ (b) You must cause any modified files to carry prominent notices
+ stating that You changed the files; and
+
+ (c) You must retain, in the Source form of any Derivative Works
+ that You distribute, all copyright, patent, trademark, and
+ attribution notices from the Source form of the Work,
+ excluding those notices that do not pertain to any part of
+ the Derivative Works; and
+
+ (d) If the Work includes a "NOTICE" text file as part of its
+ distribution, then any Derivative Works that You distribute must
+ include a readable copy of the attribution notices contained
+ within such NOTICE file, excluding those notices that do not
+ pertain to any part of the Derivative Works, in at least one
+ of the following places: within a NOTICE text file distributed
+ as part of the Derivative Works; within the Source form or
+ documentation, if provided along with the Derivative Works; or,
+ within a display generated by the Derivative Works, if and
+ wherever such third-party notices normally appear. The contents
+ of the NOTICE file are for informational purposes only and
+ do not modify the License. You may add Your own attribution
+ notices within Derivative Works that You distribute, alongside
+ or as an addendum to the NOTICE text from the Work, provided
+ that such additional attribution notices cannot be construed
+ as modifying the License.
+
+ You may add Your own copyright statement to Your modifications and
+ may provide additional or different license terms and conditions
+ for use, reproduction, or distribution of Your modifications, or
+ for any such Derivative Works as a whole, provided Your use,
+ reproduction, and distribution of the Work otherwise complies with
+ the conditions stated in this License.
+
+5. Submission of Contributions. Unless You explicitly state otherwise,
+ any Contribution intentionally submitted for inclusion in the Work
+ by You to the Licensor shall be under the terms and conditions of
+ this License, without any additional terms or conditions.
+ Notwithstanding the above, nothing herein shall supersede or modify
+ the terms of any separate license agreement you may have executed
+ with Licensor regarding such Contributions.
+
+6. Trademarks. This License does not grant permission to use the trade
+ names, trademarks, service marks, or product names of the Licensor,
+ except as required for reasonable and customary use in describing the
+ origin of the Work and reproducing the content of the NOTICE file.
+
+7. Disclaimer of Warranty. Unless required by applicable law or
+ agreed to in writing, Licensor provides the Work (and each
+ Contributor provides its Contributions) on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied, including, without limitation, any warranties or conditions
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ PARTICULAR PURPOSE. You are solely responsible for determining the
+ appropriateness of using or redistributing the Work and assume any
+ risks associated with Your exercise of permissions under this License.
+
+8. Limitation of Liability. In no event and under no legal theory,
+ whether in tort (including negligence), contract, or otherwise,
+ unless required by applicable law (such as deliberate and grossly
+ negligent acts) or agreed to in writing, shall any Contributor be
+ liable to You for damages, including any direct, indirect, special,
+ incidental, or consequential damages of any character arising as a
+ result of this License or out of the use or inability to use the
+ Work (including but not limited to damages for loss of goodwill,
+ work stoppage, computer failure or malfunction, or any and all
+ other commercial damages or losses), even if such Contributor
+ has been advised of the possibility of such damages.
+
+9. Accepting Warranty or Additional Liability. While redistributing
+ the Work or Derivative Works thereof, You may choose to offer,
+ and charge a fee for, acceptance of support, warranty, indemnity,
+ or other liability obligations and/or rights consistent with this
+ License. However, in accepting such obligations, You may act only
+ on Your own behalf and on Your sole responsibility, not on behalf
+ of any other Contributor, and only if You agree to indemnify,
+ defend, and hold each Contributor harmless for any liability
+ incurred by, or claims asserted against, such Contributor by reason
+ of your accepting any such warranty or additional liability.
+
+END OF TERMS AND CONDITIONS
+
+APPENDIX: How to apply the Apache License to your work.
+
+ To apply the Apache License to your work, attach the following
+ boilerplate notice, with the fields enclosed by brackets "[]"
+ replaced with your own identifying information. (Don't include
+ the brackets!) The text should be enclosed in the appropriate
+ comment syntax for the file format. We also recommend that a
+ file or class name and description of purpose be included on the
+ same "printed page" as the copyright notice for easier
+ identification within third-party archives.
+
+Copyright [yyyy] [name of copyright owner]
+
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
diff --git a/knife/Rakefile b/knife/Rakefile
new file mode 100644
index 0000000000..ae65175839
--- /dev/null
+++ b/knife/Rakefile
@@ -0,0 +1,38 @@
+# Copyright:: Copyright (c) Chef Software Inc.
+# License:: Apache License, Version 2.0
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+require "rubygems"
+require "bundler/gem_tasks"
+Bundler::GemHelper.install_tasks
+
+begin
+ require "rspec/core/rake_task"
+
+ desc "Run all knife specs"
+ RSpec::Core::RakeTask.new(:spec) do |t|
+ t.verbose = false
+ t.rspec_opts = %w{--profile}
+ t.pattern = FileList["../spec/unit/knife/**/*_spec.rb"] +
+ FileList["../spec/unit/knife_spec.rb"] +
+ FileList["../spec/unit/application/knife_spec.rb"] +
+ FileList["../spec/integration/knife/*_spec.rb"] +
+ FileList["../spec/functional/knife/*_spec.rb"]
+ t.ruby_opts = "-I ../spec"
+
+ end
+rescue LoadError
+ puts "rspec not available. bundle install first to make sure all dependencies are installed."
+end
diff --git a/knife/bin/knife b/knife/bin/knife
new file mode 100755
index 0000000000..85ac3b91e9
--- /dev/null
+++ b/knife/bin/knife
@@ -0,0 +1,24 @@
+#!/usr/bin/env ruby
+#
+# ./knife - Chef CLI interface
+#
+# Author:: Adam Jacob (<adam@chef.io>)
+# Copyright:: Copyright 2009-2018, Chef Software Inc.
+# License:: Apache License, Version 2.0
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+$:.unshift(File.expand_path(File.join(__dir__, "..", "lib")))
+require "chef/application/knife"
+
+Chef::Application::Knife.new.run
diff --git a/knife/knife.gemspec b/knife/knife.gemspec
new file mode 100644
index 0000000000..a9f3e2926d
--- /dev/null
+++ b/knife/knife.gemspec
@@ -0,0 +1,65 @@
+$:.unshift(File.dirname(__FILE__) + "/lib")
+require_relative "lib/chef/knife/version"
+
+Gem::Specification.new do |s|
+ s.name = "knife"
+ s.version = Chef::Knife::VERSION
+ s.platform = Gem::Platform::RUBY
+ s.extra_rdoc_files = ["README.md", "LICENSE" ]
+ s.summary = "Let's find a good description."
+ s.description = s.summary
+ s.license = "Apache-2.0"
+ s.author = "Adam Jacob"
+ s.email = "adam@chef.io" # These seem a bit out of date, and this address probably doesn't go anywhere anymore?
+ s.homepage = "https://www.chef.io"
+
+ s.required_ruby_version = ">= 2.6.0"
+
+ s.add_dependency "chef-config", "= #{Chef::Knife::VERSION}"
+ s.add_dependency "chef-utils", "= #{Chef::Knife::VERSION}"
+ s.add_dependency "chef", "= #{Chef::Knife::VERSION}"
+ s.add_dependency "train-core", "~> 3.2", ">= 3.2.28" # 3.2.28 fixes sudo prompts. See https://github.com/chef/chef/pull/9635
+ s.add_dependency "train-winrm", ">= 0.2.5"
+ s.add_dependency "license-acceptance", ">= 1.0.5", "< 3"
+ s.add_dependency "mixlib-cli", ">= 2.1.1", "< 3.0"
+ s.add_dependency "mixlib-archive", ">= 0.4", "< 2.0"
+ s.add_dependency "ohai", "~> 17.0"
+ s.add_dependency "ffi", ">= 1.9.25", "< 1.14.0" # 1.14 breaks i386 windows. It should be fixed in 1.14.3
+ s.add_dependency "ffi-yajl", "~> 2.2"
+ s.add_dependency "net-ssh", ">= 5.1", "< 7"
+ s.add_dependency "net-ssh-multi", "~> 1.2", ">= 1.2.1"
+ s.add_dependency "ed25519", "~> 1.2" # ed25519 ssh key support
+ s.add_dependency "bcrypt_pbkdf", "~> 1.1" # ed25519 ssh key support
+ s.add_dependency "highline", ">= 1.6.9", "< 3" # Used in UI to present a list, no other usage.
+
+ s.add_dependency "tty-prompt", "~> 0.21" # knife ui.ask prompt
+ s.add_dependency "tty-screen", "~> 0.6" # knife list
+ s.add_dependency "tty-table", "~> 0.11" # knife render table output.
+ s.add_dependency "pastel" # knife ui.color
+ s.add_dependency "erubis", "~> 2.7"
+ s.add_dependency "chef-vault" # knife vault
+
+ s.add_development_dependency "chefstyle"
+
+ s.bindir = "bin"
+ s.executables = %w{ knife }
+
+ s.require_paths = %w{ lib }
+ s.files = %w{Gemfile Rakefile LICENSE README.md knife.gemspec} +
+ Dir.glob("lib/**/*", File::FNM_DOTMATCH).reject { |f| File.directory?(f) } +
+ Dir.glob("../spec/**/*", File::FNM_DOTMATCH).reject do |f|
+ File.directory?(f) || (
+ !File.path(f).match(/knife*/) &&
+ !File.path(f).match(/spec.data*/)
+ )
+ end
+
+ s.metadata = {
+ "bug_tracker_uri" => "https://github.com/chef/chef/issues",
+ "changelog_uri" => "https://github.com/chef/chef/blob/master/CHANGELOG.md",
+ "documentation_uri" => "https://docs.chef.io/",
+ "homepage_uri" => "https://www.chef.io",
+ "mailing_list_uri" => "https://discourse.chef.io/",
+ "source_code_uri" => "https://github.com/chef/chef/",
+ }
+end
diff --git a/lib/chef/application/knife.rb b/knife/lib/chef/application/knife.rb
index 7906ce6eaa..9893effbe2 100644
--- a/lib/chef/application/knife.rb
+++ b/knife/lib/chef/application/knife.rb
@@ -15,8 +15,8 @@
# See the License for the specific language governing permissions and
# limitations under the License.
+require "chef/application"
require_relative "../knife"
-require_relative "../application"
require "mixlib/log"
require "ohai/config"
module Net
diff --git a/lib/chef/chef_fs/knife.rb b/knife/lib/chef/chef_fs/knife.rb
index ba993beee4..9e165ab7ea 100644
--- a/lib/chef/chef_fs/knife.rb
+++ b/knife/lib/chef/chef_fs/knife.rb
@@ -26,11 +26,11 @@ class Chef
# Workaround for CHEF-3932
def self.deps
super do
- require_relative "../config"
- require_relative "parallelizer"
- require_relative "config"
- require_relative "file_pattern"
- require_relative "path_utils"
+ require "chef/config" unless defined?(Chef::Config)
+ require "chef/chef_fs/parallelizer" unless defined?(Chef::ChefFS::Parallelizer)
+ require "chef/chef_fs/config" unless defined?(Chef::ChefFS::Config)
+ require "chef/chef_fs/file_pattern" unless defined?(Chef::ChefFS::FilePattern)
+ require "chef/chef_fs/path_utils" unless defined?(Chef::ChefFS::PathUtils)
yield
end
end
diff --git a/lib/chef/knife.rb b/knife/lib/chef/knife.rb
index d277e51105..67f5f7d54d 100644
--- a/lib/chef/knife.rb
+++ b/knife/lib/chef/knife.rb
@@ -18,22 +18,26 @@
#
require "forwardable" unless defined?(Forwardable)
-require_relative "version"
+require_relative "knife/version"
require "mixlib/cli" unless defined?(Mixlib::CLI)
require "chef-utils/dsl/default_paths" unless defined?(ChefUtils::DSL::DefaultPaths)
require "chef-utils/dist" unless defined?(ChefUtils::Dist)
-require_relative "workstation_config_loader"
-require_relative "mixin/convert_to_class_name"
-require_relative "mixin/default_paths"
+require "chef/workstation_config_loader" unless defined?(Chef::WorkstationConfigLoader)
+require "chef/mixin/convert_to_class_name" unless defined?(Chef::ConvertToClassName)
+require "chef/mixin/default_paths" unless defined?(Chef::Mixin::DefaultPaths)
require_relative "knife/core/subcommand_loader"
require_relative "knife/core/ui"
-require_relative "local_mode"
-require_relative "server_api"
-require_relative "http/authenticator"
-require_relative "http/http_request"
-require_relative "http"
+require "chef/local_mode" unless defined?(Chef::LocalMode)
+require "chef/server_api" unless defined?(Chef::ServerAPI)
+require "http/authenticator" unless defined?(Chef::HTTP::Authenticator)
+require "http/http_request" unless defined?(Chef::HTTP::HTTPRequest)
+require "http" unless defined?(Chef::HTTP)
+# End
+
require "pp" unless defined?(PP)
+require_relative "application/knife"
+
class Chef
class Knife
@@ -639,14 +643,13 @@ class Chef
def rest
@rest ||= begin
- require_relative "server_api"
Chef::ServerAPI.new(Chef::Config[:chef_server_url])
end
end
def noauth_rest
@rest ||= begin
- require_relative "http/simple_json"
+ require "chef/http/simple_json" unless defined?(Chef::HTTP::SimpleJSON)
Chef::HTTP::SimpleJSON.new(Chef::Config[:chef_server_url])
end
end
@@ -664,7 +667,7 @@ class Chef
def root_rest
@root_rest ||= begin
- require_relative "server_api"
+ require "chef/server_api" unless defined? Chef::ServerAPI
Chef::ServerAPI.new(Chef::Config[:chef_server_root])
end
end
diff --git a/lib/chef/knife/acl_add.rb b/knife/lib/chef/knife/acl_add.rb
index 144a18fcb1..144a18fcb1 100644
--- a/lib/chef/knife/acl_add.rb
+++ b/knife/lib/chef/knife/acl_add.rb
diff --git a/lib/chef/knife/acl_base.rb b/knife/lib/chef/knife/acl_base.rb
index 0835d1ac05..0835d1ac05 100644
--- a/lib/chef/knife/acl_base.rb
+++ b/knife/lib/chef/knife/acl_base.rb
diff --git a/lib/chef/knife/acl_bulk_add.rb b/knife/lib/chef/knife/acl_bulk_add.rb
index 4992fe2afa..4992fe2afa 100644
--- a/lib/chef/knife/acl_bulk_add.rb
+++ b/knife/lib/chef/knife/acl_bulk_add.rb
diff --git a/lib/chef/knife/acl_bulk_remove.rb b/knife/lib/chef/knife/acl_bulk_remove.rb
index 0f35f1e2fb..0f35f1e2fb 100644
--- a/lib/chef/knife/acl_bulk_remove.rb
+++ b/knife/lib/chef/knife/acl_bulk_remove.rb
diff --git a/lib/chef/knife/acl_remove.rb b/knife/lib/chef/knife/acl_remove.rb
index 13f089ff3e..13f089ff3e 100644
--- a/lib/chef/knife/acl_remove.rb
+++ b/knife/lib/chef/knife/acl_remove.rb
diff --git a/lib/chef/knife/acl_show.rb b/knife/lib/chef/knife/acl_show.rb
index d3a5002b30..d3a5002b30 100644
--- a/lib/chef/knife/acl_show.rb
+++ b/knife/lib/chef/knife/acl_show.rb
diff --git a/lib/chef/knife/bootstrap.rb b/knife/lib/chef/knife/bootstrap.rb
index 340ffaecfd..d57614cb3d 100644
--- a/lib/chef/knife/bootstrap.rb
+++ b/knife/lib/chef/knife/bootstrap.rb
@@ -416,10 +416,9 @@ class Chef
deps do
require "erubis" unless defined?(Erubis)
-
require "net/ssh" unless defined?(Net::SSH)
- require_relative "../json_compat"
- require_relative "../util/path_helper"
+ require "chef/json_compat" unless defined?(Chef::JSONCompat)
+ require "chef-config/path_helper" unless defined?(ChefConfig::PathHelper)
require_relative "bootstrap/chef_vault_handler"
require_relative "bootstrap/client_builder"
require_relative "bootstrap/train_connector"
@@ -502,7 +501,7 @@ class Chef
bootstrap_files = []
bootstrap_files << File.join(__dir__, "bootstrap/templates", "#{template}.erb")
bootstrap_files << File.join(Knife.chef_config_dir, "bootstrap", "#{template}.erb") if Chef::Knife.chef_config_dir
- Chef::Util::PathHelper.home(".chef", "bootstrap", "#{template}.erb") { |p| bootstrap_files << p }
+ ChefConfig::PathHelper.home(".chef", "bootstrap", "#{template}.erb") { |p| bootstrap_files << p }
bootstrap_files << Gem.find_files(File.join("chef", "knife", "bootstrap", "#{template}.erb"))
bootstrap_files.flatten!
diff --git a/lib/chef/knife/bootstrap/chef_vault_handler.rb b/knife/lib/chef/knife/bootstrap/chef_vault_handler.rb
index 20759d6fdf..20759d6fdf 100644
--- a/lib/chef/knife/bootstrap/chef_vault_handler.rb
+++ b/knife/lib/chef/knife/bootstrap/chef_vault_handler.rb
diff --git a/lib/chef/knife/bootstrap/client_builder.rb b/knife/lib/chef/knife/bootstrap/client_builder.rb
index d9c3d83d06..b1e69d90db 100644
--- a/lib/chef/knife/bootstrap/client_builder.rb
+++ b/knife/lib/chef/knife/bootstrap/client_builder.rb
@@ -16,10 +16,10 @@
# limitations under the License.
#
-require_relative "../../node"
-require_relative "../../server_api"
-require_relative "../../api_client/registration"
-require_relative "../../api_client"
+require "chef/node" unless defined?(Chef::Node)
+require "chef/server_api" unless defined?(Chef::ServerAPI)
+require "chef/api_client" unless defined?(Chef::APIClient)
+require "chef/api_client/registration" unless defined?(Chef::APIClient::Registration)
require "tmpdir" unless defined?(Dir.mktmpdir)
class Chef
diff --git a/lib/chef/knife/bootstrap/templates/README.md b/knife/lib/chef/knife/bootstrap/templates/README.md
index 7f28f8f40f..7f28f8f40f 100644
--- a/lib/chef/knife/bootstrap/templates/README.md
+++ b/knife/lib/chef/knife/bootstrap/templates/README.md
diff --git a/lib/chef/knife/bootstrap/templates/chef-full.erb b/knife/lib/chef/knife/bootstrap/templates/chef-full.erb
index 2e0c80eaef..2e0c80eaef 100644
--- a/lib/chef/knife/bootstrap/templates/chef-full.erb
+++ b/knife/lib/chef/knife/bootstrap/templates/chef-full.erb
diff --git a/lib/chef/knife/bootstrap/templates/windows-chef-client-msi.erb b/knife/lib/chef/knife/bootstrap/templates/windows-chef-client-msi.erb
index 7aa7be49f8..7aa7be49f8 100644
--- a/lib/chef/knife/bootstrap/templates/windows-chef-client-msi.erb
+++ b/knife/lib/chef/knife/bootstrap/templates/windows-chef-client-msi.erb
diff --git a/lib/chef/knife/bootstrap/train_connector.rb b/knife/lib/chef/knife/bootstrap/train_connector.rb
index a220ece5bc..a220ece5bc 100644
--- a/lib/chef/knife/bootstrap/train_connector.rb
+++ b/knife/lib/chef/knife/bootstrap/train_connector.rb
diff --git a/lib/chef/knife/client_bulk_delete.rb b/knife/lib/chef/knife/client_bulk_delete.rb
index 38d25583b3..cc200a8bee 100644
--- a/lib/chef/knife/client_bulk_delete.rb
+++ b/knife/lib/chef/knife/client_bulk_delete.rb
@@ -23,7 +23,7 @@ class Chef
class ClientBulkDelete < Knife
deps do
- require_relative "../api_client_v1"
+ require "chef/api_client_v1" unless defined?(Chef::ApiClientV1)
end
option :delete_validators,
diff --git a/lib/chef/knife/client_create.rb b/knife/lib/chef/knife/client_create.rb
index d6e0eab63b..c79ff25d5e 100644
--- a/lib/chef/knife/client_create.rb
+++ b/knife/lib/chef/knife/client_create.rb
@@ -24,7 +24,7 @@ class Chef
class ClientCreate < Knife
deps do
- require_relative "../api_client_v1"
+ require "chef/api_client_v1" unless defined?(Chef::ApiClientV1)
end
option :file,
diff --git a/lib/chef/knife/client_delete.rb b/knife/lib/chef/knife/client_delete.rb
index 3ecfa38242..874f2ba642 100644
--- a/lib/chef/knife/client_delete.rb
+++ b/knife/lib/chef/knife/client_delete.rb
@@ -23,7 +23,7 @@ class Chef
class ClientDelete < Knife
deps do
- require_relative "../api_client_v1"
+ require "chef/api_client_v1" unless defined?(Chef::ApiClientV1)
end
option :delete_validators,
diff --git a/lib/chef/knife/client_edit.rb b/knife/lib/chef/knife/client_edit.rb
index f89f5e38ec..4f58228901 100644
--- a/lib/chef/knife/client_edit.rb
+++ b/knife/lib/chef/knife/client_edit.rb
@@ -23,7 +23,7 @@ class Chef
class ClientEdit < Knife
deps do
- require_relative "../api_client_v1"
+ require "chef/api_client_v1" unless defined?(Chef::ApiClientV1)
end
banner "knife client edit CLIENT (options)"
diff --git a/lib/chef/knife/client_key_create.rb b/knife/lib/chef/knife/client_key_create.rb
index 192d724473..192d724473 100644
--- a/lib/chef/knife/client_key_create.rb
+++ b/knife/lib/chef/knife/client_key_create.rb
diff --git a/lib/chef/knife/client_key_delete.rb b/knife/lib/chef/knife/client_key_delete.rb
index 2d486ffcbd..2d486ffcbd 100644
--- a/lib/chef/knife/client_key_delete.rb
+++ b/knife/lib/chef/knife/client_key_delete.rb
diff --git a/lib/chef/knife/client_key_edit.rb b/knife/lib/chef/knife/client_key_edit.rb
index d178aafc17..d178aafc17 100644
--- a/lib/chef/knife/client_key_edit.rb
+++ b/knife/lib/chef/knife/client_key_edit.rb
diff --git a/lib/chef/knife/client_key_list.rb b/knife/lib/chef/knife/client_key_list.rb
index afc04335d9..afc04335d9 100644
--- a/lib/chef/knife/client_key_list.rb
+++ b/knife/lib/chef/knife/client_key_list.rb
diff --git a/lib/chef/knife/client_key_show.rb b/knife/lib/chef/knife/client_key_show.rb
index 14e1f0ca7a..14e1f0ca7a 100644
--- a/lib/chef/knife/client_key_show.rb
+++ b/knife/lib/chef/knife/client_key_show.rb
diff --git a/lib/chef/knife/client_list.rb b/knife/lib/chef/knife/client_list.rb
index b4fc46767b..f4a4c7e9ad 100644
--- a/lib/chef/knife/client_list.rb
+++ b/knife/lib/chef/knife/client_list.rb
@@ -23,7 +23,7 @@ class Chef
class ClientList < Knife
deps do
- require_relative "../api_client_v1"
+ require "chef/api_client_v1" unless defined?(Chef::ApiClientV1)
end
banner "knife client list (options)"
diff --git a/lib/chef/knife/client_reregister.rb b/knife/lib/chef/knife/client_reregister.rb
index 6741895b23..3408392d95 100644
--- a/lib/chef/knife/client_reregister.rb
+++ b/knife/lib/chef/knife/client_reregister.rb
@@ -23,7 +23,7 @@ class Chef
class ClientReregister < Knife
deps do
- require_relative "../api_client_v1"
+ require "chef/api_client_v1" unless defined?(Chef::ApiClientV1)
end
banner "knife client reregister CLIENT (options)"
diff --git a/lib/chef/knife/client_show.rb b/knife/lib/chef/knife/client_show.rb
index 9170c73085..102ff2c4cc 100644
--- a/lib/chef/knife/client_show.rb
+++ b/knife/lib/chef/knife/client_show.rb
@@ -25,7 +25,7 @@ class Chef
include Knife::Core::MultiAttributeReturnOption
deps do
- require_relative "../api_client_v1"
+ require "chef/api_client_v1" unless defined?(Chef::ApiClientV1)
end
banner "knife client show CLIENT (options)"
diff --git a/lib/chef/knife/config_get.rb b/knife/lib/chef/knife/config_get.rb
index 91e6b7affd..91e6b7affd 100644
--- a/lib/chef/knife/config_get.rb
+++ b/knife/lib/chef/knife/config_get.rb
diff --git a/lib/chef/knife/config_get_profile.rb b/knife/lib/chef/knife/config_get_profile.rb
index a355c531fe..a355c531fe 100644
--- a/lib/chef/knife/config_get_profile.rb
+++ b/knife/lib/chef/knife/config_get_profile.rb
diff --git a/lib/chef/knife/config_list.rb b/knife/lib/chef/knife/config_list.rb
index c9f821e2a8..be80ded3b2 100644
--- a/lib/chef/knife/config_list.rb
+++ b/knife/lib/chef/knife/config_list.rb
@@ -25,7 +25,7 @@ class Chef
TABLE_HEADER ||= [" Profile", "Client", "Key", "Server"].freeze
deps do
- require_relative "../workstation_config_loader"
+ require "chef/workstation_config_loader" unless defined?(Chef::WorkstationConfigLoader)
require "tty-screen" unless defined?(TTY::Screen)
require "tty-table" unless defined?(TTY::Table)
end
diff --git a/lib/chef/knife/config_list_profiles.rb b/knife/lib/chef/knife/config_list_profiles.rb
index c037b0de53..c037b0de53 100644
--- a/lib/chef/knife/config_list_profiles.rb
+++ b/knife/lib/chef/knife/config_list_profiles.rb
diff --git a/lib/chef/knife/config_show.rb b/knife/lib/chef/knife/config_show.rb
index 7f28891885..7f28891885 100644
--- a/lib/chef/knife/config_show.rb
+++ b/knife/lib/chef/knife/config_show.rb
diff --git a/lib/chef/knife/config_use.rb b/knife/lib/chef/knife/config_use.rb
index e944dc210b..e944dc210b 100644
--- a/lib/chef/knife/config_use.rb
+++ b/knife/lib/chef/knife/config_use.rb
diff --git a/lib/chef/knife/config_use_profile.rb b/knife/lib/chef/knife/config_use_profile.rb
index 169bdbef30..169bdbef30 100644
--- a/lib/chef/knife/config_use_profile.rb
+++ b/knife/lib/chef/knife/config_use_profile.rb
diff --git a/lib/chef/knife/configure.rb b/knife/lib/chef/knife/configure.rb
index 2a27fd5d88..4a73b6875b 100644
--- a/lib/chef/knife/configure.rb
+++ b/knife/lib/chef/knife/configure.rb
@@ -26,10 +26,10 @@ class Chef
attr_reader :chef_repo, :new_client_key, :validation_client_name, :validation_key
deps do
- require_relative "../util/path_helper"
+ require "chef-config/path_helper" unless defined?(ChefConfig::PathHelper)
require_relative "client_create"
require_relative "user_create"
- require "ohai" unless defined?(Ohai::System)
+ require "ohai" unless defined?(Ohai)
Chef::Knife::ClientCreate.load_deps
Chef::Knife::UserCreate.load_deps
end
@@ -138,7 +138,7 @@ class Chef
# @return [String] the path to the user's .chef directory
def chef_config_path
- @chef_config_path ||= Chef::Util::PathHelper.home(".chef")
+ @chef_config_path ||= ChefConfig::PathHelper.home(".chef")
end
# @return [String] the full path to the config file (credential file)
diff --git a/lib/chef/knife/configure_client.rb b/knife/lib/chef/knife/configure_client.rb
index c6f159ec8f..c6f159ec8f 100644
--- a/lib/chef/knife/configure_client.rb
+++ b/knife/lib/chef/knife/configure_client.rb
diff --git a/lib/chef/knife/cookbook_bulk_delete.rb b/knife/lib/chef/knife/cookbook_bulk_delete.rb
index d6657ccb4f..d294db842c 100644
--- a/lib/chef/knife/cookbook_bulk_delete.rb
+++ b/knife/lib/chef/knife/cookbook_bulk_delete.rb
@@ -25,7 +25,7 @@ class Chef
deps do
require_relative "cookbook_delete"
- require_relative "../cookbook_version"
+ require "chef/cookbook_version" unless defined?(Chef::CookbookVersion)
end
option :purge, short: "-p", long: "--purge", boolean: true, description: "Permanently remove files from backing data store."
diff --git a/lib/chef/knife/cookbook_delete.rb b/knife/lib/chef/knife/cookbook_delete.rb
index 04ecb95cf4..fac23ae336 100644
--- a/lib/chef/knife/cookbook_delete.rb
+++ b/knife/lib/chef/knife/cookbook_delete.rb
@@ -25,7 +25,7 @@ class Chef
attr_accessor :cookbook_name, :version
deps do
- require_relative "../cookbook_version"
+ require "chef/cookbook_version" unless defined?(Chef::CookbookVersion)
end
option :all, short: "-a", long: "--all", boolean: true, description: "Delete all versions of the cookbook."
diff --git a/lib/chef/knife/cookbook_download.rb b/knife/lib/chef/knife/cookbook_download.rb
index a07b519511..dcf7299901 100644
--- a/lib/chef/knife/cookbook_download.rb
+++ b/knife/lib/chef/knife/cookbook_download.rb
@@ -27,7 +27,7 @@ class Chef
attr_accessor :cookbook_name
deps do
- require_relative "../cookbook_version"
+ require "chef/cookbook_version" unless defined?(Chef::CookbookVersion)
end
banner "knife cookbook download COOKBOOK [VERSION] (options)"
diff --git a/lib/chef/knife/cookbook_list.rb b/knife/lib/chef/knife/cookbook_list.rb
index 719c10f893..719c10f893 100644
--- a/lib/chef/knife/cookbook_list.rb
+++ b/knife/lib/chef/knife/cookbook_list.rb
diff --git a/lib/chef/knife/cookbook_metadata.rb b/knife/lib/chef/knife/cookbook_metadata.rb
index 8d8970b1c1..854e7a6609 100644
--- a/lib/chef/knife/cookbook_metadata.rb
+++ b/knife/lib/chef/knife/cookbook_metadata.rb
@@ -23,8 +23,8 @@ class Chef
class CookbookMetadata < Knife
deps do
- require_relative "../cookbook_loader"
- require_relative "../cookbook/metadata"
+ require "chef/cookbook_loader" unless defined?(Chef::CookbookLoader)
+ require "chef/cookbook/metadata" unless defined?(Chef::Cookbook::Metadata)
end
banner "knife cookbook metadata COOKBOOK (options)"
diff --git a/lib/chef/knife/cookbook_metadata_from_file.rb b/knife/lib/chef/knife/cookbook_metadata_from_file.rb
index d768213384..77a141d426 100644
--- a/lib/chef/knife/cookbook_metadata_from_file.rb
+++ b/knife/lib/chef/knife/cookbook_metadata_from_file.rb
@@ -25,7 +25,7 @@ class Chef
class CookbookMetadataFromFile < Knife
deps do
- require_relative "../cookbook/metadata"
+ require "chef/cookbook/metadata" unless defined?(Chef::Cookbook::Metadata)
end
banner "knife cookbook metadata from file FILE (options)"
diff --git a/lib/chef/knife/cookbook_show.rb b/knife/lib/chef/knife/cookbook_show.rb
index 0b97fba139..aac26447b9 100644
--- a/lib/chef/knife/cookbook_show.rb
+++ b/knife/lib/chef/knife/cookbook_show.rb
@@ -23,9 +23,9 @@ class Chef
class CookbookShow < Knife
deps do
- require_relative "../json_compat"
+ require "chef/json_compat" unless defined?(Chef::JSONCompat)
require "uri" unless defined?(URI)
- require_relative "../cookbook_version"
+ require "chef/cookbook_version" unless defined?(Chef::CookbookVersion)
end
banner "knife cookbook show COOKBOOK [VERSION] [PART] [FILENAME] (options)"
diff --git a/lib/chef/knife/cookbook_upload.rb b/knife/lib/chef/knife/cookbook_upload.rb
index 9f6f3c4cb2..d9582a3ccc 100644
--- a/lib/chef/knife/cookbook_upload.rb
+++ b/knife/lib/chef/knife/cookbook_upload.rb
@@ -24,11 +24,11 @@ class Chef
class Knife
class CookbookUpload < Knife
deps do
- require_relative "../mixin/file_class"
+ require "chef/mixin/file_class" unless defined?(Chef::Mixin::FileClass)
include Chef::Mixin::FileClass
- require_relative "../exceptions"
- require_relative "../cookbook_loader"
- require_relative "../cookbook_uploader"
+ require "chef/exceptions" unless defined?(Chef::Exceptions)
+ require "chef/cookbook_loader" unless defined?(Chef::CookbookLoader)
+ require "chef/cookbook_uploader" unless defined?(Chef::CookbookUploader)
end
banner "knife cookbook upload [COOKBOOKS...] (options)"
diff --git a/lib/chef/knife/core/bootstrap_context.rb b/knife/lib/chef/knife/core/bootstrap_context.rb
index 9aa81da82f..0d71aa8dc3 100644
--- a/lib/chef/knife/core/bootstrap_context.rb
+++ b/knife/lib/chef/knife/core/bootstrap_context.rb
@@ -16,8 +16,8 @@
# limitations under the License.
#
-require_relative "../../run_list"
-require_relative "../../util/path_helper"
+require "run_list" unless defined?(Chef::RunList)
+require "chef-config/path_helper" unless defined?(ChefConfig::PathHelper)
require "pathname" unless defined?(Pathname)
require "chef-utils/dist" unless defined?(ChefUtils::Dist)
@@ -230,7 +230,7 @@ class Chef
def trusted_certs_content
content = ""
if chef_config[:trusted_certs_dir]
- Dir.glob(File.join(Chef::Util::PathHelper.escape_glob_dir(chef_config[:trusted_certs_dir]), "*.{crt,pem}")).each do |cert|
+ Dir.glob(File.join(ChefConfig::PathHelper.escape_glob_dir(chef_config[:trusted_certs_dir]), "*.{crt,pem}")).each do |cert|
content << "cat > /etc/chef/trusted_certs/#{File.basename(cert)} <<'EOP'\n" +
IO.read(File.expand_path(cert)) + "\nEOP\n"
end
diff --git a/lib/chef/knife/core/cookbook_scm_repo.rb b/knife/lib/chef/knife/core/cookbook_scm_repo.rb
index ba194a8a6d..921dadad8b 100644
--- a/lib/chef/knife/core/cookbook_scm_repo.rb
+++ b/knife/lib/chef/knife/core/cookbook_scm_repo.rb
@@ -16,7 +16,7 @@
# limitations under the License.
#
-require_relative "../../mixin/shell_out"
+require "chef/mixin/shell_out" unless defined?(Chef::Mixin::ShellOut)
class Chef
class Knife
diff --git a/knife/lib/chef/knife/core/cookbook_site_streaming_uploader.rb b/knife/lib/chef/knife/core/cookbook_site_streaming_uploader.rb
new file mode 100644
index 0000000000..85e83af5da
--- /dev/null
+++ b/knife/lib/chef/knife/core/cookbook_site_streaming_uploader.rb
@@ -0,0 +1,249 @@
+#
+# Author:: Stanislav Vitvitskiy
+# Author:: Nuo Yan (nuo@chef.io)
+# Author:: Christopher Walters (<cw@chef.io>)
+# Copyright:: Copyright (c) Chef Software Inc.
+# License:: Apache License, Version 2.0
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+autoload :URI, "uri"
+module Net
+ autoload :HTTP, "net/http"
+end
+autoload :OpenSSL, "openssl"
+module Mixlib
+ module Authentication
+ autoload :SignedHeaderAuth, "mixlib/authentication/signedheaderauth"
+ end
+end
+require "chef-utils/dist" unless defined?(ChefUtils::Dist)
+require_relative "../cookbook_metadata"
+class Chef
+ class Knife
+ module Core
+ # == Chef::Knife::Core::CookbookSiteStreamingUploader
+ # A streaming multipart HTTP upload implementation. Used to upload cookbooks
+ # (in tarball form) to https://supermarket.chef.io
+ #
+ # inspired by http://stanislavvitvitskiy.blogspot.com/2008/12/multipart-post-in-ruby.html
+ class CookbookSiteStreamingUploader
+
+ DefaultHeaders = { "accept" => "application/json", "x-chef-version" => ::Chef::VERSION }.freeze # rubocop:disable Naming/ConstantName
+
+ class << self
+
+ def create_build_dir(cookbook)
+ tmp_cookbook_path = Tempfile.new("#{ChefUtils::Dist::Infra::SHORT}-#{cookbook.name}-build")
+ tmp_cookbook_path.close
+ tmp_cookbook_dir = tmp_cookbook_path.path
+ File.unlink(tmp_cookbook_dir)
+ FileUtils.mkdir_p(tmp_cookbook_dir)
+ Chef::Log.trace("Staging at #{tmp_cookbook_dir}")
+ checksums_to_on_disk_paths = cookbook.checksums
+ cookbook.each_file do |manifest_record|
+ path_in_cookbook = manifest_record[:path]
+ on_disk_path = checksums_to_on_disk_paths[manifest_record[:checksum]]
+ dest = File.join(tmp_cookbook_dir, cookbook.name.to_s, path_in_cookbook)
+ FileUtils.mkdir_p(File.dirname(dest))
+ Chef::Log.trace("Staging #{on_disk_path} to #{dest}")
+ FileUtils.cp(on_disk_path, dest)
+ end
+
+ # First, generate metadata
+ Chef::Log.trace("Generating metadata")
+ kcm = Chef::Knife::CookbookMetadata.new
+ kcm.config[:cookbook_path] = [ tmp_cookbook_dir ]
+ kcm.name_args = [ cookbook.name.to_s ]
+ kcm.run
+
+ tmp_cookbook_dir
+ end
+
+ def post(to_url, user_id, secret_key_filename, params = {}, headers = {})
+ make_request(:post, to_url, user_id, secret_key_filename, params, headers)
+ end
+
+ def put(to_url, user_id, secret_key_filename, params = {}, headers = {})
+ make_request(:put, to_url, user_id, secret_key_filename, params, headers)
+ end
+
+ def make_request(http_verb, to_url, user_id, secret_key_filename, params = {}, headers = {})
+ boundary = "----RubyMultipartClient" + rand(1000000).to_s + "ZZZZZ"
+ parts = []
+ content_file = nil
+
+ secret_key = OpenSSL::PKey::RSA.new(File.read(secret_key_filename))
+
+ unless params.nil? || params.empty?
+ params.each do |key, value|
+ if value.is_a?(File)
+ content_file = value
+ filepath = value.path
+ filename = File.basename(filepath)
+ parts << StringPart.new( "--" + boundary + "\r\n" +
+ "Content-Disposition: form-data; name=\"" + key.to_s + "\"; filename=\"" + filename + "\"\r\n" +
+ "Content-Type: application/octet-stream\r\n\r\n")
+ parts << StreamPart.new(value, File.size(filepath))
+ parts << StringPart.new("\r\n")
+ else
+ parts << StringPart.new( "--" + boundary + "\r\n" +
+ "Content-Disposition: form-data; name=\"" + key.to_s + "\"\r\n\r\n")
+ parts << StringPart.new(value.to_s + "\r\n")
+ end
+ end
+ parts << StringPart.new("--" + boundary + "--\r\n")
+ end
+
+ body_stream = MultipartStream.new(parts)
+
+ timestamp = Time.now.utc.iso8601
+
+ url = URI.parse(to_url)
+
+ Chef::Log.logger.debug("Signing: method: #{http_verb}, url: #{url}, file: #{content_file}, User-id: #{user_id}, Timestamp: #{timestamp}")
+
+ # We use the body for signing the request if the file parameter
+ # wasn't a valid file or wasn't included. Extract the body (with
+ # multi-part delimiters intact) to sign the request.
+ # TODO: tim: 2009-12-28: It'd be nice to remove this special case, and
+ # always hash the entire request body. In the file case it would just be
+ # expanded multipart text - the entire body of the POST.
+ content_body = parts.inject("") { |result, part| result + part.read(0, part.size) }
+ content_file.rewind if content_file # we consumed the file for the above operation, so rewind it.
+
+ signing_options = {
+ http_method: http_verb,
+ path: url.path,
+ user_id: user_id,
+ timestamp: timestamp }
+ (content_file && signing_options[:file] = content_file) || (signing_options[:body] = (content_body || ""))
+
+ headers.merge!(Mixlib::Authentication::SignedHeaderAuth.signing_object(signing_options).sign(secret_key))
+
+ content_file.rewind if content_file
+
+ # net/http doesn't like symbols for header keys, so we'll to_s each one just in case
+ headers = DefaultHeaders.merge(Hash[*headers.map { |k, v| [k.to_s, v] }.flatten])
+
+ req = case http_verb
+ when :put
+ Net::HTTP::Put.new(url.path, headers)
+ when :post
+ Net::HTTP::Post.new(url.path, headers)
+ end
+ req.content_length = body_stream.size
+ req.content_type = "multipart/form-data; boundary=" + boundary unless parts.empty?
+ req.body_stream = body_stream
+
+ http = Chef::HTTP::BasicClient.new(url).http_client
+ res = http.request(req)
+
+ # alias status to code and to_s to body for test purposes
+ # TODO: stop the following madness!
+ class << res
+ alias :to_s :body
+
+ # BUG this makes the response compatible with what response_steps expects to test headers (response.headers[] -> response[])
+ def headers # rubocop:disable Lint/NestedMethodDefinition
+ self
+ end
+
+ def status # rubocop:disable Lint/NestedMethodDefinition
+ code.to_i
+ end
+ end
+ res
+ end
+
+ end
+
+ class StreamPart
+ def initialize(stream, size)
+ @stream, @size = stream, size
+ end
+
+ def size
+ @size
+ end
+
+ # read the specified amount from the stream
+ def read(offset, how_much)
+ @stream.read(how_much)
+ end
+ end
+
+ class StringPart
+ def initialize(str)
+ @str = str
+ end
+
+ def size
+ @str.length
+ end
+
+ # read the specified amount from the string starting at the offset
+ def read(offset, how_much)
+ @str[offset, how_much]
+ end
+ end
+
+ class MultipartStream
+ def initialize(parts)
+ @parts = parts
+ @part_no = 0
+ @part_offset = 0
+ end
+
+ def size
+ @parts.inject(0) { |size, part| size + part.size }
+ end
+
+ def read(how_much, dst_buf = nil)
+ if @part_no >= @parts.size
+ dst_buf.replace("") if dst_buf
+ return dst_buf
+ end
+
+ how_much_current_part = @parts[@part_no].size - @part_offset
+
+ how_much_current_part = if how_much_current_part > how_much
+ how_much
+ else
+ how_much_current_part
+ end
+
+ how_much_next_part = how_much - how_much_current_part
+
+ current_part = @parts[@part_no].read(@part_offset, how_much_current_part)
+
+ # recurse into the next part if the current one was not large enough
+ if how_much_next_part > 0
+ @part_no += 1
+ @part_offset = 0
+ next_part = read(how_much_next_part)
+ result = current_part + (next_part || "")
+ else
+ @part_offset += how_much_current_part
+ result = current_part
+ end
+ dst_buf ? dst_buf.replace(result || "") : result
+ end
+ end
+
+ end
+ end
+ end
+end
+
diff --git a/lib/chef/knife/core/formatting_options.rb b/knife/lib/chef/knife/core/formatting_options.rb
index cdee2c5989..cdee2c5989 100644
--- a/lib/chef/knife/core/formatting_options.rb
+++ b/knife/lib/chef/knife/core/formatting_options.rb
diff --git a/lib/chef/knife/core/gem_glob_loader.rb b/knife/lib/chef/knife/core/gem_glob_loader.rb
index d058379e71..d365602cb4 100644
--- a/lib/chef/knife/core/gem_glob_loader.rb
+++ b/knife/lib/chef/knife/core/gem_glob_loader.rb
@@ -16,8 +16,8 @@
# limitations under the License.
#
-require_relative "../../version"
-require_relative "../../util/path_helper"
+require_relative "../version"
+require "chef-config/path_helper" unless defined?(ChefConfig::PathHelper)
class Chef
class Knife
class SubcommandLoader
@@ -45,22 +45,13 @@ class Chef
find_subcommands_via_dirglob
end
- def find_subcommands_via_dirglob
- # The "require paths" of the core knife subcommands bundled with chef
- files = Dir[File.join(Chef::Util::PathHelper.escape_glob_dir(File.expand_path("../../knife", __dir__)), "*.rb")]
- subcommand_files = {}
- files.each do |knife_file|
- rel_path = knife_file[/#{CHEF_ROOT}#{Regexp.escape(File::SEPARATOR)}(.*)\.rb/, 1]
- subcommand_files[rel_path] = knife_file
- end
- subcommand_files
- end
-
def find_subcommands_via_rubygems
files = find_files_latest_gems "chef/knife/*.rb"
+ version_file_match = /#{Regexp.escape(File.join('chef', 'knife', 'version'))}$/
subcommand_files = {}
files.each do |file|
- rel_path = file[/(#{Regexp.escape File.join('chef', 'knife', '')}.*)\.rb/, 1]
+
+ rel_path = file[/(.*)(#{Regexp.escape File.join('chef', 'knife', '')}.*)\.rb/, 2]
# When not installed as a gem (ChefDK/appbundler in particular), AND
# a different version of Chef is installed via gems, `files` will
@@ -69,6 +60,10 @@ class Chef
# get a LoadError later when we try to require it.
next if from_different_chef_version?(file)
+ # Exclude knife/chef/version. It's not a knife command, and force-loading
+ # when we load all of these files will emit constant-already-defined warnings
+ next if rel_path =~ version_file_match
+
subcommand_files[rel_path] = file
end
@@ -82,8 +77,9 @@ class Chef
if check_load_path
files = $LOAD_PATH.map do |load_path|
- Dir["#{File.expand_path glob, Chef::Util::PathHelper.escape_glob_dir(load_path)}#{Gem.suffix_pattern}"]
+ Dir["#{File.expand_path glob, ChefConfig::PathHelper.escape_glob_dir(load_path)}#{Gem.suffix_pattern}"]
end.flatten.select { |file| File.file? file.untaint }
+
end
gem_files = latest_gem_specs.map do |spec|
@@ -116,7 +112,7 @@ class Chef
spec.require_paths.first
end
- glob = File.join(Chef::Util::PathHelper.escape_glob_dir(spec.full_gem_path, dirs), glob)
+ glob = File.join(ChefConfig::PathHelper.escape_glob_dir(spec.full_gem_path, dirs), glob)
Dir[glob].map(&:untaint)
end
diff --git a/lib/chef/knife/core/generic_presenter.rb b/knife/lib/chef/knife/core/generic_presenter.rb
index 850bfa8b3d..850bfa8b3d 100644
--- a/lib/chef/knife/core/generic_presenter.rb
+++ b/knife/lib/chef/knife/core/generic_presenter.rb
diff --git a/lib/chef/knife/core/hashed_command_loader.rb b/knife/lib/chef/knife/core/hashed_command_loader.rb
index c1d71f3edf..e419037b67 100644
--- a/lib/chef/knife/core/hashed_command_loader.rb
+++ b/knife/lib/chef/knife/core/hashed_command_loader.rb
@@ -15,7 +15,7 @@
# limitations under the License.
#
-require_relative "../../version"
+require_relative "../version"
class Chef
class Knife
class SubcommandLoader
diff --git a/lib/chef/knife/core/node_editor.rb b/knife/lib/chef/knife/core/node_editor.rb
index 2f9b326d16..5980cd888e 100644
--- a/lib/chef/knife/core/node_editor.rb
+++ b/knife/lib/chef/knife/core/node_editor.rb
@@ -17,8 +17,8 @@
# limitations under the License.
#
-require_relative "../../json_compat"
-require_relative "../../node"
+require "chef/json_compat" unless defined?(Chef::JSONCompat)
+require "chef/node" unless defined?(Chef::Node)
class Chef
class Knife
diff --git a/lib/chef/knife/core/node_presenter.rb b/knife/lib/chef/knife/core/node_presenter.rb
index 8c948cf76c..8c948cf76c 100644
--- a/lib/chef/knife/core/node_presenter.rb
+++ b/knife/lib/chef/knife/core/node_presenter.rb
diff --git a/lib/chef/knife/core/object_loader.rb b/knife/lib/chef/knife/core/object_loader.rb
index 5421fc46ce..edd8921c11 100644
--- a/lib/chef/knife/core/object_loader.rb
+++ b/knife/lib/chef/knife/core/object_loader.rb
@@ -17,8 +17,8 @@
#
autoload :FFI_Yajl, "ffi_yajl"
-require_relative "../../util/path_helper"
-require_relative "../../data_bag_item"
+require "chef-config/path_helper" unless defined?(ChefConfig::PathHelper)
+require "chef/data_bag_item" unless defined?(Chef::DataBagItem)
class Chef
class Knife
@@ -40,6 +40,7 @@ class Chef
def load_from(repo_location, *components)
unless object_file = find_file(repo_location, *components)
+ puts "ZZZ LOoking for: #{repo_location} #{components}"
ui.error "Could not find or open file '#{components.last}' in current directory or in '#{repo_location}/#{components.join("/")}'"
exit 1
end
@@ -71,14 +72,14 @@ class Chef
#
# @api public
def find_all_objects(path)
- path = File.join(Chef::Util::PathHelper.escape_glob_dir(File.expand_path(path)), "*")
+ path = File.join(ChefConfig::PathHelper.escape_glob_dir(File.expand_path(path)), "*")
path << ".{json,rb}"
objects = Dir.glob(path)
objects.map { |o| File.basename(o) }
end
def find_all_object_dirs(path)
- path = File.join(Chef::Util::PathHelper.escape_glob_dir(File.expand_path(path)), "*")
+ path = File.join(ChefConfig::PathHelper.escape_glob_dir(File.expand_path(path)), "*")
objects = Dir.glob(path)
objects.delete_if { |o| !File.directory?(o) }
objects.map { |o| File.basename(o) }
diff --git a/lib/chef/knife/core/status_presenter.rb b/knife/lib/chef/knife/core/status_presenter.rb
index 271c71d618..271c71d618 100644
--- a/lib/chef/knife/core/status_presenter.rb
+++ b/knife/lib/chef/knife/core/status_presenter.rb
diff --git a/lib/chef/knife/core/subcommand_loader.rb b/knife/lib/chef/knife/core/subcommand_loader.rb
index 26d7e0277c..ca7bfcd008 100644
--- a/lib/chef/knife/core/subcommand_loader.rb
+++ b/knife/lib/chef/knife/core/subcommand_loader.rb
@@ -16,8 +16,9 @@
# limitations under the License.
#
-require_relative "../../version"
-require_relative "../../util/path_helper"
+require_relative "../version"
+require "chef-config/path_helper" unless defined?(ChefConfig::PathHelper)
+require "chef/run_list" unless defined?(Chef::RunList)
require_relative "gem_glob_loader"
require_relative "hashed_command_loader"
@@ -72,7 +73,7 @@ class Chef
end
def self.plugin_manifest_path
- Chef::Util::PathHelper.home(".chef", "plugin_manifest.json")
+ ChefConfig::PathHelper.home(".chef", "plugin_manifest.json")
end
def self.generate_hash
@@ -141,13 +142,17 @@ class Chef
#
# This is shared between the custom_manifest_loader and the gem_glob_loader
- #
def find_subcommands_via_dirglob
# The "require paths" of the core knife subcommands bundled with chef
- files = Dir[File.join(Chef::Util::PathHelper.escape_glob_dir(File.expand_path("../../knife", __dir__)), "*.rb")]
+ files = Dir[File.join(ChefConfig::PathHelper.escape_glob_dir(File.expand_path("../../knife", __dir__)), "*.rb")]
+ version_file_match = /#{Regexp.escape(File.join('chef', 'knife', 'version.rb'))}/
subcommand_files = {}
files.each do |knife_file|
- rel_path = knife_file[/#{CHEF_ROOT}#{Regexp.escape(File::SEPARATOR)}(.*)\.rb/, 1]
+ rel_path = knife_file[/#{KNIFE_ROOT}#{Regexp.escape(File::SEPARATOR)}(.*)\.rb/, 1]
+ # Exclude version.rb file for the gem. It's not a knife command, and force-loading it later
+ # because loaded via in subcommand files generates CLI warnings about its consts already having been defined
+ next if knife_file =~ version_file_match
+
subcommand_files[rel_path] = knife_file
end
subcommand_files
@@ -188,12 +193,12 @@ class Chef
user_specific_files = []
if chef_config_dir
- user_specific_files.concat Dir.glob(File.expand_path("plugins/knife/*.rb", Chef::Util::PathHelper.escape_glob_dir(chef_config_dir)))
+ user_specific_files.concat Dir.glob(File.expand_path("plugins/knife/*.rb", ChefConfig::PathHelper.escape_glob_dir(chef_config_dir)))
end
# finally search ~/.chef/plugins/knife/*.rb
- Chef::Util::PathHelper.home(".chef", "plugins", "knife") do |p|
- user_specific_files.concat Dir.glob(File.join(Chef::Util::PathHelper.escape_glob_dir(p), "*.rb"))
+ ChefConfig::PathHelper.home(".chef", "plugins", "knife") do |p|
+ user_specific_files.concat Dir.glob(File.join(ChefConfig::PathHelper.escape_glob_dir(p), "*.rb"))
end
user_specific_files
diff --git a/lib/chef/knife/core/text_formatter.rb b/knife/lib/chef/knife/core/text_formatter.rb
index ec97748afb..ec97748afb 100644
--- a/lib/chef/knife/core/text_formatter.rb
+++ b/knife/lib/chef/knife/core/text_formatter.rb
diff --git a/lib/chef/knife/core/ui.rb b/knife/lib/chef/knife/core/ui.rb
index aa84537064..782df1ca10 100644
--- a/lib/chef/knife/core/ui.rb
+++ b/knife/lib/chef/knife/core/ui.rb
@@ -19,7 +19,7 @@
#
require "forwardable" unless defined?(Forwardable)
-require_relative "../../platform/query_helpers"
+require "chef/platform/query_helpers" # NOTE - this require doesn't defined any const we can check.
require_relative "generic_presenter"
require "tempfile" unless defined?(Tempfile)
diff --git a/lib/chef/knife/core/windows_bootstrap_context.rb b/knife/lib/chef/knife/core/windows_bootstrap_context.rb
index fa8b43f383..0ff209a0b7 100644
--- a/lib/chef/knife/core/windows_bootstrap_context.rb
+++ b/knife/lib/chef/knife/core/windows_bootstrap_context.rb
@@ -17,7 +17,7 @@
#
require_relative "bootstrap_context"
-require_relative "../../util/path_helper"
+require "chef-config/path_helper" unless defined?(ChefConfig::PathHelper)
require "chef-utils/dist" unless defined?(ChefUtils::Dist)
class Chef
@@ -331,7 +331,7 @@ class Chef
def trusted_certs_content
content = ""
if chef_config[:trusted_certs_dir]
- Dir.glob(File.join(Chef::Util::PathHelper.escape_glob_dir(chef_config[:trusted_certs_dir]), "*.{crt,pem}")).each do |cert|
+ Dir.glob(File.join(ChefConfig::PathHelper.escape_glob_dir(chef_config[:trusted_certs_dir]), "*.{crt,pem}")).each do |cert|
content << "> #{bootstrap_directory}/trusted_certs/#{File.basename(cert)} (\n" +
escape_and_echo(IO.read(File.expand_path(cert))) + "\n)\n"
end
diff --git a/lib/chef/knife/data_bag_create.rb b/knife/lib/chef/knife/data_bag_create.rb
index 11448c69b7..a8a9caf7e4 100644
--- a/lib/chef/knife/data_bag_create.rb
+++ b/knife/lib/chef/knife/data_bag_create.rb
@@ -26,8 +26,8 @@ class Chef
include DataBagSecretOptions
deps do
- require_relative "../data_bag"
- require_relative "../encrypted_data_bag_item"
+ require "chef/data_bag" unless defined?(Chef::DataBag)
+ require "chef/encrypted_data_bag_item" unless defined?(Chef::EncryptedDataBagItem)
end
banner "knife data bag create BAG [ITEM] (options)"
diff --git a/lib/chef/knife/data_bag_delete.rb b/knife/lib/chef/knife/data_bag_delete.rb
index ab38244e91..a7b5a4b6fd 100644
--- a/lib/chef/knife/data_bag_delete.rb
+++ b/knife/lib/chef/knife/data_bag_delete.rb
@@ -23,7 +23,7 @@ class Chef
class DataBagDelete < Knife
deps do
- require_relative "../data_bag"
+ require "chef/data_bag" unless defined?(Chef::DataBag)
end
banner "knife data bag delete BAG [ITEM] (options)"
diff --git a/lib/chef/knife/data_bag_edit.rb b/knife/lib/chef/knife/data_bag_edit.rb
index 1935f2149e..92bff8d7f7 100644
--- a/lib/chef/knife/data_bag_edit.rb
+++ b/knife/lib/chef/knife/data_bag_edit.rb
@@ -26,8 +26,8 @@ class Chef
include DataBagSecretOptions
deps do
- require_relative "../data_bag_item"
- require_relative "../encrypted_data_bag_item"
+ require "chef/data_bag_item" unless defined?(Chef::DataBagItem)
+ require "chef/encrypted_data_bag_item" unless defined?(Chef::EncryptedDataBagItem)
end
banner "knife data bag edit BAG ITEM (options)"
diff --git a/lib/chef/knife/data_bag_from_file.rb b/knife/lib/chef/knife/data_bag_from_file.rb
index 5f48b0a934..6c889e1927 100644
--- a/lib/chef/knife/data_bag_from_file.rb
+++ b/knife/lib/chef/knife/data_bag_from_file.rb
@@ -26,11 +26,11 @@ class Chef
include DataBagSecretOptions
deps do
- require_relative "../util/path_helper"
- require_relative "../data_bag"
- require_relative "../data_bag_item"
+ require "chef-config/path_helper" unless defined?(ChefConfig::PathHelper)
+ require "chef/data_bag" unless defined?(Chef::DataBag)
+ require "chef/data_bag_item" unless defined?(Chef::DataBagItem)
+ require "chef/encrypted_data_bag_item" unless defined?(Chef::EncryptedDataBagItem)
require_relative "core/object_loader"
- require_relative "../encrypted_data_bag_item"
end
banner "knife data bag from file BAG FILE|FOLDER [FILE|FOLDER..] (options)"
@@ -42,7 +42,7 @@ class Chef
description: "Upload all data bags or all items for specified data bags."
def loader
- @loader ||= Knife::Core::ObjectLoader.new(DataBagItem, ui)
+ @loader ||= Knife::Core::ObjectLoader.new(Chef::DataBagItem, ui)
end
def run
@@ -101,7 +101,7 @@ class Chef
paths = []
args.each do |path|
if File.directory?(path)
- paths.concat(Dir.glob(File.join(Chef::Util::PathHelper.escape_glob_dir(path), "*.json")))
+ paths.concat(Dir.glob(File.join(ChefConfig::PathHelper.escape_glob_dir(path), "*.json")))
else
paths << path
end
diff --git a/lib/chef/knife/data_bag_list.rb b/knife/lib/chef/knife/data_bag_list.rb
index 801bf588b4..8a8e7ba89d 100644
--- a/lib/chef/knife/data_bag_list.rb
+++ b/knife/lib/chef/knife/data_bag_list.rb
@@ -23,7 +23,7 @@ class Chef
class DataBagList < Knife
deps do
- require_relative "../data_bag"
+ require "chef/data_bag" unless defined?(Chef::DataBag)
end
banner "knife data bag list (options)"
diff --git a/lib/chef/knife/data_bag_secret_options.rb b/knife/lib/chef/knife/data_bag_secret_options.rb
index 8f9f96502f..4d8ba90929 100644
--- a/lib/chef/knife/data_bag_secret_options.rb
+++ b/knife/lib/chef/knife/data_bag_secret_options.rb
@@ -17,8 +17,8 @@
#
require "mixlib/cli" unless defined?(Mixlib::CLI)
-require_relative "../config"
-require_relative "../encrypted_data_bag_item/check_encrypted"
+require "chef/config" unless defined?(Chef::Config)
+require "encrypted_data_bag_item/check_encrypted" unless defined?(Chef::EncryptedDataBagItem::CheckEncrypted)
class Chef
class Knife
@@ -60,7 +60,7 @@ class Chef
def read_secret
# Moving the non 'compile-time' requires into here to speed up knife command loading
# IE, if we are not running 'knife data bag *' we don't need to load 'chef/encrypted_data_bag_item'
- require_relative "../encrypted_data_bag_item"
+ require "chef/encrypted_data_bag_item" unless defined?(Chef::EncryptedDataBagItem)
if config[:cl_secret]
config[:cl_secret]
diff --git a/lib/chef/knife/data_bag_show.rb b/knife/lib/chef/knife/data_bag_show.rb
index cb7b56c333..3270f45ee2 100644
--- a/lib/chef/knife/data_bag_show.rb
+++ b/knife/lib/chef/knife/data_bag_show.rb
@@ -26,8 +26,8 @@ class Chef
include DataBagSecretOptions
deps do
- require_relative "../data_bag"
- require_relative "../encrypted_data_bag_item"
+ require "chef/data_bag" unless defined?(Chef::DataBag)
+ require "chef/encrypted_data_bag_item" unless defined?(Chef::EncryptedDataBagItem)
end
banner "knife data bag show BAG [ITEM] (options)"
diff --git a/lib/chef/knife/delete.rb b/knife/lib/chef/knife/delete.rb
index 3e5c545017..2853efc21c 100644
--- a/lib/chef/knife/delete.rb
+++ b/knife/lib/chef/knife/delete.rb
@@ -24,7 +24,7 @@ class Chef
category "path-based"
deps do
- require_relative "../chef_fs/file_system"
+ require "chef/chef_fs/file_system" unless defined?(Chef::ChefFS::FileSystem)
end
option :recurse,
diff --git a/lib/chef/knife/deps.rb b/knife/lib/chef/knife/deps.rb
index f620b53bfa..fd419f15f9 100644
--- a/lib/chef/knife/deps.rb
+++ b/knife/lib/chef/knife/deps.rb
@@ -14,7 +14,7 @@
# limitations under the License.
#
-require_relative "../chef_fs/knife"
+require_relative "../chef_fs/knife" unless defined?(Chef::ChefFS::Knife)
class Chef
class Knife
@@ -24,8 +24,8 @@ class Chef
category "path-based"
deps do
- require_relative "../chef_fs/file_system"
- require_relative "../run_list"
+ require "chef/chef_fs/file_system" unless defined?(Chef::ChefFS::FileSystem)
+ require "chef/run_list" unless defined?(Chef::RunList)
end
option :recurse,
diff --git a/lib/chef/knife/diff.rb b/knife/lib/chef/knife/diff.rb
index 3e9336aacc..971f7aa7f4 100644
--- a/lib/chef/knife/diff.rb
+++ b/knife/lib/chef/knife/diff.rb
@@ -24,7 +24,7 @@ class Chef
category "path-based"
deps do
- require_relative "../chef_fs/command_line"
+ require "chef/chef_fs/command_line" unless defined?(Chef::ChefFS::CommandLine)
end
option :recurse,
diff --git a/lib/chef/knife/download.rb b/knife/lib/chef/knife/download.rb
index ab8c92a1c0..2eda642979 100644
--- a/lib/chef/knife/download.rb
+++ b/knife/lib/chef/knife/download.rb
@@ -24,7 +24,7 @@ class Chef
category "path-based"
deps do
- require_relative "../chef_fs/command_line"
+ require "chef/chef_fs/command_line" unless defined?(Chef::ChefFS::CommandLine)
end
option :recurse,
diff --git a/lib/chef/knife/edit.rb b/knife/lib/chef/knife/edit.rb
index caca201566..45702d168b 100644
--- a/lib/chef/knife/edit.rb
+++ b/knife/lib/chef/knife/edit.rb
@@ -24,8 +24,8 @@ class Chef
category "path-based"
deps do
- require_relative "../chef_fs/file_system"
- require_relative "../chef_fs/file_system/exceptions"
+ require "chef/chef_fs/file_system" unless defined?(Chef::ChefFS::FileSystem)
+ require "chef/chef_fs/file_system/exceptions" unless defined?(Chef::ChefFS::FileSystem::Exceptions)
end
option :local,
diff --git a/lib/chef/knife/environment_compare.rb b/knife/lib/chef/knife/environment_compare.rb
index 22abee59c8..532d1fc159 100644
--- a/lib/chef/knife/environment_compare.rb
+++ b/knife/lib/chef/knife/environment_compare.rb
@@ -23,7 +23,7 @@ class Chef
class EnvironmentCompare < Knife
deps do
- require_relative "../environment"
+ require "chef/environment" unless defined?(Chef::Environment)
end
banner "knife environment compare [ENVIRONMENT..] (options)"
diff --git a/lib/chef/knife/environment_create.rb b/knife/lib/chef/knife/environment_create.rb
index a724f72d4f..cfb36957d4 100644
--- a/lib/chef/knife/environment_create.rb
+++ b/knife/lib/chef/knife/environment_create.rb
@@ -23,7 +23,7 @@ class Chef
class EnvironmentCreate < Knife
deps do
- require_relative "../environment"
+ require "chef/environment" unless defined?(Chef::Environment)
end
banner "knife environment create ENVIRONMENT (options)"
diff --git a/lib/chef/knife/environment_delete.rb b/knife/lib/chef/knife/environment_delete.rb
index ec1b7cb8d8..65e5a1eb5c 100644
--- a/lib/chef/knife/environment_delete.rb
+++ b/knife/lib/chef/knife/environment_delete.rb
@@ -23,7 +23,7 @@ class Chef
class EnvironmentDelete < Knife
deps do
- require_relative "../environment"
+ require "chef/environment" unless defined?(Chef::Environment)
end
banner "knife environment delete ENVIRONMENT (options)"
diff --git a/lib/chef/knife/environment_edit.rb b/knife/lib/chef/knife/environment_edit.rb
index 7c6105a6c0..f2ad842069 100644
--- a/lib/chef/knife/environment_edit.rb
+++ b/knife/lib/chef/knife/environment_edit.rb
@@ -23,7 +23,7 @@ class Chef
class EnvironmentEdit < Knife
deps do
- require_relative "../environment"
+ require "chef/environment" unless defined?(Chef::Environment)
end
banner "knife environment edit ENVIRONMENT (options)"
diff --git a/lib/chef/knife/environment_from_file.rb b/knife/lib/chef/knife/environment_from_file.rb
index a5011a3abf..4b84abd073 100644
--- a/lib/chef/knife/environment_from_file.rb
+++ b/knife/lib/chef/knife/environment_from_file.rb
@@ -23,7 +23,7 @@ class Chef
class EnvironmentFromFile < Knife
deps do
- require_relative "../environment"
+ require "chef/environment" unless defined?(Chef::Environment)
require_relative "core/object_loader"
end
diff --git a/lib/chef/knife/environment_list.rb b/knife/lib/chef/knife/environment_list.rb
index 7bcdeb6084..7076670fb5 100644
--- a/lib/chef/knife/environment_list.rb
+++ b/knife/lib/chef/knife/environment_list.rb
@@ -23,7 +23,7 @@ class Chef
class EnvironmentList < Knife
deps do
- require_relative "../environment"
+ require "chef/environment" unless defined?(Chef::Environment)
end
banner "knife environment list (options)"
diff --git a/lib/chef/knife/environment_show.rb b/knife/lib/chef/knife/environment_show.rb
index e336b2d392..0a4000151e 100644
--- a/lib/chef/knife/environment_show.rb
+++ b/knife/lib/chef/knife/environment_show.rb
@@ -25,7 +25,7 @@ class Chef
include Knife::Core::MultiAttributeReturnOption
deps do
- require_relative "../environment"
+ require "chef/environment" unless defined?(Chef::Environment)
end
banner "knife environment show ENVIRONMENT (options)"
diff --git a/lib/chef/knife/exec.rb b/knife/lib/chef/knife/exec.rb
index d3ce2cee24..b82476220e 100644
--- a/lib/chef/knife/exec.rb
+++ b/knife/lib/chef/knife/exec.rb
@@ -24,7 +24,7 @@ class Chef::Knife::Exec < Chef::Knife
banner "knife exec [SCRIPT] (options)"
deps do
- require_relative "../util/path_helper"
+ require "chef-config/path_helper" unless defined?(ChefConfig::PathHelper)
end
option :exec,
@@ -39,7 +39,7 @@ class Chef::Knife::Exec < Chef::Knife
proc: lambda { |o| o.split(":") }
deps do
- require_relative "../shell/ext"
+ require "chef/shell/ext" unless defined?(Chef::Shell::Extensions)
end
def run
@@ -47,7 +47,7 @@ class Chef::Knife::Exec < Chef::Knife
# Default script paths are chef-repo/.chef/scripts and ~/.chef/scripts
config[:script_path] << File.join(Chef::Knife.chef_config_dir, "scripts") if Chef::Knife.chef_config_dir
- Chef::Util::PathHelper.home(".chef", "scripts") { |p| config[:script_path] << p }
+ ChefConfig::PathHelper.home(".chef", "scripts") { |p| config[:script_path] << p }
scripts = Array(name_args)
context = Object.new
diff --git a/lib/chef/knife/group_add.rb b/knife/lib/chef/knife/group_add.rb
index eccb7dd10c..eccb7dd10c 100644
--- a/lib/chef/knife/group_add.rb
+++ b/knife/lib/chef/knife/group_add.rb
diff --git a/lib/chef/knife/group_create.rb b/knife/lib/chef/knife/group_create.rb
index 4219188951..4219188951 100644
--- a/lib/chef/knife/group_create.rb
+++ b/knife/lib/chef/knife/group_create.rb
diff --git a/lib/chef/knife/group_destroy.rb b/knife/lib/chef/knife/group_destroy.rb
index 433a5cc627..433a5cc627 100644
--- a/lib/chef/knife/group_destroy.rb
+++ b/knife/lib/chef/knife/group_destroy.rb
diff --git a/lib/chef/knife/group_list.rb b/knife/lib/chef/knife/group_list.rb
index fc8f00ad6d..fc8f00ad6d 100644
--- a/lib/chef/knife/group_list.rb
+++ b/knife/lib/chef/knife/group_list.rb
diff --git a/lib/chef/knife/group_remove.rb b/knife/lib/chef/knife/group_remove.rb
index 07ab19693f..07ab19693f 100644
--- a/lib/chef/knife/group_remove.rb
+++ b/knife/lib/chef/knife/group_remove.rb
diff --git a/lib/chef/knife/group_show.rb b/knife/lib/chef/knife/group_show.rb
index 6ac53f6b6e..6ac53f6b6e 100644
--- a/lib/chef/knife/group_show.rb
+++ b/knife/lib/chef/knife/group_show.rb
diff --git a/lib/chef/knife/key_create.rb b/knife/lib/chef/knife/key_create.rb
index 6129cab683..e1baf08bb6 100644
--- a/lib/chef/knife/key_create.rb
+++ b/knife/lib/chef/knife/key_create.rb
@@ -16,9 +16,9 @@
# limitations under the License.
#
-require_relative "../key"
-require_relative "../json_compat"
-require_relative "../exceptions"
+require "chef/key" unless defined?(Chef::Key)
+require "chef/json_compat" unless defined?(Chef::JSONCompat)
+require "chef/exceptions" unless defined?(Chef::Exceptions)
class Chef
class Knife
diff --git a/lib/chef/knife/key_create_base.rb b/knife/lib/chef/knife/key_create_base.rb
index a1d658e43c..a1d658e43c 100644
--- a/lib/chef/knife/key_create_base.rb
+++ b/knife/lib/chef/knife/key_create_base.rb
diff --git a/lib/chef/knife/key_delete.rb b/knife/lib/chef/knife/key_delete.rb
index 10f1235924..83b6a8b535 100644
--- a/lib/chef/knife/key_delete.rb
+++ b/knife/lib/chef/knife/key_delete.rb
@@ -16,7 +16,7 @@
# limitations under the License.
#
-require_relative "../key"
+require "chef/key" unless defined?(Chef::Key)
class Chef
class Knife
diff --git a/lib/chef/knife/key_edit.rb b/knife/lib/chef/knife/key_edit.rb
index 3f8918f1a9..25d7b28437 100644
--- a/lib/chef/knife/key_edit.rb
+++ b/knife/lib/chef/knife/key_edit.rb
@@ -16,9 +16,9 @@
# limitations under the License.
#
-require_relative "../key"
-require_relative "../json_compat"
-require_relative "../exceptions"
+require "chef/key" unless defined?(Chef::Key)
+require "chef/json_compat" unless defined?(Chef::JSONCompat)
+require "chef/exceptions" unless defined?(Chef::Exceptions)
class Chef
class Knife
diff --git a/lib/chef/knife/key_edit_base.rb b/knife/lib/chef/knife/key_edit_base.rb
index b094877190..b094877190 100644
--- a/lib/chef/knife/key_edit_base.rb
+++ b/knife/lib/chef/knife/key_edit_base.rb
diff --git a/lib/chef/knife/key_list.rb b/knife/lib/chef/knife/key_list.rb
index 076b39d251..e01e2807cf 100644
--- a/lib/chef/knife/key_list.rb
+++ b/knife/lib/chef/knife/key_list.rb
@@ -16,9 +16,9 @@
# limitations under the License.
#
-require_relative "../key"
-require_relative "../json_compat"
-require_relative "../exceptions"
+require "chef/key" unless defined?(Chef::Key)
+require "chef/json_compat" unless defined?(Chef::JSONCompat)
+require "chef/exceptions" unless defined?(Chef::Exceptions)
class Chef
class Knife
diff --git a/lib/chef/knife/key_list_base.rb b/knife/lib/chef/knife/key_list_base.rb
index e06e908b69..e06e908b69 100644
--- a/lib/chef/knife/key_list_base.rb
+++ b/knife/lib/chef/knife/key_list_base.rb
diff --git a/lib/chef/knife/key_show.rb b/knife/lib/chef/knife/key_show.rb
index 8b3d980004..719e79fc17 100644
--- a/lib/chef/knife/key_show.rb
+++ b/knife/lib/chef/knife/key_show.rb
@@ -16,9 +16,9 @@
# limitations under the License.
#
-require_relative "../key"
-require_relative "../json_compat"
-require_relative "../exceptions"
+require "chef/key" unless defined?(Chef::Key)
+require "chef/json_compat" unless defined?(Chef::JSONCompat)
+require "chef/exceptions" unless defined?(Chef::Exceptions)
class Chef
class Knife
diff --git a/lib/chef/knife/list.rb b/knife/lib/chef/knife/list.rb
index 1cc398e01a..7fc2231c5f 100644
--- a/lib/chef/knife/list.rb
+++ b/knife/lib/chef/knife/list.rb
@@ -24,7 +24,7 @@ class Chef
category "path-based"
deps do
- require_relative "../chef_fs/file_system"
+ require "chef/chef_fs/file_system" unless defined?(Chef::ChefFS::FileSystem)
require "tty-screen"
end
diff --git a/lib/chef/knife/node_bulk_delete.rb b/knife/lib/chef/knife/node_bulk_delete.rb
index 874509b730..73975eebc7 100644
--- a/lib/chef/knife/node_bulk_delete.rb
+++ b/knife/lib/chef/knife/node_bulk_delete.rb
@@ -23,8 +23,8 @@ class Chef
class NodeBulkDelete < Knife
deps do
- require_relative "../node"
- require_relative "../json_compat"
+ require "chef/node" unless defined?(Chef::Node)
+ require "chef/json_compat" unless defined?(Chef::JSONCompat)
end
banner "knife node bulk delete REGEX (options)"
diff --git a/lib/chef/knife/node_create.rb b/knife/lib/chef/knife/node_create.rb
index c0db667b25..ed82cbe7aa 100644
--- a/lib/chef/knife/node_create.rb
+++ b/knife/lib/chef/knife/node_create.rb
@@ -23,8 +23,8 @@ class Chef
class NodeCreate < Knife
deps do
- require_relative "../node"
- require_relative "../json_compat"
+ require "chef/node" unless defined?(Chef::Node)
+ require "chef/json_compat" unless defined?(Chef::JSONCompat)
end
banner "knife node create NODE (options)"
diff --git a/lib/chef/knife/node_delete.rb b/knife/lib/chef/knife/node_delete.rb
index 7c0c6f0a21..605d99b57f 100644
--- a/lib/chef/knife/node_delete.rb
+++ b/knife/lib/chef/knife/node_delete.rb
@@ -23,8 +23,8 @@ class Chef
class NodeDelete < Knife
deps do
- require_relative "../node"
- require_relative "../json_compat"
+ require "chef/node" unless defined?(Chef::Node)
+ require "chef/json_compat" unless defined?(Chef::JSONCompat)
end
banner "knife node delete [NODE [NODE]] (options)"
diff --git a/lib/chef/knife/node_edit.rb b/knife/lib/chef/knife/node_edit.rb
index a2585391ea..ebc98f5bff 100644
--- a/lib/chef/knife/node_edit.rb
+++ b/knife/lib/chef/knife/node_edit.rb
@@ -24,8 +24,8 @@ class Chef
class NodeEdit < Knife
deps do
- require_relative "../node"
- require_relative "../json_compat"
+ require "chef/node" unless defined?(Chef::Node)
+ require "chef/json_compat" unless defined?(Chef::JSONCompat)
require_relative "core/node_editor"
end
diff --git a/lib/chef/knife/node_environment_set.rb b/knife/lib/chef/knife/node_environment_set.rb
index 644b6138b6..84d5b3969b 100644
--- a/lib/chef/knife/node_environment_set.rb
+++ b/knife/lib/chef/knife/node_environment_set.rb
@@ -23,7 +23,7 @@ class Chef
class NodeEnvironmentSet < Knife
deps do
- require_relative "../node"
+ require "chef/node" unless defined?(Chef::Node)
end
banner "knife node environment set NODE ENVIRONMENT"
diff --git a/lib/chef/knife/node_from_file.rb b/knife/lib/chef/knife/node_from_file.rb
index 86d602ae7c..4f1935641a 100644
--- a/lib/chef/knife/node_from_file.rb
+++ b/knife/lib/chef/knife/node_from_file.rb
@@ -23,8 +23,8 @@ class Chef
class NodeFromFile < Knife
deps do
- require_relative "../node"
- require_relative "../json_compat"
+ require "chef/node" unless defined?(Chef::Node)
+ require "chef/json_compat" unless defined?(Chef::JSONCompat)
require_relative "core/object_loader"
end
diff --git a/lib/chef/knife/node_list.rb b/knife/lib/chef/knife/node_list.rb
index a8b57aedc5..6aae4a617d 100644
--- a/lib/chef/knife/node_list.rb
+++ b/knife/lib/chef/knife/node_list.rb
@@ -23,8 +23,8 @@ class Chef
class NodeList < Knife
deps do
- require_relative "../node"
- require_relative "../json_compat"
+ require "chef/node" unless defined?(Chef::Node)
+ require "chef/json_compat" unless defined?(Chef::JSONCompat)
end
banner "knife node list (options)"
diff --git a/lib/chef/knife/node_policy_set.rb b/knife/lib/chef/knife/node_policy_set.rb
index d34ebd9478..3f55529b3d 100644
--- a/lib/chef/knife/node_policy_set.rb
+++ b/knife/lib/chef/knife/node_policy_set.rb
@@ -23,8 +23,8 @@ class Chef
class NodePolicySet < Knife
deps do
- require_relative "../node"
- require_relative "../json_compat"
+ require "chef/node" unless defined?(Chef::Node)
+ require "chef/json_compat" unless defined?(Chef::JSONCompat)
end
banner "knife node policy set NODE POLICY_GROUP POLICY_NAME (options)"
diff --git a/lib/chef/knife/node_run_list_add.rb b/knife/lib/chef/knife/node_run_list_add.rb
index 40476371eb..695344496a 100644
--- a/lib/chef/knife/node_run_list_add.rb
+++ b/knife/lib/chef/knife/node_run_list_add.rb
@@ -23,8 +23,8 @@ class Chef
class NodeRunListAdd < Knife
deps do
- require_relative "../node"
- require_relative "../json_compat"
+ require "chef/node" unless defined?(Chef::Node)
+ require "chef/json_compat" unless defined?(Chef::JSONCompat)
end
banner "knife node run_list add [NODE] [ENTRY [ENTRY]] (options)"
diff --git a/lib/chef/knife/node_run_list_remove.rb b/knife/lib/chef/knife/node_run_list_remove.rb
index 484e575475..0c88f8c184 100644
--- a/lib/chef/knife/node_run_list_remove.rb
+++ b/knife/lib/chef/knife/node_run_list_remove.rb
@@ -23,8 +23,8 @@ class Chef
class NodeRunListRemove < Knife
deps do
- require_relative "../node"
- require_relative "../json_compat"
+ require "chef/node" unless defined?(Chef::Node)
+ require "chef/json_compat" unless defined?(Chef::JSONCompat)
end
banner "knife node run_list remove [NODE] [ENTRY [ENTRY]] (options)"
diff --git a/lib/chef/knife/node_run_list_set.rb b/knife/lib/chef/knife/node_run_list_set.rb
index f356b39d95..37b9aef3d6 100644
--- a/lib/chef/knife/node_run_list_set.rb
+++ b/knife/lib/chef/knife/node_run_list_set.rb
@@ -23,8 +23,8 @@ class Chef
class NodeRunListSet < Knife
deps do
- require_relative "../node"
- require_relative "../json_compat"
+ require "chef/node" unless defined?(Chef::Node)
+ require "chef/json_compat" unless defined?(Chef::JSONCompat)
end
banner "knife node run_list set NODE ENTRIES (options)"
diff --git a/lib/chef/knife/node_show.rb b/knife/lib/chef/knife/node_show.rb
index 173348dc41..bce2ee3fe9 100644
--- a/lib/chef/knife/node_show.rb
+++ b/knife/lib/chef/knife/node_show.rb
@@ -29,8 +29,8 @@ class Chef
include Knife::Core::MultiAttributeReturnOption
deps do
- require_relative "../node"
- require_relative "../json_compat"
+ require "chef/node" unless defined?(Chef::Node)
+ require "chef/json_compat" unless defined?(Chef::JSONCompat)
end
banner "knife node show NODE (options)"
diff --git a/lib/chef/knife/null.rb b/knife/lib/chef/knife/null.rb
index 7221eee9f5..7221eee9f5 100644
--- a/lib/chef/knife/null.rb
+++ b/knife/lib/chef/knife/null.rb
diff --git a/lib/chef/knife/org_create.rb b/knife/lib/chef/knife/org_create.rb
index 3c1354ae22..cb5ded26f5 100644
--- a/lib/chef/knife/org_create.rb
+++ b/knife/lib/chef/knife/org_create.rb
@@ -35,7 +35,7 @@ class Chef
attr_accessor :org_name, :org_full_name
deps do
- require_relative "../org"
+ require "chef/org" unless defined?(Chef::Org)
end
def run
diff --git a/lib/chef/knife/org_delete.rb b/knife/lib/chef/knife/org_delete.rb
index 340f6c529a..340f6c529a 100644
--- a/lib/chef/knife/org_delete.rb
+++ b/knife/lib/chef/knife/org_delete.rb
diff --git a/lib/chef/knife/org_edit.rb b/knife/lib/chef/knife/org_edit.rb
index 1d684ca0b4..1d684ca0b4 100644
--- a/lib/chef/knife/org_edit.rb
+++ b/knife/lib/chef/knife/org_edit.rb
diff --git a/lib/chef/knife/org_list.rb b/knife/lib/chef/knife/org_list.rb
index 85a49ee4c5..85a49ee4c5 100644
--- a/lib/chef/knife/org_list.rb
+++ b/knife/lib/chef/knife/org_list.rb
diff --git a/lib/chef/knife/org_show.rb b/knife/lib/chef/knife/org_show.rb
index a8bb207c1d..a8bb207c1d 100644
--- a/lib/chef/knife/org_show.rb
+++ b/knife/lib/chef/knife/org_show.rb
diff --git a/lib/chef/knife/org_user_add.rb b/knife/lib/chef/knife/org_user_add.rb
index cd0ea88d56..cd0ea88d56 100644
--- a/lib/chef/knife/org_user_add.rb
+++ b/knife/lib/chef/knife/org_user_add.rb
diff --git a/lib/chef/knife/org_user_remove.rb b/knife/lib/chef/knife/org_user_remove.rb
index 50a1471443..fc78f5767c 100644
--- a/lib/chef/knife/org_user_remove.rb
+++ b/knife/lib/chef/knife/org_user_remove.rb
@@ -29,8 +29,8 @@ class Chef
description: "Force removal of user from the organization's admins and billing-admins group."
deps do
- require_relative "../org"
- require "chef/json_compat"
+ require "chef/org" unless defined?(Chef::Org)
+ require "chef/json_compat" unless defined?(Chef::JSONCompat)
end
def run
diff --git a/lib/chef/knife/raw.rb b/knife/lib/chef/knife/raw.rb
index 5adb36ea70..344de9effb 100644
--- a/lib/chef/knife/raw.rb
+++ b/knife/lib/chef/knife/raw.rb
@@ -22,13 +22,13 @@ class Chef
banner "knife raw REQUEST_PATH (options)"
deps do
- require_relative "../json_compat"
- require_relative "../config"
- require_relative "../http"
- require_relative "../http/authenticator"
- require_relative "../http/cookie_manager"
- require_relative "../http/decompressor"
- require_relative "../http/json_output"
+ require "chef/json_compat" unless defined?(Chef::JSONCompat)
+ require "chef/config" unless defined?(Chef::Config)
+ require "chef/http" unless defined?(Chef::HTTP)
+ require "chef/http/authenticator" unless defined?(Chef::HTTP::Authenticator)
+ require "chef/http/cookie_manager" unless defined?(Chef::HTTP::CookieManager)
+ require "chef/http/decompressor" unless defined?(Chef::HTTP::Decompressor)
+ require "chef/http/json_output" unless defined?(Chef::HTTP::JSONOutput)
end
option :method,
diff --git a/lib/chef/knife/recipe_list.rb b/knife/lib/chef/knife/recipe_list.rb
index 39e040a2f4..39e040a2f4 100644
--- a/lib/chef/knife/recipe_list.rb
+++ b/knife/lib/chef/knife/recipe_list.rb
diff --git a/lib/chef/knife/rehash.rb b/knife/lib/chef/knife/rehash.rb
index 69ee19229a..69ee19229a 100644
--- a/lib/chef/knife/rehash.rb
+++ b/knife/lib/chef/knife/rehash.rb
diff --git a/lib/chef/knife/role_bulk_delete.rb b/knife/lib/chef/knife/role_bulk_delete.rb
index f57ac79619..88399bae2c 100644
--- a/lib/chef/knife/role_bulk_delete.rb
+++ b/knife/lib/chef/knife/role_bulk_delete.rb
@@ -23,8 +23,8 @@ class Chef
class RoleBulkDelete < Knife
deps do
- require_relative "../role"
- require_relative "../json_compat"
+ require "chef/role" unless defined?(Chef::Role)
+ require "chef/json_compat" unless defined?(Chef::JSONCompat)
end
banner "knife role bulk delete REGEX (options)"
diff --git a/lib/chef/knife/role_create.rb b/knife/lib/chef/knife/role_create.rb
index 295445554d..91ff958fe4 100644
--- a/lib/chef/knife/role_create.rb
+++ b/knife/lib/chef/knife/role_create.rb
@@ -23,8 +23,8 @@ class Chef
class RoleCreate < Knife
deps do
- require_relative "../role"
- require_relative "../json_compat"
+ require "chef/role" unless defined?(Chef::Role)
+ require "chef/json_compat" unless defined?(Chef::JSONCompat)
end
banner "knife role create ROLE (options)"
diff --git a/lib/chef/knife/role_delete.rb b/knife/lib/chef/knife/role_delete.rb
index c46e265c5e..91ac7d3172 100644
--- a/lib/chef/knife/role_delete.rb
+++ b/knife/lib/chef/knife/role_delete.rb
@@ -23,8 +23,8 @@ class Chef
class RoleDelete < Knife
deps do
- require_relative "../role"
- require_relative "../json_compat"
+ require "chef/role" unless defined?(Chef::Role)
+ require "chef/json_compat" unless defined?(Chef::JSONCompat)
end
banner "knife role delete ROLE (options)"
diff --git a/lib/chef/knife/role_edit.rb b/knife/lib/chef/knife/role_edit.rb
index 1925336646..a1818019cb 100644
--- a/lib/chef/knife/role_edit.rb
+++ b/knife/lib/chef/knife/role_edit.rb
@@ -23,8 +23,8 @@ class Chef
class RoleEdit < Knife
deps do
- require_relative "../role"
- require_relative "../json_compat"
+ require "chef/role" unless defined?(Chef::Role)
+ require "chef/json_compat" unless defined?(Chef::JSONCompat)
end
banner "knife role edit ROLE (options)"
diff --git a/lib/chef/knife/role_env_run_list_add.rb b/knife/lib/chef/knife/role_env_run_list_add.rb
index b5753b46fc..a39bdcf5cd 100644
--- a/lib/chef/knife/role_env_run_list_add.rb
+++ b/knife/lib/chef/knife/role_env_run_list_add.rb
@@ -24,8 +24,8 @@ class Chef
class RoleEnvRunListAdd < Knife
deps do
- require_relative "../role"
- require_relative "../json_compat"
+ require "chef/role" unless defined?(Chef::Role)
+ require "chef/json_compat" unless defined?(Chef::JSONCompat)
end
banner "knife role env_run_list add [ROLE] [ENVIRONMENT] [ENTRY [ENTRY]] (options)"
diff --git a/lib/chef/knife/role_env_run_list_clear.rb b/knife/lib/chef/knife/role_env_run_list_clear.rb
index dda523e809..bb0eeabc16 100644
--- a/lib/chef/knife/role_env_run_list_clear.rb
+++ b/knife/lib/chef/knife/role_env_run_list_clear.rb
@@ -24,8 +24,8 @@ class Chef
class RoleEnvRunListClear < Knife
deps do
- require_relative "../role"
- require_relative "../json_compat"
+ require "chef/role" unless defined?(Chef::Role)
+ require "chef/json_compat" unless defined?(Chef::JSONCompat)
end
banner "knife role env_run_list clear [ROLE] [ENVIRONMENT] (options)"
diff --git a/lib/chef/knife/role_env_run_list_remove.rb b/knife/lib/chef/knife/role_env_run_list_remove.rb
index 57363610ce..c1a028340b 100644
--- a/lib/chef/knife/role_env_run_list_remove.rb
+++ b/knife/lib/chef/knife/role_env_run_list_remove.rb
@@ -23,8 +23,8 @@ class Chef
class RoleEnvRunListRemove < Knife
deps do
- require_relative "../role"
- require_relative "../json_compat"
+ require "chef/role" unless defined?(Chef::Role)
+ require "chef/json_compat" unless defined?(Chef::JSONCompat)
end
banner "knife role env_run_list remove [ROLE] [ENVIRONMENT] [ENTRIES] (options)"
diff --git a/lib/chef/knife/role_env_run_list_replace.rb b/knife/lib/chef/knife/role_env_run_list_replace.rb
index e76680661e..923a31331f 100644
--- a/lib/chef/knife/role_env_run_list_replace.rb
+++ b/knife/lib/chef/knife/role_env_run_list_replace.rb
@@ -24,8 +24,8 @@ class Chef
class RoleEnvRunListReplace < Knife
deps do
- require_relative "../role"
- require_relative "../json_compat"
+ require "chef/role" unless defined?(Chef::Role)
+ require "chef/json_compat" unless defined?(Chef::JSONCompat)
end
banner "knife role env_run_list replace [ROLE] [ENVIRONMENT] [OLD_ENTRY] [NEW_ENTRY] (options)"
diff --git a/lib/chef/knife/role_env_run_list_set.rb b/knife/lib/chef/knife/role_env_run_list_set.rb
index 0f1ce62a5d..55a50c6c0d 100644
--- a/lib/chef/knife/role_env_run_list_set.rb
+++ b/knife/lib/chef/knife/role_env_run_list_set.rb
@@ -24,8 +24,8 @@ class Chef
class RoleEnvRunListSet < Knife
deps do
- require_relative "../role"
- require_relative "../json_compat"
+ require "chef/role" unless defined?(Chef::Role)
+ require "chef/json_compat" unless defined?(Chef::JSONCompat)
end
banner "knife role env_run_list set [ROLE] [ENVIRONMENT] [ENTRIES] (options)"
diff --git a/lib/chef/knife/role_from_file.rb b/knife/lib/chef/knife/role_from_file.rb
index 16e38eeb63..7b51d8706d 100644
--- a/lib/chef/knife/role_from_file.rb
+++ b/knife/lib/chef/knife/role_from_file.rb
@@ -23,9 +23,9 @@ class Chef
class RoleFromFile < Knife
deps do
- require_relative "../role"
+ require "chef/role" unless defined?(Chef::Role)
require_relative "core/object_loader"
- require_relative "../json_compat"
+ require "chef/json_compat" unless defined?(Chef::JSONCompat)
end
banner "knife role from file FILE [FILE..] (options)"
diff --git a/lib/chef/knife/role_list.rb b/knife/lib/chef/knife/role_list.rb
index d6aad053c1..723d956b91 100644
--- a/lib/chef/knife/role_list.rb
+++ b/knife/lib/chef/knife/role_list.rb
@@ -23,8 +23,8 @@ class Chef
class RoleList < Knife
deps do
- require_relative "../node"
- require_relative "../json_compat"
+ require "chef/node" unless defined?(Chef::Node)
+ require "chef/json_compat" unless defined?(Chef::JSONCompat)
end
banner "knife role list (options)"
diff --git a/lib/chef/knife/role_run_list_add.rb b/knife/lib/chef/knife/role_run_list_add.rb
index 76633ff5f6..4276b9ab2d 100644
--- a/lib/chef/knife/role_run_list_add.rb
+++ b/knife/lib/chef/knife/role_run_list_add.rb
@@ -24,8 +24,8 @@ class Chef
class RoleRunListAdd < Knife
deps do
- require_relative "../role"
- require_relative "../json_compat"
+ require "chef/role" unless defined?(Chef::Role)
+ require "chef/json_compat" unless defined?(Chef::JSONCompat)
end
banner "knife role run_list add [ROLE] [ENTRY [ENTRY]] (options)"
diff --git a/lib/chef/knife/role_run_list_clear.rb b/knife/lib/chef/knife/role_run_list_clear.rb
index b7106233f0..150dccd7ba 100644
--- a/lib/chef/knife/role_run_list_clear.rb
+++ b/knife/lib/chef/knife/role_run_list_clear.rb
@@ -24,8 +24,8 @@ class Chef
class RoleRunListClear < Knife
deps do
- require_relative "../role"
- require_relative "../json_compat"
+ require "chef/role" unless defined?(Chef::Role)
+ require "chef/json_compat" unless defined?(Chef::JSONCompat)
end
banner "knife role run_list clear [ROLE] (options)"
diff --git a/lib/chef/knife/role_run_list_remove.rb b/knife/lib/chef/knife/role_run_list_remove.rb
index 884f3bc28d..7a0f82c092 100644
--- a/lib/chef/knife/role_run_list_remove.rb
+++ b/knife/lib/chef/knife/role_run_list_remove.rb
@@ -23,7 +23,7 @@ class Chef
class RoleRunListRemove < Knife
deps do
- require_relative "../role"
+ require "chef/role" unless defined?(Chef::Role)
end
banner "knife role run_list remove [ROLE] [ENTRY] (options)"
diff --git a/lib/chef/knife/role_run_list_replace.rb b/knife/lib/chef/knife/role_run_list_replace.rb
index 16f789fbef..63c7b87199 100644
--- a/lib/chef/knife/role_run_list_replace.rb
+++ b/knife/lib/chef/knife/role_run_list_replace.rb
@@ -24,8 +24,8 @@ class Chef
class RoleRunListReplace < Knife
deps do
- require_relative "../role"
- require_relative "../json_compat"
+ require "chef/role" unless defined?(Chef::Role)
+ require "chef/json_compat" unless defined?(Chef::JSONCompat)
end
banner "knife role run_list replace [ROLE] [OLD_ENTRY] [NEW_ENTRY] (options)"
diff --git a/lib/chef/knife/role_run_list_set.rb b/knife/lib/chef/knife/role_run_list_set.rb
index ad1a5e2923..6cddc7376c 100644
--- a/lib/chef/knife/role_run_list_set.rb
+++ b/knife/lib/chef/knife/role_run_list_set.rb
@@ -24,7 +24,7 @@ class Chef
class RoleRunListSet < Knife
deps do
- require_relative "../role"
+ require "chef/role" unless defined?(Chef::Role)
end
banner "knife role run_list set [ROLE] [ENTRIES] (options)"
diff --git a/lib/chef/knife/role_show.rb b/knife/lib/chef/knife/role_show.rb
index ee90352e50..3a2df8b782 100644
--- a/lib/chef/knife/role_show.rb
+++ b/knife/lib/chef/knife/role_show.rb
@@ -25,7 +25,7 @@ class Chef
include Knife::Core::MultiAttributeReturnOption
deps do
- require_relative "../role"
+ require "chef/role" unless defined?(Chef::Role)
end
banner "knife role show ROLE (options)"
diff --git a/lib/chef/knife/search.rb b/knife/lib/chef/knife/search.rb
index 620cfb971d..306761f109 100644
--- a/lib/chef/knife/search.rb
+++ b/knife/lib/chef/knife/search.rb
@@ -27,10 +27,10 @@ class Chef
include Knife::Core::MultiAttributeReturnOption
deps do
- require_relative "../node"
- require_relative "../environment"
- require_relative "../api_client"
- require_relative "../search/query"
+ require "chef/node" unless defined?(Chef::Node)
+ require "chef/environment" unless defined?(Chef::Environment)
+ require "chef/api_client" unless defined?(Chef::APIClient)
+ require "chef/search/query" unless defined?(Chef::Search::Query)
end
include Knife::Core::FormattingOptions
diff --git a/lib/chef/knife/serve.rb b/knife/lib/chef/knife/serve.rb
index d79e05aa85..30e4a28f9a 100644
--- a/lib/chef/knife/serve.rb
+++ b/knife/lib/chef/knife/serve.rb
@@ -15,7 +15,7 @@
#
require_relative "../knife"
-require_relative "../local_mode"
+require "local_mode" unless defined?(Chef::LocalMode)
require "chef-utils/dist" unless defined?(ChefUtils::Dist)
class Chef
diff --git a/lib/chef/knife/show.rb b/knife/lib/chef/knife/show.rb
index 0e5ab9d0fe..cdee271c63 100644
--- a/lib/chef/knife/show.rb
+++ b/knife/lib/chef/knife/show.rb
@@ -24,8 +24,8 @@ class Chef
category "path-based"
deps do
- require_relative "../chef_fs/file_system"
- require_relative "../chef_fs/file_system/exceptions"
+ require "chef/chef_fs/file_system" unless defined?(Chef::ChefFS::FileSystem)
+ require "chef/chef_fs/file_system/exceptions" unless defined?(Chef::ChefFS::FileSystem::Exceptions)
end
option :local,
diff --git a/lib/chef/knife/ssh.rb b/knife/lib/chef/knife/ssh.rb
index 8681fdfd02..e69de62bc2 100644
--- a/lib/chef/knife/ssh.rb
+++ b/knife/lib/chef/knife/ssh.rb
@@ -23,13 +23,13 @@ class Chef
class Ssh < Knife
deps do
- require_relative "../mixin/shell_out"
+ require "chef/mixin/shell_out" unless defined?(Chef::Mixin::ShellOut)
require "net/ssh" unless defined?(Net::SSH)
require "net/ssh/multi"
require "readline"
- require_relative "../exceptions"
- require_relative "../search/query"
- require_relative "../util/path_helper"
+ require "chef/exceptions" unless defined?(Chef::Exceptions)
+ require "chef/search/query" unless defined?(Chef::Search::Query)
+ require "chef-config/path_helper" unless defined?(ChefConfig::PathHelper)
include Chef::Mixin::ShellOut
end
@@ -464,7 +464,7 @@ class Chef
def screen
tf = Tempfile.new("knife-ssh-screen")
- Chef::Util::PathHelper.home(".screenrc") do |screenrc_path|
+ ChefConfig::PathHelper.home(".screenrc") do |screenrc_path|
if File.exist? screenrc_path
tf.puts("source #{screenrc_path}")
end
diff --git a/lib/chef/knife/ssl_check.rb b/knife/lib/chef/knife/ssl_check.rb
index 0cc4141d42..c829e7938b 100644
--- a/lib/chef/knife/ssl_check.rb
+++ b/knife/lib/chef/knife/ssl_check.rb
@@ -24,13 +24,13 @@ class Chef
class SslCheck < Chef::Knife
deps do
- require_relative "../config"
+ require "chef/config" unless defined?(Chef::Config)
require "pp" unless defined?(PP)
require "socket" unless defined?(Socket)
require "uri" unless defined?(URI)
- require_relative "../http/ssl_policies"
+ require "chef/http/ssl_policies" unless defined?(Chef::HTTP::DefaultSSLPolicy)
require "openssl" unless defined?(OpenSSL)
- require_relative "../mixin/proxified_socket"
+ require "chef/mixin/proxified_socket" unless defined?(Chef::Mixin::ProxifiedSocket)
include Chef::Mixin::ProxifiedSocket
end
diff --git a/lib/chef/knife/ssl_fetch.rb b/knife/lib/chef/knife/ssl_fetch.rb
index cfbbc823b2..a005cebe80 100644
--- a/lib/chef/knife/ssl_fetch.rb
+++ b/knife/lib/chef/knife/ssl_fetch.rb
@@ -23,12 +23,13 @@ class Chef
class SslFetch < Chef::Knife
deps do
- require_relative "../config"
+ require "chef/config" unless defined?(Chef::Config)
require "pp" unless defined?(PP)
require "socket" unless defined?(Socket)
require "uri" unless defined?(URI)
require "openssl" unless defined?(OpenSSL)
- require_relative "../mixin/proxified_socket"
+ require "chef/mixin/mixin/proxified_socket" unless defined?(Chef::Mixin::ProxifiedSocket)
+
include Chef::Mixin::ProxifiedSocket
end
diff --git a/lib/chef/knife/status.rb b/knife/lib/chef/knife/status.rb
index 34692d6da7..2e72f0a03b 100644
--- a/lib/chef/knife/status.rb
+++ b/knife/lib/chef/knife/status.rb
@@ -27,7 +27,7 @@ class Chef
include Knife::Core::FormattingOptions
deps do
- require_relative "../search/query"
+ require "chef/search/query" unless defined?(Chef::Search::Query)
end
banner "knife status QUERY (options)"
diff --git a/lib/chef/knife/supermarket_download.rb b/knife/lib/chef/knife/supermarket_download.rb
index 5acd733b78..5acd733b78 100644
--- a/lib/chef/knife/supermarket_download.rb
+++ b/knife/lib/chef/knife/supermarket_download.rb
diff --git a/lib/chef/knife/supermarket_install.rb b/knife/lib/chef/knife/supermarket_install.rb
index a3d3aa7a5d..c979a4d6f4 100644
--- a/lib/chef/knife/supermarket_install.rb
+++ b/knife/lib/chef/knife/supermarket_install.rb
@@ -23,11 +23,11 @@ class Chef
class SupermarketInstall < Knife
deps do
- require_relative "../exceptions"
+ require "chef/exceptions" unless defined?(Chef::Exceptions)
require "shellwords" unless defined?(Shellwords)
require "mixlib/archive" unless defined?(Mixlib::Archive)
require_relative "core/cookbook_scm_repo"
- require_relative "../cookbook/metadata"
+ require "chef/cookbook/metadata" unless defined?(Chef::Cookbook::Metadata)
end
banner "knife supermarket install COOKBOOK [VERSION] (options)"
diff --git a/lib/chef/knife/supermarket_list.rb b/knife/lib/chef/knife/supermarket_list.rb
index 7dca8d031b..7dca8d031b 100644
--- a/lib/chef/knife/supermarket_list.rb
+++ b/knife/lib/chef/knife/supermarket_list.rb
diff --git a/lib/chef/knife/supermarket_search.rb b/knife/lib/chef/knife/supermarket_search.rb
index 57befaed35..57befaed35 100644
--- a/lib/chef/knife/supermarket_search.rb
+++ b/knife/lib/chef/knife/supermarket_search.rb
diff --git a/lib/chef/knife/supermarket_share.rb b/knife/lib/chef/knife/supermarket_share.rb
index 49b3474566..61fe3b583b 100644
--- a/lib/chef/knife/supermarket_share.rb
+++ b/knife/lib/chef/knife/supermarket_share.rb
@@ -25,10 +25,10 @@ class Chef
include Chef::Mixin::ShellOut
deps do
- require_relative "../cookbook_loader"
- require_relative "../cookbook_uploader"
- require_relative "../cookbook_site_streaming_uploader"
- require_relative "../mixin/shell_out"
+ require "chef/cookbook_loader" unless defined?(Chef::CookbookLoader)
+ require "chef/cookbook_uploader" unless defined?(Chef::CookbookUploader)
+ require "chef/knife/core/cookbook_site_streaming_uploader" unless defined?(Chef::Knife::Core::CookbookSiteStreamingUploader)
+ require "chef/mixin/shell_out" unless defined?(Chef::Mixin::ShellOut)
end
banner "knife supermarket share COOKBOOK [CATEGORY] (options)"
@@ -72,7 +72,7 @@ class Chef
if cl.cookbook_exists?(cookbook_name)
cookbook = cl[cookbook_name]
Chef::CookbookUploader.new(cookbook).validate_cookbooks
- tmp_cookbook_dir = Chef::CookbookSiteStreamingUploader.create_build_dir(cookbook)
+ tmp_cookbook_dir = Chef::Knife::Core::CookbookSiteStreamingUploader.create_build_dir(cookbook)
begin
Chef::Log.trace("Temp cookbook directory is #{tmp_cookbook_dir.inspect}")
ui.info("Making tarball #{cookbook_name}.tgz")
@@ -124,7 +124,7 @@ class Chef
category_string = Chef::JSONCompat.to_json({ "category" => cookbook_category })
- http_resp = Chef::CookbookSiteStreamingUploader.post(uri, user_id, user_secret_filename, {
+ http_resp = Chef::Knife::Core::CookbookSiteStreamingUploader.post(uri, user_id, user_secret_filename, {
tarball: File.open(cookbook_filename),
cookbook: category_string,
})
diff --git a/lib/chef/knife/supermarket_show.rb b/knife/lib/chef/knife/supermarket_show.rb
index 7237cf0bc7..7237cf0bc7 100644
--- a/lib/chef/knife/supermarket_show.rb
+++ b/knife/lib/chef/knife/supermarket_show.rb
diff --git a/lib/chef/knife/supermarket_unshare.rb b/knife/lib/chef/knife/supermarket_unshare.rb
index 686d95f47a..8c86769804 100644
--- a/lib/chef/knife/supermarket_unshare.rb
+++ b/knife/lib/chef/knife/supermarket_unshare.rb
@@ -23,7 +23,7 @@ class Chef
class SupermarketUnshare < Knife
deps do
- require_relative "../json_compat"
+ require "chef/json_compat" unless defined?(Chef::JSONCompat)
end
banner "knife supermarket unshare COOKBOOK"
diff --git a/lib/chef/knife/tag_create.rb b/knife/lib/chef/knife/tag_create.rb
index 2f0d302e74..ed7d37e7b8 100644
--- a/lib/chef/knife/tag_create.rb
+++ b/knife/lib/chef/knife/tag_create.rb
@@ -25,7 +25,7 @@ class Chef
class TagCreate < Knife
deps do
- require_relative "../node"
+ require "chef/node" unless defined?(Chef::Node)
end
banner "knife tag create NODE TAG ..."
diff --git a/lib/chef/knife/tag_delete.rb b/knife/lib/chef/knife/tag_delete.rb
index 85fa6a9e27..539ae39273 100644
--- a/lib/chef/knife/tag_delete.rb
+++ b/knife/lib/chef/knife/tag_delete.rb
@@ -25,7 +25,7 @@ class Chef
class TagDelete < Knife
deps do
- require_relative "../node"
+ require "chef/node" unless defined?(Chef::Node)
end
banner "knife tag delete NODE TAG ..."
diff --git a/lib/chef/knife/tag_list.rb b/knife/lib/chef/knife/tag_list.rb
index 8b91034609..3ab960c361 100644
--- a/lib/chef/knife/tag_list.rb
+++ b/knife/lib/chef/knife/tag_list.rb
@@ -25,7 +25,7 @@ class Chef
class TagList < Knife
deps do
- require_relative "../node"
+ require "chef/node" unless defined?(Chef::Node)
end
banner "knife tag list NODE"
diff --git a/lib/chef/knife/upload.rb b/knife/lib/chef/knife/upload.rb
index 190549d86a..e8dd052e77 100644
--- a/lib/chef/knife/upload.rb
+++ b/knife/lib/chef/knife/upload.rb
@@ -24,7 +24,7 @@ class Chef
category "path-based"
deps do
- require_relative "../chef_fs/command_line"
+ require "chef/chef_fs/command_line" unless defined?(Chef::ChefFS::CommandLine)
end
option :recurse,
diff --git a/lib/chef/knife/user_create.rb b/knife/lib/chef/knife/user_create.rb
index aa1d4d54f2..ae1f81628c 100644
--- a/lib/chef/knife/user_create.rb
+++ b/knife/lib/chef/knife/user_create.rb
@@ -26,7 +26,7 @@ class Chef
attr_accessor :user_field
deps do
- require_relative "../user_v1"
+ require "chef/user_v1" unless defined?(Chef::UserV1)
end
option :file,
diff --git a/lib/chef/knife/user_delete.rb b/knife/lib/chef/knife/user_delete.rb
index 64d729c951..c1ab78174b 100644
--- a/lib/chef/knife/user_delete.rb
+++ b/knife/lib/chef/knife/user_delete.rb
@@ -23,7 +23,7 @@ class Chef
class UserDelete < Knife
deps do
- require_relative "../org"
+ require "chef/org" unless defined? Chef::Org
end
banner "knife user delete USER (options)"
diff --git a/lib/chef/knife/user_dissociate.rb b/knife/lib/chef/knife/user_dissociate.rb
index 6af1559608..6af1559608 100644
--- a/lib/chef/knife/user_dissociate.rb
+++ b/knife/lib/chef/knife/user_dissociate.rb
diff --git a/lib/chef/knife/user_edit.rb b/knife/lib/chef/knife/user_edit.rb
index fff8c6b70f..fff8c6b70f 100644
--- a/lib/chef/knife/user_edit.rb
+++ b/knife/lib/chef/knife/user_edit.rb
diff --git a/lib/chef/knife/user_invite_add.rb b/knife/lib/chef/knife/user_invite_add.rb
index 1690147535..1690147535 100644
--- a/lib/chef/knife/user_invite_add.rb
+++ b/knife/lib/chef/knife/user_invite_add.rb
diff --git a/lib/chef/knife/user_invite_list.rb b/knife/lib/chef/knife/user_invite_list.rb
index 831774d1bf..831774d1bf 100644
--- a/lib/chef/knife/user_invite_list.rb
+++ b/knife/lib/chef/knife/user_invite_list.rb
diff --git a/lib/chef/knife/user_invite_rescind.rb b/knife/lib/chef/knife/user_invite_rescind.rb
index fd5804e10a..fd5804e10a 100644
--- a/lib/chef/knife/user_invite_rescind.rb
+++ b/knife/lib/chef/knife/user_invite_rescind.rb
diff --git a/lib/chef/knife/user_key_create.rb b/knife/lib/chef/knife/user_key_create.rb
index efc783dd7f..efc783dd7f 100644
--- a/lib/chef/knife/user_key_create.rb
+++ b/knife/lib/chef/knife/user_key_create.rb
diff --git a/lib/chef/knife/user_key_delete.rb b/knife/lib/chef/knife/user_key_delete.rb
index b4f84fdb7b..b4f84fdb7b 100644
--- a/lib/chef/knife/user_key_delete.rb
+++ b/knife/lib/chef/knife/user_key_delete.rb
diff --git a/lib/chef/knife/user_key_edit.rb b/knife/lib/chef/knife/user_key_edit.rb
index 15ef2ada1e..15ef2ada1e 100644
--- a/lib/chef/knife/user_key_edit.rb
+++ b/knife/lib/chef/knife/user_key_edit.rb
diff --git a/lib/chef/knife/user_key_list.rb b/knife/lib/chef/knife/user_key_list.rb
index 781998b301..781998b301 100644
--- a/lib/chef/knife/user_key_list.rb
+++ b/knife/lib/chef/knife/user_key_list.rb
diff --git a/lib/chef/knife/user_key_show.rb b/knife/lib/chef/knife/user_key_show.rb
index 2bf535c792..2bf535c792 100644
--- a/lib/chef/knife/user_key_show.rb
+++ b/knife/lib/chef/knife/user_key_show.rb
diff --git a/lib/chef/knife/user_list.rb b/knife/lib/chef/knife/user_list.rb
index 3284964a47..cb3b577541 100644
--- a/lib/chef/knife/user_list.rb
+++ b/knife/lib/chef/knife/user_list.rb
@@ -22,6 +22,11 @@ class Chef
class Knife
class UserList < Knife
+ deps do
+ # is not used there, only in knife.
+ require "chef/user_v1" unless defined?(Chef::UserV1)
+ end
+
banner "knife user list (options)"
option :with_uri,
@@ -30,9 +35,9 @@ class Chef
description: "Show corresponding URIs."
def run
- results = root_rest.get("users")
- output(format_list_for_display(results))
+ output(format_list_for_display(Chef::UserV1.list))
end
+
end
end
end
diff --git a/lib/chef/knife/user_password.rb b/knife/lib/chef/knife/user_password.rb
index 2da3c3e285..2da3c3e285 100644
--- a/lib/chef/knife/user_password.rb
+++ b/knife/lib/chef/knife/user_password.rb
diff --git a/lib/chef/knife/user_reregister.rb b/knife/lib/chef/knife/user_reregister.rb
index ee58c19d9f..cf2adbceb2 100644
--- a/lib/chef/knife/user_reregister.rb
+++ b/knife/lib/chef/knife/user_reregister.rb
@@ -23,7 +23,7 @@ class Chef
class UserReregister < Knife
deps do
- require_relative "../user_v1"
+ require "chef/user_v1" unless defined?(Chef::UserV1)
end
banner "knife user reregister USER (options)"
diff --git a/lib/chef/knife/user_show.rb b/knife/lib/chef/knife/user_show.rb
index ea2b06b753..ea2b06b753 100644
--- a/lib/chef/knife/user_show.rb
+++ b/knife/lib/chef/knife/user_show.rb
diff --git a/knife/lib/chef/knife/version.rb b/knife/lib/chef/knife/version.rb
new file mode 100644
index 0000000000..109f033187
--- /dev/null
+++ b/knife/lib/chef/knife/version.rb
@@ -0,0 +1,24 @@
+# Copyright:: Copyright (c) Chef Software Inc.
+# License:: Apache License, Version 2.0
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+class Chef
+ class Knife
+ KNIFE_ROOT = File.expand_path("../..", __dir__)
+ VERSION = "17.0.173".freeze
+ end
+end
+
+
diff --git a/lib/chef/knife/xargs.rb b/knife/lib/chef/knife/xargs.rb
index 9dcc724d38..fc82d390cb 100644
--- a/lib/chef/knife/xargs.rb
+++ b/knife/lib/chef/knife/xargs.rb
@@ -24,8 +24,8 @@ class Chef
category "path-based"
deps do
- require_relative "../chef_fs/file_system"
- require_relative "../chef_fs/file_system/exceptions"
+ require "chef/chef_fs/file_system" unless defined?(Chef::ChefFS::FileSystem)
+ require "chef/chef_fs/file_system/exceptions" unless defined?(Chef::ChefFS::FileSystem::Exceptions)
end
# TODO modify to remote-only / local-only pattern (more like delete)
diff --git a/lib/chef/knife/yaml_convert.rb b/knife/lib/chef/knife/yaml_convert.rb
index 6bd2d1c0ea..6bd2d1c0ea 100644
--- a/lib/chef/knife/yaml_convert.rb
+++ b/knife/lib/chef/knife/yaml_convert.rb
diff --git a/lib/chef/applications.rb b/lib/chef/applications.rb
index a30b765c77..8f7f418d3f 100644
--- a/lib/chef/applications.rb
+++ b/lib/chef/applications.rb
@@ -1,4 +1,3 @@
require_relative "application/client"
-require_relative "application/knife"
require_relative "application/solo"
require_relative "application/apply"
diff --git a/lib/chef/cookbook_site_streaming_uploader.rb b/lib/chef/cookbook_site_streaming_uploader.rb
deleted file mode 100644
index d7226b79b3..0000000000
--- a/lib/chef/cookbook_site_streaming_uploader.rb
+++ /dev/null
@@ -1,244 +0,0 @@
-#
-# Author:: Stanislav Vitvitskiy
-# Author:: Nuo Yan (nuo@chef.io)
-# Author:: Christopher Walters (<cw@chef.io>)
-# Copyright:: Copyright (c) Chef Software Inc.
-# License:: Apache License, Version 2.0
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-
-autoload :URI, "uri"
-module Net
- autoload :HTTP, "net/http"
-end
-autoload :OpenSSL, "openssl"
-module Mixlib
- module Authentication
- autoload :SignedHeaderAuth, "mixlib/authentication/signedheaderauth"
- end
-end
-require "chef-utils/dist" unless defined?(ChefUtils::Dist)
-
-class Chef
- # == Chef::CookbookSiteStreamingUploader
- # A streaming multipart HTTP upload implementation. Used to upload cookbooks
- # (in tarball form) to https://supermarket.chef.io
- #
- # inspired by http://stanislavvitvitskiy.blogspot.com/2008/12/multipart-post-in-ruby.html
- class CookbookSiteStreamingUploader
-
- DefaultHeaders = { "accept" => "application/json", "x-chef-version" => ::Chef::VERSION }.freeze # rubocop:disable Naming/ConstantName
-
- class << self
-
- def create_build_dir(cookbook)
- tmp_cookbook_path = Tempfile.new("#{ChefUtils::Dist::Infra::SHORT}-#{cookbook.name}-build")
- tmp_cookbook_path.close
- tmp_cookbook_dir = tmp_cookbook_path.path
- File.unlink(tmp_cookbook_dir)
- FileUtils.mkdir_p(tmp_cookbook_dir)
- Chef::Log.trace("Staging at #{tmp_cookbook_dir}")
- checksums_to_on_disk_paths = cookbook.checksums
- cookbook.each_file do |manifest_record|
- path_in_cookbook = manifest_record[:path]
- on_disk_path = checksums_to_on_disk_paths[manifest_record[:checksum]]
- dest = File.join(tmp_cookbook_dir, cookbook.name.to_s, path_in_cookbook)
- FileUtils.mkdir_p(File.dirname(dest))
- Chef::Log.trace("Staging #{on_disk_path} to #{dest}")
- FileUtils.cp(on_disk_path, dest)
- end
-
- # First, generate metadata
- Chef::Log.trace("Generating metadata")
- kcm = Chef::Knife::CookbookMetadata.new
- kcm.config[:cookbook_path] = [ tmp_cookbook_dir ]
- kcm.name_args = [ cookbook.name.to_s ]
- kcm.run
-
- tmp_cookbook_dir
- end
-
- def post(to_url, user_id, secret_key_filename, params = {}, headers = {})
- make_request(:post, to_url, user_id, secret_key_filename, params, headers)
- end
-
- def put(to_url, user_id, secret_key_filename, params = {}, headers = {})
- make_request(:put, to_url, user_id, secret_key_filename, params, headers)
- end
-
- def make_request(http_verb, to_url, user_id, secret_key_filename, params = {}, headers = {})
- boundary = "----RubyMultipartClient" + rand(1000000).to_s + "ZZZZZ"
- parts = []
- content_file = nil
-
- secret_key = OpenSSL::PKey::RSA.new(File.read(secret_key_filename))
-
- unless params.nil? || params.empty?
- params.each do |key, value|
- if value.is_a?(File)
- content_file = value
- filepath = value.path
- filename = File.basename(filepath)
- parts << StringPart.new( "--" + boundary + "\r\n" +
- "Content-Disposition: form-data; name=\"" + key.to_s + "\"; filename=\"" + filename + "\"\r\n" +
- "Content-Type: application/octet-stream\r\n\r\n")
- parts << StreamPart.new(value, File.size(filepath))
- parts << StringPart.new("\r\n")
- else
- parts << StringPart.new( "--" + boundary + "\r\n" +
- "Content-Disposition: form-data; name=\"" + key.to_s + "\"\r\n\r\n")
- parts << StringPart.new(value.to_s + "\r\n")
- end
- end
- parts << StringPart.new("--" + boundary + "--\r\n")
- end
-
- body_stream = MultipartStream.new(parts)
-
- timestamp = Time.now.utc.iso8601
-
- url = URI.parse(to_url)
-
- Chef::Log.logger.debug("Signing: method: #{http_verb}, url: #{url}, file: #{content_file}, User-id: #{user_id}, Timestamp: #{timestamp}")
-
- # We use the body for signing the request if the file parameter
- # wasn't a valid file or wasn't included. Extract the body (with
- # multi-part delimiters intact) to sign the request.
- # TODO: tim: 2009-12-28: It'd be nice to remove this special case, and
- # always hash the entire request body. In the file case it would just be
- # expanded multipart text - the entire body of the POST.
- content_body = parts.inject("") { |result, part| result + part.read(0, part.size) }
- content_file.rewind if content_file # we consumed the file for the above operation, so rewind it.
-
- signing_options = {
- http_method: http_verb,
- path: url.path,
- user_id: user_id,
- timestamp: timestamp }
- (content_file && signing_options[:file] = content_file) || (signing_options[:body] = (content_body || ""))
-
- headers.merge!(Mixlib::Authentication::SignedHeaderAuth.signing_object(signing_options).sign(secret_key))
-
- content_file.rewind if content_file
-
- # net/http doesn't like symbols for header keys, so we'll to_s each one just in case
- headers = DefaultHeaders.merge(Hash[*headers.map { |k, v| [k.to_s, v] }.flatten])
-
- req = case http_verb
- when :put
- Net::HTTP::Put.new(url.path, headers)
- when :post
- Net::HTTP::Post.new(url.path, headers)
- end
- req.content_length = body_stream.size
- req.content_type = "multipart/form-data; boundary=" + boundary unless parts.empty?
- req.body_stream = body_stream
-
- http = Chef::HTTP::BasicClient.new(url).http_client
- res = http.request(req)
-
- # alias status to code and to_s to body for test purposes
- # TODO: stop the following madness!
- class << res
- alias :to_s :body
-
- # BUG this makes the response compatible with what response_steps expects to test headers (response.headers[] -> response[])
- def headers # rubocop:disable Lint/NestedMethodDefinition
- self
- end
-
- def status # rubocop:disable Lint/NestedMethodDefinition
- code.to_i
- end
- end
- res
- end
-
- end
-
- class StreamPart
- def initialize(stream, size)
- @stream, @size = stream, size
- end
-
- def size
- @size
- end
-
- # read the specified amount from the stream
- def read(offset, how_much)
- @stream.read(how_much)
- end
- end
-
- class StringPart
- def initialize(str)
- @str = str
- end
-
- def size
- @str.length
- end
-
- # read the specified amount from the string starting at the offset
- def read(offset, how_much)
- @str[offset, how_much]
- end
- end
-
- class MultipartStream
- def initialize(parts)
- @parts = parts
- @part_no = 0
- @part_offset = 0
- end
-
- def size
- @parts.inject(0) { |size, part| size + part.size }
- end
-
- def read(how_much, dst_buf = nil)
- if @part_no >= @parts.size
- dst_buf.replace("") if dst_buf
- return dst_buf
- end
-
- how_much_current_part = @parts[@part_no].size - @part_offset
-
- how_much_current_part = if how_much_current_part > how_much
- how_much
- else
- how_much_current_part
- end
-
- how_much_next_part = how_much - how_much_current_part
-
- current_part = @parts[@part_no].read(@part_offset, how_much_current_part)
-
- # recurse into the next part if the current one was not large enough
- if how_much_next_part > 0
- @part_no += 1
- @part_offset = 0
- next_part = read(how_much_next_part)
- result = current_part + (next_part || "")
- else
- @part_offset += how_much_current_part
- result = current_part
- end
- dst_buf ? dst_buf.replace(result || "") : result
- end
- end
-
- end
-end
diff --git a/lib/chef/cookbook_uploader.rb b/lib/chef/cookbook_uploader.rb
index 235a539b94..21a15f706c 100644
--- a/lib/chef/cookbook_uploader.rb
+++ b/lib/chef/cookbook_uploader.rb
@@ -1,7 +1,6 @@
autoload :Set, "set"
require_relative "exceptions"
-require_relative "knife/cookbook_metadata"
require_relative "digester"
require_relative "cookbook_manifest"
require_relative "cookbook_version"
diff --git a/spec/functional/knife/configure_spec.rb b/spec/functional/knife/configure_spec.rb
index 8f2a5b4d6e..402e988132 100644
--- a/spec/functional/knife/configure_spec.rb
+++ b/spec/functional/knife/configure_spec.rb
@@ -16,7 +16,7 @@
# limitations under the License.
#
-require "spec_helper"
+require "knife_spec_helper"
require "chef/knife/configure"
diff --git a/spec/functional/knife/cookbook_delete_spec.rb b/spec/functional/knife/cookbook_delete_spec.rb
index 650db0ede5..f25999f0fc 100644
--- a/spec/functional/knife/cookbook_delete_spec.rb
+++ b/spec/functional/knife/cookbook_delete_spec.rb
@@ -16,7 +16,7 @@
# limitations under the License.
#
-require "spec_helper"
+require "knife_spec_helper"
require "tiny_server"
describe Chef::Knife::CookbookDelete do
diff --git a/spec/functional/knife/exec_spec.rb b/spec/functional/knife/exec_spec.rb
index 3905798317..267fe8492e 100644
--- a/spec/functional/knife/exec_spec.rb
+++ b/spec/functional/knife/exec_spec.rb
@@ -16,7 +16,7 @@
# limitations under the License.
#
-require "spec_helper"
+require "knife_spec_helper"
require "tiny_server"
describe Chef::Knife::Exec do
diff --git a/spec/functional/knife/rehash_spec.rb b/spec/functional/knife/rehash_spec.rb
index 8f59eec270..a4b7e5507c 100644
--- a/spec/functional/knife/rehash_spec.rb
+++ b/spec/functional/knife/rehash_spec.rb
@@ -16,7 +16,7 @@
# limitations under the License.
#
-require "spec_helper"
+require "knife_spec_helper"
require "chef/knife/rehash"
require "chef/knife/core/subcommand_loader"
diff --git a/spec/functional/knife/ssh_spec.rb b/spec/functional/knife/ssh_spec.rb
index 1d4aff15b5..5a29f995f8 100644
--- a/spec/functional/knife/ssh_spec.rb
+++ b/spec/functional/knife/ssh_spec.rb
@@ -16,7 +16,7 @@
# limitations under the License.
#
-require "spec_helper"
+require "knife_spec_helper"
require "tiny_server"
describe Chef::Knife::Ssh do
diff --git a/spec/functional/knife/version_spec.rb b/spec/functional/knife/version_spec.rb
new file mode 100644
index 0000000000..b024cc1cda
--- /dev/null
+++ b/spec/functional/knife/version_spec.rb
@@ -0,0 +1,26 @@
+# Copyright:: Copyright (c) Chef Software Inc.
+# License:: Apache License, Version 2.0
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+require "knife_spec_helper"
+require "chef/mixin/shell_out"
+
+describe "Knife Version", :executables do
+ include Chef::Mixin::ShellOut
+ let(:knife_dir) { File.join(__dir__, "..", "..", "..", "knife") }
+ xit "should be sane" do
+ expect(shell_out!("bundle exec knife -v", cwd: knife_dir).stdout.chomp).to match(/.*: #{Chef::Knife::VERSION}/)
+ end
+end
+
diff --git a/spec/functional/version_spec.rb b/spec/functional/version_spec.rb
index 5d0f0fce43..3b348ed024 100644
--- a/spec/functional/version_spec.rb
+++ b/spec/functional/version_spec.rb
@@ -25,7 +25,7 @@ describe "Chef Versions", :executables do
include Chef::Mixin::ShellOut
let(:chef_dir) { File.join(__dir__, "..", "..") }
- binaries = [ ChefUtils::Dist::Infra::CLIENT, "chef-shell", "chef-apply", "knife", ChefUtils::Dist::Solo::EXEC ]
+ binaries = [ ChefUtils::Dist::Infra::CLIENT, "chef-shell", "chef-apply", ChefUtils::Dist::Solo::EXEC ]
binaries.each do |binary|
it "#{binary} version should be sane" do
diff --git a/spec/integration/knife/chef_fs_data_store_spec.rb b/spec/integration/knife/chef_fs_data_store_spec.rb
index 6e04684c33..fda06164a4 100644
--- a/spec/integration/knife/chef_fs_data_store_spec.rb
+++ b/spec/integration/knife/chef_fs_data_store_spec.rb
@@ -15,7 +15,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-require "spec_helper"
+require "knife_spec_helper"
require "support/shared/integration/integration_helper"
require "chef/knife/list"
require "chef/knife/delete"
diff --git a/spec/integration/knife/chef_repo_path_spec.rb b/spec/integration/knife/chef_repo_path_spec.rb
index ac7dae15f0..27b45ac428 100644
--- a/spec/integration/knife/chef_repo_path_spec.rb
+++ b/spec/integration/knife/chef_repo_path_spec.rb
@@ -15,7 +15,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-require "spec_helper"
+require "knife_spec_helper"
require "support/shared/integration/integration_helper"
require "support/shared/context/config"
require "chef/knife/list"
diff --git a/spec/integration/knife/chef_repository_file_system_spec.rb b/spec/integration/knife/chef_repository_file_system_spec.rb
index 295efc0c3a..9a129dcb98 100644
--- a/spec/integration/knife/chef_repository_file_system_spec.rb
+++ b/spec/integration/knife/chef_repository_file_system_spec.rb
@@ -15,7 +15,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-require "spec_helper"
+require "knife_spec_helper"
require "support/shared/integration/integration_helper"
require "chef/knife/list"
require "chef/knife/show"
diff --git a/spec/integration/knife/chefignore_spec.rb b/spec/integration/knife/chefignore_spec.rb
index eccd38d928..f111cd56e1 100644
--- a/spec/integration/knife/chefignore_spec.rb
+++ b/spec/integration/knife/chefignore_spec.rb
@@ -15,7 +15,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-require "spec_helper"
+require "knife_spec_helper"
require "support/shared/integration/integration_helper"
require "chef/knife/list"
require "chef/knife/show"
diff --git a/spec/integration/knife/client_bulk_delete_spec.rb b/spec/integration/knife/client_bulk_delete_spec.rb
index 5c0ff94867..b7733f638d 100644
--- a/spec/integration/knife/client_bulk_delete_spec.rb
+++ b/spec/integration/knife/client_bulk_delete_spec.rb
@@ -14,7 +14,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-require "spec_helper"
+require "knife_spec_helper"
require "support/shared/integration/integration_helper"
require "support/shared/context/config"
diff --git a/spec/integration/knife/client_create_spec.rb b/spec/integration/knife/client_create_spec.rb
index 2e48cde7ab..3898ff9d24 100644
--- a/spec/integration/knife/client_create_spec.rb
+++ b/spec/integration/knife/client_create_spec.rb
@@ -14,7 +14,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-require "spec_helper"
+require "knife_spec_helper"
require "support/shared/integration/integration_helper"
require "support/shared/context/config"
require "openssl"
diff --git a/spec/integration/knife/client_delete_spec.rb b/spec/integration/knife/client_delete_spec.rb
index 76a3b9a686..057561eaea 100644
--- a/spec/integration/knife/client_delete_spec.rb
+++ b/spec/integration/knife/client_delete_spec.rb
@@ -14,7 +14,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-require "spec_helper"
+require "knife_spec_helper"
require "support/shared/integration/integration_helper"
require "support/shared/context/config"
diff --git a/spec/integration/knife/client_key_create_spec.rb b/spec/integration/knife/client_key_create_spec.rb
index b9838d6718..29b960111c 100644
--- a/spec/integration/knife/client_key_create_spec.rb
+++ b/spec/integration/knife/client_key_create_spec.rb
@@ -14,7 +14,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-require "spec_helper"
+require "knife_spec_helper"
require "support/shared/integration/integration_helper"
require "support/shared/context/config"
require "openssl"
diff --git a/spec/integration/knife/client_key_delete_spec.rb b/spec/integration/knife/client_key_delete_spec.rb
index 2730ee8cae..8c15377986 100644
--- a/spec/integration/knife/client_key_delete_spec.rb
+++ b/spec/integration/knife/client_key_delete_spec.rb
@@ -14,7 +14,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-require "spec_helper"
+require "knife_spec_helper"
require "support/shared/integration/integration_helper"
require "support/shared/context/config"
diff --git a/spec/integration/knife/client_key_list_spec.rb b/spec/integration/knife/client_key_list_spec.rb
index 773445eca9..01e5b78585 100644
--- a/spec/integration/knife/client_key_list_spec.rb
+++ b/spec/integration/knife/client_key_list_spec.rb
@@ -14,7 +14,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-require "spec_helper"
+require "knife_spec_helper"
require "support/shared/integration/integration_helper"
require "support/shared/context/config"
require "date"
diff --git a/spec/integration/knife/client_key_show_spec.rb b/spec/integration/knife/client_key_show_spec.rb
index ee17fc3e5a..05024d40b2 100644
--- a/spec/integration/knife/client_key_show_spec.rb
+++ b/spec/integration/knife/client_key_show_spec.rb
@@ -14,7 +14,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-require "spec_helper"
+require "knife_spec_helper"
require "support/shared/integration/integration_helper"
require "support/shared/context/config"
require "date"
diff --git a/spec/integration/knife/client_list_spec.rb b/spec/integration/knife/client_list_spec.rb
index f7875b44af..7668b9e455 100644
--- a/spec/integration/knife/client_list_spec.rb
+++ b/spec/integration/knife/client_list_spec.rb
@@ -14,7 +14,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-require "spec_helper"
+require "knife_spec_helper"
require "support/shared/integration/integration_helper"
require "support/shared/context/config"
diff --git a/spec/integration/knife/client_show_spec.rb b/spec/integration/knife/client_show_spec.rb
index 1520575e48..39a107e37f 100644
--- a/spec/integration/knife/client_show_spec.rb
+++ b/spec/integration/knife/client_show_spec.rb
@@ -14,7 +14,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-require "spec_helper"
+require "knife_spec_helper"
require "support/shared/integration/integration_helper"
require "support/shared/context/config"
diff --git a/spec/integration/knife/common_options_spec.rb b/spec/integration/knife/common_options_spec.rb
index 468b7af8be..7796bf9923 100644
--- a/spec/integration/knife/common_options_spec.rb
+++ b/spec/integration/knife/common_options_spec.rb
@@ -15,7 +15,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-require "spec_helper"
+require "knife_spec_helper"
require "support/shared/integration/integration_helper"
require "chef/knife/raw"
diff --git a/spec/integration/knife/config_list_spec.rb b/spec/integration/knife/config_list_spec.rb
index b05350ed87..5193608f36 100644
--- a/spec/integration/knife/config_list_spec.rb
+++ b/spec/integration/knife/config_list_spec.rb
@@ -13,7 +13,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-require "spec_helper"
+require "knife_spec_helper"
require "support/shared/integration/integration_helper"
require "support/shared/context/config"
diff --git a/spec/integration/knife/config_show_spec.rb b/spec/integration/knife/config_show_spec.rb
index 9e6ff73aa1..e11d001df9 100644
--- a/spec/integration/knife/config_show_spec.rb
+++ b/spec/integration/knife/config_show_spec.rb
@@ -13,7 +13,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-require "spec_helper"
+require "knife_spec_helper"
require "support/shared/integration/integration_helper"
require "support/shared/context/config"
diff --git a/spec/integration/knife/config_use_spec.rb b/spec/integration/knife/config_use_spec.rb
index 0431729b25..4a982bc0bd 100644
--- a/spec/integration/knife/config_use_spec.rb
+++ b/spec/integration/knife/config_use_spec.rb
@@ -13,7 +13,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-require "spec_helper"
+require "knife_spec_helper"
require "support/shared/integration/integration_helper"
require "support/shared/context/config"
diff --git a/spec/integration/knife/cookbook_api_ipv6_spec.rb b/spec/integration/knife/cookbook_api_ipv6_spec.rb
index b65cdc697b..5d0ce0707f 100644
--- a/spec/integration/knife/cookbook_api_ipv6_spec.rb
+++ b/spec/integration/knife/cookbook_api_ipv6_spec.rb
@@ -15,7 +15,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-require "spec_helper"
+require "knife_spec_helper"
require "support/shared/integration/integration_helper"
require "chef/mixin/shell_out"
@@ -62,7 +62,7 @@ describe "Knife cookbook API integration with IPv6", :workstation, :not_supporte
Dir.mktmpdir
end
- let(:chef_dir) { File.join(__dir__, "..", "..", "..", "bin") }
+ let(:chef_dir) { File.join(__dir__, "..", "..", "..", "knife", "bin") }
let(:knife) { "ruby '#{chef_dir}/knife'" }
let(:knife_config_flag) { "-c '#{path_to("config/knife.rb")}'" }
@@ -102,7 +102,7 @@ describe "Knife cookbook API integration with IPv6", :workstation, :not_supporte
end
it "downloads the cookbook" do
- shell_out!("knife cookbook download apache2 #{knife_config_flag} -d #{cache_path}", cwd: chef_dir)
+ shell_out!("#{knife} cookbook download apache2 #{knife_config_flag} -d #{cache_path}", cwd: chef_dir)
expect(Dir["#{cache_path}/*"].map { |entry| File.basename(entry) }).to include("apache2-0.0.1")
end
end
diff --git a/spec/integration/knife/cookbook_bulk_delete_spec.rb b/spec/integration/knife/cookbook_bulk_delete_spec.rb
index 677a6aaa31..0e791f5a1e 100644
--- a/spec/integration/knife/cookbook_bulk_delete_spec.rb
+++ b/spec/integration/knife/cookbook_bulk_delete_spec.rb
@@ -14,7 +14,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-require "spec_helper"
+require "knife_spec_helper"
require "support/shared/integration/integration_helper"
require "support/shared/context/config"
require "chef/knife/cookbook_bulk_delete"
diff --git a/spec/integration/knife/cookbook_download_spec.rb b/spec/integration/knife/cookbook_download_spec.rb
index 1cc05c909a..589417126c 100644
--- a/spec/integration/knife/cookbook_download_spec.rb
+++ b/spec/integration/knife/cookbook_download_spec.rb
@@ -14,7 +14,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-require "spec_helper"
+require "knife_spec_helper"
require "support/shared/integration/integration_helper"
require "support/shared/context/config"
require "chef/knife/cookbook_download"
diff --git a/spec/integration/knife/cookbook_list_spec.rb b/spec/integration/knife/cookbook_list_spec.rb
index c94df52272..e712ae3235 100644
--- a/spec/integration/knife/cookbook_list_spec.rb
+++ b/spec/integration/knife/cookbook_list_spec.rb
@@ -14,7 +14,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-require "spec_helper"
+require "knife_spec_helper"
require "support/shared/integration/integration_helper"
require "support/shared/context/config"
require "chef/knife/cookbook_list"
diff --git a/spec/integration/knife/cookbook_show_spec.rb b/spec/integration/knife/cookbook_show_spec.rb
index 57701d4426..d8c2e38f64 100644
--- a/spec/integration/knife/cookbook_show_spec.rb
+++ b/spec/integration/knife/cookbook_show_spec.rb
@@ -14,7 +14,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-require "spec_helper"
+require "knife_spec_helper"
require "support/shared/integration/integration_helper"
require "support/shared/context/config"
require "chef/knife/cookbook_show"
diff --git a/spec/integration/knife/cookbook_upload_spec.rb b/spec/integration/knife/cookbook_upload_spec.rb
index 7139f0accd..f42683b2a3 100644
--- a/spec/integration/knife/cookbook_upload_spec.rb
+++ b/spec/integration/knife/cookbook_upload_spec.rb
@@ -14,7 +14,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-require "spec_helper"
+require "knife_spec_helper"
require "support/shared/integration/integration_helper"
require "support/shared/context/config"
require "chef/knife/cookbook_upload"
diff --git a/spec/integration/knife/data_bag_create_spec.rb b/spec/integration/knife/data_bag_create_spec.rb
index ca01a2d8ab..439d69507c 100644
--- a/spec/integration/knife/data_bag_create_spec.rb
+++ b/spec/integration/knife/data_bag_create_spec.rb
@@ -14,7 +14,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-require "spec_helper"
+require "knife_spec_helper"
require "support/shared/integration/integration_helper"
require "support/shared/context/config"
require "chef/knife/data_bag_create"
diff --git a/spec/integration/knife/data_bag_delete_spec.rb b/spec/integration/knife/data_bag_delete_spec.rb
index c0a17779b9..a7fac7e2ee 100644
--- a/spec/integration/knife/data_bag_delete_spec.rb
+++ b/spec/integration/knife/data_bag_delete_spec.rb
@@ -14,7 +14,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-require "spec_helper"
+require "knife_spec_helper"
require "support/shared/integration/integration_helper"
require "support/shared/context/config"
require "chef/knife/data_bag_delete"
diff --git a/spec/integration/knife/data_bag_edit_spec.rb b/spec/integration/knife/data_bag_edit_spec.rb
index 1063b5d14f..1071df2a78 100644
--- a/spec/integration/knife/data_bag_edit_spec.rb
+++ b/spec/integration/knife/data_bag_edit_spec.rb
@@ -14,7 +14,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-require "spec_helper"
+require "knife_spec_helper"
require "support/shared/integration/integration_helper"
require "support/shared/context/config"
require "chef/knife/data_bag_edit"
diff --git a/spec/integration/knife/data_bag_from_file_spec.rb b/spec/integration/knife/data_bag_from_file_spec.rb
index 93801226d0..bb8bd192f0 100644
--- a/spec/integration/knife/data_bag_from_file_spec.rb
+++ b/spec/integration/knife/data_bag_from_file_spec.rb
@@ -14,7 +14,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-require "spec_helper"
+require "knife_spec_helper"
require "support/shared/integration/integration_helper"
require "support/shared/context/config"
diff --git a/spec/integration/knife/data_bag_list_spec.rb b/spec/integration/knife/data_bag_list_spec.rb
index 0216b90c5d..1e7734db64 100644
--- a/spec/integration/knife/data_bag_list_spec.rb
+++ b/spec/integration/knife/data_bag_list_spec.rb
@@ -14,7 +14,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-require "spec_helper"
+require "knife_spec_helper"
require "support/shared/integration/integration_helper"
require "support/shared/context/config"
require "chef/knife/data_bag_list"
diff --git a/spec/integration/knife/data_bag_show_spec.rb b/spec/integration/knife/data_bag_show_spec.rb
index b332b1b114..91ebf605f1 100644
--- a/spec/integration/knife/data_bag_show_spec.rb
+++ b/spec/integration/knife/data_bag_show_spec.rb
@@ -14,7 +14,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-require "spec_helper"
+require "knife_spec_helper"
require "support/shared/integration/integration_helper"
require "support/shared/context/config"
require "chef/knife/data_bag_show"
diff --git a/spec/integration/knife/delete_spec.rb b/spec/integration/knife/delete_spec.rb
index 851c492a66..e00949e7f4 100644
--- a/spec/integration/knife/delete_spec.rb
+++ b/spec/integration/knife/delete_spec.rb
@@ -15,7 +15,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-require "spec_helper"
+require "knife_spec_helper"
require "support/shared/integration/integration_helper"
require "chef/knife/delete"
require "chef/knife/list"
diff --git a/spec/integration/knife/deps_spec.rb b/spec/integration/knife/deps_spec.rb
index 77505e6332..9875277f14 100644
--- a/spec/integration/knife/deps_spec.rb
+++ b/spec/integration/knife/deps_spec.rb
@@ -15,7 +15,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-require "spec_helper"
+require "knife_spec_helper"
require "support/shared/integration/integration_helper"
require "support/shared/context/config"
require "chef/knife/deps"
diff --git a/spec/integration/knife/diff_spec.rb b/spec/integration/knife/diff_spec.rb
index 41ae5ea519..c69573735a 100644
--- a/spec/integration/knife/diff_spec.rb
+++ b/spec/integration/knife/diff_spec.rb
@@ -15,7 +15,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-require "spec_helper"
+require "knife_spec_helper"
require "support/shared/integration/integration_helper"
require "chef/knife/diff"
diff --git a/spec/integration/knife/download_spec.rb b/spec/integration/knife/download_spec.rb
index 7bdec7b356..29200d66f2 100644
--- a/spec/integration/knife/download_spec.rb
+++ b/spec/integration/knife/download_spec.rb
@@ -15,7 +15,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-require "spec_helper"
+require "knife_spec_helper"
require "support/shared/integration/integration_helper"
require "chef/knife/download"
require "chef/knife/diff"
diff --git a/spec/integration/knife/environment_compare_spec.rb b/spec/integration/knife/environment_compare_spec.rb
index 7a623adf4c..a8d207466a 100644
--- a/spec/integration/knife/environment_compare_spec.rb
+++ b/spec/integration/knife/environment_compare_spec.rb
@@ -14,7 +14,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-require "spec_helper"
+require "knife_spec_helper"
require "support/shared/integration/integration_helper"
require "support/shared/context/config"
diff --git a/spec/integration/knife/environment_create_spec.rb b/spec/integration/knife/environment_create_spec.rb
index 66ba9ed6e6..496828073d 100644
--- a/spec/integration/knife/environment_create_spec.rb
+++ b/spec/integration/knife/environment_create_spec.rb
@@ -14,7 +14,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-require "spec_helper"
+require "knife_spec_helper"
require "support/shared/integration/integration_helper"
require "support/shared/context/config"
diff --git a/spec/integration/knife/environment_delete_spec.rb b/spec/integration/knife/environment_delete_spec.rb
index f55a1c96bd..93427aaf2f 100644
--- a/spec/integration/knife/environment_delete_spec.rb
+++ b/spec/integration/knife/environment_delete_spec.rb
@@ -14,7 +14,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-require "spec_helper"
+require "knife_spec_helper"
require "support/shared/integration/integration_helper"
require "support/shared/context/config"
diff --git a/spec/integration/knife/environment_from_file_spec.rb b/spec/integration/knife/environment_from_file_spec.rb
index f9d35f4d47..e5ba056bb7 100644
--- a/spec/integration/knife/environment_from_file_spec.rb
+++ b/spec/integration/knife/environment_from_file_spec.rb
@@ -14,7 +14,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-require "spec_helper"
+require "knife_spec_helper"
require "support/shared/integration/integration_helper"
require "support/shared/context/config"
diff --git a/spec/integration/knife/environment_list_spec.rb b/spec/integration/knife/environment_list_spec.rb
index dba685a82e..f74b2b6360 100644
--- a/spec/integration/knife/environment_list_spec.rb
+++ b/spec/integration/knife/environment_list_spec.rb
@@ -14,7 +14,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-require "spec_helper"
+require "knife_spec_helper"
require "support/shared/integration/integration_helper"
require "support/shared/context/config"
diff --git a/spec/integration/knife/environment_show_spec.rb b/spec/integration/knife/environment_show_spec.rb
index de6ad1efd4..b961e85734 100644
--- a/spec/integration/knife/environment_show_spec.rb
+++ b/spec/integration/knife/environment_show_spec.rb
@@ -14,7 +14,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-require "spec_helper"
+require "knife_spec_helper"
require "support/shared/integration/integration_helper"
require "support/shared/context/config"
diff --git a/spec/integration/knife/list_spec.rb b/spec/integration/knife/list_spec.rb
index 4c711f3306..8228ba6056 100644
--- a/spec/integration/knife/list_spec.rb
+++ b/spec/integration/knife/list_spec.rb
@@ -15,7 +15,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-require "spec_helper"
+require "knife_spec_helper"
require "support/shared/integration/integration_helper"
require "support/shared/context/config"
require "chef/knife/list"
diff --git a/spec/integration/knife/node_bulk_delete_spec.rb b/spec/integration/knife/node_bulk_delete_spec.rb
index dcaa71ef58..8784b5ea8a 100644
--- a/spec/integration/knife/node_bulk_delete_spec.rb
+++ b/spec/integration/knife/node_bulk_delete_spec.rb
@@ -14,7 +14,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-require "spec_helper"
+require "knife_spec_helper"
require "support/shared/integration/integration_helper"
require "support/shared/context/config"
diff --git a/spec/integration/knife/node_create_spec.rb b/spec/integration/knife/node_create_spec.rb
index e8f6d71694..d3debb8f00 100644
--- a/spec/integration/knife/node_create_spec.rb
+++ b/spec/integration/knife/node_create_spec.rb
@@ -14,7 +14,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-require "spec_helper"
+require "knife_spec_helper"
require "support/shared/integration/integration_helper"
require "support/shared/context/config"
require "openssl"
diff --git a/spec/integration/knife/node_delete_spec.rb b/spec/integration/knife/node_delete_spec.rb
index c743d6e03f..3cece6ebaf 100644
--- a/spec/integration/knife/node_delete_spec.rb
+++ b/spec/integration/knife/node_delete_spec.rb
@@ -14,7 +14,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-require "spec_helper"
+require "knife_spec_helper"
require "support/shared/integration/integration_helper"
require "support/shared/context/config"
diff --git a/spec/integration/knife/node_environment_set_spec.rb b/spec/integration/knife/node_environment_set_spec.rb
index 16a86dbc30..51b288fe39 100644
--- a/spec/integration/knife/node_environment_set_spec.rb
+++ b/spec/integration/knife/node_environment_set_spec.rb
@@ -14,7 +14,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-require "spec_helper"
+require "knife_spec_helper"
require "support/shared/integration/integration_helper"
require "support/shared/context/config"
diff --git a/spec/integration/knife/node_from_file_spec.rb b/spec/integration/knife/node_from_file_spec.rb
index 6f7e0780f0..5dcaaaa463 100644
--- a/spec/integration/knife/node_from_file_spec.rb
+++ b/spec/integration/knife/node_from_file_spec.rb
@@ -14,7 +14,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-require "spec_helper"
+require "knife_spec_helper"
require "support/shared/integration/integration_helper"
require "support/shared/context/config"
diff --git a/spec/integration/knife/node_list_spec.rb b/spec/integration/knife/node_list_spec.rb
index 8d3bc29a5a..65c201be3f 100644
--- a/spec/integration/knife/node_list_spec.rb
+++ b/spec/integration/knife/node_list_spec.rb
@@ -14,7 +14,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-require "spec_helper"
+require "knife_spec_helper"
require "support/shared/integration/integration_helper"
require "support/shared/context/config"
diff --git a/spec/integration/knife/node_run_list_add_spec.rb b/spec/integration/knife/node_run_list_add_spec.rb
index f13e584526..72b5328b17 100644
--- a/spec/integration/knife/node_run_list_add_spec.rb
+++ b/spec/integration/knife/node_run_list_add_spec.rb
@@ -14,7 +14,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-require "spec_helper"
+require "knife_spec_helper"
require "support/shared/integration/integration_helper"
require "support/shared/context/config"
diff --git a/spec/integration/knife/node_run_list_remove_spec.rb b/spec/integration/knife/node_run_list_remove_spec.rb
index 55f224b5ac..19aeb81806 100644
--- a/spec/integration/knife/node_run_list_remove_spec.rb
+++ b/spec/integration/knife/node_run_list_remove_spec.rb
@@ -14,7 +14,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-require "spec_helper"
+require "knife_spec_helper"
require "support/shared/integration/integration_helper"
require "support/shared/context/config"
diff --git a/spec/integration/knife/node_run_list_set_spec.rb b/spec/integration/knife/node_run_list_set_spec.rb
index e642afc1ce..d83e74dd04 100644
--- a/spec/integration/knife/node_run_list_set_spec.rb
+++ b/spec/integration/knife/node_run_list_set_spec.rb
@@ -14,7 +14,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-require "spec_helper"
+require "knife_spec_helper"
require "support/shared/integration/integration_helper"
require "support/shared/context/config"
diff --git a/spec/integration/knife/node_show_spec.rb b/spec/integration/knife/node_show_spec.rb
index cf3f166699..be63011ef8 100644
--- a/spec/integration/knife/node_show_spec.rb
+++ b/spec/integration/knife/node_show_spec.rb
@@ -14,7 +14,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-require "spec_helper"
+require "knife_spec_helper"
require "support/shared/integration/integration_helper"
require "support/shared/context/config"
diff --git a/spec/integration/knife/raw_spec.rb b/spec/integration/knife/raw_spec.rb
index ba26def473..8e7e913b02 100644
--- a/spec/integration/knife/raw_spec.rb
+++ b/spec/integration/knife/raw_spec.rb
@@ -15,7 +15,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-require "spec_helper"
+require "knife_spec_helper"
require "support/shared/integration/integration_helper"
require "support/shared/context/config"
require "chef/knife/raw"
diff --git a/spec/integration/knife/redirection_spec.rb b/spec/integration/knife/redirection_spec.rb
index 34d5fe6efc..eea5556cff 100644
--- a/spec/integration/knife/redirection_spec.rb
+++ b/spec/integration/knife/redirection_spec.rb
@@ -15,7 +15,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-require "spec_helper"
+require "knife_spec_helper"
require "tiny_server"
require "support/shared/integration/integration_helper"
require "support/shared/context/config"
diff --git a/spec/integration/knife/role_bulk_delete_spec.rb b/spec/integration/knife/role_bulk_delete_spec.rb
index 6810cebc91..76745d9b6a 100644
--- a/spec/integration/knife/role_bulk_delete_spec.rb
+++ b/spec/integration/knife/role_bulk_delete_spec.rb
@@ -14,7 +14,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-require "spec_helper"
+require "knife_spec_helper"
require "support/shared/integration/integration_helper"
require "support/shared/context/config"
diff --git a/spec/integration/knife/role_create_spec.rb b/spec/integration/knife/role_create_spec.rb
index 80ef1d9a9f..03f59d4b99 100644
--- a/spec/integration/knife/role_create_spec.rb
+++ b/spec/integration/knife/role_create_spec.rb
@@ -14,7 +14,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-require "spec_helper"
+require "knife_spec_helper"
require "support/shared/integration/integration_helper"
require "support/shared/context/config"
diff --git a/spec/integration/knife/role_delete_spec.rb b/spec/integration/knife/role_delete_spec.rb
index c4c6498c51..22b36e5572 100644
--- a/spec/integration/knife/role_delete_spec.rb
+++ b/spec/integration/knife/role_delete_spec.rb
@@ -14,7 +14,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-require "spec_helper"
+require "knife_spec_helper"
require "support/shared/integration/integration_helper"
require "support/shared/context/config"
diff --git a/spec/integration/knife/role_from_file_spec.rb b/spec/integration/knife/role_from_file_spec.rb
index 4a2912935c..ae296122ce 100644
--- a/spec/integration/knife/role_from_file_spec.rb
+++ b/spec/integration/knife/role_from_file_spec.rb
@@ -14,7 +14,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-require "spec_helper"
+require "knife_spec_helper"
require "support/shared/integration/integration_helper"
require "support/shared/context/config"
diff --git a/spec/integration/knife/role_list_spec.rb b/spec/integration/knife/role_list_spec.rb
index 9e4b983698..39aa28783f 100644
--- a/spec/integration/knife/role_list_spec.rb
+++ b/spec/integration/knife/role_list_spec.rb
@@ -14,7 +14,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-require "spec_helper"
+require "knife_spec_helper"
require "support/shared/integration/integration_helper"
require "support/shared/context/config"
diff --git a/spec/integration/knife/role_show_spec.rb b/spec/integration/knife/role_show_spec.rb
index dfa989bf69..a4ecea1d61 100644
--- a/spec/integration/knife/role_show_spec.rb
+++ b/spec/integration/knife/role_show_spec.rb
@@ -14,7 +14,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-require "spec_helper"
+require "knife_spec_helper"
require "support/shared/integration/integration_helper"
require "support/shared/context/config"
diff --git a/spec/integration/knife/search_node_spec.rb b/spec/integration/knife/search_node_spec.rb
index 8eaa30f7fa..9e7935b83c 100644
--- a/spec/integration/knife/search_node_spec.rb
+++ b/spec/integration/knife/search_node_spec.rb
@@ -14,7 +14,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-require "spec_helper"
+require "knife_spec_helper"
require "support/shared/integration/integration_helper"
require "support/shared/context/config"
diff --git a/spec/integration/knife/show_spec.rb b/spec/integration/knife/show_spec.rb
index 4bee492e7b..6913494916 100644
--- a/spec/integration/knife/show_spec.rb
+++ b/spec/integration/knife/show_spec.rb
@@ -15,7 +15,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-require "spec_helper"
+require "knife_spec_helper"
require "support/shared/integration/integration_helper"
require "support/shared/context/config"
require "chef/knife/show"
diff --git a/spec/integration/knife/upload_spec.rb b/spec/integration/knife/upload_spec.rb
index 37cfcefa32..e4bb44ad7e 100644
--- a/spec/integration/knife/upload_spec.rb
+++ b/spec/integration/knife/upload_spec.rb
@@ -15,7 +15,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-require "spec_helper"
+require "knife_spec_helper"
require "support/shared/integration/integration_helper"
require "chef/knife/upload"
require "chef/knife/diff"
diff --git a/spec/knife_spec_helper.rb b/spec/knife_spec_helper.rb
new file mode 100644
index 0000000000..fd40f4002e
--- /dev/null
+++ b/spec/knife_spec_helper.rb
@@ -0,0 +1,245 @@
+#
+# Author:: Adam Jacob (<adam@chef.io>)
+# Copyright:: Copyright (c) Chef Software Inc.
+# License:: Apache License, Version 2.0
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+# If you need to add anything in here, don't.
+# Add it to one of the files in spec/support
+
+# Abuse ruby's constant lookup to avoid undefined constant errors
+
+$LOAD_PATH.unshift File.expand_path("..", __dir__)
+$LOAD_PATH.unshift File.expand_path("../../chef-config/lib", __dir__)
+$LOAD_PATH.unshift File.expand_path("../../chef-utils/lib", __dir__)
+
+require "rubygems"
+require "rspec/mocks"
+require "rexml/document"
+require "webmock/rspec"
+
+require "chef/knife"
+
+# cwd is knife/
+Dir["lib/chef/knife/**/*.rb"]
+ .map { |f| f.gsub("lib/", "") }
+ .map { |f| f.gsub(/\.rb$/, "") }
+ .each { |f| require f }
+
+require "chef/resource_resolver"
+require "chef/provider_resolver"
+
+require "chef/mixins"
+require "chef/dsl"
+
+require "chef/shell"
+require "chef/util/file_edit"
+
+require "chef/config"
+
+require "chef/chef_fs/file_system_cache"
+
+require "chef/api_client_v1"
+
+require "chef/mixin/versioned_api"
+require "chef/server_api_versions"
+
+# MPTD relevant for knife?
+if ENV["CHEF_FIPS"] == "1"
+ Chef::Config.init_openssl
+end
+
+# If you want to load anything into the testing environment
+# without versioning it, add it to spec/support/local_gems.rb
+require "spec/support/local_gems" if File.exist?(File.join(File.dirname(__FILE__), "support", "local_gems.rb"))
+
+# Explicitly require spec helpers that need to load first
+require "spec/support/platform_helpers"
+require "spec/support/shared/unit/mock_shellout"
+require "spec/support/recipe_dsl_helper"
+
+# MPTD - I had to add each of these manually, but I'm not clear why they were
+# _not_ required before splitting the gem.
+require "spec/support/key_helpers"
+require "spec/support/shared/unit/knife_shared"
+require "spec/support/shared/functional/knife"
+require "spec/support/shared/integration/knife_support"
+require "spec/support/shared/matchers/exit_with_code"
+require "spec/support/shared/matchers/match_environment_variable"
+
+# Autoloads support files
+# Excludes support/platforms by default
+# Do not change the gsub.
+Dir["spec/support/**/*.rb"]
+ .reject { |f| f =~ %r{^spec/support/platforms} }
+ .reject { |f| f =~ %r{^spec/support/pedant} }
+ .map { |f| f.gsub(/.rb$/, "") }
+ .map { |f| f.gsub(%r{spec/}, "") }
+ .each { |f| require f }
+
+OHAI_SYSTEM = Ohai::System.new
+OHAI_SYSTEM.all_plugins(["platform", "hostname", "languages/powershell", "uptime"])
+
+test_node = Chef::Node.new
+test_node.automatic["os"] = (OHAI_SYSTEM["os"] || "unknown_os").dup.freeze
+test_node.automatic["platform_family"] = (OHAI_SYSTEM["platform_family"] || "unknown_platform_family").dup.freeze
+test_node.automatic["platform"] = (OHAI_SYSTEM["platform"] || "unknown_platform").dup.freeze
+test_node.automatic["platform_version"] = (OHAI_SYSTEM["platform_version"] || "unknown_platform_version").dup.freeze
+TEST_NODE = test_node.freeze
+TEST_OS = TEST_NODE["os"]
+TEST_PLATFORM = TEST_NODE["platform"]
+TEST_PLATFORM_VERSION = TEST_NODE["platform_version"]
+TEST_PLATFORM_FAMILY = TEST_NODE["platform_family"]
+
+provider_priority_map ||= nil
+resource_priority_map ||= nil
+provider_handler_map ||= nil
+resource_handler_map ||= nil
+
+class UnexpectedSystemExit < RuntimeError
+ def self.from(system_exit)
+ new(system_exit.message).tap { |e| e.set_backtrace(system_exit.backtrace) }
+ end
+end
+
+RSpec.configure do |config|
+ config.include(RSpec::Matchers)
+ config.include(MockShellout::RSpec)
+ config.filter_run focus: true
+ config.filter_run_excluding external: true
+ config.raise_on_warning = true
+
+ # Explicitly disable :should syntax
+ # And set max_formatted_output_length to nil to prevent RSpec from doing truncation.
+ config.expect_with :rspec do |c|
+ c.syntax = :expect
+ c.max_formatted_output_length = nil
+ end
+ config.mock_with :rspec do |c|
+ c.syntax = :expect
+ c.allow_message_expectations_on_nil = false
+ end
+
+ # TODO - which if any of these filters apply to knife tests?
+ #
+ # Only run these tests on platforms that are also chef workstations
+ config.filter_run_excluding :workstation if solaris? || aix?
+
+ # Tests that randomly fail, but may have value.
+ config.filter_run_excluding volatile: true
+ config.filter_run_excluding volatile_on_solaris: true if solaris?
+ config.filter_run_excluding volatile_from_verify: false
+
+ config.filter_run_excluding skip_buildkite: true if ENV["BUILDKITE"]
+
+ config.filter_run_excluding windows_only: true unless windows?
+ config.filter_run_excluding unix_only: true unless unix?
+
+ # check for particular binaries we need
+
+ running_platform_arch = `uname -m`.strip unless windows?
+
+ config.filter_run_excluding arch: lambda { |target_arch|
+ running_platform_arch != target_arch
+ }
+
+ config.run_all_when_everything_filtered = true
+
+ config.before(:each) do
+ # it'd be nice to run this with connections blocked or only to localhost, but we do make lots
+ # of real connections, so cannot. we reset it to allow connections every time to avoid
+ # tests setting connections to be disabled and that state leaking into other tests.
+ WebMock.allow_net_connect!
+ Chef.reset!
+ Chef::ChefFS::FileSystemCache.instance.reset!
+ Chef::Config.reset
+ Chef::Log.setup!
+ Chef::ServerAPIVersions.instance.reset!
+ Chef::Config[:log_level] = :fatal
+ Chef::Log.level(Chef::Config[:log_level])
+
+ # By default, treat deprecation warnings as errors in tests.
+ # and set environment variable so the setting persists in child processes
+ Chef::Config.treat_deprecation_warnings_as_errors(true)
+ ENV["CHEF_TREAT_DEPRECATION_WARNINGS_AS_ERRORS"] = "1"
+ end
+
+ # This bit of jankiness guards against specs which accidentally drop privs when running as
+ # root -- which are nearly impossible to debug and so we bail out very hard if this
+ # condition ever happens. If a spec stubs Process.[e]uid this can throw a false positive
+ # which the spec must work around by unmocking Process.[e]uid to and_call_original in its
+ # after block.
+ # Should not be a problem with knife which does not escalate local privs, but
+ # it seems wise to continue to guard against.
+ if Process.euid == 0 && Process.uid == 0
+ config.after(:each) do
+ if Process.uid != 0
+ RSpec.configure { |c| c.fail_fast = true }
+ raise "rspec was invoked as root, but the last test dropped real uid to #{Process.uid}"
+ end
+ if Process.euid != 0
+ RSpec.configure { |c| c.fail_fast = true }
+ raise "rspec was invoked as root, but the last test dropped effective uid to #{Process.euid}"
+ end
+ end
+ end
+
+ # raise if anyone commits any test to CI with :focus set on it
+ if ENV["CI"]
+ config.before(:example, :focus) do
+ raise "This example was committed with `:focus` and should not have been"
+ end
+ end
+
+ config.before(:suite) do
+ ARGV.clear
+ end
+
+ # Protect Rspec from accidental exit(0) causing rspec to terminate without error
+ config.around(:example) do |ex|
+ ex.run
+ rescue SystemExit => e
+ raise UnexpectedSystemExit.from(e)
+
+ end
+end
+
+require "webrick/utils"
+# Webrick uses a centralized/synchronized timeout manager. It works by
+# starting a thread to check for timeouts on an interval. The timeout
+# checker thread cannot be stopped or canceled in any easy way, and it
+# makes calls to Time.new, which fail when rspec is in the process of
+# creating a method stub for that method. Since our tests don't rely on
+# any timeout behavior enforced by webrick, disable the timeout manager
+# via a monkey patch.
+#
+# Hopefully this fails loudly if the webrick code should change. As of this
+# writing, the relevant code is in webrick/utils, which can be located on
+# your system with:
+#
+# $ gem which webrick/utils
+module WEBrick
+ module Utils
+ class TimeoutHandler
+ def initialize; end
+
+ def register(*args); end
+
+ def cancel(*args); end
+ end
+ end
+end
+
+# Enough stuff needs json serialization that I'm just adding it here for equality asserts
+require "chef/json_compat"
diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb
index 83cec749a7..2924b2abdb 100644
--- a/spec/spec_helper.rb
+++ b/spec/spec_helper.rb
@@ -35,12 +35,6 @@ require "rexml/document"
require "webmock/rspec"
require "chef"
-require "chef/knife"
-
-Dir["lib/chef/knife/**/*.rb"]
- .map { |f| f.gsub("lib/", "") }
- .map { |f| f.gsub(/\.rb$/, "") }
- .each { |f| require f }
require "chef/resource_resolver"
require "chef/provider_resolver"
@@ -82,6 +76,7 @@ require "spec/support/recipe_dsl_helper"
Dir["spec/support/**/*.rb"]
.reject { |f| f =~ %r{^spec/support/platforms} }
.reject { |f| f =~ %r{^spec/support/pedant} }
+ .reject { |f| f =~ %r{^spec/support/shared/integration/knife_support} }
.map { |f| f.gsub(/.rb$/, "") }
.map { |f| f.gsub(%r{spec/}, "") }
.each { |f| require f }
@@ -232,6 +227,14 @@ RSpec.configure do |config|
Chef.reset!
+ # Hack warning:
+ #
+ # Something across gem_installer_spec and mixlib_cli specs are polluting gem state so that the 'unmockening' test in rubygems_spec fails.
+ # This works around that until we can understand root cause.
+ #
+ # To explore the minimal test case around that and see more detailed notes, see branch `mp/broken-gems`
+ Gem.clear_paths
+
Chef::ChefFS::FileSystemCache.instance.reset!
Chef::Config.reset
diff --git a/spec/support/lib/chef/resource/with_state.rb b/spec/support/lib/chef/resource/with_state.rb
index 98e4033e01..1977fb3f6a 100644
--- a/spec/support/lib/chef/resource/with_state.rb
+++ b/spec/support/lib/chef/resource/with_state.rb
@@ -16,7 +16,6 @@
# limitations under the License.
#
-require "chef/knife"
require "chef/json_compat"
class Chef
diff --git a/spec/support/lib/chef/resource/zen_follower.rb b/spec/support/lib/chef/resource/zen_follower.rb
index 44de913f8b..c7d01dcebb 100644
--- a/spec/support/lib/chef/resource/zen_follower.rb
+++ b/spec/support/lib/chef/resource/zen_follower.rb
@@ -15,7 +15,6 @@
# limitations under the License.
#
-require "chef/knife"
require "chef/json_compat"
class Chef
diff --git a/spec/support/lib/chef/resource/zen_master.rb b/spec/support/lib/chef/resource/zen_master.rb
index ba2f950bed..0e0853d0b3 100644
--- a/spec/support/lib/chef/resource/zen_master.rb
+++ b/spec/support/lib/chef/resource/zen_master.rb
@@ -16,7 +16,6 @@
# limitations under the License.
#
-require "chef/knife"
require "chef/json_compat"
class Chef
diff --git a/spec/support/platform_helpers.rb b/spec/support/platform_helpers.rb
index 83f2fcf172..4cc9943709 100644
--- a/spec/support/platform_helpers.rb
+++ b/spec/support/platform_helpers.rb
@@ -2,6 +2,8 @@ require "fcntl"
require "chef/mixin/shell_out"
require "ohai/mixin/http_helper"
require "ohai/mixin/gce_metadata"
+# MPTD - why has nobody had to do this before now?
+require "spec/support/chef_helpers"
class ShellHelpers
extend Chef::Mixin::ShellOut
diff --git a/spec/support/shared/integration/integration_helper.rb b/spec/support/shared/integration/integration_helper.rb
index 41f2b46995..c42a04004a 100644
--- a/spec/support/shared/integration/integration_helper.rb
+++ b/spec/support/shared/integration/integration_helper.rb
@@ -22,7 +22,6 @@ require "fileutils"
require "chef/config"
require "chef/json_compat"
require "chef/server_api"
-require "support/shared/integration/knife_support"
require "cheffish/rspec/chef_run_support"
module Cheffish
diff --git a/spec/unit/application/knife_spec.rb b/spec/unit/application/knife_spec.rb
index bce6b19366..ad705ab1e5 100644
--- a/spec/unit/application/knife_spec.rb
+++ b/spec/unit/application/knife_spec.rb
@@ -15,7 +15,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-require "spec_helper"
+require "knife_spec_helper"
require "#{CHEF_SPEC_DATA}/knife_subcommand/test_yourself"
describe Chef::Application::Knife do
diff --git a/spec/unit/knife/bootstrap/chef_vault_handler_spec.rb b/spec/unit/knife/bootstrap/chef_vault_handler_spec.rb
index 4d36208be0..a4d007611e 100644
--- a/spec/unit/knife/bootstrap/chef_vault_handler_spec.rb
+++ b/spec/unit/knife/bootstrap/chef_vault_handler_spec.rb
@@ -16,7 +16,7 @@
# limitations under the License.
#
-require "spec_helper"
+require "knife_spec_helper"
describe Chef::Knife::Bootstrap::ChefVaultHandler do
diff --git a/spec/unit/knife/bootstrap/client_builder_spec.rb b/spec/unit/knife/bootstrap/client_builder_spec.rb
index 10edd13882..cf6999b093 100644
--- a/spec/unit/knife/bootstrap/client_builder_spec.rb
+++ b/spec/unit/knife/bootstrap/client_builder_spec.rb
@@ -16,7 +16,7 @@
# limitations under the License.
#
-require "spec_helper"
+require "knife_spec_helper"
describe Chef::Knife::Bootstrap::ClientBuilder do
diff --git a/spec/unit/knife/bootstrap/train_connector_spec.rb b/spec/unit/knife/bootstrap/train_connector_spec.rb
index 4c384100fa..0a1091fa8d 100644
--- a/spec/unit/knife/bootstrap/train_connector_spec.rb
+++ b/spec/unit/knife/bootstrap/train_connector_spec.rb
@@ -15,7 +15,7 @@
# limitations under the License.
#
-require "spec_helper"
+require "knife_spec_helper"
require "ostruct"
require "chef/knife/bootstrap/train_connector"
diff --git a/spec/unit/knife/bootstrap_spec.rb b/spec/unit/knife/bootstrap_spec.rb
index a3dd714094..f2f2f48f98 100644
--- a/spec/unit/knife/bootstrap_spec.rb
+++ b/spec/unit/knife/bootstrap_spec.rb
@@ -17,7 +17,7 @@
# limitations under the License.
#
-require "spec_helper"
+require "knife_spec_helper"
Chef::Knife::Bootstrap.load_deps
@@ -185,7 +185,7 @@ describe Chef::Knife::Bootstrap do
context "when :bootstrap_template config is set to a template name" do
let(:bootstrap_template) { "example" }
- let(:builtin_template_path) { File.expand_path(File.join(__dir__, "../../../lib/chef/knife/bootstrap/templates", "example.erb")) }
+ let(:builtin_template_path) { File.expand_path(File.join(__dir__, "../../../knife/lib/chef/knife/bootstrap/templates", "example.erb")) }
let(:chef_config_dir_template_path) { "/knife/chef/config/bootstrap/example.erb" }
diff --git a/spec/unit/knife/client_bulk_delete_spec.rb b/spec/unit/knife/client_bulk_delete_spec.rb
index 435eb888aa..86d69ff4d6 100644
--- a/spec/unit/knife/client_bulk_delete_spec.rb
+++ b/spec/unit/knife/client_bulk_delete_spec.rb
@@ -16,7 +16,7 @@
# limitations under the License.
#
-require "spec_helper"
+require "knife_spec_helper"
describe Chef::Knife::ClientBulkDelete do
let(:stdout_io) { StringIO.new }
diff --git a/spec/unit/knife/client_create_spec.rb b/spec/unit/knife/client_create_spec.rb
index d8b67de101..48a7e71df5 100644
--- a/spec/unit/knife/client_create_spec.rb
+++ b/spec/unit/knife/client_create_spec.rb
@@ -16,7 +16,7 @@
# limitations under the License.
#
-require "spec_helper"
+require "knife_spec_helper"
Chef::Knife::ClientCreate.load_deps
diff --git a/spec/unit/knife/client_delete_spec.rb b/spec/unit/knife/client_delete_spec.rb
index 41a83b05e4..ec20878ade 100644
--- a/spec/unit/knife/client_delete_spec.rb
+++ b/spec/unit/knife/client_delete_spec.rb
@@ -16,7 +16,7 @@
# limitations under the License.
#
-require "spec_helper"
+require "knife_spec_helper"
describe Chef::Knife::ClientDelete do
before(:each) do
diff --git a/spec/unit/knife/client_edit_spec.rb b/spec/unit/knife/client_edit_spec.rb
index e7c9030883..03ac450b3e 100644
--- a/spec/unit/knife/client_edit_spec.rb
+++ b/spec/unit/knife/client_edit_spec.rb
@@ -16,7 +16,7 @@
# limitations under the License.
#
-require "spec_helper"
+require "knife_spec_helper"
require "chef/api_client_v1"
describe Chef::Knife::ClientEdit do
diff --git a/spec/unit/knife/client_list_spec.rb b/spec/unit/knife/client_list_spec.rb
index d1b379a787..b6a205e6b1 100644
--- a/spec/unit/knife/client_list_spec.rb
+++ b/spec/unit/knife/client_list_spec.rb
@@ -16,7 +16,7 @@
# limitations under the License.
#
-require "spec_helper"
+require "knife_spec_helper"
describe Chef::Knife::ClientList do
before(:each) do
diff --git a/spec/unit/knife/client_reregister_spec.rb b/spec/unit/knife/client_reregister_spec.rb
index 6b6519d44f..f1217edee4 100644
--- a/spec/unit/knife/client_reregister_spec.rb
+++ b/spec/unit/knife/client_reregister_spec.rb
@@ -16,7 +16,7 @@
# limitations under the License.
#
-require "spec_helper"
+require "knife_spec_helper"
describe Chef::Knife::ClientReregister do
before(:each) do
diff --git a/spec/unit/knife/client_show_spec.rb b/spec/unit/knife/client_show_spec.rb
index 47b4b6ccb0..39928a6289 100644
--- a/spec/unit/knife/client_show_spec.rb
+++ b/spec/unit/knife/client_show_spec.rb
@@ -16,7 +16,7 @@
# limitations under the License.
#
-require "spec_helper"
+require "knife_spec_helper"
describe Chef::Knife::ClientShow do
before(:each) do
diff --git a/spec/unit/knife/configure_client_spec.rb b/spec/unit/knife/configure_client_spec.rb
index b104718c89..f88ffb31ed 100644
--- a/spec/unit/knife/configure_client_spec.rb
+++ b/spec/unit/knife/configure_client_spec.rb
@@ -16,7 +16,7 @@
# limitations under the License.
#
-require "spec_helper"
+require "knife_spec_helper"
describe Chef::Knife::ConfigureClient do
before do
diff --git a/spec/unit/knife/configure_spec.rb b/spec/unit/knife/configure_spec.rb
index 7d6c840d1f..f9d1bea8fd 100644
--- a/spec/unit/knife/configure_spec.rb
+++ b/spec/unit/knife/configure_spec.rb
@@ -1,4 +1,4 @@
-require "spec_helper"
+require "knife_spec_helper"
describe Chef::Knife::Configure do
before do
diff --git a/spec/unit/knife/cookbook_bulk_delete_spec.rb b/spec/unit/knife/cookbook_bulk_delete_spec.rb
index 3527d39bd8..52f9c1eeb9 100644
--- a/spec/unit/knife/cookbook_bulk_delete_spec.rb
+++ b/spec/unit/knife/cookbook_bulk_delete_spec.rb
@@ -16,7 +16,7 @@
# limitations under the License.
#
-require "spec_helper"
+require "knife_spec_helper"
describe Chef::Knife::CookbookBulkDelete do
before(:each) do
diff --git a/spec/unit/knife/cookbook_delete_spec.rb b/spec/unit/knife/cookbook_delete_spec.rb
index f2aa7e1be0..b05006f2d3 100644
--- a/spec/unit/knife/cookbook_delete_spec.rb
+++ b/spec/unit/knife/cookbook_delete_spec.rb
@@ -16,7 +16,7 @@
# limitations under the License.
#
-require "spec_helper"
+require "knife_spec_helper"
describe Chef::Knife::CookbookDelete do
before(:each) do
diff --git a/spec/unit/knife/cookbook_download_spec.rb b/spec/unit/knife/cookbook_download_spec.rb
index c8903dea5b..b3dbc81205 100644
--- a/spec/unit/knife/cookbook_download_spec.rb
+++ b/spec/unit/knife/cookbook_download_spec.rb
@@ -16,7 +16,7 @@
# limitations under the License.
#
-require "spec_helper"
+require "knife_spec_helper"
describe Chef::Knife::CookbookDownload do
before(:each) do
diff --git a/spec/unit/knife/cookbook_list_spec.rb b/spec/unit/knife/cookbook_list_spec.rb
index 4cf806c6f0..42c3ef1bfd 100644
--- a/spec/unit/knife/cookbook_list_spec.rb
+++ b/spec/unit/knife/cookbook_list_spec.rb
@@ -16,7 +16,7 @@
# limitations under the License.
#
-require "spec_helper"
+require "knife_spec_helper"
describe Chef::Knife::CookbookList do
before do
diff --git a/spec/unit/knife/cookbook_metadata_from_file_spec.rb b/spec/unit/knife/cookbook_metadata_from_file_spec.rb
index f9bbffae2d..c595aef96f 100644
--- a/spec/unit/knife/cookbook_metadata_from_file_spec.rb
+++ b/spec/unit/knife/cookbook_metadata_from_file_spec.rb
@@ -18,7 +18,7 @@
# limitations under the License.
#
-require "spec_helper"
+require "knife_spec_helper"
describe Chef::Knife::CookbookMetadataFromFile do
before(:each) do
diff --git a/spec/unit/knife/cookbook_metadata_spec.rb b/spec/unit/knife/cookbook_metadata_spec.rb
index 732cf78421..1a274cc6f4 100644
--- a/spec/unit/knife/cookbook_metadata_spec.rb
+++ b/spec/unit/knife/cookbook_metadata_spec.rb
@@ -16,7 +16,7 @@
# limitations under the License.
#
-require "spec_helper"
+require "knife_spec_helper"
describe Chef::Knife::CookbookMetadata do
let(:knife) do
diff --git a/spec/unit/knife/cookbook_show_spec.rb b/spec/unit/knife/cookbook_show_spec.rb
index defc243de3..94e080cb15 100644
--- a/spec/unit/knife/cookbook_show_spec.rb
+++ b/spec/unit/knife/cookbook_show_spec.rb
@@ -16,7 +16,7 @@
# limitations under the License.
#
-require "spec_helper"
+require "knife_spec_helper"
describe Chef::Knife::CookbookShow do
before do
diff --git a/spec/unit/knife/cookbook_upload_spec.rb b/spec/unit/knife/cookbook_upload_spec.rb
index dbed8b8a67..0893f6a6b3 100644
--- a/spec/unit/knife/cookbook_upload_spec.rb
+++ b/spec/unit/knife/cookbook_upload_spec.rb
@@ -17,7 +17,7 @@
# limitations under the License.
#
-require "spec_helper"
+require "knife_spec_helper"
require "chef/cookbook_uploader"
require "timeout"
diff --git a/spec/unit/knife/core/bootstrap_context_spec.rb b/spec/unit/knife/core/bootstrap_context_spec.rb
index a55047a739..79fddc8184 100644
--- a/spec/unit/knife/core/bootstrap_context_spec.rb
+++ b/spec/unit/knife/core/bootstrap_context_spec.rb
@@ -16,7 +16,7 @@
# limitations under the License.
#
-require "spec_helper"
+require "knife_spec_helper"
require "chef/knife/core/bootstrap_context"
describe Chef::Knife::Core::BootstrapContext do
diff --git a/spec/unit/knife/core/cookbook_scm_repo_spec.rb b/spec/unit/knife/core/cookbook_scm_repo_spec.rb
index 316cbdfaa6..68a155bbbe 100644
--- a/spec/unit/knife/core/cookbook_scm_repo_spec.rb
+++ b/spec/unit/knife/core/cookbook_scm_repo_spec.rb
@@ -16,7 +16,7 @@
# limitations under the License.
#
-require "spec_helper"
+require "knife_spec_helper"
require "chef/knife/core/cookbook_scm_repo"
describe Chef::Knife::CookbookSCMRepo do
diff --git a/spec/unit/cookbook_site_streaming_uploader_spec.rb b/spec/unit/knife/core/cookbook_site_streaming_uploader_spec.rb
index af714094d0..f40626990a 100644
--- a/spec/unit/cookbook_site_streaming_uploader_spec.rb
+++ b/spec/unit/knife/core/cookbook_site_streaming_uploader_spec.rb
@@ -16,9 +16,9 @@
# limitations under the License.
#
-require "spec_helper"
+require "knife_spec_helper"
-require "chef/cookbook_site_streaming_uploader"
+require "chef/knife/core/cookbook_site_streaming_uploader"
class FakeTempfile
def initialize(basename)
@@ -33,10 +33,10 @@ class FakeTempfile
end
-describe Chef::CookbookSiteStreamingUploader do
+describe Chef::Knife::Core::CookbookSiteStreamingUploader do
+ let(:subject) { Chef::Knife::Core::CookbookSiteStreamingUploader }
describe "create_build_dir" do
-
before(:each) do
@cookbook_repo = File.expand_path(File.join(CHEF_SPEC_DATA, "cookbooks"))
@loader = Chef::CookbookLoader.new(@cookbook_repo)
@@ -51,7 +51,7 @@ describe Chef::CookbookSiteStreamingUploader do
expect(Tempfile).to receive(:new).with("chef-#{cookbook.name}-build").and_return(FakeTempfile.new("chef-#{cookbook.name}-build"))
expect(FileUtils).to receive(:mkdir_p).exactly(files_count + 1).times
expect(FileUtils).to receive(:cp).exactly(files_count).times
- Chef::CookbookSiteStreamingUploader.create_build_dir(cookbook)
+ subject.create_build_dir(cookbook)
end
end # create_build_dir
@@ -68,17 +68,17 @@ describe Chef::CookbookSiteStreamingUploader do
it "should send an http request" do
expect_any_instance_of(Net::HTTP).to receive(:request)
- Chef::CookbookSiteStreamingUploader.make_request(:post, @uri, "bill", @secret_filename)
+ subject.make_request(:post, @uri, "bill", @secret_filename)
end
it "should read the private key file" do
expect(File).to receive(:read).with(@secret_filename).and_return(@rsa_key)
- Chef::CookbookSiteStreamingUploader.make_request(:post, @uri, "bill", @secret_filename)
+ subject.make_request(:post, @uri, "bill", @secret_filename)
end
it "should add the authentication signed header" do
expect_any_instance_of(Mixlib::Authentication::SigningObject).to receive(:sign).and_return({})
- Chef::CookbookSiteStreamingUploader.make_request(:post, @uri, "bill", @secret_filename)
+ subject.make_request(:post, @uri, "bill", @secret_filename)
end
it "should be able to send post requests" do
@@ -87,7 +87,7 @@ describe Chef::CookbookSiteStreamingUploader do
expect(Net::HTTP::Post).to receive(:new).once.and_return(post)
expect(Net::HTTP::Put).not_to receive(:new)
expect(Net::HTTP::Get).not_to receive(:new)
- Chef::CookbookSiteStreamingUploader.make_request(:post, @uri, "bill", @secret_filename)
+ subject.make_request(:post, @uri, "bill", @secret_filename)
end
it "should be able to send put requests" do
@@ -96,23 +96,23 @@ describe Chef::CookbookSiteStreamingUploader do
expect(Net::HTTP::Post).not_to receive(:new)
expect(Net::HTTP::Put).to receive(:new).once.and_return(put)
expect(Net::HTTP::Get).not_to receive(:new)
- Chef::CookbookSiteStreamingUploader.make_request(:put, @uri, "bill", @secret_filename)
+ subject.make_request(:put, @uri, "bill", @secret_filename)
end
it "should be able to receive files to attach as argument" do
- Chef::CookbookSiteStreamingUploader.make_request(:put, @uri, "bill", @secret_filename, {
+ subject.make_request(:put, @uri, "bill", @secret_filename, {
myfile: File.new(File.join(CHEF_SPEC_DATA, "config.rb")), # a dummy file
})
end
it "should be able to receive strings to attach as argument" do
- Chef::CookbookSiteStreamingUploader.make_request(:put, @uri, "bill", @secret_filename, {
+ subject.make_request(:put, @uri, "bill", @secret_filename, {
mystring: "Lorem ipsum",
})
end
it "should be able to receive strings and files as argument at the same time" do
- Chef::CookbookSiteStreamingUploader.make_request(:put, @uri, "bill", @secret_filename, {
+ subject.make_request(:put, @uri, "bill", @secret_filename, {
myfile1: File.new(File.join(CHEF_SPEC_DATA, "config.rb")),
mystring1: "Lorem ipsum",
myfile2: File.new(File.join(CHEF_SPEC_DATA, "config.rb")),
@@ -125,11 +125,11 @@ describe Chef::CookbookSiteStreamingUploader do
describe "StreamPart" do
before(:each) do
@file = File.new(File.join(CHEF_SPEC_DATA, "config.rb"))
- @stream_part = Chef::CookbookSiteStreamingUploader::StreamPart.new(@file, File.size(@file))
+ @stream_part = Chef::Knife::Core::CookbookSiteStreamingUploader::StreamPart.new(@file, File.size(@file))
end
it "should create a StreamPart" do
- expect(@stream_part).to be_instance_of(Chef::CookbookSiteStreamingUploader::StreamPart)
+ expect(@stream_part).to be_instance_of(Chef::Knife::Core::CookbookSiteStreamingUploader::StreamPart)
end
it "should expose its size" do
@@ -147,11 +147,11 @@ describe Chef::CookbookSiteStreamingUploader do
describe "StringPart" do
before(:each) do
@str = "What a boring string"
- @string_part = Chef::CookbookSiteStreamingUploader::StringPart.new(@str)
+ @string_part = Chef::Knife::Core::CookbookSiteStreamingUploader::StringPart.new(@str)
end
it "should create a StringPart" do
- expect(@string_part).to be_instance_of(Chef::CookbookSiteStreamingUploader::StringPart)
+ expect(@string_part).to be_instance_of(Chef::Knife::Core::CookbookSiteStreamingUploader::StringPart)
end
it "should expose its size" do
@@ -168,15 +168,15 @@ describe Chef::CookbookSiteStreamingUploader do
before(:each) do
@string1 = "stream1"
@string2 = "stream2"
- @stream1 = Chef::CookbookSiteStreamingUploader::StringPart.new(@string1)
- @stream2 = Chef::CookbookSiteStreamingUploader::StringPart.new(@string2)
+ @stream1 = Chef::Knife::Core::CookbookSiteStreamingUploader::StringPart.new(@string1)
+ @stream2 = Chef::Knife::Core::CookbookSiteStreamingUploader::StringPart.new(@string2)
@parts = [ @stream1, @stream2 ]
- @multipart_stream = Chef::CookbookSiteStreamingUploader::MultipartStream.new(@parts)
+ @multipart_stream = Chef::Knife::Core::CookbookSiteStreamingUploader::MultipartStream.new(@parts)
end
it "should create a MultipartStream" do
- expect(@multipart_stream).to be_instance_of(Chef::CookbookSiteStreamingUploader::MultipartStream)
+ expect(@multipart_stream).to be_instance_of(Chef::Knife::Core::CookbookSiteStreamingUploader::MultipartStream)
end
it "should expose its size" do
diff --git a/spec/unit/knife/core/gem_glob_loader_spec.rb b/spec/unit/knife/core/gem_glob_loader_spec.rb
index f0c29b86a0..a6a94cc57a 100644
--- a/spec/unit/knife/core/gem_glob_loader_spec.rb
+++ b/spec/unit/knife/core/gem_glob_loader_spec.rb
@@ -15,7 +15,7 @@
# limitations under the License.
#
-require "spec_helper"
+require "knife_spec_helper"
describe Chef::Knife::SubcommandLoader::GemGlobLoader do
let(:loader) { Chef::Knife::SubcommandLoader::GemGlobLoader.new(File.join(CHEF_SPEC_DATA, "knife-site-subcommands")) }
@@ -24,11 +24,11 @@ describe Chef::Knife::SubcommandLoader::GemGlobLoader do
before do
allow(ChefUtils).to receive(:windows?) { false }
- Chef::Util::PathHelper.class_variable_set(:@@home_dir, home)
+ ChefConfig::PathHelper.class_variable_set(:@@home_dir, home)
end
after do
- Chef::Util::PathHelper.class_variable_set(:@@home_dir, nil)
+ ChefConfig::PathHelper.class_variable_set(:@@home_dir, nil)
end
it "builds a list of the core subcommand file require paths" do
@@ -62,12 +62,42 @@ describe Chef::Knife::SubcommandLoader::GemGlobLoader do
expect(loader).to receive(:find_subcommands_via_dirglob).and_return({})
expect(loader.subcommand_files.select { |file| file.include?("knife-ec2") }.sort).to eq(gem_files)
end
+ it "excludes knife version file if loaded from a gem" do
+ gems = [ double("knife-ec2-0.5.12") ]
+ gem_files = [
+ "/usr/lib/ruby/gems/knife-ec2-0.5.12/lib/chef/knife/ec2_base.rb",
+ "/usr/lib/ruby/gems/knife-ec2-0.5.12/lib/chef/knife/ec2_otherstuff.rb",
+ "/usr/lib/ruby/gems/knife-ec2-0.5.12/lib/chef/knife/version.rb",
+ ]
+ expected_files = [
+ "/usr/lib/ruby/gems/knife-ec2-0.5.12/lib/chef/knife/ec2_base.rb",
+ "/usr/lib/ruby/gems/knife-ec2-0.5.12/lib/chef/knife/ec2_otherstuff.rb"
+ ]
+
+ expect($LOAD_PATH).to receive(:map).and_return([])
+ if Gem::Specification.respond_to? :latest_specs
+ expect(Gem::Specification).to receive(:latest_specs).with(true).and_return(gems)
+ expect(gems[0]).to receive(:matches_for_glob).with(%r{chef/knife/\*\.rb\{(.*),\.rb,(.*)\}}).and_return(gem_files)
+ else
+ expect(Gem.source_index).to receive(:latest_specs).with(true).and_return(gems)
+ expect(gems[0]).to receive(:require_paths).twice.and_return(["lib"])
+ expect(gems[0]).to receive(:full_gem_path).and_return("/usr/lib/ruby/gems/knife-ec2-0.5.12")
+ expect(Dir).to receive(:[]).with("/usr/lib/ruby/gems/knife-ec2-0.5.12/lib/chef/knife/*.rb").and_return(gem_files)
+ end
+ expect(loader).to receive(:find_subcommands_via_dirglob).and_return({})
+ expect(loader.subcommand_files.select { |file| file.include?("knife-ec2") }.sort).to eq(expected_files)
+ end
it "finds files using a dirglob when rubygems is not available" do
expect(loader.find_subcommands_via_dirglob).to include("chef/knife/node_create")
loader.find_subcommands_via_dirglob.each_value { |abs_path| expect(abs_path).to match(%r{chef/knife/.+}) }
end
+ it "excludes chef/knife/version.rb using a dirglob when rubygems is not available" do
+ expect(loader.find_subcommands_via_dirglob).to_not include("chef/knife/version")
+ loader.find_subcommands_via_dirglob.each_value { |abs_path| expect(abs_path).to match(%r{chef/knife/.+}) }
+ end
+
it "finds user-specific subcommands in the user's ~/.chef directory" do
expected_command = File.join(home, ".chef", "plugins", "knife", "example_home_subcommand.rb")
expect(loader.site_subcommands).to include(expected_command)
@@ -86,6 +116,9 @@ describe Chef::Knife::SubcommandLoader::GemGlobLoader do
# source tree of the "primary" chef install, it can be loaded and cause an
# error. We also want to ensure that we only load builtin commands from the
# "primary" chef install.
+ #
+ # NOTE - we need to revisit coverage now that we're moving knife to its own gem;
+ # or remove this test if it's no longer a supported scenario.
context "when a different version of chef is also installed as a gem" do
let(:all_found_commands) do
diff --git a/spec/unit/knife/core/hashed_command_loader_spec.rb b/spec/unit/knife/core/hashed_command_loader_spec.rb
index c88656945b..305c928309 100644
--- a/spec/unit/knife/core/hashed_command_loader_spec.rb
+++ b/spec/unit/knife/core/hashed_command_loader_spec.rb
@@ -15,7 +15,7 @@
# limitations under the License.
#
-require "spec_helper"
+require "knife_spec_helper"
describe Chef::Knife::SubcommandLoader::HashedCommandLoader do
before do
diff --git a/spec/unit/knife/core/node_editor_spec.rb b/spec/unit/knife/core/node_editor_spec.rb
index d8e5c86d2c..f4fbe76695 100644
--- a/spec/unit/knife/core/node_editor_spec.rb
+++ b/spec/unit/knife/core/node_editor_spec.rb
@@ -16,7 +16,7 @@
# limitations under the License.
#
-require "spec_helper"
+require "knife_spec_helper"
require "chef/knife/core/node_editor"
describe Chef::Knife::NodeEditor do
diff --git a/spec/unit/knife/core/object_loader_spec.rb b/spec/unit/knife/core/object_loader_spec.rb
index 0dcabff46d..00a9ed4553 100644
--- a/spec/unit/knife/core/object_loader_spec.rb
+++ b/spec/unit/knife/core/object_loader_spec.rb
@@ -17,7 +17,7 @@
# limitations under the License.
#
-require "spec_helper"
+require "knife_spec_helper"
require "chef/knife/core/object_loader"
describe Chef::Knife::Core::ObjectLoader do
diff --git a/spec/unit/knife/core/status_presenter_spec.rb b/spec/unit/knife/core/status_presenter_spec.rb
index 377c581bfc..a3f297045b 100644
--- a/spec/unit/knife/core/status_presenter_spec.rb
+++ b/spec/unit/knife/core/status_presenter_spec.rb
@@ -14,7 +14,7 @@
# limitations under the License.
#
-require "spec_helper"
+require "knife_spec_helper"
describe Chef::Knife::Core::StatusPresenter do
describe "#summarize_json" do
diff --git a/spec/unit/knife/core/subcommand_loader_spec.rb b/spec/unit/knife/core/subcommand_loader_spec.rb
index e8bc045946..ad53a422fe 100644
--- a/spec/unit/knife/core/subcommand_loader_spec.rb
+++ b/spec/unit/knife/core/subcommand_loader_spec.rb
@@ -15,7 +15,7 @@
# limitations under the License.
#
-require "spec_helper"
+require "knife_spec_helper"
describe Chef::Knife::SubcommandLoader do
let(:loader) { Chef::Knife::SubcommandLoader.new(File.join(CHEF_SPEC_DATA, "knife-site-subcommands")) }
diff --git a/spec/unit/knife/core/ui_spec.rb b/spec/unit/knife/core/ui_spec.rb
index 3bbe799267..d5d09c0fdf 100644
--- a/spec/unit/knife/core/ui_spec.rb
+++ b/spec/unit/knife/core/ui_spec.rb
@@ -19,7 +19,7 @@
# limitations under the License.
#
-require "spec_helper"
+require "knife_spec_helper"
describe Chef::Knife::UI do
before do
diff --git a/spec/unit/knife/core/windows_bootstrap_context_spec.rb b/spec/unit/knife/core/windows_bootstrap_context_spec.rb
index 76b90c955e..1243dd1559 100644
--- a/spec/unit/knife/core/windows_bootstrap_context_spec.rb
+++ b/spec/unit/knife/core/windows_bootstrap_context_spec.rb
@@ -16,7 +16,7 @@
# limitations under the License.
#
-require "spec_helper"
+require "knife_spec_helper"
require "chef/knife/core/windows_bootstrap_context"
describe Chef::Knife::Core::WindowsBootstrapContext do
let(:config) { {} }
diff --git a/spec/unit/knife/data_bag_create_spec.rb b/spec/unit/knife/data_bag_create_spec.rb
index 93082c190e..6700d886fc 100644
--- a/spec/unit/knife/data_bag_create_spec.rb
+++ b/spec/unit/knife/data_bag_create_spec.rb
@@ -17,7 +17,7 @@
# limitations under the License.
#
-require "spec_helper"
+require "knife_spec_helper"
require "tempfile"
describe Chef::Knife::DataBagCreate do
diff --git a/spec/unit/knife/data_bag_edit_spec.rb b/spec/unit/knife/data_bag_edit_spec.rb
index 6ebcaf4945..1be75ba014 100644
--- a/spec/unit/knife/data_bag_edit_spec.rb
+++ b/spec/unit/knife/data_bag_edit_spec.rb
@@ -16,7 +16,7 @@
# limitations under the License.
#
-require "spec_helper"
+require "knife_spec_helper"
require "tempfile"
describe Chef::Knife::DataBagEdit do
diff --git a/spec/unit/knife/data_bag_from_file_spec.rb b/spec/unit/knife/data_bag_from_file_spec.rb
index 12211eede3..4d7c506d0d 100644
--- a/spec/unit/knife/data_bag_from_file_spec.rb
+++ b/spec/unit/knife/data_bag_from_file_spec.rb
@@ -16,7 +16,7 @@
# limitations under the License.
#
-require "spec_helper"
+require "knife_spec_helper"
require "chef/data_bag_item"
require "chef/encrypted_data_bag_item"
diff --git a/spec/unit/knife/data_bag_secret_options_spec.rb b/spec/unit/knife/data_bag_secret_options_spec.rb
index e8f99c3f79..9946b82110 100644
--- a/spec/unit/knife/data_bag_secret_options_spec.rb
+++ b/spec/unit/knife/data_bag_secret_options_spec.rb
@@ -16,7 +16,7 @@
# limitations under the License.
#
-require "spec_helper"
+require "knife_spec_helper"
require "chef/knife"
require "chef/config"
require "tempfile"
diff --git a/spec/unit/knife/data_bag_show_spec.rb b/spec/unit/knife/data_bag_show_spec.rb
index 2b806b8a65..0cc0bdf766 100644
--- a/spec/unit/knife/data_bag_show_spec.rb
+++ b/spec/unit/knife/data_bag_show_spec.rb
@@ -17,7 +17,7 @@
# limitations under the License.
#
-require "spec_helper"
+require "knife_spec_helper"
require "chef/data_bag_item"
require "chef/encrypted_data_bag_item"
diff --git a/spec/unit/knife/environment_compare_spec.rb b/spec/unit/knife/environment_compare_spec.rb
index bfaeed0c82..001c725624 100644
--- a/spec/unit/knife/environment_compare_spec.rb
+++ b/spec/unit/knife/environment_compare_spec.rb
@@ -16,7 +16,7 @@
# limitations under the License.
#
-require "spec_helper"
+require "knife_spec_helper"
describe Chef::Knife::EnvironmentCompare do
before(:each) do
diff --git a/spec/unit/knife/environment_create_spec.rb b/spec/unit/knife/environment_create_spec.rb
index d54cab8dc9..0535276e9c 100644
--- a/spec/unit/knife/environment_create_spec.rb
+++ b/spec/unit/knife/environment_create_spec.rb
@@ -16,7 +16,7 @@
# limitations under the License.
#
-require "spec_helper"
+require "knife_spec_helper"
describe Chef::Knife::EnvironmentCreate do
before(:each) do
diff --git a/spec/unit/knife/environment_delete_spec.rb b/spec/unit/knife/environment_delete_spec.rb
index 643bf1cc13..e088f6a791 100644
--- a/spec/unit/knife/environment_delete_spec.rb
+++ b/spec/unit/knife/environment_delete_spec.rb
@@ -16,7 +16,7 @@
# limitations under the License.
#
-require "spec_helper"
+require "knife_spec_helper"
describe Chef::Knife::EnvironmentDelete do
before(:each) do
diff --git a/spec/unit/knife/environment_edit_spec.rb b/spec/unit/knife/environment_edit_spec.rb
index 1feb1c05fd..f05de2cb2f 100644
--- a/spec/unit/knife/environment_edit_spec.rb
+++ b/spec/unit/knife/environment_edit_spec.rb
@@ -16,7 +16,7 @@
# limitations under the License.
#
-require "spec_helper"
+require "knife_spec_helper"
describe Chef::Knife::EnvironmentEdit do
before(:each) do
diff --git a/spec/unit/knife/environment_from_file_spec.rb b/spec/unit/knife/environment_from_file_spec.rb
index 2090ec7bbd..fb9329eb57 100644
--- a/spec/unit/knife/environment_from_file_spec.rb
+++ b/spec/unit/knife/environment_from_file_spec.rb
@@ -17,7 +17,7 @@
# limitations under the License.
#
-require "spec_helper"
+require "knife_spec_helper"
Chef::Knife::EnvironmentFromFile.load_deps
diff --git a/spec/unit/knife/environment_list_spec.rb b/spec/unit/knife/environment_list_spec.rb
index 7bb0e723aa..4f44a93f60 100644
--- a/spec/unit/knife/environment_list_spec.rb
+++ b/spec/unit/knife/environment_list_spec.rb
@@ -16,7 +16,7 @@
# limitations under the License.
#
-require "spec_helper"
+require "knife_spec_helper"
describe Chef::Knife::EnvironmentList do
before(:each) do
diff --git a/spec/unit/knife/environment_show_spec.rb b/spec/unit/knife/environment_show_spec.rb
index 8f67e593bc..536afcc058 100644
--- a/spec/unit/knife/environment_show_spec.rb
+++ b/spec/unit/knife/environment_show_spec.rb
@@ -16,7 +16,7 @@
# limitations under the License.
#
-require "spec_helper"
+require "knife_spec_helper"
describe Chef::Knife::EnvironmentShow do
before(:each) do
diff --git a/spec/unit/knife/key_create_spec.rb b/spec/unit/knife/key_create_spec.rb
index 12826ae7e2..91d3fc0f69 100644
--- a/spec/unit/knife/key_create_spec.rb
+++ b/spec/unit/knife/key_create_spec.rb
@@ -16,7 +16,7 @@
# limitations under the License.
#
-require "spec_helper"
+require "knife_spec_helper"
require "chef/knife/user_key_create"
require "chef/knife/client_key_create"
require "chef/knife/key_create"
diff --git a/spec/unit/knife/key_delete_spec.rb b/spec/unit/knife/key_delete_spec.rb
index fd39c7381a..ff669446bb 100644
--- a/spec/unit/knife/key_delete_spec.rb
+++ b/spec/unit/knife/key_delete_spec.rb
@@ -16,7 +16,7 @@
# limitations under the License.
#
-require "spec_helper"
+require "knife_spec_helper"
require "chef/knife/user_key_delete"
require "chef/knife/client_key_delete"
require "chef/knife/key_delete"
diff --git a/spec/unit/knife/key_edit_spec.rb b/spec/unit/knife/key_edit_spec.rb
index b42503af59..ae58d281b7 100644
--- a/spec/unit/knife/key_edit_spec.rb
+++ b/spec/unit/knife/key_edit_spec.rb
@@ -16,7 +16,7 @@
# limitations under the License.
#
-require "spec_helper"
+require "knife_spec_helper"
require "chef/knife/user_key_edit"
require "chef/knife/client_key_edit"
require "chef/knife/key_edit"
diff --git a/spec/unit/knife/key_helper.rb b/spec/unit/knife/key_helper.rb
index 6dbfb567f4..c58d383703 100644
--- a/spec/unit/knife/key_helper.rb
+++ b/spec/unit/knife/key_helper.rb
@@ -16,7 +16,7 @@
# limitations under the License.
#
-require "spec_helper"
+require "knife_spec_helper"
shared_examples_for "a knife key command" do
let(:stderr) { StringIO.new }
diff --git a/spec/unit/knife/key_list_spec.rb b/spec/unit/knife/key_list_spec.rb
index 51ed73b64f..3cb8a1c58d 100644
--- a/spec/unit/knife/key_list_spec.rb
+++ b/spec/unit/knife/key_list_spec.rb
@@ -16,7 +16,7 @@
# limitations under the License.
#
-require "spec_helper"
+require "knife_spec_helper"
require "chef/knife/user_key_list"
require "chef/knife/client_key_list"
require "chef/knife/key_list"
diff --git a/spec/unit/knife/key_show_spec.rb b/spec/unit/knife/key_show_spec.rb
index 6d1ca2ccc7..ace6dad990 100644
--- a/spec/unit/knife/key_show_spec.rb
+++ b/spec/unit/knife/key_show_spec.rb
@@ -16,7 +16,7 @@
# limitations under the License.
#
-require "spec_helper"
+require "knife_spec_helper"
require "chef/knife/user_key_show"
require "chef/knife/client_key_show"
require "chef/knife/key_show"
diff --git a/spec/unit/knife/node_bulk_delete_spec.rb b/spec/unit/knife/node_bulk_delete_spec.rb
index e23f286999..cf38d542fa 100644
--- a/spec/unit/knife/node_bulk_delete_spec.rb
+++ b/spec/unit/knife/node_bulk_delete_spec.rb
@@ -16,7 +16,7 @@
# limitations under the License.
#
-require "spec_helper"
+require "knife_spec_helper"
describe Chef::Knife::NodeBulkDelete do
before(:each) do
diff --git a/spec/unit/knife/node_delete_spec.rb b/spec/unit/knife/node_delete_spec.rb
index e6c677c041..92932c0b6f 100644
--- a/spec/unit/knife/node_delete_spec.rb
+++ b/spec/unit/knife/node_delete_spec.rb
@@ -16,7 +16,7 @@
# limitations under the License.
#
-require "spec_helper"
+require "knife_spec_helper"
describe Chef::Knife::NodeDelete do
before(:each) do
diff --git a/spec/unit/knife/node_edit_spec.rb b/spec/unit/knife/node_edit_spec.rb
index 7b2ebb5b2c..e89322d415 100644
--- a/spec/unit/knife/node_edit_spec.rb
+++ b/spec/unit/knife/node_edit_spec.rb
@@ -16,7 +16,7 @@
# limitations under the License.
#
-require "spec_helper"
+require "knife_spec_helper"
Chef::Knife::NodeEdit.load_deps
describe Chef::Knife::NodeEdit do
diff --git a/spec/unit/knife/node_environment_set_spec.rb b/spec/unit/knife/node_environment_set_spec.rb
index 6a6d48cc2f..c2d55d0ab1 100644
--- a/spec/unit/knife/node_environment_set_spec.rb
+++ b/spec/unit/knife/node_environment_set_spec.rb
@@ -16,7 +16,7 @@
# limitations under the License.
#
-require "spec_helper"
+require "knife_spec_helper"
describe Chef::Knife::NodeEnvironmentSet do
before(:each) do
diff --git a/spec/unit/knife/node_from_file_spec.rb b/spec/unit/knife/node_from_file_spec.rb
index 00d6dd5d1a..359b9726b6 100644
--- a/spec/unit/knife/node_from_file_spec.rb
+++ b/spec/unit/knife/node_from_file_spec.rb
@@ -16,7 +16,7 @@
# limitations under the License.
#
-require "spec_helper"
+require "knife_spec_helper"
Chef::Knife::NodeFromFile.load_deps
diff --git a/spec/unit/knife/node_list_spec.rb b/spec/unit/knife/node_list_spec.rb
index d594fffc14..baa79cb81f 100644
--- a/spec/unit/knife/node_list_spec.rb
+++ b/spec/unit/knife/node_list_spec.rb
@@ -16,7 +16,7 @@
# limitations under the License.
#
-require "spec_helper"
+require "knife_spec_helper"
describe Chef::Knife::NodeList do
before(:each) do
diff --git a/spec/unit/knife/node_policy_set_spec.rb b/spec/unit/knife/node_policy_set_spec.rb
index 40b1d2617d..5815da29df 100644
--- a/spec/unit/knife/node_policy_set_spec.rb
+++ b/spec/unit/knife/node_policy_set_spec.rb
@@ -16,7 +16,7 @@
# limitations under the License.
#
-require "spec_helper"
+require "knife_spec_helper"
describe Chef::Knife::NodePolicySet do
let(:node) do
diff --git a/spec/unit/knife/node_run_list_add_spec.rb b/spec/unit/knife/node_run_list_add_spec.rb
index 0148711fac..87b75d9818 100644
--- a/spec/unit/knife/node_run_list_add_spec.rb
+++ b/spec/unit/knife/node_run_list_add_spec.rb
@@ -16,7 +16,7 @@
# limitations under the License.
#
-require "spec_helper"
+require "knife_spec_helper"
describe Chef::Knife::NodeRunListAdd do
before(:each) do
diff --git a/spec/unit/knife/node_run_list_remove_spec.rb b/spec/unit/knife/node_run_list_remove_spec.rb
index 1974821728..0eff7c6d27 100644
--- a/spec/unit/knife/node_run_list_remove_spec.rb
+++ b/spec/unit/knife/node_run_list_remove_spec.rb
@@ -16,7 +16,7 @@
# limitations under the License.
#
-require "spec_helper"
+require "knife_spec_helper"
describe Chef::Knife::NodeRunListRemove do
before(:each) do
diff --git a/spec/unit/knife/node_run_list_set_spec.rb b/spec/unit/knife/node_run_list_set_spec.rb
index 6246dfce6a..35fdd63e4d 100644
--- a/spec/unit/knife/node_run_list_set_spec.rb
+++ b/spec/unit/knife/node_run_list_set_spec.rb
@@ -16,7 +16,7 @@
# limitations under the License.
#
-require "spec_helper"
+require "knife_spec_helper"
describe Chef::Knife::NodeRunListSet do
before(:each) do
diff --git a/spec/unit/knife/node_show_spec.rb b/spec/unit/knife/node_show_spec.rb
index 037672501e..c26ae94f40 100644
--- a/spec/unit/knife/node_show_spec.rb
+++ b/spec/unit/knife/node_show_spec.rb
@@ -16,7 +16,7 @@
# limitations under the License.
#
-require "spec_helper"
+require "knife_spec_helper"
describe Chef::Knife::NodeShow do
diff --git a/spec/unit/knife/org_create_spec.rb b/spec/unit/knife/org_create_spec.rb
index 3c33817b55..f45ade2df7 100644
--- a/spec/unit/knife/org_create_spec.rb
+++ b/spec/unit/knife/org_create_spec.rb
@@ -15,7 +15,7 @@
# limitations under the License.
#
-require "spec_helper"
+require "knife_spec_helper"
require "chef/org"
describe Chef::Knife::OrgCreate do
diff --git a/spec/unit/knife/org_delete_spec.rb b/spec/unit/knife/org_delete_spec.rb
index baa102f8c8..33311bd678 100644
--- a/spec/unit/knife/org_delete_spec.rb
+++ b/spec/unit/knife/org_delete_spec.rb
@@ -16,7 +16,7 @@
# limitations under the License.
#
-require "spec_helper"
+require "knife_spec_helper"
require "chef/org"
describe Chef::Knife::OrgDelete do
diff --git a/spec/unit/knife/org_edit_spec.rb b/spec/unit/knife/org_edit_spec.rb
index 05339e8f21..af9dae2c49 100644
--- a/spec/unit/knife/org_edit_spec.rb
+++ b/spec/unit/knife/org_edit_spec.rb
@@ -16,7 +16,7 @@
# limitations under the License.
#
-require "spec_helper"
+require "knife_spec_helper"
describe Chef::Knife::OrgEdit do
let(:knife) { Chef::Knife::OrgEdit.new }
diff --git a/spec/unit/knife/org_list_spec.rb b/spec/unit/knife/org_list_spec.rb
index de77b4b0c7..aa5fca5099 100644
--- a/spec/unit/knife/org_list_spec.rb
+++ b/spec/unit/knife/org_list_spec.rb
@@ -15,7 +15,7 @@
# limitations under the License.
#
-require "spec_helper"
+require "knife_spec_helper"
require "chef/org"
describe Chef::Knife::OrgList do
diff --git a/spec/unit/knife/org_show_spec.rb b/spec/unit/knife/org_show_spec.rb
index 2f5246dd84..364b879a7c 100644
--- a/spec/unit/knife/org_show_spec.rb
+++ b/spec/unit/knife/org_show_spec.rb
@@ -16,7 +16,7 @@
# limitations under the License.
#
-require "spec_helper"
+require "knife_spec_helper"
require "chef/org"
describe Chef::Knife::OrgShow do
diff --git a/spec/unit/knife/org_user_add_spec.rb b/spec/unit/knife/org_user_add_spec.rb
index 20e28d6919..72ee1d0607 100644
--- a/spec/unit/knife/org_user_add_spec.rb
+++ b/spec/unit/knife/org_user_add_spec.rb
@@ -15,7 +15,7 @@
# limitations under the License.
#
-require "spec_helper"
+require "knife_spec_helper"
require "chef/org"
describe Chef::Knife::OrgUserAdd do
diff --git a/spec/unit/knife/raw_spec.rb b/spec/unit/knife/raw_spec.rb
index 1f88195e65..90a09a31e6 100644
--- a/spec/unit/knife/raw_spec.rb
+++ b/spec/unit/knife/raw_spec.rb
@@ -15,7 +15,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-require "spec_helper"
+require "knife_spec_helper"
describe Chef::Knife::Raw do
let(:rest) do
diff --git a/spec/unit/knife/role_bulk_delete_spec.rb b/spec/unit/knife/role_bulk_delete_spec.rb
index 5af7c51584..f68efba57c 100644
--- a/spec/unit/knife/role_bulk_delete_spec.rb
+++ b/spec/unit/knife/role_bulk_delete_spec.rb
@@ -16,7 +16,7 @@
# limitations under the License.
#
-require "spec_helper"
+require "knife_spec_helper"
describe Chef::Knife::RoleBulkDelete do
before(:each) do
diff --git a/spec/unit/knife/role_create_spec.rb b/spec/unit/knife/role_create_spec.rb
index 0d563e40dd..13f47492b1 100644
--- a/spec/unit/knife/role_create_spec.rb
+++ b/spec/unit/knife/role_create_spec.rb
@@ -16,7 +16,7 @@
# limitations under the License.
#
-require "spec_helper"
+require "knife_spec_helper"
describe Chef::Knife::RoleCreate do
before(:each) do
diff --git a/spec/unit/knife/role_delete_spec.rb b/spec/unit/knife/role_delete_spec.rb
index d43f99689d..658da5299d 100644
--- a/spec/unit/knife/role_delete_spec.rb
+++ b/spec/unit/knife/role_delete_spec.rb
@@ -16,7 +16,7 @@
# limitations under the License.
#
-require "spec_helper"
+require "knife_spec_helper"
describe Chef::Knife::RoleDelete do
before(:each) do
diff --git a/spec/unit/knife/role_edit_spec.rb b/spec/unit/knife/role_edit_spec.rb
index faf9cf7d84..adade177a7 100644
--- a/spec/unit/knife/role_edit_spec.rb
+++ b/spec/unit/knife/role_edit_spec.rb
@@ -16,7 +16,7 @@
# limitations under the License.
#
-require "spec_helper"
+require "knife_spec_helper"
describe Chef::Knife::RoleEdit do
before(:each) do
diff --git a/spec/unit/knife/role_env_run_list_add_spec.rb b/spec/unit/knife/role_env_run_list_add_spec.rb
index 13a05db33e..b42ec6141f 100644
--- a/spec/unit/knife/role_env_run_list_add_spec.rb
+++ b/spec/unit/knife/role_env_run_list_add_spec.rb
@@ -17,7 +17,7 @@
# limitations under the License.
#
-require "spec_helper"
+require "knife_spec_helper"
describe Chef::Knife::RoleEnvRunListAdd do
before(:each) do
diff --git a/spec/unit/knife/role_env_run_list_clear_spec.rb b/spec/unit/knife/role_env_run_list_clear_spec.rb
index d4b9625550..ad88d1ae37 100644
--- a/spec/unit/knife/role_env_run_list_clear_spec.rb
+++ b/spec/unit/knife/role_env_run_list_clear_spec.rb
@@ -17,7 +17,7 @@
# limitations under the License.
#
-require "spec_helper"
+require "knife_spec_helper"
describe Chef::Knife::RoleEnvRunListClear do
before(:each) do
diff --git a/spec/unit/knife/role_env_run_list_remove_spec.rb b/spec/unit/knife/role_env_run_list_remove_spec.rb
index 7f9b41475c..8755ce452b 100644
--- a/spec/unit/knife/role_env_run_list_remove_spec.rb
+++ b/spec/unit/knife/role_env_run_list_remove_spec.rb
@@ -17,7 +17,7 @@
# limitations under the License.
#
-require "spec_helper"
+require "knife_spec_helper"
describe Chef::Knife::RoleEnvRunListRemove do
before(:each) do
diff --git a/spec/unit/knife/role_env_run_list_replace_spec.rb b/spec/unit/knife/role_env_run_list_replace_spec.rb
index 93b233efdc..457f4efbd7 100644
--- a/spec/unit/knife/role_env_run_list_replace_spec.rb
+++ b/spec/unit/knife/role_env_run_list_replace_spec.rb
@@ -17,7 +17,7 @@
# limitations under the License.
#
-require "spec_helper"
+require "knife_spec_helper"
describe Chef::Knife::RoleEnvRunListReplace do
before(:each) do
diff --git a/spec/unit/knife/role_env_run_list_set_spec.rb b/spec/unit/knife/role_env_run_list_set_spec.rb
index d35e4dbb17..34233398f5 100644
--- a/spec/unit/knife/role_env_run_list_set_spec.rb
+++ b/spec/unit/knife/role_env_run_list_set_spec.rb
@@ -17,7 +17,7 @@
# limitations under the License.
#
-require "spec_helper"
+require "knife_spec_helper"
describe Chef::Knife::RoleEnvRunListSet do
before(:each) do
diff --git a/spec/unit/knife/role_from_file_spec.rb b/spec/unit/knife/role_from_file_spec.rb
index 51e94d31e3..6e2fdf7cfb 100644
--- a/spec/unit/knife/role_from_file_spec.rb
+++ b/spec/unit/knife/role_from_file_spec.rb
@@ -16,7 +16,7 @@
# limitations under the License.
#
-require "spec_helper"
+require "knife_spec_helper"
Chef::Knife::RoleFromFile.load_deps
diff --git a/spec/unit/knife/role_list_spec.rb b/spec/unit/knife/role_list_spec.rb
index dea2e874a4..f37a85b6dc 100644
--- a/spec/unit/knife/role_list_spec.rb
+++ b/spec/unit/knife/role_list_spec.rb
@@ -16,7 +16,7 @@
# limitations under the License.
#
-require "spec_helper"
+require "knife_spec_helper"
describe Chef::Knife::RoleList do
before(:each) do
diff --git a/spec/unit/knife/role_run_list_add_spec.rb b/spec/unit/knife/role_run_list_add_spec.rb
index 6f222ee80a..7b038c2e81 100644
--- a/spec/unit/knife/role_run_list_add_spec.rb
+++ b/spec/unit/knife/role_run_list_add_spec.rb
@@ -17,7 +17,7 @@
# limitations under the License.
#
-require "spec_helper"
+require "knife_spec_helper"
describe Chef::Knife::RoleRunListAdd do
before(:each) do
diff --git a/spec/unit/knife/role_run_list_clear_spec.rb b/spec/unit/knife/role_run_list_clear_spec.rb
index 327a9979b0..5479b01811 100644
--- a/spec/unit/knife/role_run_list_clear_spec.rb
+++ b/spec/unit/knife/role_run_list_clear_spec.rb
@@ -17,7 +17,7 @@
# limitations under the License.
#
-require "spec_helper"
+require "knife_spec_helper"
describe Chef::Knife::RoleRunListClear do
before(:each) do
diff --git a/spec/unit/knife/role_run_list_remove_spec.rb b/spec/unit/knife/role_run_list_remove_spec.rb
index 200a559c08..353ae36c1a 100644
--- a/spec/unit/knife/role_run_list_remove_spec.rb
+++ b/spec/unit/knife/role_run_list_remove_spec.rb
@@ -17,7 +17,7 @@
# limitations under the License.
#
-require "spec_helper"
+require "knife_spec_helper"
describe Chef::Knife::RoleRunListRemove do
before(:each) do
diff --git a/spec/unit/knife/role_run_list_replace_spec.rb b/spec/unit/knife/role_run_list_replace_spec.rb
index 1957403fb1..e59b704f00 100644
--- a/spec/unit/knife/role_run_list_replace_spec.rb
+++ b/spec/unit/knife/role_run_list_replace_spec.rb
@@ -17,7 +17,7 @@
# limitations under the License.
#
-require "spec_helper"
+require "knife_spec_helper"
describe Chef::Knife::RoleRunListReplace do
before(:each) do
diff --git a/spec/unit/knife/role_run_list_set_spec.rb b/spec/unit/knife/role_run_list_set_spec.rb
index 06098c585e..b75f1ab377 100644
--- a/spec/unit/knife/role_run_list_set_spec.rb
+++ b/spec/unit/knife/role_run_list_set_spec.rb
@@ -17,7 +17,7 @@
# limitations under the License.
#
-require "spec_helper"
+require "knife_spec_helper"
describe Chef::Knife::RoleRunListSet do
before(:each) do
diff --git a/spec/unit/knife/role_show_spec.rb b/spec/unit/knife/role_show_spec.rb
index fe48e2f940..a79cb40e81 100644
--- a/spec/unit/knife/role_show_spec.rb
+++ b/spec/unit/knife/role_show_spec.rb
@@ -16,7 +16,7 @@
# limitations under the License.
#
-require "spec_helper"
+require "knife_spec_helper"
describe Chef::Knife::RoleShow do
let(:role) { "base" }
diff --git a/spec/unit/knife/ssh_spec.rb b/spec/unit/knife/ssh_spec.rb
index 8606045e8c..59015f024a 100644
--- a/spec/unit/knife/ssh_spec.rb
+++ b/spec/unit/knife/ssh_spec.rb
@@ -16,7 +16,7 @@
# limitations under the License.
#
-require "spec_helper"
+require "knife_spec_helper"
require "net/ssh"
require "net/ssh/multi"
diff --git a/spec/unit/knife/ssl_check_spec.rb b/spec/unit/knife/ssl_check_spec.rb
index 1165da4539..4412ee0be9 100644
--- a/spec/unit/knife/ssl_check_spec.rb
+++ b/spec/unit/knife/ssl_check_spec.rb
@@ -16,7 +16,7 @@
# limitations under the License.
#
-require "spec_helper"
+require "knife_spec_helper"
require "stringio"
describe Chef::Knife::SslCheck do
diff --git a/spec/unit/knife/ssl_fetch_spec.rb b/spec/unit/knife/ssl_fetch_spec.rb
index 2184994dc0..c2dc5bdade 100644
--- a/spec/unit/knife/ssl_fetch_spec.rb
+++ b/spec/unit/knife/ssl_fetch_spec.rb
@@ -16,7 +16,7 @@
# limitations under the License.
#
-require "spec_helper"
+require "knife_spec_helper"
require "chef/knife/ssl_fetch"
describe Chef::Knife::SslFetch do
diff --git a/spec/unit/knife/status_spec.rb b/spec/unit/knife/status_spec.rb
index 838e4c9600..f3b31c1897 100644
--- a/spec/unit/knife/status_spec.rb
+++ b/spec/unit/knife/status_spec.rb
@@ -16,7 +16,7 @@
# limitations under the License.
#
-require "spec_helper"
+require "knife_spec_helper"
describe Chef::Knife::Status do
before(:each) do
diff --git a/spec/unit/knife/supermarket_download_spec.rb b/spec/unit/knife/supermarket_download_spec.rb
index 5d15e74966..3796140d61 100644
--- a/spec/unit/knife/supermarket_download_spec.rb
+++ b/spec/unit/knife/supermarket_download_spec.rb
@@ -18,7 +18,7 @@
#
require "chef/knife/supermarket_download"
-require "spec_helper"
+require "knife_spec_helper"
describe Chef::Knife::SupermarketDownload do
diff --git a/spec/unit/knife/supermarket_install_spec.rb b/spec/unit/knife/supermarket_install_spec.rb
index 03cc5d1992..6ebbbc005c 100644
--- a/spec/unit/knife/supermarket_install_spec.rb
+++ b/spec/unit/knife/supermarket_install_spec.rb
@@ -16,8 +16,9 @@
# limitations under the License.
#
-require "spec_helper"
+require "knife_spec_helper"
require "chef/knife/supermarket_install"
+require "mixlib/archive"
describe Chef::Knife::SupermarketInstall do
let(:knife) { Chef::Knife::SupermarketInstall.new }
diff --git a/spec/unit/knife/supermarket_list_spec.rb b/spec/unit/knife/supermarket_list_spec.rb
index a1acccaaaa..bbaf733f44 100644
--- a/spec/unit/knife/supermarket_list_spec.rb
+++ b/spec/unit/knife/supermarket_list_spec.rb
@@ -17,7 +17,7 @@
#
require "chef/knife/supermarket_list"
-require "spec_helper"
+require "knife_spec_helper"
describe Chef::Knife::SupermarketList do
let(:knife) { described_class.new }
diff --git a/spec/unit/knife/supermarket_search_spec.rb b/spec/unit/knife/supermarket_search_spec.rb
index cba2f615aa..18092f52c8 100644
--- a/spec/unit/knife/supermarket_search_spec.rb
+++ b/spec/unit/knife/supermarket_search_spec.rb
@@ -17,7 +17,7 @@
#
require "chef/knife/supermarket_search"
-require "spec_helper"
+require "knife_spec_helper"
describe Chef::Knife::SupermarketSearch do
let(:knife) { described_class.new }
diff --git a/spec/unit/knife/supermarket_share_spec.rb b/spec/unit/knife/supermarket_share_spec.rb
index 088cef9dfd..d362edf3c0 100644
--- a/spec/unit/knife/supermarket_share_spec.rb
+++ b/spec/unit/knife/supermarket_share_spec.rb
@@ -16,10 +16,10 @@
# limitations under the License.
#
-require "spec_helper"
+require "knife_spec_helper"
require "chef/knife/supermarket_share"
require "chef/cookbook_uploader"
-require "chef/cookbook_site_streaming_uploader"
+require "chef/knife/core/cookbook_site_streaming_uploader"
describe Chef::Knife::SupermarketShare do
@@ -42,7 +42,7 @@ describe Chef::Knife::SupermarketShare do
@cookbook_uploader = Chef::CookbookUploader.new("herpderp", rest: "norest")
allow(Chef::CookbookUploader).to receive(:new).and_return(@cookbook_uploader)
allow(@cookbook_uploader).to receive(:validate_cookbooks).and_return(true)
- allow(Chef::CookbookSiteStreamingUploader).to receive(:create_build_dir).and_return(Dir.mktmpdir)
+ allow(Chef::Knife::Core::CookbookSiteStreamingUploader).to receive(:create_build_dir).and_return(Dir.mktmpdir)
allow(@knife).to receive(:shell_out!).and_return(true)
@stdout = StringIO.new
@@ -140,7 +140,7 @@ describe Chef::Knife::SupermarketShare do
context "when the --dry-run flag is specified" do
before do
- allow(Chef::CookbookSiteStreamingUploader).to receive(:create_build_dir).and_return("/var/tmp/dummy")
+ allow(Chef::Knife::Core::CookbookSiteStreamingUploader).to receive(:create_build_dir).and_return("/var/tmp/dummy")
@knife.config = { dry_run: true }
@so = instance_double("Mixlib::ShellOut")
allow(@knife).to receive(:shell_out!).and_return(@so)
@@ -165,7 +165,7 @@ describe Chef::Knife::SupermarketShare do
before(:each) do
@upload_response = double("Net::HTTPResponse")
- allow(Chef::CookbookSiteStreamingUploader).to receive(:post).and_return(@upload_response)
+ allow(Chef::Knife::Core::CookbookSiteStreamingUploader).to receive(:post).and_return(@upload_response)
allow(File).to receive(:open).and_return(true)
end
@@ -174,7 +174,7 @@ describe Chef::Knife::SupermarketShare do
response_text = Chef::JSONCompat.to_json({ uri: "https://supermarket.chef.io/cookbooks/cookbook_name" })
allow(@upload_response).to receive(:body).and_return(response_text)
allow(@upload_response).to receive(:code).and_return(201)
- expect(Chef::CookbookSiteStreamingUploader).to receive(:post).with(/supermarket\.chef\.io/, anything, anything, anything)
+ expect(Chef::Knife::Core::CookbookSiteStreamingUploader).to receive(:post).with(/supermarket\.chef\.io/, anything, anything, anything)
@knife.run
end
diff --git a/spec/unit/knife/supermarket_unshare_spec.rb b/spec/unit/knife/supermarket_unshare_spec.rb
index 8ae4d03cb5..63682a663c 100644
--- a/spec/unit/knife/supermarket_unshare_spec.rb
+++ b/spec/unit/knife/supermarket_unshare_spec.rb
@@ -17,7 +17,7 @@
# limitations under the License.
#
-require "spec_helper"
+require "knife_spec_helper"
require "chef/knife/supermarket_unshare"
describe Chef::Knife::SupermarketUnshare do
diff --git a/spec/unit/knife/tag_create_spec.rb b/spec/unit/knife/tag_create_spec.rb
index a1a4923871..290b925f4e 100644
--- a/spec/unit/knife/tag_create_spec.rb
+++ b/spec/unit/knife/tag_create_spec.rb
@@ -1,4 +1,4 @@
-require "spec_helper"
+require "knife_spec_helper"
describe Chef::Knife::TagCreate do
before(:each) do
diff --git a/spec/unit/knife/tag_delete_spec.rb b/spec/unit/knife/tag_delete_spec.rb
index 4201196de0..dd01fba50f 100644
--- a/spec/unit/knife/tag_delete_spec.rb
+++ b/spec/unit/knife/tag_delete_spec.rb
@@ -1,4 +1,4 @@
-require "spec_helper"
+require "knife_spec_helper"
describe Chef::Knife::TagDelete do
before(:each) do
diff --git a/spec/unit/knife/tag_list_spec.rb b/spec/unit/knife/tag_list_spec.rb
index dceec9a5ea..5da7803e09 100644
--- a/spec/unit/knife/tag_list_spec.rb
+++ b/spec/unit/knife/tag_list_spec.rb
@@ -1,4 +1,4 @@
-require "spec_helper"
+require "knife_spec_helper"
describe Chef::Knife::TagList do
before(:each) do
diff --git a/spec/unit/knife/user_create_spec.rb b/spec/unit/knife/user_create_spec.rb
index c69a668f7e..fb6a2c3ba0 100644
--- a/spec/unit/knife/user_create_spec.rb
+++ b/spec/unit/knife/user_create_spec.rb
@@ -17,7 +17,7 @@
# limitations under the License.
#
-require "spec_helper"
+require "knife_spec_helper"
Chef::Knife::UserCreate.load_deps
diff --git a/spec/unit/knife/user_delete_spec.rb b/spec/unit/knife/user_delete_spec.rb
index 4dd2665cda..57d4072c50 100644
--- a/spec/unit/knife/user_delete_spec.rb
+++ b/spec/unit/knife/user_delete_spec.rb
@@ -16,7 +16,7 @@
# limitations under the License.
#
-require "spec_helper"
+require "knife_spec_helper"
require "chef/org"
Chef::Knife::UserDelete.load_deps
diff --git a/spec/unit/knife/user_edit_spec.rb b/spec/unit/knife/user_edit_spec.rb
index 2fde328c0c..12e2f19561 100644
--- a/spec/unit/knife/user_edit_spec.rb
+++ b/spec/unit/knife/user_edit_spec.rb
@@ -16,7 +16,7 @@
# limitations under the License.
#
-require "spec_helper"
+require "knife_spec_helper"
describe Chef::Knife::UserEdit do
let(:knife) { Chef::Knife::UserEdit.new }
diff --git a/spec/unit/knife/user_list_spec.rb b/spec/unit/knife/user_list_spec.rb
index 63df590591..01013de352 100644
--- a/spec/unit/knife/user_list_spec.rb
+++ b/spec/unit/knife/user_list_spec.rb
@@ -16,7 +16,7 @@
# limitations under the License.
#
-require "spec_helper"
+require "knife_spec_helper"
Chef::Knife::UserList.load_deps
diff --git a/spec/unit/knife/user_password_spec.rb b/spec/unit/knife/user_password_spec.rb
index 098597a14c..139ed242de 100644
--- a/spec/unit/knife/user_password_spec.rb
+++ b/spec/unit/knife/user_password_spec.rb
@@ -16,7 +16,7 @@
# limitations under the License.
#
-require "spec_helper"
+require "knife_spec_helper"
require "chef/org"
Chef::Knife::UserDelete.load_deps
diff --git a/spec/unit/knife/user_reregister_spec.rb b/spec/unit/knife/user_reregister_spec.rb
index 481415e432..9178996abf 100644
--- a/spec/unit/knife/user_reregister_spec.rb
+++ b/spec/unit/knife/user_reregister_spec.rb
@@ -16,7 +16,7 @@
# limitations under the License.
#
-require "spec_helper"
+require "knife_spec_helper"
describe Chef::Knife::UserReregister do
let(:knife) { Chef::Knife::UserReregister.new }
diff --git a/spec/unit/knife/user_show_spec.rb b/spec/unit/knife/user_show_spec.rb
index 30742d8c21..3bcbbcb648 100644
--- a/spec/unit/knife/user_show_spec.rb
+++ b/spec/unit/knife/user_show_spec.rb
@@ -16,7 +16,7 @@
# limitations under the License.
#
-require "spec_helper"
+require "knife_spec_helper"
require "chef/org"
Chef::Knife::UserShow.load_deps
diff --git a/spec/unit/knife_spec.rb b/spec/unit/knife_spec.rb
index 88f36a3973..f3315f3cf5 100644
--- a/spec/unit/knife_spec.rb
+++ b/spec/unit/knife_spec.rb
@@ -21,7 +21,7 @@
module KnifeSpecs
end
-require "spec_helper"
+require "knife_spec_helper"
require "uri"
require "chef/knife/core/gem_glob_loader"
diff --git a/spec/unit/provider/service/arch_service_spec.rb b/spec/unit/provider/service/arch_service_spec.rb
index 026db3dc75..c92af83de5 100644
--- a/spec/unit/provider/service/arch_service_spec.rb
+++ b/spec/unit/provider/service/arch_service_spec.rb
@@ -44,6 +44,7 @@ describe Chef::Provider::Service::Arch, "load_current_resource" do
describe "when first created" do
it "should set the current resources service name to the new resources service name" do
+ allow(@provider).to receive(:determine_current_status!)
allow(@provider).to receive(:shell_out).and_return(OpenStruct.new(exitstatus: 0, stdout: ""))
@provider.load_current_resource
expect(@provider.current_resource.service_name).to eq("chef")
diff --git a/spec/unit/provider/service/debian_service_spec.rb b/spec/unit/provider/service/debian_service_spec.rb
index d0cd048c4f..0ae1d28cd3 100644
--- a/spec/unit/provider/service/debian_service_spec.rb
+++ b/spec/unit/provider/service/debian_service_spec.rb
@@ -33,6 +33,7 @@ describe Chef::Provider::Service::Debian do
@pid, @stdin, @stdout, @stderr = nil, nil, nil, nil
allow(File).to receive(:exist?).with("/etc/init.d/chef").and_return true
+ allow(@provider).to receive(:determine_current_status!)
end
let(:init_lines) do
diff --git a/tasks/rspec.rb b/tasks/rspec.rb
index 929e0f91b0..050c40be5c 100644
--- a/tasks/rspec.rb
+++ b/tasks/rspec.rb
@@ -25,8 +25,9 @@ begin
desc "Run specs for Chef's Gem Components"
task :component_specs do
- %w{chef-utils chef-config}.each do |gem|
+ %w{chef-utils chef-config knife}.each do |gem|
Dir.chdir(gem) do
+ puts "--- Running #{gem} specs"
Bundler.with_unbundled_env do
sh("bundle install --jobs=3 --retry=3")
sh("bundle exec rake spec")
@@ -39,19 +40,24 @@ begin
task spec: :component_specs
- desc "Run all specs in spec directory"
+ desc "Run all chef specs in spec directory"
RSpec::Core::RakeTask.new(:spec) do |t|
t.verbose = false
t.rspec_opts = %w{--profile}
- t.pattern = FileList["spec/**/*_spec.rb"]
+ t.pattern = FileList["spec/**/*_spec.rb"].reject do |path|
+ path =~ /knife.*/
+ end
end
namespace :spec do
- desc "Run all specs in spec directory"
+ desc "Run all chef specs in spec directory"
RSpec::Core::RakeTask.new(:all) do |t|
t.verbose = false
t.rspec_opts = %w{--profile}
t.pattern = FileList["spec/**/*_spec.rb"]
+ t.pattern = FileList["spec/**/*_spec.rb"].reject do |path|
+ path =~ /knife.*/
+ end
end
desc "Print Specdoc for all specs"
@@ -61,7 +67,7 @@ begin
t.pattern = FileList["spec/**/*_spec.rb"]
end
- desc "Run the specs under spec/unit with activesupport loaded"
+ desc "Run chef's node and role unit specs with activesupport loaded"
RSpec::Core::RakeTask.new(:activesupport) do |t|
t.verbose = false
t.rspec_opts = %w{--require active_support/core_ext --profile}
@@ -70,11 +76,13 @@ begin
end
%i{unit functional integration stress}.each do |sub|
- desc "Run the specs under spec/#{sub}"
+ desc "Run the chef specs under spec/#{sub}"
RSpec::Core::RakeTask.new(sub) do |t|
t.verbose = false
t.rspec_opts = %w{--profile}
- t.pattern = FileList["spec/#{sub}/**/*_spec.rb"]
+ t.pattern = FileList["spec/#{sub}/**/*_spec.rb"].reject do |path|
+ path =~ /knife.*/
+ end
end
end
end