class Chef::Knife::SupermarketShare
Public Instance Methods
do_upload(cookbook_filename, cookbook_category, user_id, user_secret_filename)
click to toggle source
# File lib/chef/knife/supermarket_share.rb, line 59 def do_upload(cookbook_filename, cookbook_category, user_id, user_secret_filename) uri = "#{config[:supermarket_site]}/api/v1/cookbooks" # Categories are optional both in knife cookbook site # (which this plugin seeks to replace) and on the # Supermarket community site. Best practice now # seems to be to just omit the category entirely. # # see: # https://github.com/chef/supermarket/pull/915 # https://github.com/chef/chef/pull/2198 category_string = { 'category'=>'' }.to_json http_resp = Chef::CookbookSiteStreamingUploader.post(uri, user_id, user_secret_filename, { :tarball => File.open(cookbook_filename), :cookbook => category_string }) res = Chef::JSONCompat.from_json(http_resp.body) if http_resp.code.to_i != 201 if res['error_messages'] if res['error_messages'][0] =~ /Version already exists/ ui.error "The same version of this cookbook already exists on the Opscode Cookbook Site." exit(1) else ui.error "#{res['error_messages'][0]}" exit(1) end else ui.error "Unknown error while sharing cookbook" ui.error "Server response: #{http_resp.body}" exit(1) end end res end
run()
click to toggle source
since we subclass cookbook_site and it expects a category, pass a phantom empty category parameter before invoking Chef::Knife::CookbookSiteShare#run … Tested on 11.16.4 and 12.0.3.
Calls superclass method
# File lib/chef/knife/supermarket_share.rb, line 52 def run Chef::Log.deprecation <<EOF The `knife-supermarket` gem has been deprecated and the `knife supermarket` subcommands have been moved in to core Chef. Please ensure you have Chef 12.12 or newer, and then uninstall this gem. EOF @name_args << "" if @name_args.length == 1 super end