docs: clarify application of HOMEBREW_ARTIFACT_DOMAIN
bottle URLs are treated differently than any other URL. this change clarifies the resulting URLs in the manpage. closes #13222
This commit is contained in:
parent
bb3d97030c
commit
b2796ec7fb
@ -23,7 +23,12 @@ module Homebrew
|
|||||||
description: "Prefix all download URLs, including those for bottles, with this value. " \
|
description: "Prefix all download URLs, including those for bottles, with this value. " \
|
||||||
"For example, `HOMEBREW_ARTIFACT_DOMAIN=http://localhost:8080` will cause a " \
|
"For example, `HOMEBREW_ARTIFACT_DOMAIN=http://localhost:8080` will cause a " \
|
||||||
"formula with the URL `https://example.com/foo.tar.gz` to instead download from " \
|
"formula with the URL `https://example.com/foo.tar.gz` to instead download from " \
|
||||||
"`http://localhost:8080/example.com/foo.tar.gz`.",
|
"`http://localhost:8080/https://example.com/foo.tar.gz`. " \
|
||||||
|
"Bottle URLs however, have their domain replaced with this prefix. " \
|
||||||
|
"Using the same value for example, would cause data hosted under " \
|
||||||
|
"`https://ghcr.io/v2/homebrew/core/gettext/manifests/0.21` " \
|
||||||
|
"to be instead downloaded from " \
|
||||||
|
"`http://localhost:8080/v2/homebrew/core/gettext/manifests/0.21`",
|
||||||
},
|
},
|
||||||
HOMEBREW_AUTO_UPDATE_SECS: {
|
HOMEBREW_AUTO_UPDATE_SECS: {
|
||||||
description: "Run `brew update` once every `HOMEBREW_AUTO_UPDATE_SECS` seconds before some commands, " \
|
description: "Run `brew update` once every `HOMEBREW_AUTO_UPDATE_SECS` seconds before some commands, " \
|
||||||
|
@ -10,6 +10,7 @@ describe CurlDownloadStrategy do
|
|||||||
let(:url) { "https://example.com/foo.tar.gz" }
|
let(:url) { "https://example.com/foo.tar.gz" }
|
||||||
let(:version) { "1.2.3" }
|
let(:version) { "1.2.3" }
|
||||||
let(:specs) { { user: "download:123456" } }
|
let(:specs) { { user: "download:123456" } }
|
||||||
|
let(:artifact_domain) { nil }
|
||||||
|
|
||||||
it "parses the opts and sets the corresponding args" do
|
it "parses the opts and sets the corresponding args" do
|
||||||
expect(strategy.send(:_curl_args)).to eq(["--user", "download:123456"])
|
expect(strategy.send(:_curl_args)).to eq(["--user", "download:123456"])
|
||||||
@ -17,6 +18,8 @@ describe CurlDownloadStrategy do
|
|||||||
|
|
||||||
describe "#fetch" do
|
describe "#fetch" do
|
||||||
before do
|
before do
|
||||||
|
allow(Homebrew::EnvConfig).to receive(:artifact_domain).and_return(artifact_domain)
|
||||||
|
|
||||||
strategy.temporary_path.dirname.mkpath
|
strategy.temporary_path.dirname.mkpath
|
||||||
FileUtils.touch strategy.temporary_path
|
FileUtils.touch strategy.temporary_path
|
||||||
end
|
end
|
||||||
@ -123,6 +126,59 @@ describe CurlDownloadStrategy do
|
|||||||
strategy.fetch
|
strategy.fetch
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
context "with artifact_domain set" do
|
||||||
|
let(:artifact_domain) { "https://mirror.example.com/oci" }
|
||||||
|
|
||||||
|
context "with an asset hosted under example.com" do
|
||||||
|
let(:status) { instance_double(Process::Status, success?: true, exitstatus: 0) }
|
||||||
|
|
||||||
|
it "prefixes the URL unchanged" do
|
||||||
|
expect(strategy).to receive(:system_command).with(
|
||||||
|
/curl/,
|
||||||
|
hash_including(args: array_including_cons("#{artifact_domain}/#{url}")),
|
||||||
|
)
|
||||||
|
.at_least(:once)
|
||||||
|
.and_return(SystemCommand::Result.new(["curl"], [""], status, secrets: []))
|
||||||
|
|
||||||
|
strategy.fetch
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
context "with an asset hosted under #{GitHubPackages::URL_DOMAIN} (HTTP)" do
|
||||||
|
let(:resource_path) { "v2/homebrew/core/spec/manifests/0.0" }
|
||||||
|
let(:url) { "http://#{GitHubPackages::URL_DOMAIN}/#{resource_path}" }
|
||||||
|
let(:status) { instance_double(Process::Status, success?: true, exitstatus: 0) }
|
||||||
|
|
||||||
|
it "rewrites the URL correctly" do
|
||||||
|
expect(strategy).to receive(:system_command).with(
|
||||||
|
/curl/,
|
||||||
|
hash_including(args: array_including_cons("#{artifact_domain}/#{resource_path}")),
|
||||||
|
)
|
||||||
|
.at_least(:once)
|
||||||
|
.and_return(SystemCommand::Result.new(["curl"], [""], status, secrets: []))
|
||||||
|
|
||||||
|
strategy.fetch
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
context "with an asset hosted under #{GitHubPackages::URL_DOMAIN} (HTTPS)" do
|
||||||
|
let(:resource_path) { "v2/homebrew/core/spec/manifests/0.0" }
|
||||||
|
let(:url) { "https://#{GitHubPackages::URL_DOMAIN}/#{resource_path}" }
|
||||||
|
let(:status) { instance_double(Process::Status, success?: true, exitstatus: 0) }
|
||||||
|
|
||||||
|
it "rewrites the URL correctly" do
|
||||||
|
expect(strategy).to receive(:system_command).with(
|
||||||
|
/curl/,
|
||||||
|
hash_including(args: array_including_cons("#{artifact_domain}/#{resource_path}")),
|
||||||
|
)
|
||||||
|
.at_least(:once)
|
||||||
|
.and_return(SystemCommand::Result.new(["curl"], [""], status, secrets: []))
|
||||||
|
|
||||||
|
strategy.fetch
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
describe "#cached_location" do
|
describe "#cached_location" do
|
||||||
|
Loading…
x
Reference in New Issue
Block a user