DownloadStrategyDetector recognizes s3 URL scheme
DownloadStrategyDetector now detects URLs with the s3:// prefix, e.g.: s3://my-bucket/path/to/key/tarball.tar.gz
This commit is contained in:
parent
2ec684a123
commit
a096284d03
@ -473,7 +473,8 @@ end
|
|||||||
# distribution. (It will work for public buckets as well.)
|
# distribution. (It will work for public buckets as well.)
|
||||||
class S3DownloadStrategy < CurlDownloadStrategy
|
class S3DownloadStrategy < CurlDownloadStrategy
|
||||||
def _fetch
|
def _fetch
|
||||||
if @url !~ %r{^https?://([^.].*)\.s3\.amazonaws\.com/(.+)$}
|
if @url !~ %r{^https?://([^.].*)\.s3\.amazonaws\.com/(.+)$} &&
|
||||||
|
@url !~ %r{^s3://([^.].*?)/(.+)$}
|
||||||
raise "Bad S3 URL: " + @url
|
raise "Bad S3 URL: " + @url
|
||||||
end
|
end
|
||||||
bucket = Regexp.last_match(1)
|
bucket = Regexp.last_match(1)
|
||||||
@ -1141,6 +1142,9 @@ class DownloadStrategyDetector
|
|||||||
SubversionDownloadStrategy
|
SubversionDownloadStrategy
|
||||||
when %r{^https?://(.+?\.)?sourceforge\.net/hgweb/}
|
when %r{^https?://(.+?\.)?sourceforge\.net/hgweb/}
|
||||||
MercurialDownloadStrategy
|
MercurialDownloadStrategy
|
||||||
|
when %r{^s3://}
|
||||||
|
require_aws_sdk
|
||||||
|
S3DownloadStrategy
|
||||||
else
|
else
|
||||||
CurlDownloadStrategy
|
CurlDownloadStrategy
|
||||||
end
|
end
|
||||||
|
|||||||
@ -260,6 +260,14 @@ describe DownloadStrategyDetector do
|
|||||||
it { is_expected.to eq(GitHubGitDownloadStrategy) }
|
it { is_expected.to eq(GitHubGitDownloadStrategy) }
|
||||||
end
|
end
|
||||||
|
|
||||||
|
context "when given an S3 URL" do
|
||||||
|
let(:url) { "s3://bucket/homebrew/brew.tar.gz" }
|
||||||
|
it "returns S3DownloadStrategy" do
|
||||||
|
allow(DownloadStrategyDetector).to receive(:require_aws_sdk).and_return(true)
|
||||||
|
is_expected.to eq(S3DownloadStrategy)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
context "when given strategy = S3DownloadStrategy" do
|
context "when given strategy = S3DownloadStrategy" do
|
||||||
let(:url) { "https://bkt.s3.amazonaws.com/key.tar.gz" }
|
let(:url) { "https://bkt.s3.amazonaws.com/key.tar.gz" }
|
||||||
let(:strategy) { S3DownloadStrategy }
|
let(:strategy) { S3DownloadStrategy }
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user