Unverified Commit 2795a39d authored by Jared Szechy's avatar Jared Szechy
Browse files

Add config option to use path style S3 URLs



Signed-off-by: default avatarJared Szechy <jared.szechy@gmail.com>
parent f9446595
...@@ -315,6 +315,11 @@ module Omnibus ...@@ -315,6 +315,11 @@ module Omnibus
# @return [String, nil] # @return [String, nil]
default(:s3_endpoint, nil) default(:s3_endpoint, nil)
# Use path style URLs instead of subdomains for S3 URLs
#
# @return [true, false]
default(:s3_force_path_style, false)
# Enable or disable S3 Accelerate support # Enable or disable S3 Accelerate support
# #
# @return [true, false] # @return [true, false]
......
...@@ -144,6 +144,7 @@ module Omnibus ...@@ -144,6 +144,7 @@ module Omnibus
bucket_name: Config.s3_bucket, bucket_name: Config.s3_bucket,
endpoint: Config.s3_endpoint, endpoint: Config.s3_endpoint,
use_accelerate_endpoint: Config.s3_accelerate, use_accelerate_endpoint: Config.s3_accelerate,
force_path_style: Config.s3_force_path_style,
} }
if Config.s3_profile if Config.s3_profile
......
...@@ -38,6 +38,7 @@ module Omnibus ...@@ -38,6 +38,7 @@ module Omnibus
# bucket_name: Config.s3_bucket, # bucket_name: Config.s3_bucket,
# endpoint: Config.s3_endpoint, # endpoint: Config.s3_endpoint,
# use_accelerate_endpoint: Config.s3_accelerate # use_accelerate_endpoint: Config.s3_accelerate
# force_path_style: Config.s3_force_path_style
# } # }
# #
# @return [Hash<String, String>] # @return [Hash<String, String>]
...@@ -68,6 +69,7 @@ module Omnibus ...@@ -68,6 +69,7 @@ module Omnibus
def resource_params def resource_params
params = { params = {
use_accelerate_endpoint: s3_configuration[:use_accelerate_endpoint], use_accelerate_endpoint: s3_configuration[:use_accelerate_endpoint],
force_path_style: s3_configuration[:force_path_style],
} }
if s3_configuration[:use_accelerate_endpoint] if s3_configuration[:use_accelerate_endpoint]
......
...@@ -200,6 +200,17 @@ module Omnibus ...@@ -200,6 +200,17 @@ module Omnibus
end end
end end
context "custom endpoint with path style urls" do
before do
Config.s3_force_path_style(true)
Config.s3_endpoint("http://example.com")
end
it "returns the url using path style" do
expect(subject.send(:download_url)).to eq("http://example.com/mybucket/file-1.2.3-abcd1234")
end
end
context "s3 transfer acceleration" do context "s3 transfer acceleration" do
before { Config.s3_accelerate(true) } before { Config.s3_accelerate(true) }
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment