Spec-Zone.ru › Homebrew

Class: GitHubArtifactDownloadStrategy Private

Inherits:
AbstractFileDownloadStrategy
  • Object
  • AbstractDownloadStrategy
  • AbstractFileDownloadStrategy
  • GitHubArtifactDownloadStrategy
show all
Defined in:
utils/github/artifacts/github_artifact_download_strategy.rb

Overview

This class is part of a private API. This class may only be used in the Homebrew/brew repository. Third parties should avoid using this class if possible, as it may be removed or changed without warning.

Strategy for downloading an artifact from GitHub Actions.

Instance Attribute Summary

Attributes inherited from AbstractDownloadStrategy

#cache, #url

Instance Method Summary collapse

  • #fetch(timeout: nil) ⇒ void private
  • #initialize(url, artifact_id, token:) ⇒ void constructor private

Methods inherited from AbstractFileDownloadStrategy

#basename, #cached_location, #create_symlink_to_cached_download, #fetched_size, #symlink_location, #temporary_path

Methods inherited from AbstractDownloadStrategy

#basename, #cached_location, #clear_cache, #fetched_size, #ohai, #quiet!, #quiet?, #source_modified_time, #source_revision, #stage, #total_size

Methods included from Utils::Output::Mixin

#issue_reporting_message, #odebug, #odeprecated, #odie, #odisabled, #ofail, #oh1, #oh1_title, #ohai, #ohai_title, #onoe, #opoo, #opoo_outside_github_actions, #opoo_without_github_actions_annotation, #pretty_deprecated, #pretty_disabled, #pretty_duration, #pretty_install_status, #pretty_installed, #pretty_uninstalled, #pretty_upgradable, #pretty_warning

Methods included from SystemCommand::Mixin

#system_command, #system_command!

Methods included from Context

current, current=, #debug?, #quiet?, #verbose?, #with_context

Constructor Details

#initialize(url, artifact_id, token:) ⇒ void

This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.

Parameters:

  • url (String)
  • artifact_id (String)
  • token (String)


7
8
9
10
11
# File 'utils/github/artifacts/github_artifact_download_strategy.rb', line 7

def initialize(url, artifact_id, token:)
  super(url, "artifact", artifact_id)
  @cache = T.let(HOMEBREW_CACHE/"gh-actions-artifact", Pathname)
  @token = token
end

Instance Method Details

#fetch(timeout: nil) ⇒ void

This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.

This method returns an undefined value.

Parameters:

  • timeout (Float, Integer, nil) (defaults to: nil)


14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'utils/github/artifacts/github_artifact_download_strategy.rb', line 14

def fetch(timeout: nil)
  ohai "Downloading #{url}"
  if cached_location.exist?
    puts "Already downloaded: #{cached_location}"
  else
    begin
      Utils::Curl.curl_download(url, to:      temporary_path,
                                     header:  "Authorization: token #{@token}",
                                     secrets: [@token],
                                     timeout:)
    rescue ErrorDuringExecution
      raise CurlDownloadStrategyError, url
    end
    cached_location.dirname.mkpath
    temporary_path.rename(cached_location.to_s)
  end

  symlink_location.dirname.mkpath
  FileUtils.ln_s cached_location.relative_path_from(symlink_location.dirname), symlink_location, force: true
end

© 2009–present Homebrew contributors
Licensed under the BSD 2-Clause License.
https://docs.brew.sh/rubydoc/GitHubArtifactDownloadStrategy.html

Spec-Zone.ru

Настройки Оффлайн Что нового Помощь О нас
Spec-Zone .ru
спецификации, руководства, описания, API