diff --git a/Package.swift b/Package.swift index fe9533bd..39a85520 100644 --- a/Package.swift +++ b/Package.swift @@ -55,7 +55,14 @@ let package = Package( verb: "archive", description: "Archive the Lambda binary and prepare it for uploading to AWS. Requires docker on macOS or non Amazonlinux 2 distributions." - ) + ), + permissions: [ + .allowNetworkConnections( + scope: .docker, + reason: + "The archiver plugin needs docker to build the executable that can be run in AWS Lambda." + ) + ] ) ), .testTarget( diff --git a/Plugins/AWSLambdaPackager/Plugin.swift b/Plugins/AWSLambdaPackager/Plugin.swift index 2e091c74..52fbe624 100644 --- a/Plugins/AWSLambdaPackager/Plugin.swift +++ b/Plugins/AWSLambdaPackager/Plugin.swift @@ -12,8 +12,8 @@ // //===----------------------------------------------------------------------===// -import PackagePlugin import Foundation +import PackagePlugin @main @available(macOS 15.0, *) @@ -112,7 +112,9 @@ struct AWSLambdaPackager: CommandPlugin { guard let buildPathOutput = dockerBuildOutputPath.split(separator: "\n").last else { throw Errors.failedParsingDockerOutput(dockerBuildOutputPath) } - let buildOutputPath = URL(string: buildPathOutput.replacingOccurrences(of: "/workspace/", with: packageDirectory.description))! + let buildOutputPath = URL( + string: buildPathOutput.replacingOccurrences(of: "/workspace/", with: packageDirectory.description) + )! // build the products var builtProducts = [LambdaProduct: URL]() @@ -126,7 +128,7 @@ struct AWSLambdaPackager: CommandPlugin { // just like Package.swift's examples assume ../.., we assume we are two levels below the root project let slice = packageDirectory.pathComponents.suffix(2) let beforeLastComponent = packageDirectory.pathComponents[slice.startIndex] - let lastComponent = packageDirectory.pathComponents[slice.endIndex-1] + let lastComponent = packageDirectory.pathComponents[slice.endIndex - 1] try Utils.execute( executable: dockerToolPath, arguments: [ @@ -302,7 +304,7 @@ private struct Configuration: CustomStringConvertible { var isDirectory: Bool = false #else var isDirectory: ObjCBool = false - #endif + #endif guard FileManager.default.fileExists(atPath: outputPath, isDirectory: &isDirectory) else { throw Errors.invalidArgument("invalid output directory '\(outputPath)'") @@ -447,7 +449,9 @@ private struct LambdaProduct: Hashable { extension PackageManager.BuildResult { // find the executable produced by the build func executableArtifact(for product: Product) -> PackageManager.BuildResult.BuiltArtifact? { - let executables = self.builtArtifacts.filter { $0.kind == .executable && $0.url.lastPathComponent == product.name } + let executables = self.builtArtifacts.filter { + $0.kind == .executable && $0.url.lastPathComponent == product.name + } guard !executables.isEmpty else { return nil } diff --git a/Plugins/AWSLambdaPackager/PluginUtils.swift b/Plugins/AWSLambdaPackager/PluginUtils.swift index 6f60f7c4..0cc3b5fe 100644 --- a/Plugins/AWSLambdaPackager/PluginUtils.swift +++ b/Plugins/AWSLambdaPackager/PluginUtils.swift @@ -13,9 +13,9 @@ //===----------------------------------------------------------------------===// import Dispatch +import Foundation import PackagePlugin import Synchronization -import Foundation @available(macOS 15.0, *) struct Utils { diff --git a/Sources/AWSLambdaRuntimeCore/LambdaRuntime.swift b/Sources/AWSLambdaRuntimeCore/LambdaRuntime.swift index f36c7ee3..908e2ab2 100644 --- a/Sources/AWSLambdaRuntimeCore/LambdaRuntime.swift +++ b/Sources/AWSLambdaRuntimeCore/LambdaRuntime.swift @@ -14,15 +14,15 @@ import Foundation import Logging -import NIOCore import NIOConcurrencyHelpers +import NIOCore // We need `@unchecked` Sendable here, as `NIOLockedValueBox` does not understand `sending` today. // We don't want to use `NIOLockedValueBox` here anyway. We would love to use Mutex here, but this // sadly crashes the compiler today. public final class LambdaRuntime: @unchecked Sendable where Handler: StreamingLambdaHandler { // TODO: We want to change this to Mutex as soon as this doesn't crash the Swift compiler on Linux anymore - let handlerMutex: NIOLockedValueBox> + let handlerMutex: NIOLockedValueBox let logger: Logger let eventLoop: EventLoop