summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristopher Maier <cm@opscode.com>2012-11-28 17:41:30 -0500
committerChristopher Maier <cm@opscode.com>2012-11-28 17:41:30 -0500
commitde5af27d854e193b6783bea1d79711c7756c8c6b (patch)
tree4d657cf4c70f83877068bdd11200c1187698e962
parentea3678bdbde7465927bc23f897b6fc9e16d8640a (diff)
downloadchef-de5af27d854e193b6783bea1d79711c7756c8c6b.tar.gz
Add a dummy Chef::Sandbox class back in
This allows Chef 11 clients to interact with Chef 10 servers (specifically, to upload cookbooks) without crashing.
-rw-r--r--lib/chef/cookbook_uploader.rb1
-rw-r--r--lib/chef/sandbox.rb20
-rw-r--r--spec/unit/json_compat_spec.rb8
3 files changed, 29 insertions, 0 deletions
diff --git a/lib/chef/cookbook_uploader.rb b/lib/chef/cookbook_uploader.rb
index 8dd50ac043..90c9ee9996 100644
--- a/lib/chef/cookbook_uploader.rb
+++ b/lib/chef/cookbook_uploader.rb
@@ -7,6 +7,7 @@ require 'chef/checksum_cache'
require 'chef/cookbook_version'
require 'chef/cookbook/syntax_check'
require 'chef/cookbook/file_system_file_vendor'
+require 'chef/sandbox'
class Chef
class CookbookUploader
diff --git a/lib/chef/sandbox.rb b/lib/chef/sandbox.rb
new file mode 100644
index 0000000000..28bc4ffa12
--- /dev/null
+++ b/lib/chef/sandbox.rb
@@ -0,0 +1,20 @@
+class Chef
+ class Sandbox
+ # I DO NOTHING!!
+
+ # So, the reason we have a completely empty class here is so that
+ # Chef 11 clients do not choke when interacting with Chef 10
+ # servers. The original Chef::Sandbox class (that actually did
+ # things) has been removed since its functionality is no longer
+ # needed for Chef 11. However, since we still use the JSON gem
+ # and make use of its "auto-inflation" of classes (driven by the
+ # contents of the 'json_class' key in all of our JSON), any
+ # sandbox responses from a Chef 10 server to a Chef 11 client
+ # would cause knife to crash. The JSON gem would attempt to
+ # auto-inflate based on a "json_class": "Chef::Sandbox" hash
+ # entry, but would not be able to find a Chef::Sandbox class!
+ #
+ # This is a workaround until such time as we can completely remove
+ # the reliance on the "json_class" field.
+ end
+end
diff --git a/spec/unit/json_compat_spec.rb b/spec/unit/json_compat_spec.rb
index 674e2ae17a..f21493e060 100644
--- a/spec/unit/json_compat_spec.rb
+++ b/spec/unit/json_compat_spec.rb
@@ -28,6 +28,14 @@ describe Chef::JSONCompat do
end
end
+ describe 'with JSON containing "Chef::Sandbox" as a json_class value' do
+ require 'chef/sandbox' # Only needed for this test
+ let(:json){'{"json_class": "Chef::Sandbox", "arbitrary": "data"}'}
+ it "returns a Hash, because Chef::Sandbox is a dummy class" do
+ Chef::JSONCompat.from_json(json).should eq({"json_class" => "Chef::Sandbox", "arbitrary" => "data"})
+ end
+ end
+
describe "with a file with 1000 or less nested entries" do
before(:all) do
@json = IO.read(File.join(CHEF_SPEC_DATA, 'big_json.json'))