GitHubArtifactDownloadStrategy: fix initialize signature

This commit is contained in:
Carlo Cabrera 2023-05-17 12:58:31 +08:00
parent ee6ef00a73
commit 9260bd97e8
No known key found for this signature in database
GPG Key ID: C74D447FC549A1D0
2 changed files with 6 additions and 12 deletions

View File

@ -637,9 +637,10 @@ end
# #
# @api private # @api private
class GitHubArtifactDownloadStrategy < AbstractFileDownloadStrategy class GitHubArtifactDownloadStrategy < AbstractFileDownloadStrategy
def initialize def initialize(url, artifact_id, token:)
super super(url, "artifact", artifact_id)
@cache = HOMEBREW_CACHE/"gh-actions-artifact" @cache = HOMEBREW_CACHE/"gh-actions-artifact"
@token = token
end end
def fetch(timeout: nil) def fetch(timeout: nil)
@ -649,8 +650,8 @@ class GitHubArtifactDownloadStrategy < AbstractFileDownloadStrategy
else else
begin begin
curl "--location", "--create-dirs", "--output", temporary_path, url, curl "--location", "--create-dirs", "--output", temporary_path, url,
*meta.fetch(:curl_args, []), "--header", "Authorization: token #{@token}",
secrets: meta.fetch(:secrets, []), secrets: [@token],
timeout: timeout timeout: timeout
rescue ErrorDuringExecution rescue ErrorDuringExecution
raise CurlDownloadStrategyError, url raise CurlDownloadStrategyError, url

View File

@ -383,18 +383,11 @@ module GitHub
odie "Credentials must be set to access the Artifacts API" if API.credentials_type == :none odie "Credentials must be set to access the Artifacts API" if API.credentials_type == :none
token = API.credentials token = API.credentials
curl_args = ["--header", "Authorization: token #{token}"]
# Download the artifact as a zip file and unpack it into `dir`. This is # Download the artifact as a zip file and unpack it into `dir`. This is
# preferred over system `curl` and `tar` as this leverages the Homebrew # preferred over system `curl` and `tar` as this leverages the Homebrew
# cache to avoid repeated downloads of (possibly large) bottles. # cache to avoid repeated downloads of (possibly large) bottles.
downloader = GitHubArtifactDownloadStrategy.new( downloader = GitHubArtifactDownloadStrategy.new(url, artifact_id, token: token)
url,
"artifact",
artifact_id,
curl_args: curl_args,
secrets: [token],
)
downloader.fetch downloader.fetch
downloader.stage downloader.stage
end end