Skip to content

Commit

Permalink
Set Package.swift tools version to 5.9 (#739)
Browse files Browse the repository at this point in the history
* Set Package.swift tools version to 5.9

* swift format

* swift format
  • Loading branch information
adam-fowler authored Oct 17, 2024
1 parent 74b9952 commit e115810
Show file tree
Hide file tree
Showing 21 changed files with 59 additions and 63 deletions.
2 changes: 1 addition & 1 deletion .swiftformat
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
--minversion 0.51.0

# Swift version
--swiftversion 5.8
--swiftversion 5.9

# file options
--exclude .build
Expand Down
2 changes: 1 addition & 1 deletion Package.swift
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// swift-tools-version:5.8
// swift-tools-version:5.9
//===----------------------------------------------------------------------===//
//
// This source file is part of the Soto for AWS open source project
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public struct IdentityProviderFactory: Sendable {
self.cb = cb
}

internal func createProvider(context: Context) -> IdentityProvider {
func createProvider(context: Context) -> IdentityProvider {
self.cb(context)
}
}
Expand Down
2 changes: 1 addition & 1 deletion Sources/Soto/Extensions/DynamoDB/DynamoDBDecoder.swift
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ private class _DynamoDBDecoder: Decoder {
var attribute: DynamoDB.AttributeValue
let decoder: _DynamoDBDecoder

internal init(attribute: DynamoDB.AttributeValue, decoder: _DynamoDBDecoder) {
init(attribute: DynamoDB.AttributeValue, decoder: _DynamoDBDecoder) {
self.attribute = attribute
self.decoder = decoder
self.codingPath = decoder.codingPath
Expand Down
4 changes: 2 additions & 2 deletions Sources/Soto/Extensions/DynamoDB/DynamoDBEncoder.swift
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ class _DynamoDBEncoder: Encoder {
let container: _EncoderKeyedContainer
let encoder: _DynamoDBEncoder

internal init(container: _EncoderKeyedContainer, encoder: _DynamoDBEncoder) {
init(container: _EncoderKeyedContainer, encoder: _DynamoDBEncoder) {
self.container = container
self.encoder = encoder
self.codingPath = encoder.codingPath
Expand Down Expand Up @@ -274,7 +274,7 @@ class _DynamoDBEncoder: Encoder {
let container: _EncoderUnkeyedContainer
let encoder: _DynamoDBEncoder

internal init(container: _EncoderUnkeyedContainer, encoder: _DynamoDBEncoder) {
init(container: _EncoderUnkeyedContainer, encoder: _DynamoDBEncoder) {
self.container = container
self.encoder = encoder
self.codingPath = encoder.codingPath
Expand Down
21 changes: 9 additions & 12 deletions Sources/Soto/Extensions/S3/S3+multipart.swift
Original file line number Diff line number Diff line change
Expand Up @@ -402,11 +402,10 @@ extension S3 {

// create array of upload part requests.
let uploadPartRequests: [UploadPartCopyRequest] = (1...numParts).map { part in
let copyRange: String
if part != numParts {
copyRange = "bytes=\((part - 1) * partSize)-\(part * partSize - 1)"
let copyRange = if part != numParts {
"bytes=\((part - 1) * partSize)-\(part * partSize - 1)"
} else {
copyRange = "bytes=\((part - 1) * partSize)-\((part - 1) * partSize + finalPartSize - 1)"
"bytes=\((part - 1) * partSize)-\((part - 1) * partSize + finalPartSize - 1)"
}
return .init(bucket: input.bucket, copySource: input.copySource, copySourceRange: copyRange, copySourceSSECustomerAlgorithm: input.copySourceSSECustomerAlgorithm, copySourceSSECustomerKey: input.copySourceSSECustomerKey, copySourceSSECustomerKeyMD5: input.copySourceSSECustomerKeyMD5, expectedBucketOwner: input.expectedBucketOwner, expectedSourceBucketOwner: input.expectedSourceBucketOwner, key: input.key, partNumber: part, requestPayer: input.requestPayer, sseCustomerAlgorithm: input.sseCustomerAlgorithm, sseCustomerKey: input.sseCustomerKey, sseCustomerKeyMD5: input.sseCustomerKeyMD5, uploadId: uploadId)
}
Expand Down Expand Up @@ -687,11 +686,10 @@ extension S3 {
results.append(element)
}
}
let body: AWSHTTPBody
if let progress = newProgress {
body = .init(asyncSequence: buffer.asyncSequence(chunkSize: 64 * 1024).reportProgress(reportFn: progress), length: buffer.readableBytes)
let body: AWSHTTPBody = if let progress = newProgress {
.init(asyncSequence: buffer.asyncSequence(chunkSize: 64 * 1024).reportProgress(reportFn: progress), length: buffer.readableBytes)
} else {
body = .init(asyncSequence: buffer.asyncSequence(chunkSize: 64 * 1024), length: buffer.readableBytes)
.init(asyncSequence: buffer.asyncSequence(chunkSize: 64 * 1024), length: buffer.readableBytes)
}
group.addTask {
// Multipart uploads part numbers start at 1 not 0
Expand Down Expand Up @@ -747,12 +745,11 @@ extension S3 {

// from bucket, key and version id from a copySource string
func getBucketKeyVersion(from copySource: String) -> (bucket: String, key: String, versionId: String?)? {
let path: Substring
// drop first slash if it exists
if copySource.first == "/" {
path = copySource.dropFirst()
let path = if copySource.first == "/" {
copySource.dropFirst()
} else {
path = Substring(copySource)
Substring(copySource)
}
// find first slash
guard let slashIndex = path.firstIndex(of: "/") else { return nil }
Expand Down
4 changes: 2 additions & 2 deletions Sources/Soto/Extensions/STS/Environment.swift
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ import Glibc
import Darwin.C
#endif

internal enum Environment {
internal static subscript(_ name: String) -> String? {
enum Environment {
static subscript(_ name: String) -> String? {
guard let value = getenv(name) else {
return nil
}
Expand Down
4 changes: 2 additions & 2 deletions Tests/SotoTests/Services/APIGateway/APIGatewayTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,12 @@ class APIGatewayTests: XCTestCase {
static var restApiId: String!

override class func setUp() {
Self.client = AWSClient(
self.client = AWSClient(
credentialProvider: TestEnvironment.credentialProvider,
middleware: TestEnvironment.middlewares,
logger: TestEnvironment.logger
)
Self.apiGateway = APIGateway(
self.apiGateway = APIGateway(
client: APIGatewayTests.client,
region: .euwest1,
endpoint: TestEnvironment.getEndPoint(environment: "LOCALSTACK_ENDPOINT")
Expand Down
6 changes: 3 additions & 3 deletions Tests/SotoTests/Services/ApiGatewayV2/APIGatewayV2Tests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,13 @@ class APIGatewayV2Tests: XCTestCase {

override class func setUp() {
guard !TestEnvironment.isUsingLocalstack else { return }
Self.client = AWSClient(
self.client = AWSClient(
credentialProvider: TestEnvironment.credentialProvider,
middleware: TestEnvironment.middlewares,
logger: TestEnvironment.logger
)
Self.apiGatewayV2 = ApiGatewayV2(
client: Self.client,
self.apiGatewayV2 = ApiGatewayV2(
client: self.client,
region: .euwest1,
endpoint: TestEnvironment.getEndPoint(environment: "LOCALSTACK_ENDPOINT")
)
Expand Down
4 changes: 2 additions & 2 deletions Tests/SotoTests/Services/CloudTrail/CloudTrailTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ class CloudTrailTests: XCTestCase {
static var cloudTrail: CloudTrail!

override class func setUp() {
Self.client = AWSClient(credentialProvider: TestEnvironment.credentialProvider, middleware: TestEnvironment.middlewares)
Self.cloudTrail = CloudTrail(
self.client = AWSClient(credentialProvider: TestEnvironment.credentialProvider, middleware: TestEnvironment.middlewares)
self.cloudTrail = CloudTrail(
client: CloudTrailTests.client,
region: .euwest1,
endpoint: TestEnvironment.getEndPoint(environment: "LOCALSTACK_ENDPOINT")
Expand Down
4 changes: 2 additions & 2 deletions Tests/SotoTests/Services/DynamoDB/DynamoDBTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ class DynamoDBTests: XCTestCase {
print("Connecting to AWS")
}

Self.client = AWSClient(credentialProvider: TestEnvironment.credentialProvider, middleware: TestEnvironment.middlewares)
Self.dynamoDB = DynamoDB(
self.client = AWSClient(credentialProvider: TestEnvironment.credentialProvider, middleware: TestEnvironment.middlewares)
self.dynamoDB = DynamoDB(
client: DynamoDBTests.client,
region: .useast1,
endpoint: TestEnvironment.getEndPoint(environment: "LOCALSTACK_ENDPOINT")
Expand Down
4 changes: 2 additions & 2 deletions Tests/SotoTests/Services/Glacier/GlacierTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ class GlacierTests: XCTestCase {
static var glacier: Glacier!

override class func setUp() {
Self.client = AWSClient(credentialProvider: TestEnvironment.credentialProvider, middleware: TestEnvironment.middlewares)
Self.glacier = Glacier(
self.client = AWSClient(credentialProvider: TestEnvironment.credentialProvider, middleware: TestEnvironment.middlewares)
self.glacier = Glacier(
client: GlacierTests.client,
region: .euwest1,
endpoint: TestEnvironment.getEndPoint(environment: "LOCALSTACK_ENDPOINT")
Expand Down
6 changes: 3 additions & 3 deletions Tests/SotoTests/Services/IAM/IAMTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -29,15 +29,15 @@ class IAMTests: XCTestCase {
print("Connecting to AWS")
}

Self.client = AWSClient(credentialProvider: TestEnvironment.credentialProvider, middleware: TestEnvironment.middlewares)
Self.iam = IAM(
self.client = AWSClient(credentialProvider: TestEnvironment.credentialProvider, middleware: TestEnvironment.middlewares)
self.iam = IAM(
client: IAMTests.client,
endpoint: TestEnvironment.getEndPoint(environment: "LOCALSTACK_ENDPOINT")
)
}

override class func tearDown() {
XCTAssertNoThrow(try Self.client.syncShutdown())
XCTAssertNoThrow(try self.client.syncShutdown())
}

/// create SNS topic with supplied name and run supplied closure
Expand Down
8 changes: 4 additions & 4 deletions Tests/SotoTests/Services/Lambda/LambdaTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -103,17 +103,17 @@ class LambdaTests: XCTestCase {
print("Connecting to AWS")
}

Self.client = AWSClient(
self.client = AWSClient(
credentialProvider: TestEnvironment.credentialProvider,
middleware: TestEnvironment.middlewares
)
Self.lambda = Lambda(
self.lambda = Lambda(
client: LambdaTests.client,
region: .euwest1,
endpoint: TestEnvironment.getEndPoint(environment: "LOCALSTACK_ENDPOINT")
).with(middleware: TestEnvironment.middlewares)
Self.iam = IAM(
client: Self.client,
self.iam = IAM(
client: self.client,
endpoint: TestEnvironment.getEndPoint(environment: "LOCALSTACK_ENDPOINT")
).with(middleware: TestEnvironment.middlewares)

Expand Down
17 changes: 8 additions & 9 deletions Tests/SotoTests/Services/S3/S3Tests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -34,20 +34,20 @@ class S3Tests: XCTestCase {
print("Connecting to AWS")
}

Self.client = AWSClient(
self.client = AWSClient(
credentialProvider: TestEnvironment.credentialProvider,
middleware: TestEnvironment.middlewares
)
Self.s3 = S3(
client: Self.client,
self.s3 = S3(
client: self.client,
region: .useast1,
endpoint: TestEnvironment.getEndPoint(environment: "LOCALSTACK_ENDPOINT")
)
Self.randomBytes = self.createRandomBuffer(size: 11 * 1024 * 1024)
self.randomBytes = self.createRandomBuffer(size: 11 * 1024 * 1024)
}

override class func tearDown() {
XCTAssertNoThrow(try Self.client.syncShutdown())
XCTAssertNoThrow(try self.client.syncShutdown())
}

static func createRandomBuffer(size: Int) -> ByteBuffer {
Expand Down Expand Up @@ -124,11 +124,10 @@ class S3Tests: XCTestCase {

func testPutGetObjectWithSpecialName() async throws {
let name = TestEnvironment.generateResourceName()
let filename: String
if TestEnvironment.isUsingLocalstack {
filename = "test $filé+!@£$%^&*()_=-[]{}\\|';:\",./?><~`.txt"
let filename = if TestEnvironment.isUsingLocalstack {
"test $filé+!@£$%^&*()_=-[]{}\\|';:\",./?><~`.txt"
} else {
filename = "test $filé+!@£$%2F%^&*()_=-[]{}\\|';:\",./?><~`.txt"
"test $filé+!@£$%2F%^&*()_=-[]{}\\|';:\",./?><~`.txt"
}
try await self.testPutGetObject(
bucket: name,
Expand Down
8 changes: 4 additions & 4 deletions Tests/SotoTests/Services/SES/SESTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -28,16 +28,16 @@ class SESTests: XCTestCase {
print("Connecting to AWS")
}

Self.client = AWSClient(credentialProvider: TestEnvironment.credentialProvider, middleware: TestEnvironment.middlewares)
Self.ses = SES(
client: Self.client,
self.client = AWSClient(credentialProvider: TestEnvironment.credentialProvider, middleware: TestEnvironment.middlewares)
self.ses = SES(
client: self.client,
region: .useast1,
endpoint: TestEnvironment.getEndPoint(environment: "LOCALSTACK_ENDPOINT")
)
}

override class func tearDown() {
XCTAssertNoThrow(try Self.client.syncShutdown())
XCTAssertNoThrow(try self.client.syncShutdown())
}

// Tests query protocol requests with no body
Expand Down
6 changes: 3 additions & 3 deletions Tests/SotoTests/Services/SNS/SNSTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -28,16 +28,16 @@ class SNSTests: XCTestCase {
print("Connecting to AWS")
}

Self.client = AWSClient(credentialProvider: TestEnvironment.credentialProvider, middleware: TestEnvironment.middlewares)
Self.sns = SNS(
self.client = AWSClient(credentialProvider: TestEnvironment.credentialProvider, middleware: TestEnvironment.middlewares)
self.sns = SNS(
client: SNSTests.client,
region: .useast1,
endpoint: TestEnvironment.getEndPoint(environment: "LOCALSTACK_ENDPOINT")
)
}

override class func tearDown() {
XCTAssertNoThrow(try Self.client.syncShutdown())
XCTAssertNoThrow(try self.client.syncShutdown())
}

/// create SNS topic with supplied name and run supplied closure
Expand Down
6 changes: 3 additions & 3 deletions Tests/SotoTests/Services/SQS/SQSTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -28,16 +28,16 @@ class SQSTests: XCTestCase {
print("Connecting to AWS")
}

Self.client = AWSClient(credentialProvider: TestEnvironment.credentialProvider, middleware: TestEnvironment.middlewares)
Self.sqs = SQS(
self.client = AWSClient(credentialProvider: TestEnvironment.credentialProvider, middleware: TestEnvironment.middlewares)
self.sqs = SQS(
client: SQSTests.client,
region: .useast1,
endpoint: TestEnvironment.getEndPoint(environment: "LOCALSTACK_ENDPOINT")
)
}

override class func tearDown() {
XCTAssertNoThrow(try Self.client.syncShutdown())
XCTAssertNoThrow(try self.client.syncShutdown())
}

/// create SQS queue with supplied name and run supplied closure
Expand Down
6 changes: 3 additions & 3 deletions Tests/SotoTests/Services/SSM/SSMTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -28,16 +28,16 @@ class SSMTests: XCTestCase {
print("Connecting to AWS")
}

Self.client = AWSClient(credentialProvider: TestEnvironment.credentialProvider, middleware: TestEnvironment.middlewares)
Self.ssm = SSM(
self.client = AWSClient(credentialProvider: TestEnvironment.credentialProvider, middleware: TestEnvironment.middlewares)
self.ssm = SSM(
client: SSMTests.client,
region: .useast1,
endpoint: TestEnvironment.getEndPoint(environment: "LOCALSTACK_ENDPOINT")
)
}

override class func tearDown() {
XCTAssertNoThrow(try Self.client.syncShutdown())
XCTAssertNoThrow(try self.client.syncShutdown())
}

/// put parameter, test it, delete it
Expand Down
4 changes: 2 additions & 2 deletions Tests/SotoTests/test.swift
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ extension Task where Failure == Error {
///
/// - Note: This function blocks the thread until the given operation is finished. The caller is responsible for managing multithreading.
@available(*, noasync, message: "synchronous() can block indefinitely")
internal func syncAwait() throws -> Success {
func syncAwait() throws -> Success {
let semaphore = DispatchSemaphore(value: 0)
let resultBox = SendableBox<Result<Success, Failure>>()

Expand All @@ -56,7 +56,7 @@ extension Task where Failure == Never {
///
/// - Note: This function blocks the thread until the given operation is finished. The caller is responsible for managing multithreading.
@available(*, noasync, message: "synchronous() can block indefinitely")
internal func syncAwait() -> Success {
func syncAwait() -> Success {
let semaphore = DispatchSemaphore(value: 0)
let resultBox = SendableBox<Success>()

Expand Down
2 changes: 1 addition & 1 deletion scripts/templates/generate-package/Package.mustache
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{{%CONTENT_TYPE:TEXT}}
// swift-tools-version:5.8
// swift-tools-version:5.9
//===----------------------------------------------------------------------===//
//
// This source file is part of the Soto for AWS open source project
Expand Down

0 comments on commit e115810

Please sign in to comment.