summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLamont Granquist <lamont@chef.io>2020-01-23 16:57:40 -0800
committerGitHub <noreply@github.com>2020-01-23 16:57:40 -0800
commit81a06320a03e0b3e696b1f967a09cc86d38e0d7b (patch)
tree757c49c484535158ea84c57628e821d9d927d143
parentca5cf342b9d63118b9d2248d0fa516b87d9cb0a1 (diff)
parent614743e0fb0c830f2419b0f445084d8f5c731296 (diff)
downloadchef-81a06320a03e0b3e696b1f967a09cc86d38e0d7b.tar.gz
Use .load! in the Cookbook loader not .load_cookbooks (#9266)
Use .load! in the Cookbook loader not .load_cookbooks
-rw-r--r--lib/chef/chef_fs/file_system/chef_server/cookbook_artifacts_dir.rb2
-rw-r--r--lib/chef/chef_fs/file_system/chef_server/versioned_cookbooks_dir.rb2
-rw-r--r--lib/chef/chef_fs/file_system/repository/chef_repository_file_system_cookbook_artifact_dir.rb2
-rw-r--r--lib/chef/chef_fs/file_system/repository/chef_repository_file_system_cookbook_dir.rb2
-rw-r--r--lib/chef/chef_fs/file_system/repository/chef_repository_file_system_versioned_cookbook_dir.rb2
-rw-r--r--spec/integration/knife/upload_spec.rb29
6 files changed, 6 insertions, 33 deletions
diff --git a/lib/chef/chef_fs/file_system/chef_server/cookbook_artifacts_dir.rb b/lib/chef/chef_fs/file_system/chef_server/cookbook_artifacts_dir.rb
index 974bbc91fd..96f281253f 100644
--- a/lib/chef/chef_fs/file_system/chef_server/cookbook_artifacts_dir.rb
+++ b/lib/chef/chef_fs/file_system/chef_server/cookbook_artifacts_dir.rb
@@ -66,7 +66,7 @@ class Chef
# Instantiate a proxy loader using the temporary symlink
proxy_loader = Chef::Cookbook::CookbookVersionLoader.new(proxy_cookbook_path, other.chefignore)
- proxy_loader.load_cookbooks
+ proxy_loader.load!
cookbook_to_upload = proxy_loader.cookbook_version
cookbook_to_upload.identifier = identifier
diff --git a/lib/chef/chef_fs/file_system/chef_server/versioned_cookbooks_dir.rb b/lib/chef/chef_fs/file_system/chef_server/versioned_cookbooks_dir.rb
index 9a65f70f33..a5d76d10c7 100644
--- a/lib/chef/chef_fs/file_system/chef_server/versioned_cookbooks_dir.rb
+++ b/lib/chef/chef_fs/file_system/chef_server/versioned_cookbooks_dir.rb
@@ -72,7 +72,7 @@ class Chef
# Instantiate a proxy loader using the temporary symlink
proxy_loader = Chef::Cookbook::CookbookVersionLoader.new(proxy_cookbook_path, other.chefignore)
- proxy_loader.load_cookbooks
+ proxy_loader.load!
cookbook_to_upload = proxy_loader.cookbook_version
cookbook_to_upload.freeze_version if options[:freeze]
diff --git a/lib/chef/chef_fs/file_system/repository/chef_repository_file_system_cookbook_artifact_dir.rb b/lib/chef/chef_fs/file_system/repository/chef_repository_file_system_cookbook_artifact_dir.rb
index a15b47ca73..5c893952ee 100644
--- a/lib/chef/chef_fs/file_system/repository/chef_repository_file_system_cookbook_artifact_dir.rb
+++ b/lib/chef/chef_fs/file_system/repository/chef_repository_file_system_cookbook_artifact_dir.rb
@@ -29,7 +29,7 @@ class Chef
cookbook_name, _dash, identifier = name.rpartition("-")
# KLUDGE: We shouldn't have to use instance_variable_set
loader.instance_variable_set(:@cookbook_name, cookbook_name)
- loader.load_cookbooks
+ loader.load!
cookbook_version = loader.cookbook_version
cookbook_version.identifier = identifier
cookbook_version
diff --git a/lib/chef/chef_fs/file_system/repository/chef_repository_file_system_cookbook_dir.rb b/lib/chef/chef_fs/file_system/repository/chef_repository_file_system_cookbook_dir.rb
index 4f8368b025..3aba5ba51b 100644
--- a/lib/chef/chef_fs/file_system/repository/chef_repository_file_system_cookbook_dir.rb
+++ b/lib/chef/chef_fs/file_system/repository/chef_repository_file_system_cookbook_dir.rb
@@ -143,7 +143,7 @@ class Chef
def cookbook_version
loader = Chef::Cookbook::CookbookVersionLoader.new(file_path, chefignore)
- loader.load_cookbooks
+ loader.load!
loader.cookbook_version
end
end
diff --git a/lib/chef/chef_fs/file_system/repository/chef_repository_file_system_versioned_cookbook_dir.rb b/lib/chef/chef_fs/file_system/repository/chef_repository_file_system_versioned_cookbook_dir.rb
index 4d76be579a..976e0f38f3 100644
--- a/lib/chef/chef_fs/file_system/repository/chef_repository_file_system_versioned_cookbook_dir.rb
+++ b/lib/chef/chef_fs/file_system/repository/chef_repository_file_system_versioned_cookbook_dir.rb
@@ -33,7 +33,7 @@ class Chef
# KLUDGE: We shouldn't have to use instance_variable_set
loader.instance_variable_set(:@cookbook_name, canonical_name)
- loader.load_cookbooks
+ loader.load!
loader.cookbook_version
end
end
diff --git a/spec/integration/knife/upload_spec.rb b/spec/integration/knife/upload_spec.rb
index 645e7365af..5e151515e2 100644
--- a/spec/integration/knife/upload_spec.rb
+++ b/spec/integration/knife/upload_spec.rb
@@ -178,7 +178,7 @@ describe "knife upload", :workstation do
file "cookbooks/x/metadata.rb", "name 'x'; version '1.0.0'; depends 'x'"
end
- it "should fail in Chef 13" do
+ it "fails with RuntimeError" do
expect { knife("upload /cookbooks") }.to raise_error RuntimeError, /Cookbook depends on itself/
end
end
@@ -197,7 +197,6 @@ describe "knife upload", :workstation do
end
it "knife upload adds the new files" do
- expect(Chef::Log).to receive(:warn).with(/load method is deprecated. Please use load! instead./).at_least(2).times
knife("upload /").should_succeed <<~EOM
Created /clients/y.json
Updated /cookbooks/x
@@ -217,7 +216,6 @@ describe "knife upload", :workstation do
end
it "knife upload --no-diff adds the new files" do
- expect(Chef::Log).to receive(:warn).with(/load method is deprecated. Please use load! instead./).at_least(2).times
knife("upload --no-diff /").should_succeed <<~EOM
Created /clients/y.json
Updated /cookbooks/x
@@ -494,7 +492,6 @@ describe "knife upload", :workstation do
# technically we shouldn't have deleted missing files. But ... cookbooks
# are a special case.
it "knife upload of the cookbook itself succeeds" do
- expect(Chef::Log).to receive(:warn).with(/load method is deprecated. Please use load! instead./).at_least(2).times
knife("upload /cookbooks/x").should_succeed <<~EOM
Updated /cookbooks/x
EOM
@@ -504,7 +501,6 @@ describe "knife upload", :workstation do
end
it "knife upload --purge of the cookbook itself succeeds" do
- expect(Chef::Log).to receive(:warn).with(/load method is deprecated. Please use load! instead./).at_least(2).times
knife("upload /cookbooks/x").should_succeed <<~EOM
Updated /cookbooks/x
EOM
@@ -520,7 +516,6 @@ describe "knife upload", :workstation do
end
it "knife upload of the cookbook succeeds" do
- expect(Chef::Log).to receive(:warn).with(/load method is deprecated. Please use load! instead./).at_least(2).times
knife("upload /cookbooks/x").should_succeed <<~EOM
Updated /cookbooks/x
EOM
@@ -538,7 +533,6 @@ describe "knife upload", :workstation do
end
it "knife upload of the cookbook succeeds" do
- expect(Chef::Log).to receive(:warn).with(/load method is deprecated. Please use load! instead./).at_least(2).times
knife("upload /cookbooks/x").should_succeed <<~EOM
Updated /cookbooks/x
EOM
@@ -554,7 +548,6 @@ describe "knife upload", :workstation do
end
it "knife upload --freeze freezes the cookbook" do
- expect(Chef::Log).to receive(:warn).with(/load method is deprecated. Please use load! instead./).at_least(2).times
knife("upload --freeze /cookbooks/x").should_succeed <<~EOM
Updated /cookbooks/x
EOM
@@ -577,11 +570,9 @@ describe "knife upload", :workstation do
end
it "knife upload fails to upload the frozen cookbook" do
- expect(Chef::Log).to receive(:warn).with(/load method is deprecated. Please use load! instead./).at_least(2).times
knife("upload /cookbooks/frozencook").should_fail "ERROR: /cookbooks failed to write: Cookbook frozencook is frozen\n"
end
it "knife upload --force uploads the frozen cookbook" do
- expect(Chef::Log).to receive(:warn).with(/load method is deprecated. Please use load! instead./).at_least(2).times
knife("upload --force /cookbooks/frozencook").should_succeed <<~EOM
Updated /cookbooks/frozencook
EOM
@@ -603,7 +594,6 @@ describe "knife upload", :workstation do
end
it "knife upload /cookbooks/x uploads the local version" do
- expect(Chef::Log).to receive(:warn).with(/load method is deprecated. Please use load! instead./).at_least(2).times
knife("diff --name-status /cookbooks").should_succeed <<~EOM
M\t/cookbooks/x/metadata.rb
D\t/cookbooks/x/onlyin1.0.1.rb
@@ -641,7 +631,6 @@ describe "knife upload", :workstation do
D\t/cookbooks/x/onlyin1.0.1.rb
A\t/cookbooks/x/onlyin1.0.0.rb
EOM
- expect(Chef::Log).to receive(:warn).with(/load method is deprecated. Please use load! instead./).at_least(2).times
knife("upload --purge /cookbooks/x").should_succeed <<~EOM
Updated /cookbooks/x
EOM
@@ -660,7 +649,6 @@ describe "knife upload", :workstation do
end
it "knife upload /cookbooks/x uploads the local version generates metadata.json and uploads it." do
- expect(Chef::Log).to receive(:warn).with(/load method is deprecated. Please use load! instead./).at_least(2).times
knife("upload --purge /cookbooks/x").should_succeed <<~EOM
Updated /cookbooks/x
EOM
@@ -676,7 +664,6 @@ describe "knife upload", :workstation do
end
it "knife upload /cookbooks/x uploads the local version and generates metadata.json before upload and uploads it." do
- expect(Chef::Log).to receive(:warn).with(/load method is deprecated. Please use load! instead./).at_least(2).times
knife("diff --name-status /cookbooks").should_succeed <<~EOM
M\t/cookbooks/x/metadata.rb
D\t/cookbooks/x/onlyin1.0.1.rb
@@ -699,7 +686,6 @@ describe "knife upload", :workstation do
end
it "knife upload /cookbooks/x uploads the new version" do
- expect(Chef::Log).to receive(:warn).with(/load method is deprecated. Please use load! instead./).at_least(2).times
knife("upload --purge /cookbooks/x").should_succeed <<~EOM
Updated /cookbooks/x
EOM
@@ -802,7 +788,6 @@ describe "knife upload", :workstation do
file "cookbooks/x/metadata.rb", cb_metadata("x", "1.0.0", "\nchef_version '~> 999.0'")
end
it "knife upload succeeds" do
- expect(Chef::Log).to receive(:warn).with(/load method is deprecated. Please use load! instead./).at_least(2).times
knife("upload /cookbooks/x").should_succeed <<~EOM
Created /cookbooks/x
EOM
@@ -953,7 +938,6 @@ describe "knife upload", :workstation do
end
it "knife upload adds the new files" do
- expect(Chef::Log).to receive(:warn).with(/load method is deprecated. Please use load! instead./).at_least(3).times
knife("upload /").should_succeed <<~EOM
Created /clients/y.json
Updated /cookbooks/x-1.0.0
@@ -1160,7 +1144,6 @@ describe "knife upload", :workstation do
# technically we shouldn't have deleted missing files. But ... cookbooks
# are a special case.
it "knife upload of the cookbook itself succeeds" do
- expect(Chef::Log).to receive(:warn).with(/load method is deprecated. Please use load! instead./).once
knife("upload /cookbooks/x-1.0.0").should_succeed <<~EOM
Updated /cookbooks/x-1.0.0
EOM
@@ -1168,7 +1151,6 @@ describe "knife upload", :workstation do
end
it "knife upload --purge of the cookbook itself succeeds" do
- expect(Chef::Log).to receive(:warn).with(/load method is deprecated. Please use load! instead./).once
knife("upload /cookbooks/x-1.0.0").should_succeed <<~EOM
Updated /cookbooks/x-1.0.0
EOM
@@ -1182,7 +1164,6 @@ describe "knife upload", :workstation do
end
it "knife upload of the cookbook succeeds" do
- expect(Chef::Log).to receive(:warn).with(/load method is deprecated. Please use load! instead./).once
knife("upload /cookbooks/x-1.0.0").should_succeed <<~EOM
Updated /cookbooks/x-1.0.0
EOM
@@ -1198,7 +1179,6 @@ describe "knife upload", :workstation do
end
it "knife upload of the cookbook succeeds" do
- expect(Chef::Log).to receive(:warn).with(/load method is deprecated. Please use load! instead./).once
knife("upload /cookbooks/x-1.0.0").should_succeed <<~EOM
Updated /cookbooks/x-1.0.0
EOM
@@ -1220,7 +1200,6 @@ describe "knife upload", :workstation do
end
it "knife upload /cookbooks uploads the local version" do
- expect(Chef::Log).to receive(:warn).with(/load method is deprecated. Please use load! instead./).once
knife("diff --name-status /cookbooks").should_succeed <<~EOM
M\t/cookbooks/x-1.0.0/onlyin1.0.0.rb
D\t/cookbooks/x-1.0.1
@@ -1239,7 +1218,6 @@ describe "knife upload", :workstation do
cookbook "x", "0.9.9", { "onlyin0.9.9.rb" => "hi" }
end
it "knife upload /cookbooks uploads the local version" do
- expect(Chef::Log).to receive(:warn).with(/load method is deprecated. Please use load! instead./).once
knife("upload --purge /cookbooks").should_succeed <<~EOM
Updated /cookbooks/x-1.0.0
Deleted extra entry /cookbooks/x-0.9.9 (purge is on)
@@ -1254,7 +1232,6 @@ describe "knife upload", :workstation do
end
it "knife upload /cookbooks/x uploads the local version" do
- expect(Chef::Log).to receive(:warn).with(/load method is deprecated. Please use load! instead./).once
knife("diff --name-status /cookbooks").should_succeed <<~EOM
D\t/cookbooks/x-1.0.1
A\t/cookbooks/x-1.0.0
@@ -1273,7 +1250,6 @@ describe "knife upload", :workstation do
end
it "knife upload /cookbooks/x uploads the new version" do
- expect(Chef::Log).to receive(:warn).with(/load method is deprecated. Please use load! instead./).once
knife("upload --purge /cookbooks").should_succeed <<~EOM
Created /cookbooks/x-1.0.0
Deleted extra entry /cookbooks/x-0.9.9 (purge is on)
@@ -1348,7 +1324,6 @@ describe "knife upload", :workstation do
file "cookbooks/x-1.0.0/metadata.rb", cb_metadata("x", "1.0.0", "\nchef_version '~> 999.0'")
end
it "knife upload succeeds" do
- expect(Chef::Log).to receive(:warn).with(/load method is deprecated. Please use load! instead./).once
knife("upload /cookbooks/x-1.0.0").should_succeed <<~EOM
Created /cookbooks/x-1.0.0
EOM
@@ -1412,7 +1387,6 @@ describe "knife upload", :workstation do
end
it "knife upload / uploads everything" do
- expect(Chef::Log).to receive(:warn).with(/load method is deprecated. Please use load! instead./).at_least(2).times
knife("upload /").should_succeed <<~EOM
Updated /acls/groups/blah.json
Created /clients/x.json
@@ -1520,7 +1494,6 @@ describe "knife upload", :workstation do
end
it "knife upload updates everything" do
- expect(Chef::Log).to receive(:warn).with(/load method is deprecated. Please use load! instead./).at_least(2).times
knife("upload /").should_succeed <<~EOM
Updated /acls/groups/blah.json
Updated /clients/x.json