Skip to content

Commit 3652941

Browse files
authored
Merge pull request #52 from Automattic/remove/soto-s3
Remove SotoS3 and Alamofire
2 parents 314c1eb + 4eba395 commit 3652941

File tree

11 files changed

+128
-320
lines changed

11 files changed

+128
-320
lines changed

Package.resolved

Lines changed: 17 additions & 89 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Package.swift

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// swift-tools-version:5.6
1+
// swift-tools-version:5.7
22
// The swift-tools-version declares the minimum version of Swift required to build this package.
33

44
import PackageDescription
@@ -11,13 +11,12 @@ let package = Package(
1111
dependencies: [
1212
// Dependencies declare other packages that this package depends on.
1313
.package(url: "https://github.com/apple/swift-argument-parser", from: "1.1.4"),
14-
.package(url: "https://github.com/soto-project/soto.git", from: "6.0.0"),
15-
.package(url: "https://github.com/jkmassel/prlctl.git", from: "1.21.0"),
14+
.package(url: "https://github.com/jkmassel/tinys3.git", branch: "main"),
15+
.package(url: "https://github.com/jkmassel/prlctl.git", from: "1.22.0"),
1616
.package(url: "https://github.com/apple/swift-log.git", from: "1.0.0"),
1717
.package(url: "https://github.com/jkmassel/kcpassword-swift.git", from: "1.0.0"),
1818
.package(url: "https://github.com/swiftpackages/DotEnv.git", from: "3.0.0"),
1919
.package(url: "https://github.com/apple/swift-tools-support-core", from: "0.2.5"),
20-
.package(url: "https://github.com/Alamofire/Alamofire.git", .upToNextMajor(from: "5.6.1")),
2120
.package(url: "https://github.com/vapor/console-kit.git", .upToNextMajor(from: "4.5.0")),
2221
],
2322
targets: [
@@ -36,9 +35,8 @@ let package = Package(
3635
name: "libhostmgr",
3736
dependencies: [
3837
.product(name: "ArgumentParser", package: "swift-argument-parser"),
39-
.product(name: "SotoS3", package: "soto"),
4038
.product(name: "TSCBasic", package: "swift-tools-support-core"),
41-
.product(name: "Alamofire", package: "Alamofire"),
39+
.product(name: "tinys3", package: "tinys3"),
4240
.product(name: "ConsoleKit", package: "console-kit"),
4341
.product(name: "prlctl", package: "prlctl"),
4442
]

Sources/hostmgr/commands/sync/SyncAuthorizedKeysCommand.swift

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import Foundation
22
import ArgumentParser
33
import libhostmgr
4+
import tinys3
45

56
struct SyncAuthorizedKeysCommand: AsyncParsableCommand, FollowsCommandPolicies {
67

@@ -30,9 +31,13 @@ struct SyncAuthorizedKeysCommand: AsyncParsableCommand, FollowsCommandPolicies {
3031

3132
Console.heading("Syncing Authorized Keys")
3233

33-
let s3Manager = S3Manager(
34+
let credentials = try AWSCredentials.fromUserConfiguration()
35+
36+
let s3Manager = try S3Manager(
3437
bucket: Configuration.shared.authorizedKeysBucket,
35-
region: Configuration.shared.authorizedKeysRegion
38+
region: Configuration.shared.authorizedKeysRegion,
39+
credentials: credentials,
40+
endpoint: .accelerated
3641
)
3742

3843
guard let object = try await s3Manager.lookupObject(atPath: Constants.s3Key) else {
@@ -43,7 +48,7 @@ struct SyncAuthorizedKeysCommand: AsyncParsableCommand, FollowsCommandPolicies {
4348
let progressBar = Console.startFileDownload(object)
4449

4550
try await s3Manager.download(
46-
object: object,
51+
key: object.key,
4752
to: destination,
4853
progressCallback: progressBar.update
4954
)

Sources/libhostmgr/CLI/Console.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import Foundation
22
import ConsoleKit
3+
import tinys3
34

45
public struct Console {
56

Sources/libhostmgr/Model/Configuration.swift

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import Foundation
2-
import SotoS3
32
import ArgumentParser
43

54
public struct Configuration: Codable {
@@ -35,15 +34,15 @@ public struct Configuration: Codable {
3534

3635
/// VM Remote Image Settings
3736
public var vmImagesBucket: String = ""
38-
public var vmImagesRegion: String = SotoS3.Region.useast1.rawValue
37+
public var vmImagesRegion: String = "us-east-1"
3938

4039
/// Images that are protected from deletion (useful for local work, or for a fallback image)
4140
public var protectedImages: [String] = []
4241

4342
/// authorized_keys file sync
4443
public var authorizedKeysSyncInterval = Defaults.defaultAuthorizedKeysRefreshInterval
4544
public var authorizedKeysBucket = ""
46-
public var authorizedKeysRegion: String = SotoS3.Region.useast1.rawValue
45+
public var authorizedKeysRegion: String = "us-east-1"
4746

4847
/// git repo mirroring
4948
public var gitMirrorBucket = ""
@@ -84,15 +83,15 @@ public struct Configuration: Codable {
8483
)
8584

8685
vmImagesBucket = try values.decode(String.self, forKey: .vmImagesBucket)
87-
vmImagesRegion = try values.decode(Region.self, forKey: .vmImagesRegion).rawValue
86+
vmImagesRegion = try values.decode(String.self, forKey: .vmImagesRegion)
8887

8988
protectedImages = values.decode(
9089
forKey: .protectedImages,
9190
defaultingTo: [])
9291

9392
authorizedKeysSyncInterval = values.decode(forKey: .authorizedKeysSyncInterval, defaultingTo: 3600)
9493
authorizedKeysBucket = try values.decode(String.self, forKey: .authorizedKeysBucket)
95-
authorizedKeysRegion = try values.decode(Region.self, forKey: .authorizedKeysRegion).rawValue
94+
authorizedKeysRegion = try values.decode(String.self, forKey: .authorizedKeysRegion)
9695

9796
gitMirrorBucket = try values.decode(String.self, forKey: .gitMirrorBucket)
9897
gitMirrorPort = values.decode(
Lines changed: 4 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,44 +1,28 @@
11
import Foundation
2+
import tinys3
23

34
public struct RemoteVMImage: FilterableByBasename {
45
public let imageObject: S3Object
56
public let checksumObject: S3Object
67

7-
public var imagePath: String {
8-
imageObject.key
9-
}
10-
118
public var fileName: String {
12-
URL(fileURLWithPath: imagePath)
9+
URL(fileURLWithPath: imageObject.key)
1310
.lastPathComponent
1411
}
1512

1613
public var basename: String {
17-
URL(fileURLWithPath: imagePath)
14+
URL(fileURLWithPath: imageObject.key)
1815
.deletingPathExtension()
1916
.lastPathComponent
2017
}
2118

22-
public var checksumKey: String {
23-
checksumObject.key
24-
}
25-
2619
public var checksumFileName: String {
2720
basename + ".sha256.txt"
2821
}
29-
30-
public init(imageObject: S3Object, checksumKey: String) {
31-
self.imageObject = imageObject
32-
self.checksumObject = S3Object(
33-
key: checksumKey,
34-
size: 64, // Checksums are always 64 bytes
35-
modifiedAt: .now
36-
)
37-
}
3822
}
3923

4024
extension RemoteVMImage: Equatable {
4125
public static func == (lhs: RemoteVMImage, rhs: RemoteVMImage) -> Bool {
42-
lhs.imageObject == rhs.imageObject && lhs.checksumKey == rhs.checksumKey
26+
lhs.imageObject == rhs.imageObject && lhs.checksumObject == rhs.checksumObject
4327
}
4428
}

0 commit comments

Comments
 (0)