class Chef::Knife::CookbookSiteDownload
Public Instance Methods
run()
click to toggle source
# File lib/chef/knife/cookbook_site_download.rb, line 40 def run if current_cookbook_deprecated? message = 'DEPRECATION: This cookbook has been deprecated. ' message << "It has been replaced by #{replacement_cookbook}." ui.warn message unless config[:force] ui.warn 'Use --force to force download deprecated cookbook.' return end end download_cookbook end
version()
click to toggle source
# File lib/chef/knife/cookbook_site_download.rb, line 55 def version @version = desired_cookbook_data['version'] end
Private Instance Methods
cookbooks_api_url()
click to toggle source
# File lib/chef/knife/cookbook_site_download.rb, line 60 def cookbooks_api_url 'http://cookbooks.opscode.com/api/v1/cookbooks' end
current_cookbook_data()
click to toggle source
# File lib/chef/knife/cookbook_site_download.rb, line 64 def current_cookbook_data @current_cookbook_data ||= begin noauth_rest.get_rest "#{cookbooks_api_url}/#{@name_args[0]}" end end
current_cookbook_deprecated?()
click to toggle source
# File lib/chef/knife/cookbook_site_download.rb, line 70 def current_cookbook_deprecated? current_cookbook_data['deprecated'] == true end
desired_cookbook_data()
click to toggle source
# File lib/chef/knife/cookbook_site_download.rb, line 74 def desired_cookbook_data @desired_cookbook_data ||= begin uri = if @name_args.length == 1 current_cookbook_data['latest_version'] else specific_cookbook_version_url end noauth_rest.get_rest uri end end
download_cookbook()
click to toggle source
# File lib/chef/knife/cookbook_site_download.rb, line 86 def download_cookbook ui.info "Downloading #{@name_args[0]} from the cookbooks site at version #{version} to #{download_location}" noauth_rest.sign_on_redirect = false tf = noauth_rest.get_rest desired_cookbook_data["file"], true ::FileUtils.cp tf.path, download_location ui.info "Cookbook saved: #{download_location}" end
download_location()
click to toggle source
# File lib/chef/knife/cookbook_site_download.rb, line 95 def download_location config[:file] ||= File.join Dir.pwd, "#{@name_args[0]}-#{version}.tar.gz" config[:file] end
replacement_cookbook()
click to toggle source
# File lib/chef/knife/cookbook_site_download.rb, line 100 def replacement_cookbook replacement = File.basename(current_cookbook_data['replacement']) end
specific_cookbook_version_url()
click to toggle source
# File lib/chef/knife/cookbook_site_download.rb, line 104 def specific_cookbook_version_url "#{cookbooks_api_url}/#{@name_args[0]}/versions/#{@name_args[1].gsub('.', '_')}" end