class Chef::Knife::SupermarketDownload
Public Instance Methods
run()
click to toggle source
# File lib/chef/knife/supermarket_download.rb, line 48 def run if current_cookbook_deprecated? message = "DEPRECATION: This cookbook has been deprecated. " replacement = replacement_cookbook if !replacement.to_s.strip.empty? message << "It has been replaced by #{replacement}." else message << "No replacement has been defined." end 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/supermarket_download.rb, line 68 def version @version = desired_cookbook_data["version"] end
Private Instance Methods
cookbooks_api_url()
click to toggle source
# File lib/chef/knife/supermarket_download.rb, line 74 def cookbooks_api_url "#{config[:supermarket_site]}/api/v1/cookbooks" end
current_cookbook_data()
click to toggle source
# File lib/chef/knife/supermarket_download.rb, line 78 def current_cookbook_data @current_cookbook_data ||= begin noauth_rest.get "#{cookbooks_api_url}/#{@name_args[0]}" end end
current_cookbook_deprecated?()
click to toggle source
# File lib/chef/knife/supermarket_download.rb, line 84 def current_cookbook_deprecated? current_cookbook_data["deprecated"] == true end
desired_cookbook_data()
click to toggle source
# File lib/chef/knife/supermarket_download.rb, line 88 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 uri end end
download_cookbook()
click to toggle source
# File lib/chef/knife/supermarket_download.rb, line 100 def download_cookbook ui.info "Downloading #{@name_args[0]} from Supermarket at version #{version} to #{download_location}" tf = noauth_rest.streaming_request(desired_cookbook_data["file"]) ::FileUtils.cp tf.path, download_location ui.info "Cookbook saved: #{download_location}" end
download_location()
click to toggle source
# File lib/chef/knife/supermarket_download.rb, line 108 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/supermarket_download.rb, line 113 def replacement_cookbook File.basename(current_cookbook_data["replacement"] || "") end
specific_cookbook_version_url()
click to toggle source
# File lib/chef/knife/supermarket_download.rb, line 117 def specific_cookbook_version_url "#{cookbooks_api_url}/#{@name_args[0]}/versions/#{@name_args[1].tr('.', '_')}" end