-
Notifications
You must be signed in to change notification settings - Fork 62
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Added Support for Custom Hosts/Regions #13
Merged
Merged
Changes from 8 commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
7940ea6
Added possibility to change the host
lluuaapp 637df2d
Fixed packages for Xcode 10
lluuaapp e16d7f4
Revert "Added possibility to change the host"
lluuaapp b19dcad
Added possibility to change tht hostname for minio support
lluuaapp 2371277
Added codable for new region object
lluuaapp a644104
Fixed URL for buckets in minio-configuration
lluuaapp d5eed6c
Added support for metadata
lluuaapp 9acfca8
Reverted changes for S3 metadata support
lluuaapp 5bc36d9
Added comments and improved formatting
lluuaapp File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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
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 |
---|---|---|
|
@@ -2,64 +2,126 @@ import Foundation | |
|
||
|
||
/// AWS Region | ||
public enum Region: String, Codable { | ||
|
||
/// US East (N. Virginia) | ||
case usEast1 = "us-east-1" | ||
|
||
/// US East (Ohio) | ||
case usEast2 = "us-east-2" | ||
|
||
/// US West (N. California) | ||
case usWest1 = "us-west-1" | ||
|
||
/// US West (Oregon) | ||
case usWest2 = "us-west-2" | ||
|
||
/// Canada (Central) | ||
case caCentral1 = "ca-central-1" | ||
|
||
/// EU (Frankfurt) | ||
case euCentral1 = "eu-central-1" | ||
|
||
/// EU (Ireland) | ||
case euWest1 = "eu-west-1" | ||
|
||
/// EU (London) | ||
case euWest2 = "eu-west-2" | ||
|
||
/// EU (Paris) | ||
case euWest3 = "eu-west-3" | ||
|
||
/// Asia Pacific (Tokyo) | ||
case apNortheast1 = "ap-northeast-1" | ||
|
||
/// Asia Pacific (Seoul) | ||
case apNortheast2 = "ap-northeast-2" | ||
|
||
/// Asia Pacific (Osaka-Local) | ||
case apNortheast3 = "ap-northeast-3" | ||
|
||
/// Asia Pacific (Singapore) | ||
case apSoutheast1 = "ap-southeast-1" | ||
|
||
/// Asia Pacific (Sydney) | ||
case apSoutheast2 = "ap-southeast-2" | ||
|
||
/// Asia Pacific (Mumbai) | ||
case apSouth1 = "ap-south-1" | ||
|
||
/// South America (São Paulo) | ||
case saEast1 = "sa-east-1" | ||
|
||
public struct Region { | ||
|
||
public let name: RegionName | ||
public let hostName: String? | ||
public let useTLS: Bool | ||
|
||
public enum RegionName : String, Codable { | ||
/// US East (N. Virginia) | ||
case usEast1 = "us-east-1" | ||
|
||
/// US East (Ohio) | ||
case usEast2 = "us-east-2" | ||
|
||
/// US West (N. California) | ||
case usWest1 = "us-west-1" | ||
|
||
/// US West (Oregon) | ||
case usWest2 = "us-west-2" | ||
|
||
/// Canada (Central) | ||
case caCentral1 = "ca-central-1" | ||
|
||
/// EU (Frankfurt) | ||
case euCentral1 = "eu-central-1" | ||
|
||
/// EU (Ireland) | ||
case euWest1 = "eu-west-1" | ||
|
||
/// EU (London) | ||
case euWest2 = "eu-west-2" | ||
|
||
/// EU (Paris) | ||
case euWest3 = "eu-west-3" | ||
|
||
/// Asia Pacific (Tokyo) | ||
case apNortheast1 = "ap-northeast-1" | ||
|
||
/// Asia Pacific (Seoul) | ||
case apNortheast2 = "ap-northeast-2" | ||
|
||
/// Asia Pacific (Osaka-Local) | ||
case apNortheast3 = "ap-northeast-3" | ||
|
||
/// Asia Pacific (Singapore) | ||
case apSoutheast1 = "ap-southeast-1" | ||
|
||
/// Asia Pacific (Sydney) | ||
case apSoutheast2 = "ap-southeast-2" | ||
|
||
/// Asia Pacific (Mumbai) | ||
case apSouth1 = "ap-south-1" | ||
|
||
/// South America (São Paulo) | ||
case saEast1 = "sa-east-1" | ||
} | ||
|
||
public init(name: RegionName, hostName: String? = nil, useTLS: Bool = true) { | ||
self.name = name | ||
self.hostName = hostName | ||
self.useTLS = useTLS | ||
} | ||
} | ||
|
||
|
||
extension Region { | ||
|
||
/// Base URL / Host | ||
public var host: String { | ||
return "s3.\(rawValue).amazonaws.com" | ||
if let host = hostName { | ||
return host | ||
} | ||
return "s3.\(name.rawValue).amazonaws.com" | ||
} | ||
} | ||
|
||
public extension Region { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don’t think the extension needs to have public, only methods within do |
||
init?(rawValue: String) { | ||
guard let name = RegionName(rawValue: rawValue) else { | ||
return nil | ||
} | ||
|
||
self.init(name: name) | ||
} | ||
|
||
static var usEast1: Region { return Region(name: RegionName.usEast1) } | ||
static var usEast2: Region { return Region(name: RegionName.usEast2) } | ||
static var usWest1: Region { return Region(name: RegionName.usWest1) } | ||
static var usWest2: Region { return Region(name: RegionName.usWest2) } | ||
static var caCentral1: Region { return Region(name: RegionName.caCentral1) } | ||
static var euCentral1: Region { return Region(name: RegionName.euCentral1) } | ||
static var euWest1: Region { return Region(name: RegionName.euWest1) } | ||
static var euWest2: Region { return Region(name: RegionName.euWest2) } | ||
static var euWest3: Region { return Region(name: RegionName.euWest3) } | ||
static var apNortheast1: Region { return Region(name: RegionName.apNortheast1) } | ||
static var apNortheast2: Region { return Region(name: RegionName.apNortheast2) } | ||
static var apNortheast3: Region { return Region(name: RegionName.apNortheast3) } | ||
static var apSoutheast1: Region { return Region(name: RegionName.apSoutheast1) } | ||
static var apSoutheast2: Region { return Region(name: RegionName.apSoutheast2) } | ||
static var apSouth1: Region { return Region(name: RegionName.apSouth1) } | ||
static var saEast1: Region { return Region(name: RegionName.saEast1) } | ||
} | ||
|
||
extension Region: Codable { | ||
public init(from decoder: Decoder) throws { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Space and comment please |
||
let container = try decoder.singleValueContainer() | ||
|
||
let name = try container.decode(String.self) | ||
|
||
guard let regionName = RegionName(rawValue: name) else { | ||
throw DecodingError.typeMismatch(String.self, DecodingError.Context(codingPath: [], | ||
debugDescription: "Could not find region for \(name)")) | ||
} | ||
|
||
self.name = regionName | ||
self.hostName = nil | ||
self.useTLS = true | ||
} | ||
|
||
public func encode(to encoder: Encoder) throws { | ||
var container = encoder.singleValueContainer() | ||
try container.encode(self.name.rawValue) | ||
} | ||
} |
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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add helper comments to these