summaryrefslogtreecommitdiff
path: root/lib/chef/knife
diff options
context:
space:
mode:
authorLamont Granquist <lamont@scriptkiddie.org>2014-08-11 17:36:52 -0700
committerLamont Granquist <lamont@scriptkiddie.org>2014-08-11 17:36:52 -0700
commit3f415b11dfb1c494a45a0a83d69196cd75924cf1 (patch)
treeee6bbff8836a1a8514fe3be7ce9ead67ad8cb02a /lib/chef/knife
parentb4dfc6a1f478f29105a3b4746029e3ad46291b82 (diff)
downloadchef-3f415b11dfb1c494a45a0a83d69196cd75924cf1.tar.gz
remove JSON gem usage
should fully convert to using ffi-yajl there are still issues with JSON gem monkeypatching interacting with chef-zero and the spec tests so we keep the requires here for the json gem and the ffi_yajl/json_gem here. when ohai and chef-zero are fixed, we an just require ffi_yajl.
Diffstat (limited to 'lib/chef/knife')
-rw-r--r--lib/chef/knife/bootstrap.rb4
-rw-r--r--lib/chef/knife/cookbook_site_share.rb2
-rw-r--r--lib/chef/knife/deps.rb5
3 files changed, 5 insertions, 6 deletions
diff --git a/lib/chef/knife/bootstrap.rb b/lib/chef/knife/bootstrap.rb
index 46cacbd3e0..d3d45bad4b 100644
--- a/lib/chef/knife/bootstrap.rb
+++ b/lib/chef/knife/bootstrap.rb
@@ -126,7 +126,7 @@ class Chef
:short => "-j JSON_ATTRIBS",
:long => "--json-attributes",
:description => "A JSON string to be added to the first run of chef-client",
- :proc => lambda { |o| JSON.parse(o) },
+ :proc => lambda { |o| Chef::JSONCompat.parse(o) },
:default => {}
option :host_key_verify,
@@ -141,7 +141,7 @@ class Chef
:proc => Proc.new { |h|
Chef::Config[:knife][:hints] ||= Hash.new
name, path = h.split("=")
- Chef::Config[:knife][:hints][name] = path ? JSON.parse(::File.read(path)) : Hash.new }
+ Chef::Config[:knife][:hints][name] = path ? Chef::JSONCompat.parse(::File.read(path)) : Hash.new }
option :secret,
:short => "-s SECRET",
diff --git a/lib/chef/knife/cookbook_site_share.rb b/lib/chef/knife/cookbook_site_share.rb
index 330f3cb229..b360cad728 100644
--- a/lib/chef/knife/cookbook_site_share.rb
+++ b/lib/chef/knife/cookbook_site_share.rb
@@ -87,7 +87,7 @@ class Chef
def do_upload(cookbook_filename, cookbook_category, user_id, user_secret_filename)
uri = "http://cookbooks.opscode.com/api/v1/cookbooks"
- category_string = { 'category'=>cookbook_category }.to_json
+ category_string = Chef::JSONCompat.to_json({ 'category'=>cookbook_category })
http_resp = Chef::CookbookSiteStreamingUploader.post(uri, user_id, user_secret_filename, {
:tarball => File.open(cookbook_filename),
diff --git a/lib/chef/knife/deps.rb b/lib/chef/knife/deps.rb
index b2a39a0725..4b23468962 100644
--- a/lib/chef/knife/deps.rb
+++ b/lib/chef/knife/deps.rb
@@ -77,7 +77,7 @@ class Chef
return entry.chef_object.metadata.dependencies.keys.map { |cookbook| "/cookbooks/#{cookbook}" }
elsif entry.parent && entry.parent.path == '/nodes'
- node = JSON.parse(entry.read, :create_additions => false)
+ node = Chef::JSONCompat.parse(entry.read)
result = []
if node['chef_environment'] && node['chef_environment'] != '_default'
result << "/environments/#{node['chef_environment']}.json"
@@ -88,7 +88,7 @@ class Chef
result
elsif entry.parent && entry.parent.path == '/roles'
- role = JSON.parse(entry.read, :create_additions => false)
+ role = Chef::JSONCompat.parse(entry.read)
result = []
if role['run_list']
dependencies_from_runlist(role['run_list']).each do |dependency|
@@ -138,4 +138,3 @@ class Chef
end
end
end
-