Skip to content

Commit

Permalink
fix: update apis to new versions of Soto
Browse files Browse the repository at this point in the history
  • Loading branch information
portellaa committed Jul 17, 2024
1 parent 6691263 commit 880bf7e
Show file tree
Hide file tree
Showing 8 changed files with 26 additions and 49 deletions.
6 changes: 3 additions & 3 deletions Sources/App/ASG/ASGClient.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@ public protocol ASGClientRepresentable {
func updateTags(_ tags: [AutoScaling.Tag]) async throws
}

public struct ASGClient<Provider: ASGProvider>: 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
}
Expand Down
13 changes: 0 additions & 13 deletions Sources/App/ASG/ASGProvider.swift

This file was deleted.

15 changes: 15 additions & 0 deletions Sources/App/AWSClient.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import Foundation
import NIO
import SotoCore

extension AWSClient {
public func shutdown(eventLoop: EventLoop) -> EventLoopFuture<Void> {
let promise = eventLoop.makePromise(of: Void.self)

promise.completeWithTask {
try await self.shutdown()
}

return promise.futureResult
}
}
14 changes: 2 additions & 12 deletions Sources/App/Application.swift
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import AsyncHTTPClient
import AWSLambdaRuntime
import Models
import SotoCore
Expand All @@ -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)

Expand Down Expand Up @@ -44,13 +44,3 @@ public struct Application {
}
}
}

extension AWSClient {
func shutdown(eventLoop: EventLoop) -> EventLoopFuture<Void> {
let promise = eventLoop.makePromise(of: Void.self)

promise.completeWithTask { try await self.shutdown() }

return promise.futureResult
}
}
6 changes: 3 additions & 3 deletions Sources/App/EKS/EKSClient.swift
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ public protocol EKSClientRepresentable {
func describeNodeGroup(name: String, clusterName: String) async throws -> EKS.Nodegroup
}

public struct EKSClient<Provider: EKSProvider>: 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
}
Expand Down
15 changes: 0 additions & 15 deletions Sources/App/EKS/EKSProvider.swift

This file was deleted.

4 changes: 2 additions & 2 deletions Sources/Command/run.swift
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import App
import ArgumentParser
import AsyncHTTPClient
import Foundation
import Models
import NIO
Expand Down Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion lambda.Dockerfile
Original file line number Diff line number Diff line change
@@ -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
Expand Down

0 comments on commit 880bf7e

Please sign in to comment.