diff --git a/Sources/App/ASG/ASGClient.swift b/Sources/App/ASG/ASGClient.swift index dd52748..9293ebe 100644 --- a/Sources/App/ASG/ASGClient.swift +++ b/Sources/App/ASG/ASGClient.swift @@ -5,11 +5,11 @@ public protocol ASGClientRepresentable { func updateTags(_ tags: [AutoScaling.Tag]) async throws } -public struct ASGClient: ASGClientRepresentable { +public struct ASGClient: ASGClientRepresentable { let logger: Logger - let provider: Provider + let provider: AutoScaling - public init(logger: Logger, provider: Provider) { + public init(logger: Logger, provider: AutoScaling) { self.logger = logger self.provider = provider } diff --git a/Sources/App/ASG/ASGProvider.swift b/Sources/App/ASG/ASGProvider.swift deleted file mode 100644 index 9d1d2c7..0000000 --- a/Sources/App/ASG/ASGProvider.swift +++ /dev/null @@ -1,13 +0,0 @@ -import Foundation -import SotoAutoScaling - -public protocol ASGProvider { - func createOrUpdateTags(_ input: AutoScaling.CreateOrUpdateTagsType, logger: Logger) async throws -} - -extension AutoScaling: ASGProvider { - @inlinable - public func createOrUpdateTags(_ input: CreateOrUpdateTagsType, logger: Logger) async throws { - try await createOrUpdateTags(input, logger: logger, on: nil) - } -} diff --git a/Sources/App/AWSClient.swift b/Sources/App/AWSClient.swift new file mode 100644 index 0000000..1c73566 --- /dev/null +++ b/Sources/App/AWSClient.swift @@ -0,0 +1,15 @@ +import Foundation +import NIO +import SotoCore + +extension AWSClient { + public func shutdown(eventLoop: EventLoop) -> EventLoopFuture { + let promise = eventLoop.makePromise(of: Void.self) + + promise.completeWithTask { + try await self.shutdown() + } + + return promise.futureResult + } +} diff --git a/Sources/App/Application.swift b/Sources/App/Application.swift index 520eb56..cf3cec2 100644 --- a/Sources/App/Application.swift +++ b/Sources/App/Application.swift @@ -1,3 +1,4 @@ +import AsyncHTTPClient import AWSLambdaRuntime import Models import SotoCore @@ -14,8 +15,7 @@ public struct Application { self.context = context self.awsClient = AWSClient( - httpClientProvider: .createNewWithEventLoopGroup(self.context.eventLoop), - logger: self.context.logger + httpClient: HTTPClient(eventLoopGroup: self.context.eventLoop), logger: self.context.logger ) self.context.terminator.register(name: "\(type(of: AWSClient.self))", handler: self.awsClient.shutdown) @@ -44,13 +44,3 @@ public struct Application { } } } - -extension AWSClient { - func shutdown(eventLoop: EventLoop) -> EventLoopFuture { - let promise = eventLoop.makePromise(of: Void.self) - - promise.completeWithTask { try await self.shutdown() } - - return promise.futureResult - } -} diff --git a/Sources/App/EKS/EKSClient.swift b/Sources/App/EKS/EKSClient.swift index 881aad9..8f33aad 100644 --- a/Sources/App/EKS/EKSClient.swift +++ b/Sources/App/EKS/EKSClient.swift @@ -4,11 +4,11 @@ public protocol EKSClientRepresentable { func describeNodeGroup(name: String, clusterName: String) async throws -> EKS.Nodegroup } -public struct EKSClient: EKSClientRepresentable { +public struct EKSClient: EKSClientRepresentable { let logger: Logger - let provider: Provider + let provider: EKS - public init(logger: Logger, provider: Provider) { + public init(logger: Logger, provider: EKS) { self.logger = logger self.provider = provider } diff --git a/Sources/App/EKS/EKSProvider.swift b/Sources/App/EKS/EKSProvider.swift deleted file mode 100644 index fe6d71a..0000000 --- a/Sources/App/EKS/EKSProvider.swift +++ /dev/null @@ -1,15 +0,0 @@ -import Foundation -import SotoEKS - -public protocol EKSProvider { - func describeNodegroup(_ input: EKS.DescribeNodegroupRequest, logger: Logger) async throws - -> EKS.DescribeNodegroupResponse -} - -extension EKS: EKSProvider { - @inlinable - public func describeNodegroup(_ input: DescribeNodegroupRequest, logger: Logger) async throws - -> DescribeNodegroupResponse { - try await describeNodegroup(input, logger: logger, on: nil) - } -} diff --git a/Sources/Command/run.swift b/Sources/Command/run.swift index 918309c..5f8add8 100644 --- a/Sources/Command/run.swift +++ b/Sources/Command/run.swift @@ -1,5 +1,6 @@ import App import ArgumentParser +import AsyncHTTPClient import Foundation import Models import NIO @@ -27,8 +28,7 @@ struct Command: AsyncParsableCommand { let eventLoop = MultiThreadedEventLoopGroup(numberOfThreads: System.coreCount) let awsClient = AWSClient( - httpClientProvider: .createNewWithEventLoopGroup(eventLoop), - logger: logger + httpClient: HTTPClient(eventLoopGroup: eventLoop), logger: logger ) defer { diff --git a/lambda.Dockerfile b/lambda.Dockerfile index 05fc470..8b900a9 100644 --- a/lambda.Dockerfile +++ b/lambda.Dockerfile @@ -1,7 +1,7 @@ # ================================ # Build image # ================================ -FROM swift:5.9-bionic as builder +FROM swift:5.9-amazonlinux2 as builder # Set up a build area WORKDIR /build