Skip to content

Commit

Permalink
Refactor resolveRegion method name to getRegion for consistency.
Browse files Browse the repository at this point in the history
  • Loading branch information
Sichan Yoo committed Jan 9, 2024
1 parent ed21c50 commit c981525
Show file tree
Hide file tree
Showing 9 changed files with 14 additions and 14 deletions.
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 @@ -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")
}
}

0 comments on commit c981525

Please sign in to comment.