Skip to content
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

fix!: Refactor resolveRegion method name to getRegion for consistency. #1291

Merged
merged 3 commits into from
Jan 12, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Sources/Core/AWSClientRuntime/AWSClientConfiguration.swift
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ extension AWSClientConfiguration {
if let region = region {
resolvedRegion = region
} else {
resolvedRegion = await resolvedRegionResolver.resolveRegion()
resolvedRegion = await resolvedRegionResolver.getRegion()
}
let resolvedCredentialsProvider: AWSClientRuntime.CredentialsProviding
if let credentialsProvider = credentialsProvider {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public struct BundleRegionProvider: RegionProvider {
self.regionKey = regionKey
}

public func resolveRegion() async throws -> String? {
public func getRegion() async throws -> String? {
#if os(iOS) || os(watchOS) || os(tvOS)
guard let region = region() else {
return nil
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@ public struct DefaultRegionResolver: RegionResolver {
self.logger = SwiftLogger(label: "DefaultRegionProvider")
}

public func resolveRegion() async -> String? {
public func getRegion() async -> String? {
for provider in providers {
logger.debug("Attempting to resolve region with: \(String(describing: type(of: provider)))")
do {
if let region = try await provider.resolveRegion() {
if let region = try await provider.getRegion() {
logger.debug("Resolved region with: \(String(describing: type(of: provider)))")
return region
}
Expand All @@ -49,7 +49,7 @@ public struct StaticRegionResolver: RegionResolver {
self.region = region
}

public func resolveRegion() async -> String? {
public func getRegion() async -> String? {
return region
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public struct EnvironmentRegionProvider: RegionProvider {
self.env = env
}

public func resolveRegion() async throws -> String? {
public func getRegion() async throws -> String? {
return env.environmentVariable(key: AWS_ENVIRON_REGION)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public struct IMDSRegionProvider: RegionProvider {
self.imdsClient = try IMDSClient()
}

public func resolveRegion() async throws -> String? {
public func getRegion() async throws -> String? {
return try await imdsClient.get(path: REGION_PATH)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ struct ProfileRegionProvider: RegionProvider {
self.credentialsFilePath = credentialsFilePath
}

func resolveRegion() async throws -> String? {
func getRegion() async throws -> String? {
guard let configuration = try await fileBasedConfigurationProvider(
configFilePath,
credentialsFilePath
Expand Down
2 changes: 1 addition & 1 deletion Sources/Core/AWSClientRuntime/Regions/RegionProvider.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@
import AwsCommonRuntimeKit

public protocol RegionProvider {
func resolveRegion() async throws -> String?
func getRegion() async throws -> String?
}
2 changes: 1 addition & 1 deletion Sources/Core/AWSClientRuntime/Regions/RegionResolver.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@

public protocol RegionResolver {
var providers: [RegionProvider] {get}
func resolveRegion() async -> String?
func getRegion() async -> String?
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class DefaultRegionResolverTests: XCTestCase {
let resolver = try DefaultRegionResolver(
fileBasedConfigurationProvider: fileBasedConfigProvider
)
let region = await resolver.resolveRegion()
let region = await resolver.getRegion()
XCTAssertEqual(region, "us-west-1")
} catch {
XCTFail("Failed to resolve region")
Expand All @@ -47,7 +47,7 @@ class DefaultRegionResolverTests: XCTestCase {
let resolver = try DefaultRegionResolver(
fileBasedConfigurationProvider: fileBasedConfigProvider
)
let region = await resolver.resolveRegion()
let region = await resolver.getRegion()
XCTAssertEqual(region, "us-east-2")
} catch {
XCTFail("Failed to resolve region")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class ProfileRegionProviderTests: XCTestCase {
fileBasedConfigurationProvider: fileBasedConfigProvider,
configFilePath: configPath
)
let region = try! await provider.resolveRegion()
let region = try! await provider.getRegion()
XCTAssertEqual(region, "us-east-2")
}

Expand All @@ -33,7 +33,7 @@ class ProfileRegionProviderTests: XCTestCase {
profileName: "west",
configFilePath: configPath
)
let region = try! await provider.resolveRegion()
let region = try! await provider.getRegion()
XCTAssertEqual(region, "us-west-2")
}

Expand All @@ -44,7 +44,7 @@ class ProfileRegionProviderTests: XCTestCase {
},
credentialsFilePath: configPath
)
let region = try! await provider.resolveRegion()
let region = try! await provider.getRegion()
XCTAssertEqual(region, "us-east-2")
}
}
Loading