resources/download_buildpack_cache.rb
def download_cache(configs)
    if configs.empty?
      @logger.warn 'No cache to download.'
      return
    end

    FileUtils.mkdir_p(@cache_dir)

    configs.each do |config|
      # Download index.yml first.
      index_uri = index_path(config)
      index_file = File.join(@cache_dir, filename(index_uri))
      download(index_uri, index_file)
      # Parse index.yml to see what files it references
      begin
        index = YAML.load_file(index_file)
      rescue => e
        abort "ERROR: Failed loading #{index_uri}: #{e}"
      end
      candidate = LibertyBuildpack::Util::TokenizedVersion.new(config[VERSION])
      version = LibertyBuildpack::Repository::VersionResolver.resolve(candidate, index.keys)
      if version.nil?
        @logger.warn "No matches found for #{candidate} version in #{index_uri}."
        next
      end
      file_uri = download_license(index[version.to_s], config[TYPE_KEY])
      file = File.join(@cache_dir, filename(file_uri))
      download(file_uri, file)
      # If file is a component_index.yml parse and download files it references as well
      download_components(file_uri, file) if file_uri.end_with? COMP_INDEX_PATH
    end
  end
# Downloads remote resources into the cache directory
#
# @param [Array<Hash>] configs array of configurations referencing index.yml
Downloads remote resources into the cache directory
Downloads remote resources into the cache directory
def download_cache(configs)
    if configs.empty?
      @logger.warn 'No cache to download.'
      return
    end
    FileUtils.mkdir_p(@cache_dir)
    configs.each do |config|
      index_uri = index_path(config)
      index_file = File.join(@cache_dir, filename(index_uri))
      download(index_uri, index_file)
      begin
        index = YAML.load_file(index_file)
      rescue => e
        abort "ERROR: Failed loading #{index_uri}: #{e}"
      end
      candidate = LibertyBuildpack::Util::TokenizedVersion.new(config[VERSION])
      version = LibertyBuildpack::Repository::VersionResolver.resolve(candidate, index.keys)
      if version.nil?
        @logger.warn "No matches found for #{candidate} version in #{index_uri}."
        next
      end
      file_uri = download_license(index[version.to_s], config[TYPE_KEY])
      file = File.join(@cache_dir, filename(file_uri))
      download(file_uri, file)
      download_components(file_uri, file) if file_uri.end_with? COMP_INDEX_PATH
    end
  end
def download_cache ( configs ) if configs . empty? @logger . warn 'No cache to download.' return end FileUtils . mkdir_p ( @cache_dir ) configs . each do | config | index_uri = index_path ( config ) index_file = File . join ( @cache_dir , filename ( index_uri ) ) download ( index_uri , index_file ) begin index = YAML . load_file ( index_file ) rescue => e abort "ERROR: Failed loading #{index_uri}: #{e}" end candidate = LibertyBuildpack :: Util :: TokenizedVersion . new ( config [ VERSION ] ) version = LibertyBuildpack :: Repository :: VersionResolver . resolve ( candidate , index . keys ) if version . nil? @logger . warn "No matches found for #{candidate} version in #{index_uri}." next end file_uri = download_license ( index [ version . to_s ] , config [ TYPE_KEY ] ) file = File . join ( @cache_dir , filename ( file_uri ) ) download ( file_uri , file ) download_components ( file_uri , file ) if file_uri . end_with? COMP_INDEX_PATH end end
Downloads remote resources into the cache directory
Downloads remote resources into the cache directory
# Download index.yml first. # Parse index.yml to see what files it references # If file is a component_index.yml parse and download files it references as well
configs
configs array of configurations referencing index.yml
configs array of configurations referencing index . yml