diff --git a/.swiftformat b/.swiftformat index c6a065612f..e223f70e2b 100644 --- a/.swiftformat +++ b/.swiftformat @@ -2,7 +2,7 @@ --minversion 0.51.0 # Swift version ---swiftversion 5.8 +--swiftversion 5.9 # file options --exclude .build diff --git a/Package.swift b/Package.swift index d8aca3a6bb..a2cdcc2579 100644 --- a/Package.swift +++ b/Package.swift @@ -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 diff --git a/Sources/Soto/Extensions/CognitoIdentity/CognitoIdentity+IdentityProvider.swift b/Sources/Soto/Extensions/CognitoIdentity/CognitoIdentity+IdentityProvider.swift index a651d7dd01..f5a20fdd77 100644 --- a/Sources/Soto/Extensions/CognitoIdentity/CognitoIdentity+IdentityProvider.swift +++ b/Sources/Soto/Extensions/CognitoIdentity/CognitoIdentity+IdentityProvider.swift @@ -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) } } diff --git a/Sources/Soto/Extensions/DynamoDB/DynamoDBDecoder.swift b/Sources/Soto/Extensions/DynamoDB/DynamoDBDecoder.swift index a29fbef55f..510822190d 100644 --- a/Sources/Soto/Extensions/DynamoDB/DynamoDBDecoder.swift +++ b/Sources/Soto/Extensions/DynamoDB/DynamoDBDecoder.swift @@ -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 diff --git a/Sources/Soto/Extensions/DynamoDB/DynamoDBEncoder.swift b/Sources/Soto/Extensions/DynamoDB/DynamoDBEncoder.swift index 77ff52eea5..f39191a794 100644 --- a/Sources/Soto/Extensions/DynamoDB/DynamoDBEncoder.swift +++ b/Sources/Soto/Extensions/DynamoDB/DynamoDBEncoder.swift @@ -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 @@ -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 diff --git a/Sources/Soto/Extensions/S3/S3+multipart.swift b/Sources/Soto/Extensions/S3/S3+multipart.swift index 6e4738b7b3..984f781bad 100644 --- a/Sources/Soto/Extensions/S3/S3+multipart.swift +++ b/Sources/Soto/Extensions/S3/S3+multipart.swift @@ -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) } @@ -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 @@ -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 } diff --git a/Sources/Soto/Extensions/STS/Environment.swift b/Sources/Soto/Extensions/STS/Environment.swift index b4f473c6ed..59ec727ce5 100644 --- a/Sources/Soto/Extensions/STS/Environment.swift +++ b/Sources/Soto/Extensions/STS/Environment.swift @@ -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 } diff --git a/Tests/SotoTests/Services/APIGateway/APIGatewayTests.swift b/Tests/SotoTests/Services/APIGateway/APIGatewayTests.swift index 4489103b3a..07ddbec253 100644 --- a/Tests/SotoTests/Services/APIGateway/APIGatewayTests.swift +++ b/Tests/SotoTests/Services/APIGateway/APIGatewayTests.swift @@ -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") diff --git a/Tests/SotoTests/Services/ApiGatewayV2/APIGatewayV2Tests.swift b/Tests/SotoTests/Services/ApiGatewayV2/APIGatewayV2Tests.swift index 34beb2c893..d4f6a4ab68 100644 --- a/Tests/SotoTests/Services/ApiGatewayV2/APIGatewayV2Tests.swift +++ b/Tests/SotoTests/Services/ApiGatewayV2/APIGatewayV2Tests.swift @@ -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") ) diff --git a/Tests/SotoTests/Services/CloudTrail/CloudTrailTests.swift b/Tests/SotoTests/Services/CloudTrail/CloudTrailTests.swift index 0e6f7e3fb9..d595db0347 100644 --- a/Tests/SotoTests/Services/CloudTrail/CloudTrailTests.swift +++ b/Tests/SotoTests/Services/CloudTrail/CloudTrailTests.swift @@ -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") diff --git a/Tests/SotoTests/Services/DynamoDB/DynamoDBTests.swift b/Tests/SotoTests/Services/DynamoDB/DynamoDBTests.swift index b94d865985..dcb00d7214 100644 --- a/Tests/SotoTests/Services/DynamoDB/DynamoDBTests.swift +++ b/Tests/SotoTests/Services/DynamoDB/DynamoDBTests.swift @@ -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") diff --git a/Tests/SotoTests/Services/Glacier/GlacierTests.swift b/Tests/SotoTests/Services/Glacier/GlacierTests.swift index 702c9b904c..6d4e175daa 100644 --- a/Tests/SotoTests/Services/Glacier/GlacierTests.swift +++ b/Tests/SotoTests/Services/Glacier/GlacierTests.swift @@ -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") diff --git a/Tests/SotoTests/Services/IAM/IAMTests.swift b/Tests/SotoTests/Services/IAM/IAMTests.swift index 313c9ae601..2e67cc5b22 100644 --- a/Tests/SotoTests/Services/IAM/IAMTests.swift +++ b/Tests/SotoTests/Services/IAM/IAMTests.swift @@ -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 diff --git a/Tests/SotoTests/Services/Lambda/LambdaTests.swift b/Tests/SotoTests/Services/Lambda/LambdaTests.swift index 550befeff9..2d13911a9b 100644 --- a/Tests/SotoTests/Services/Lambda/LambdaTests.swift +++ b/Tests/SotoTests/Services/Lambda/LambdaTests.swift @@ -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) diff --git a/Tests/SotoTests/Services/S3/S3Tests.swift b/Tests/SotoTests/Services/S3/S3Tests.swift index 9a340044d1..dbdc699581 100644 --- a/Tests/SotoTests/Services/S3/S3Tests.swift +++ b/Tests/SotoTests/Services/S3/S3Tests.swift @@ -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 { @@ -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, diff --git a/Tests/SotoTests/Services/SES/SESTests.swift b/Tests/SotoTests/Services/SES/SESTests.swift index 70a720799c..4e1153eed3 100644 --- a/Tests/SotoTests/Services/SES/SESTests.swift +++ b/Tests/SotoTests/Services/SES/SESTests.swift @@ -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 diff --git a/Tests/SotoTests/Services/SNS/SNSTests.swift b/Tests/SotoTests/Services/SNS/SNSTests.swift index 933431bb0b..b34c02c962 100644 --- a/Tests/SotoTests/Services/SNS/SNSTests.swift +++ b/Tests/SotoTests/Services/SNS/SNSTests.swift @@ -28,8 +28,8 @@ 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") @@ -37,7 +37,7 @@ class SNSTests: XCTestCase { } override class func tearDown() { - XCTAssertNoThrow(try Self.client.syncShutdown()) + XCTAssertNoThrow(try self.client.syncShutdown()) } /// create SNS topic with supplied name and run supplied closure diff --git a/Tests/SotoTests/Services/SQS/SQSTests.swift b/Tests/SotoTests/Services/SQS/SQSTests.swift index a3d34ef6a6..e9c0495094 100644 --- a/Tests/SotoTests/Services/SQS/SQSTests.swift +++ b/Tests/SotoTests/Services/SQS/SQSTests.swift @@ -28,8 +28,8 @@ 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") @@ -37,7 +37,7 @@ class SQSTests: XCTestCase { } override class func tearDown() { - XCTAssertNoThrow(try Self.client.syncShutdown()) + XCTAssertNoThrow(try self.client.syncShutdown()) } /// create SQS queue with supplied name and run supplied closure diff --git a/Tests/SotoTests/Services/SSM/SSMTests.swift b/Tests/SotoTests/Services/SSM/SSMTests.swift index 982f6f4bb9..3c752704df 100644 --- a/Tests/SotoTests/Services/SSM/SSMTests.swift +++ b/Tests/SotoTests/Services/SSM/SSMTests.swift @@ -28,8 +28,8 @@ 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") @@ -37,7 +37,7 @@ class SSMTests: XCTestCase { } override class func tearDown() { - XCTAssertNoThrow(try Self.client.syncShutdown()) + XCTAssertNoThrow(try self.client.syncShutdown()) } /// put parameter, test it, delete it diff --git a/Tests/SotoTests/test.swift b/Tests/SotoTests/test.swift index 87db25c235..63d2c5c40d 100644 --- a/Tests/SotoTests/test.swift +++ b/Tests/SotoTests/test.swift @@ -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>() @@ -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() diff --git a/scripts/templates/generate-package/Package.mustache b/scripts/templates/generate-package/Package.mustache index 7155b7eef8..bf316bf8f9 100644 --- a/scripts/templates/generate-package/Package.mustache +++ b/scripts/templates/generate-package/Package.mustache @@ -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