class Chef::Knife::ArtifactoryDownload

Public Instance Methods

orig_run()
Alias for: run
run() click to toggle source
# File lib/chef/knife/artifactory_download.rb, line 25
def run
  config[:artifactory_download] = true
  Chef::Log.debug("[KNIFE-ART] running site download with config: #{config}")
  orig_run
end
Also aliased as: orig_run

Private Instance Methods

auth_header() click to toggle source
# File lib/chef/knife/artifactory_download.rb, line 71
def auth_header
  @auth_header ||= begin
                     ::KnifeArtifactory::Utils.auth_header_from(cookbooks_api_url)
                   end
end
current_cookbook_data() click to toggle source
# File lib/chef/knife/artifactory_download.rb, line 33
def current_cookbook_data
  unless config[:artifactory_download]
    Chef::Log.debug("[KNIFE-ART] ArtifactoryDownload::current_cookbook_data called without artifactory flag, delegating to super")
    return orig_current_cookbook_data
  end
  @current_cookbook_data ||= begin
    noauth_rest.get("#{cookbooks_api_url}/#{@name_args[0]}", auth_header)
  end
end
Also aliased as: orig_current_cookbook_data
desired_cookbook_data() click to toggle source
# File lib/chef/knife/artifactory_download.rb, line 43
def desired_cookbook_data
  unless config[:artifactory_download]
    Chef::Log.debug("[KNIFE-ART] ArtifactoryDownload::desired_cookbook_data called without artifactory flag, delegating to super")
    return orig_desired_cookbook_data
  end
  @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, auth_header)
  end
end
Also aliased as: orig_desired_cookbook_data
download_cookbook() click to toggle source
# File lib/chef/knife/artifactory_download.rb, line 59
def download_cookbook
  unless config[:artifactory_download]
    Chef::Log.debug("[KNIFE-ART] ArtifactoryDownload::download_cookbook called without artifactory flag, delegating to super")
    return orig_download_cookbook
  end
  ui.info "Downloading #{@name_args[0]} from Supermarket at version #{version} to #{download_location}"
  tf = noauth_rest.streaming_request(desired_cookbook_data["file"], auth_header)

  ::FileUtils.cp tf.path, download_location
  ui.info "Cookbook saved: #{download_location}"
end
Also aliased as: orig_download_cookbook
orig_current_cookbook_data()
orig_desired_cookbook_data()
orig_download_cookbook()
Alias for: download_cookbook