This repository was archived by the owner on Mar 26, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
expand S3 shorthand urls in authenticate_box_url hook
Vagrant 1.8 only supports HTTP metadata boxes. Expand s3:// shorthand URLs in the authenticate_box_url hook so that Vagrant's metadata check sees HTTP URLs. This method should also be compatibile with Vagrant 1.5+. Fix #27.
- Loading branch information
Showing
3 changed files
with
36 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
require 'uri' | ||
|
||
module VagrantPlugins | ||
module S3Auth | ||
class ExpandS3Urls | ||
def initialize(app, _) | ||
@app = app | ||
end | ||
|
||
def call(env) | ||
env[:box_urls].map! do |url_string| | ||
url = URI(url_string) | ||
|
||
if url.scheme == 's3' | ||
bucket = url.host | ||
key = url.path[1..-1] | ||
raise Errors::MalformedShorthandURLError, url: url unless bucket && key | ||
next "http://s3.amazonaws.com/#{bucket}/#{key}" | ||
end | ||
|
||
url_string | ||
end | ||
|
||
@app.call(env) | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters