diff --git a/.spi.yml b/.spi.yml index 51909d5b..491ffa59 100644 --- a/.spi.yml +++ b/.spi.yml @@ -3,10 +3,15 @@ builder: configs: - documentation_targets: + - ContainerAPIService + - ContainerAPIClient - ContainerSandboxService + - ContainerSandboxServiceClient - ContainerNetworkService + - ContainerNetworkServiceClient - ContainerImagesService - - ContainerClient + - ContainerImagesServiceClient + - ContainerResource - ContainerLog - ContainerPlugin - ContainerXPC diff --git a/Package.swift b/Package.swift index eaa50768..a20b03f3 100644 --- a/Package.swift +++ b/Package.swift @@ -29,13 +29,14 @@ let package = Package( name: "container", platforms: [.macOS("15")], products: [ - .library(name: "ContainerAPIService", targets: ["ContainerAPIService"]), - .library(name: "ContainerSandboxService", targets: ["ContainerSandboxService"]), - .library(name: "ContainerNetworkService", targets: ["ContainerNetworkService"]), - .library(name: "ContainerImagesService", targets: ["ContainerImagesService", "ContainerImagesServiceClient"]), .library(name: "ContainerCommands", targets: ["ContainerCommands"]), - .library(name: "ContainerClient", targets: ["ContainerClient"]), .library(name: "ContainerBuild", targets: ["ContainerBuild"]), + .library(name: "ContainerAPIService", targets: ["ContainerAPIService"]), + .library(name: "ContainerAPIClient", targets: ["ContainerAPIClient"]), + .library(name: "ContainerImagesService", targets: ["ContainerImagesService", "ContainerImagesServiceClient"]), + .library(name: "ContainerNetworkService", targets: ["ContainerNetworkService", "ContainerNetworkServiceClient"]), + .library(name: "ContainerSandboxService", targets: ["ContainerSandboxService", "ContainerSandboxServiceClient"]), + .library(name: "ContainerResource", targets: ["ContainerResource"]), .library(name: "ContainerLog", targets: ["ContainerLog"]), .library(name: "ContainerPersistence", targets: ["ContainerPersistence"]), .library(name: "ContainerPlugin", targets: ["ContainerPlugin"]), @@ -61,11 +62,23 @@ let package = Package( name: "container", dependencies: [ .product(name: "ArgumentParser", package: "swift-argument-parser"), - "ContainerClient", + "ContainerAPIClient", "ContainerCommands", ], path: "Sources/CLI" ), + .testTarget( + name: "CLITests", + dependencies: [ + .product(name: "AsyncHTTPClient", package: "async-http-client"), + .product(name: "Containerization", package: "containerization"), + .product(name: "ContainerizationExtras", package: "containerization"), + .product(name: "ContainerizationOS", package: "containerization"), + "ContainerBuild", + "ContainerResource", + ], + path: "Tests/CLITests" + ), .target( name: "ContainerCommands", dependencies: [ @@ -76,15 +89,34 @@ let package = Package( .product(name: "ContainerizationOCI", package: "containerization"), .product(name: "ContainerizationOS", package: "containerization"), "ContainerBuild", - "ContainerClient", + "ContainerAPIClient", "ContainerLog", "ContainerPersistence", "ContainerPlugin", + "ContainerResource", "ContainerVersion", "TerminalProgress", ], path: "Sources/ContainerCommands" ), + .target( + name: "ContainerBuild", + dependencies: [ + .product(name: "Logging", package: "swift-log"), + .product(name: "NIO", package: "swift-nio"), + .product(name: "Containerization", package: "containerization"), + .product(name: "ContainerizationArchive", package: "containerization"), + .product(name: "ContainerizationOCI", package: "containerization"), + .product(name: "ArgumentParser", package: "swift-argument-parser"), + "ContainerAPIClient", + ] + ), + .testTarget( + name: "ContainerBuildTests", + dependencies: [ + "ContainerBuild" + ] + ), .executableTarget( name: "container-apiserver", dependencies: [ @@ -96,11 +128,12 @@ let package = Package( .product(name: "GRPC", package: "grpc-swift"), .product(name: "Logging", package: "swift-log"), "ContainerAPIService", - "ContainerClient", + "ContainerAPIClient", "ContainerLog", "ContainerNetworkService", "ContainerPersistence", "ContainerPlugin", + "ContainerResource", "ContainerVersion", "ContainerXPC", "DNSServer", @@ -111,83 +144,49 @@ let package = Package( name: "ContainerAPIService", dependencies: [ .product(name: "Containerization", package: "containerization"), + .product(name: "ContainerizationArchive", package: "containerization"), .product(name: "ContainerizationExtras", package: "containerization"), .product(name: "ContainerizationOS", package: "containerization"), .product(name: "Logging", package: "swift-log"), - "ContainerClient", - "ContainerNetworkService", + "CVersion", + "ContainerAPIClient", + "ContainerNetworkServiceClient", "ContainerPersistence", "ContainerPlugin", - "ContainerSandboxService", + "ContainerResource", + "ContainerSandboxServiceClient", "ContainerVersion", "ContainerXPC", - "CVersion", "TerminalProgress", ], - path: "Sources/Services/ContainerAPIService" - ), - .executableTarget( - name: "container-runtime-linux", - dependencies: [ - .product(name: "ArgumentParser", package: "swift-argument-parser"), - .product(name: "Logging", package: "swift-log"), - .product(name: "GRPC", package: "grpc-swift"), - .product(name: "Containerization", package: "containerization"), - "ContainerLog", - "ContainerNetworkService", - "ContainerSandboxService", - "ContainerVersion", - "ContainerXPC", - ], - path: "Sources/Helpers/RuntimeLinux" + path: "Sources/Services/ContainerAPIService/Server" ), .target( - name: "ContainerSandboxService", - dependencies: [ - .product(name: "Logging", package: "swift-log"), - .product(name: "Containerization", package: "containerization"), - .product(name: "ContainerizationExtras", package: "containerization"), - .product(name: "ContainerizationOS", package: "containerization"), - .product(name: "ArgumentParser", package: "swift-argument-parser"), - "ContainerClient", - "ContainerNetworkService", - "ContainerPersistence", - "ContainerXPC", - "SocketForwarder", - ], - path: "Sources/Services/ContainerSandboxService" - ), - .executableTarget( - name: "container-network-vmnet", + name: "ContainerAPIClient", dependencies: [ .product(name: "ArgumentParser", package: "swift-argument-parser"), .product(name: "Logging", package: "swift-log"), + .product(name: "NIOCore", package: "swift-nio"), + .product(name: "NIOPosix", package: "swift-nio"), .product(name: "Containerization", package: "containerization"), - .product(name: "ContainerizationExtras", package: "containerization"), - .product(name: "ContainerizationIO", package: "containerization"), - .product(name: "ContainerizationOS", package: "containerization"), - "ContainerLog", - "ContainerNetworkService", - "ContainerVersion", - "ContainerXPC", - ], - path: "Sources/Helpers/NetworkVmnet" - ), - .target( - name: "ContainerNetworkService", - dependencies: [ - .product(name: "Logging", package: "swift-log"), - .product(name: "Containerization", package: "containerization"), + .product(name: "ContainerizationArchive", package: "containerization"), + .product(name: "ContainerizationOCI", package: "containerization"), .product(name: "ContainerizationOS", package: "containerization"), + "ContainerImagesServiceClient", "ContainerPersistence", + "ContainerPlugin", + "ContainerResource", "ContainerXPC", + "TerminalProgress", ], - path: "Sources/Services/ContainerNetworkService" + path: "Sources/Services/ContainerAPIService/Client" ), .testTarget( - name: "ContainerNetworkServiceTests", + name: "ContainerAPIClientTests", dependencies: [ - "ContainerNetworkService" + .product(name: "Containerization", package: "containerization"), + "ContainerAPIClient", + "ContainerPersistence", ] ), .executableTarget( @@ -209,10 +208,17 @@ let package = Package( dependencies: [ .product(name: "Logging", package: "swift-log"), .product(name: "Containerization", package: "containerization"), - "ContainerXPC", - "ContainerLog", - "ContainerClient", + .product(name: "ContainerizationArchive", package: "containerization"), + .product(name: "ContainerizationExtras", package: "containerization"), + .product(name: "ContainerizationOCI", package: "containerization"), + .product(name: "ContainerizationOS", package: "containerization"), + "ContainerAPIClient", "ContainerImagesServiceClient", + "ContainerLog", + "ContainerPersistence", + "ContainerResource", + "ContainerXPC", + "TerminalProgress", ], path: "Sources/Services/ContainerImagesService/Server" ), @@ -226,48 +232,107 @@ let package = Package( ], path: "Sources/Services/ContainerImagesService/Client" ), - .target( - name: "ContainerBuild", + .executableTarget( + name: "container-network-vmnet", dependencies: [ - .product(name: "Logging", package: "swift-log"), - .product(name: "NIO", package: "swift-nio"), - .product(name: "Containerization", package: "containerization"), - .product(name: "ContainerizationArchive", package: "containerization"), - .product(name: "ContainerizationOCI", package: "containerization"), .product(name: "ArgumentParser", package: "swift-argument-parser"), - "ContainerClient", - ] - ), - .testTarget( - name: "ContainerBuildTests", - dependencies: [ - "ContainerBuild" - ] - ), - .target( - name: "ContainerClient", - dependencies: [ .product(name: "Logging", package: "swift-log"), - .product(name: "NIOCore", package: "swift-nio"), - .product(name: "NIOPosix", package: "swift-nio"), .product(name: "Containerization", package: "containerization"), - .product(name: "ContainerizationOCI", package: "containerization"), + .product(name: "ContainerizationExtras", package: "containerization"), + .product(name: "ContainerizationIO", package: "containerization"), .product(name: "ContainerizationOS", package: "containerization"), - .product(name: "ContainerizationArchive", package: "containerization"), - .product(name: "ArgumentParser", package: "swift-argument-parser"), - "ContainerImagesServiceClient", + "ContainerLog", "ContainerNetworkService", - "ContainerPlugin", + "ContainerNetworkServiceClient", + "ContainerResource", + "ContainerVersion", "ContainerXPC", - "TerminalProgress", + ], + path: "Sources/Helpers/NetworkVmnet" + ), + .target( + name: "ContainerNetworkService", + dependencies: [ + .product(name: "Logging", package: "swift-log"), + .product(name: "Containerization", package: "containerization"), + .product(name: "ContainerizationOS", package: "containerization"), + "ContainerNetworkServiceClient", + "ContainerPersistence", + "ContainerResource", + "ContainerXPC", + ], + path: "Sources/Services/ContainerNetworkService/Server" + ), + .target( + name: "ContainerNetworkServiceClient", + dependencies: [ + .product(name: "Logging", package: "swift-log"), + .product(name: "Containerization", package: "containerization"), + "ContainerLog", + "ContainerResource", + "ContainerXPC", + ], + path: "Sources/Services/ContainerNetworkService/Client" + ), + .executableTarget( + name: "container-runtime-linux", + dependencies: [ + .product(name: "ArgumentParser", package: "swift-argument-parser"), + .product(name: "Logging", package: "swift-log"), + .product(name: "GRPC", package: "grpc-swift"), + .product(name: "Containerization", package: "containerization"), + "ContainerLog", + "ContainerResource", + "ContainerSandboxService", + "ContainerSandboxServiceClient", + "ContainerVersion", + "ContainerXPC", + ], + path: "Sources/Helpers/RuntimeLinux" + ), + .target( + name: "ContainerSandboxService", + dependencies: [ + .product(name: "Logging", package: "swift-log"), + .product(name: "Containerization", package: "containerization"), + .product(name: "ContainerizationExtras", package: "containerization"), + .product(name: "ContainerizationOS", package: "containerization"), + .product(name: "ArgumentParser", package: "swift-argument-parser"), + "ContainerAPIClient", + "ContainerNetworkServiceClient", + "ContainerPersistence", + "ContainerResource", + "ContainerSandboxServiceClient", + "ContainerXPC", + "SocketForwarder", + ], + path: "Sources/Services/ContainerSandboxService/Server" + ), + .target( + name: "ContainerSandboxServiceClient", + dependencies: [ + "ContainerResource", + "ContainerXPC", + ], + path: "Sources/Services/ContainerSandboxService/Client" + ), + .target( + name: "ContainerResource", + dependencies: [ + .product(name: "Containerization", package: "containerization") ] ), .testTarget( - name: "ContainerClientTests", + name: "ContainerResourceTests", dependencies: [ .product(name: "Containerization", package: "containerization"), - "ContainerClient", - "ContainerPersistence", + "ContainerResource", + ] + ), + .target( + name: "ContainerLog", + dependencies: [ + .product(name: "Logging", package: "swift-log") ] ), .target( @@ -275,8 +340,8 @@ let package = Package( dependencies: [ .product(name: "Logging", package: "swift-log"), .product(name: "Containerization", package: "containerization"), - "ContainerVersion", "CVersion", + "ContainerVersion", ] ), .target( @@ -293,12 +358,6 @@ let package = Package( "ContainerPlugin" ] ), - .target( - name: "ContainerLog", - dependencies: [ - .product(name: "Logging", package: "swift-log") - ] - ), .target( name: "ContainerXPC", dependencies: [ @@ -347,19 +406,6 @@ let package = Package( name: "SocketForwarderTests", dependencies: ["SocketForwarder"] ), - .testTarget( - name: "CLITests", - dependencies: [ - .product(name: "AsyncHTTPClient", package: "async-http-client"), - .product(name: "Containerization", package: "containerization"), - .product(name: "ContainerizationExtras", package: "containerization"), - .product(name: "ContainerizationOS", package: "containerization"), - "ContainerBuild", - "ContainerClient", - "ContainerNetworkService", - ], - path: "Tests/CLITests" - ), .target( name: "ContainerVersion", dependencies: [ diff --git a/Sources/CLI/ContainerCLI.swift b/Sources/CLI/ContainerCLI.swift index 89261cc3..9646d9d6 100644 --- a/Sources/CLI/ContainerCLI.swift +++ b/Sources/CLI/ContainerCLI.swift @@ -15,7 +15,7 @@ //===----------------------------------------------------------------------===// import ArgumentParser -import ContainerClient +import ContainerAPIClient import ContainerCommands @main diff --git a/Sources/ContainerBuild/BuildFSSync.swift b/Sources/ContainerBuild/BuildFSSync.swift index db6d19f0..c26f8597 100644 --- a/Sources/ContainerBuild/BuildFSSync.swift +++ b/Sources/ContainerBuild/BuildFSSync.swift @@ -15,7 +15,7 @@ //===----------------------------------------------------------------------===// import Collections -import ContainerClient +import ContainerAPIClient import ContainerizationArchive import ContainerizationOCI import Foundation diff --git a/Sources/ContainerBuild/BuildImageResolver.swift b/Sources/ContainerBuild/BuildImageResolver.swift index edad4894..cec4af61 100644 --- a/Sources/ContainerBuild/BuildImageResolver.swift +++ b/Sources/ContainerBuild/BuildImageResolver.swift @@ -14,7 +14,7 @@ // limitations under the License. //===----------------------------------------------------------------------===// -import ContainerClient +import ContainerAPIClient import Containerization import ContainerizationOCI import Foundation diff --git a/Sources/ContainerBuild/BuildRemoteContentProxy.swift b/Sources/ContainerBuild/BuildRemoteContentProxy.swift index e05185f0..7b46fac7 100644 --- a/Sources/ContainerBuild/BuildRemoteContentProxy.swift +++ b/Sources/ContainerBuild/BuildRemoteContentProxy.swift @@ -14,7 +14,7 @@ // limitations under the License. //===----------------------------------------------------------------------===// -import ContainerClient +import ContainerAPIClient import Containerization import ContainerizationArchive import ContainerizationOCI diff --git a/Sources/ContainerBuild/Builder.swift b/Sources/ContainerBuild/Builder.swift index a40be4b4..cc941bb1 100644 --- a/Sources/ContainerBuild/Builder.swift +++ b/Sources/ContainerBuild/Builder.swift @@ -14,7 +14,7 @@ // limitations under the License. //===----------------------------------------------------------------------===// -import ContainerClient +import ContainerAPIClient import Containerization import ContainerizationOCI import ContainerizationOS diff --git a/Sources/ContainerCommands/Application.swift b/Sources/ContainerCommands/Application.swift index 543e597a..5acf862e 100644 --- a/Sources/ContainerCommands/Application.swift +++ b/Sources/ContainerCommands/Application.swift @@ -15,7 +15,7 @@ //===----------------------------------------------------------------------===// import ArgumentParser -import ContainerClient +import ContainerAPIClient import ContainerLog import ContainerPlugin import ContainerVersion diff --git a/Sources/ContainerCommands/BuildCommand.swift b/Sources/ContainerCommands/BuildCommand.swift index bbb0f4fa..3515f274 100644 --- a/Sources/ContainerCommands/BuildCommand.swift +++ b/Sources/ContainerCommands/BuildCommand.swift @@ -15,8 +15,8 @@ //===----------------------------------------------------------------------===// import ArgumentParser +import ContainerAPIClient import ContainerBuild -import ContainerClient import ContainerImagesServiceClient import Containerization import ContainerizationError diff --git a/Sources/ContainerCommands/Builder/BuilderDelete.swift b/Sources/ContainerCommands/Builder/BuilderDelete.swift index 9a111691..f340d374 100644 --- a/Sources/ContainerCommands/Builder/BuilderDelete.swift +++ b/Sources/ContainerCommands/Builder/BuilderDelete.swift @@ -15,7 +15,7 @@ //===----------------------------------------------------------------------===// import ArgumentParser -import ContainerClient +import ContainerAPIClient import ContainerizationError import Foundation diff --git a/Sources/ContainerCommands/Builder/BuilderStart.swift b/Sources/ContainerCommands/Builder/BuilderStart.swift index 90d4595c..5aa4d3d0 100644 --- a/Sources/ContainerCommands/Builder/BuilderStart.swift +++ b/Sources/ContainerCommands/Builder/BuilderStart.swift @@ -15,10 +15,10 @@ //===----------------------------------------------------------------------===// import ArgumentParser +import ContainerAPIClient import ContainerBuild -import ContainerClient -import ContainerNetworkService import ContainerPersistence +import ContainerResource import Containerization import ContainerizationError import ContainerizationExtras @@ -164,7 +164,7 @@ extension Application { ].compactMap { $0 } let id = "buildkit" - try ContainerClient.Utility.validEntityName(id) + try ContainerAPIClient.Utility.validEntityName(id) let image = try await ClientImage.fetch( reference: builderImage, diff --git a/Sources/ContainerCommands/Builder/BuilderStatus.swift b/Sources/ContainerCommands/Builder/BuilderStatus.swift index d2f4e733..bd9b80e9 100644 --- a/Sources/ContainerCommands/Builder/BuilderStatus.swift +++ b/Sources/ContainerCommands/Builder/BuilderStatus.swift @@ -15,7 +15,7 @@ //===----------------------------------------------------------------------===// import ArgumentParser -import ContainerClient +import ContainerAPIClient import ContainerizationError import ContainerizationExtras import Foundation diff --git a/Sources/ContainerCommands/Builder/BuilderStop.swift b/Sources/ContainerCommands/Builder/BuilderStop.swift index ce6cf043..bff7ab7a 100644 --- a/Sources/ContainerCommands/Builder/BuilderStop.swift +++ b/Sources/ContainerCommands/Builder/BuilderStop.swift @@ -15,7 +15,7 @@ //===----------------------------------------------------------------------===// import ArgumentParser -import ContainerClient +import ContainerAPIClient import ContainerizationError import Foundation diff --git a/Sources/ContainerCommands/Container/ContainerCreate.swift b/Sources/ContainerCommands/Container/ContainerCreate.swift index 7e1d2bd5..e084e875 100644 --- a/Sources/ContainerCommands/Container/ContainerCreate.swift +++ b/Sources/ContainerCommands/Container/ContainerCreate.swift @@ -15,7 +15,8 @@ //===----------------------------------------------------------------------===// import ArgumentParser -import ContainerClient +import ContainerAPIClient +import ContainerResource import ContainerizationError import Foundation import TerminalProgress diff --git a/Sources/ContainerCommands/Container/ContainerDelete.swift b/Sources/ContainerCommands/Container/ContainerDelete.swift index 22807d39..1e5234e0 100644 --- a/Sources/ContainerCommands/Container/ContainerDelete.swift +++ b/Sources/ContainerCommands/Container/ContainerDelete.swift @@ -15,7 +15,7 @@ //===----------------------------------------------------------------------===// import ArgumentParser -import ContainerClient +import ContainerAPIClient import ContainerizationError import Foundation diff --git a/Sources/ContainerCommands/Container/ContainerExec.swift b/Sources/ContainerCommands/Container/ContainerExec.swift index c8a7d3e3..6684b59c 100644 --- a/Sources/ContainerCommands/Container/ContainerExec.swift +++ b/Sources/ContainerCommands/Container/ContainerExec.swift @@ -15,7 +15,7 @@ //===----------------------------------------------------------------------===// import ArgumentParser -import ContainerClient +import ContainerAPIClient import ContainerizationError import ContainerizationOS import Foundation diff --git a/Sources/ContainerCommands/Container/ContainerInspect.swift b/Sources/ContainerCommands/Container/ContainerInspect.swift index 7c8434b3..74bd97fa 100644 --- a/Sources/ContainerCommands/Container/ContainerInspect.swift +++ b/Sources/ContainerCommands/Container/ContainerInspect.swift @@ -15,7 +15,7 @@ //===----------------------------------------------------------------------===// import ArgumentParser -import ContainerClient +import ContainerAPIClient import Foundation import SwiftProtobuf diff --git a/Sources/ContainerCommands/Container/ContainerKill.swift b/Sources/ContainerCommands/Container/ContainerKill.swift index c34c697e..c9bfbc20 100644 --- a/Sources/ContainerCommands/Container/ContainerKill.swift +++ b/Sources/ContainerCommands/Container/ContainerKill.swift @@ -15,7 +15,7 @@ //===----------------------------------------------------------------------===// import ArgumentParser -import ContainerClient +import ContainerAPIClient import ContainerizationError import ContainerizationOS import Darwin diff --git a/Sources/ContainerCommands/Container/ContainerList.swift b/Sources/ContainerCommands/Container/ContainerList.swift index 99d24569..6f72230f 100644 --- a/Sources/ContainerCommands/Container/ContainerList.swift +++ b/Sources/ContainerCommands/Container/ContainerList.swift @@ -15,8 +15,8 @@ //===----------------------------------------------------------------------===// import ArgumentParser -import ContainerClient -import ContainerNetworkService +import ContainerAPIClient +import ContainerResource import ContainerizationExtras import Foundation import SwiftProtobuf diff --git a/Sources/ContainerCommands/Container/ContainerLogs.swift b/Sources/ContainerCommands/Container/ContainerLogs.swift index 9549c362..160b2f5e 100644 --- a/Sources/ContainerCommands/Container/ContainerLogs.swift +++ b/Sources/ContainerCommands/Container/ContainerLogs.swift @@ -15,7 +15,7 @@ //===----------------------------------------------------------------------===// import ArgumentParser -import ContainerClient +import ContainerAPIClient import ContainerizationError import Darwin import Dispatch diff --git a/Sources/ContainerCommands/Container/ContainerRun.swift b/Sources/ContainerCommands/Container/ContainerRun.swift index 7a0b9fd8..31de0b24 100644 --- a/Sources/ContainerCommands/Container/ContainerRun.swift +++ b/Sources/ContainerCommands/Container/ContainerRun.swift @@ -15,7 +15,8 @@ //===----------------------------------------------------------------------===// import ArgumentParser -import ContainerClient +import ContainerAPIClient +import ContainerResource import Containerization import ContainerizationError import ContainerizationExtras diff --git a/Sources/ContainerCommands/Container/ContainerStart.swift b/Sources/ContainerCommands/Container/ContainerStart.swift index 6273ec41..226cabd4 100644 --- a/Sources/ContainerCommands/Container/ContainerStart.swift +++ b/Sources/ContainerCommands/Container/ContainerStart.swift @@ -15,7 +15,7 @@ //===----------------------------------------------------------------------===// import ArgumentParser -import ContainerClient +import ContainerAPIClient import ContainerizationError import ContainerizationOS import TerminalProgress diff --git a/Sources/ContainerCommands/Container/ContainerStats.swift b/Sources/ContainerCommands/Container/ContainerStats.swift index eaa55e61..92aa605c 100644 --- a/Sources/ContainerCommands/Container/ContainerStats.swift +++ b/Sources/ContainerCommands/Container/ContainerStats.swift @@ -15,7 +15,8 @@ //===----------------------------------------------------------------------===// import ArgumentParser -import ContainerClient +import ContainerAPIClient +import ContainerResource import ContainerizationError import ContainerizationExtras import Foundation @@ -148,8 +149,8 @@ extension Application { private struct StatsSnapshot { let container: ClientContainer - let stats1: ContainerClient.ContainerStats - let stats2: ContainerClient.ContainerStats + let stats1: ContainerResource.ContainerStats + let stats2: ContainerResource.ContainerStats } private func collectStats(for containers: [ClientContainer]) async throws -> [StatsSnapshot] { diff --git a/Sources/ContainerCommands/Container/ContainerStop.swift b/Sources/ContainerCommands/Container/ContainerStop.swift index 548eb8aa..42cd25f8 100644 --- a/Sources/ContainerCommands/Container/ContainerStop.swift +++ b/Sources/ContainerCommands/Container/ContainerStop.swift @@ -15,7 +15,8 @@ //===----------------------------------------------------------------------===// import ArgumentParser -import ContainerClient +import ContainerAPIClient +import ContainerResource import ContainerizationError import ContainerizationOS import Foundation diff --git a/Sources/ContainerCommands/Container/ProcessUtils.swift b/Sources/ContainerCommands/Container/ProcessUtils.swift index 3d8d7819..e37f4119 100644 --- a/Sources/ContainerCommands/Container/ProcessUtils.swift +++ b/Sources/ContainerCommands/Container/ProcessUtils.swift @@ -14,7 +14,7 @@ // limitations under the License. //===----------------------------------------------------------------------===// -import ContainerClient +import ContainerAPIClient import Containerization import ContainerizationError import ContainerizationOS diff --git a/Sources/ContainerCommands/DefaultCommand.swift b/Sources/ContainerCommands/DefaultCommand.swift index 7ea7a3f0..2c6de6f3 100644 --- a/Sources/ContainerCommands/DefaultCommand.swift +++ b/Sources/ContainerCommands/DefaultCommand.swift @@ -15,7 +15,7 @@ //===----------------------------------------------------------------------===// import ArgumentParser -import ContainerClient +import ContainerAPIClient import ContainerPlugin import Darwin import Foundation diff --git a/Sources/ContainerCommands/Image/ImageDelete.swift b/Sources/ContainerCommands/Image/ImageDelete.swift index e0b87617..ef7ee303 100644 --- a/Sources/ContainerCommands/Image/ImageDelete.swift +++ b/Sources/ContainerCommands/Image/ImageDelete.swift @@ -15,7 +15,7 @@ //===----------------------------------------------------------------------===// import ArgumentParser -import ContainerClient +import ContainerAPIClient import Containerization import ContainerizationError import Foundation diff --git a/Sources/ContainerCommands/Image/ImageInspect.swift b/Sources/ContainerCommands/Image/ImageInspect.swift index 89fcd71c..785bf486 100644 --- a/Sources/ContainerCommands/Image/ImageInspect.swift +++ b/Sources/ContainerCommands/Image/ImageInspect.swift @@ -15,7 +15,7 @@ //===----------------------------------------------------------------------===// import ArgumentParser -import ContainerClient +import ContainerAPIClient import ContainerizationError import Foundation import SwiftProtobuf diff --git a/Sources/ContainerCommands/Image/ImageList.swift b/Sources/ContainerCommands/Image/ImageList.swift index 042d2823..e403aeaf 100644 --- a/Sources/ContainerCommands/Image/ImageList.swift +++ b/Sources/ContainerCommands/Image/ImageList.swift @@ -15,7 +15,7 @@ //===----------------------------------------------------------------------===// import ArgumentParser -import ContainerClient +import ContainerAPIClient import Containerization import ContainerizationError import ContainerizationOCI diff --git a/Sources/ContainerCommands/Image/ImageLoad.swift b/Sources/ContainerCommands/Image/ImageLoad.swift index 9f3b0c54..a170a88c 100644 --- a/Sources/ContainerCommands/Image/ImageLoad.swift +++ b/Sources/ContainerCommands/Image/ImageLoad.swift @@ -15,7 +15,7 @@ //===----------------------------------------------------------------------===// import ArgumentParser -import ContainerClient +import ContainerAPIClient import Containerization import ContainerizationError import Foundation diff --git a/Sources/ContainerCommands/Image/ImagePrune.swift b/Sources/ContainerCommands/Image/ImagePrune.swift index 4e8b189a..3e18cdfc 100644 --- a/Sources/ContainerCommands/Image/ImagePrune.swift +++ b/Sources/ContainerCommands/Image/ImagePrune.swift @@ -15,7 +15,7 @@ //===----------------------------------------------------------------------===// import ArgumentParser -import ContainerClient +import ContainerAPIClient import ContainerizationOCI import Foundation diff --git a/Sources/ContainerCommands/Image/ImagePull.swift b/Sources/ContainerCommands/Image/ImagePull.swift index 65ffb7ee..8654de15 100644 --- a/Sources/ContainerCommands/Image/ImagePull.swift +++ b/Sources/ContainerCommands/Image/ImagePull.swift @@ -15,7 +15,7 @@ //===----------------------------------------------------------------------===// import ArgumentParser -import ContainerClient +import ContainerAPIClient import Containerization import ContainerizationOCI import TerminalProgress diff --git a/Sources/ContainerCommands/Image/ImagePush.swift b/Sources/ContainerCommands/Image/ImagePush.swift index aa08863e..d9298568 100644 --- a/Sources/ContainerCommands/Image/ImagePush.swift +++ b/Sources/ContainerCommands/Image/ImagePush.swift @@ -15,7 +15,7 @@ //===----------------------------------------------------------------------===// import ArgumentParser -import ContainerClient +import ContainerAPIClient import Containerization import ContainerizationOCI import TerminalProgress diff --git a/Sources/ContainerCommands/Image/ImageSave.swift b/Sources/ContainerCommands/Image/ImageSave.swift index a13692e4..1b9fe71b 100644 --- a/Sources/ContainerCommands/Image/ImageSave.swift +++ b/Sources/ContainerCommands/Image/ImageSave.swift @@ -15,7 +15,8 @@ //===----------------------------------------------------------------------===// import ArgumentParser -import ContainerClient +import ContainerAPIClient +import ContainerResource import Containerization import ContainerizationError import ContainerizationOCI diff --git a/Sources/ContainerCommands/Image/ImageTag.swift b/Sources/ContainerCommands/Image/ImageTag.swift index 0bd291e3..2d8c243f 100644 --- a/Sources/ContainerCommands/Image/ImageTag.swift +++ b/Sources/ContainerCommands/Image/ImageTag.swift @@ -15,7 +15,7 @@ //===----------------------------------------------------------------------===// import ArgumentParser -import ContainerClient +import ContainerAPIClient extension Application { public struct ImageTag: AsyncParsableCommand { diff --git a/Sources/ContainerCommands/Network/NetworkCreate.swift b/Sources/ContainerCommands/Network/NetworkCreate.swift index d4e79570..3a565e5e 100644 --- a/Sources/ContainerCommands/Network/NetworkCreate.swift +++ b/Sources/ContainerCommands/Network/NetworkCreate.swift @@ -15,8 +15,8 @@ //===----------------------------------------------------------------------===// import ArgumentParser -import ContainerClient -import ContainerNetworkService +import ContainerAPIClient +import ContainerResource import ContainerizationError import ContainerizationExtras import Foundation diff --git a/Sources/ContainerCommands/Network/NetworkDelete.swift b/Sources/ContainerCommands/Network/NetworkDelete.swift index 564b8269..c989aad6 100644 --- a/Sources/ContainerCommands/Network/NetworkDelete.swift +++ b/Sources/ContainerCommands/Network/NetworkDelete.swift @@ -15,8 +15,8 @@ //===----------------------------------------------------------------------===// import ArgumentParser -import ContainerClient -import ContainerNetworkService +import ContainerAPIClient +import ContainerResource import ContainerizationError import Foundation diff --git a/Sources/ContainerCommands/Network/NetworkInspect.swift b/Sources/ContainerCommands/Network/NetworkInspect.swift index eea42c56..78a4b375 100644 --- a/Sources/ContainerCommands/Network/NetworkInspect.swift +++ b/Sources/ContainerCommands/Network/NetworkInspect.swift @@ -15,8 +15,7 @@ //===----------------------------------------------------------------------===// import ArgumentParser -import ContainerClient -import ContainerNetworkService +import ContainerAPIClient import Foundation import SwiftProtobuf diff --git a/Sources/ContainerCommands/Network/NetworkList.swift b/Sources/ContainerCommands/Network/NetworkList.swift index 1de28c26..334c3d5e 100644 --- a/Sources/ContainerCommands/Network/NetworkList.swift +++ b/Sources/ContainerCommands/Network/NetworkList.swift @@ -15,8 +15,8 @@ //===----------------------------------------------------------------------===// import ArgumentParser -import ContainerClient -import ContainerNetworkService +import ContainerAPIClient +import ContainerResource import ContainerizationExtras import Foundation import SwiftProtobuf diff --git a/Sources/ContainerCommands/Network/NetworkPrune.swift b/Sources/ContainerCommands/Network/NetworkPrune.swift index a6c97565..7d85f4ef 100644 --- a/Sources/ContainerCommands/Network/NetworkPrune.swift +++ b/Sources/ContainerCommands/Network/NetworkPrune.swift @@ -15,7 +15,7 @@ //===----------------------------------------------------------------------===// import ArgumentParser -import ContainerClient +import ContainerAPIClient import Foundation extension Application.NetworkCommand { diff --git a/Sources/ContainerCommands/Registry/Login.swift b/Sources/ContainerCommands/Registry/Login.swift index d19925c6..7af61fc2 100644 --- a/Sources/ContainerCommands/Registry/Login.swift +++ b/Sources/ContainerCommands/Registry/Login.swift @@ -15,7 +15,7 @@ //===----------------------------------------------------------------------===// import ArgumentParser -import ContainerClient +import ContainerAPIClient import Containerization import ContainerizationError import ContainerizationOCI diff --git a/Sources/ContainerCommands/Registry/Logout.swift b/Sources/ContainerCommands/Registry/Logout.swift index 2c7743ff..ad7145e3 100644 --- a/Sources/ContainerCommands/Registry/Logout.swift +++ b/Sources/ContainerCommands/Registry/Logout.swift @@ -15,7 +15,7 @@ //===----------------------------------------------------------------------===// import ArgumentParser -import ContainerClient +import ContainerAPIClient import Containerization import ContainerizationOCI diff --git a/Sources/ContainerCommands/System/DNS/DNSCreate.swift b/Sources/ContainerCommands/System/DNS/DNSCreate.swift index 2f24c1c6..7ab7b1bc 100644 --- a/Sources/ContainerCommands/System/DNS/DNSCreate.swift +++ b/Sources/ContainerCommands/System/DNS/DNSCreate.swift @@ -15,7 +15,7 @@ //===----------------------------------------------------------------------===// import ArgumentParser -import ContainerClient +import ContainerAPIClient import ContainerizationError import ContainerizationExtras import Foundation diff --git a/Sources/ContainerCommands/System/DNS/DNSDelete.swift b/Sources/ContainerCommands/System/DNS/DNSDelete.swift index 5fed7cba..8215d0a1 100644 --- a/Sources/ContainerCommands/System/DNS/DNSDelete.swift +++ b/Sources/ContainerCommands/System/DNS/DNSDelete.swift @@ -15,7 +15,7 @@ //===----------------------------------------------------------------------===// import ArgumentParser -import ContainerClient +import ContainerAPIClient import ContainerizationError import Foundation diff --git a/Sources/ContainerCommands/System/DNS/DNSList.swift b/Sources/ContainerCommands/System/DNS/DNSList.swift index 3e103e17..8d2f67b5 100644 --- a/Sources/ContainerCommands/System/DNS/DNSList.swift +++ b/Sources/ContainerCommands/System/DNS/DNSList.swift @@ -15,7 +15,7 @@ //===----------------------------------------------------------------------===// import ArgumentParser -import ContainerClient +import ContainerAPIClient import Foundation extension Application { diff --git a/Sources/ContainerCommands/System/Kernel/KernelSet.swift b/Sources/ContainerCommands/System/Kernel/KernelSet.swift index 249c537d..01486e20 100644 --- a/Sources/ContainerCommands/System/Kernel/KernelSet.swift +++ b/Sources/ContainerCommands/System/Kernel/KernelSet.swift @@ -15,7 +15,7 @@ //===----------------------------------------------------------------------===// import ArgumentParser -import ContainerClient +import ContainerAPIClient import ContainerPersistence import Containerization import ContainerizationError diff --git a/Sources/ContainerCommands/System/Property/PropertyClear.swift b/Sources/ContainerCommands/System/Property/PropertyClear.swift index ef107f17..d523bfeb 100644 --- a/Sources/ContainerCommands/System/Property/PropertyClear.swift +++ b/Sources/ContainerCommands/System/Property/PropertyClear.swift @@ -15,7 +15,7 @@ //===----------------------------------------------------------------------===// import ArgumentParser -import ContainerClient +import ContainerAPIClient import ContainerPersistence import ContainerizationError import Foundation diff --git a/Sources/ContainerCommands/System/Property/PropertyGet.swift b/Sources/ContainerCommands/System/Property/PropertyGet.swift index 5fafc064..5c36b666 100644 --- a/Sources/ContainerCommands/System/Property/PropertyGet.swift +++ b/Sources/ContainerCommands/System/Property/PropertyGet.swift @@ -15,7 +15,7 @@ //===----------------------------------------------------------------------===// import ArgumentParser -import ContainerClient +import ContainerAPIClient import ContainerPersistence import ContainerizationError import Foundation diff --git a/Sources/ContainerCommands/System/Property/PropertyList.swift b/Sources/ContainerCommands/System/Property/PropertyList.swift index 9f79c169..1cfe6d6a 100644 --- a/Sources/ContainerCommands/System/Property/PropertyList.swift +++ b/Sources/ContainerCommands/System/Property/PropertyList.swift @@ -15,7 +15,7 @@ //===----------------------------------------------------------------------===// import ArgumentParser -import ContainerClient +import ContainerAPIClient import ContainerPersistence import Foundation diff --git a/Sources/ContainerCommands/System/Property/PropertySet.swift b/Sources/ContainerCommands/System/Property/PropertySet.swift index 3ea50167..24753a4d 100644 --- a/Sources/ContainerCommands/System/Property/PropertySet.swift +++ b/Sources/ContainerCommands/System/Property/PropertySet.swift @@ -15,7 +15,7 @@ //===----------------------------------------------------------------------===// import ArgumentParser -import ContainerClient +import ContainerAPIClient import ContainerPersistence import ContainerizationError import ContainerizationExtras diff --git a/Sources/ContainerCommands/System/SystemDF.swift b/Sources/ContainerCommands/System/SystemDF.swift index 120c7521..09617980 100644 --- a/Sources/ContainerCommands/System/SystemDF.swift +++ b/Sources/ContainerCommands/System/SystemDF.swift @@ -15,7 +15,7 @@ //===----------------------------------------------------------------------===// import ArgumentParser -import ContainerClient +import ContainerAPIClient import ContainerizationError import Foundation diff --git a/Sources/ContainerCommands/System/SystemLogs.swift b/Sources/ContainerCommands/System/SystemLogs.swift index 86a97440..5ffd5408 100644 --- a/Sources/ContainerCommands/System/SystemLogs.swift +++ b/Sources/ContainerCommands/System/SystemLogs.swift @@ -15,7 +15,7 @@ //===----------------------------------------------------------------------===// import ArgumentParser -import ContainerClient +import ContainerAPIClient import ContainerizationError import ContainerizationOS import Foundation diff --git a/Sources/ContainerCommands/System/SystemStart.swift b/Sources/ContainerCommands/System/SystemStart.swift index fe0e91a8..eae26800 100644 --- a/Sources/ContainerCommands/System/SystemStart.swift +++ b/Sources/ContainerCommands/System/SystemStart.swift @@ -15,7 +15,7 @@ //===----------------------------------------------------------------------===// import ArgumentParser -import ContainerClient +import ContainerAPIClient import ContainerPersistence import ContainerPlugin import ContainerizationError diff --git a/Sources/ContainerCommands/System/SystemStatus.swift b/Sources/ContainerCommands/System/SystemStatus.swift index f5ed65fb..a6978757 100644 --- a/Sources/ContainerCommands/System/SystemStatus.swift +++ b/Sources/ContainerCommands/System/SystemStatus.swift @@ -15,7 +15,7 @@ //===----------------------------------------------------------------------===// import ArgumentParser -import ContainerClient +import ContainerAPIClient import ContainerPlugin import ContainerizationError import Foundation diff --git a/Sources/ContainerCommands/System/SystemStop.swift b/Sources/ContainerCommands/System/SystemStop.swift index 7e2765b9..53d80ecc 100644 --- a/Sources/ContainerCommands/System/SystemStop.swift +++ b/Sources/ContainerCommands/System/SystemStop.swift @@ -15,8 +15,9 @@ //===----------------------------------------------------------------------===// import ArgumentParser -import ContainerClient +import ContainerAPIClient import ContainerPlugin +import ContainerResource import ContainerizationOS import Foundation import Logging diff --git a/Sources/ContainerCommands/System/Version.swift b/Sources/ContainerCommands/System/Version.swift index 78ad5a53..8ee4e468 100644 --- a/Sources/ContainerCommands/System/Version.swift +++ b/Sources/ContainerCommands/System/Version.swift @@ -15,7 +15,7 @@ //===----------------------------------------------------------------------===// import ArgumentParser -import ContainerClient +import ContainerAPIClient import ContainerVersion import Foundation diff --git a/Sources/ContainerCommands/Volume/VolumeCreate.swift b/Sources/ContainerCommands/Volume/VolumeCreate.swift index 8c0829bb..c0d1e28a 100644 --- a/Sources/ContainerCommands/Volume/VolumeCreate.swift +++ b/Sources/ContainerCommands/Volume/VolumeCreate.swift @@ -15,7 +15,7 @@ //===----------------------------------------------------------------------===// import ArgumentParser -import ContainerClient +import ContainerAPIClient import Foundation extension Application.VolumeCommand { diff --git a/Sources/ContainerCommands/Volume/VolumeDelete.swift b/Sources/ContainerCommands/Volume/VolumeDelete.swift index efb6460b..7b152d96 100644 --- a/Sources/ContainerCommands/Volume/VolumeDelete.swift +++ b/Sources/ContainerCommands/Volume/VolumeDelete.swift @@ -15,7 +15,8 @@ //===----------------------------------------------------------------------===// import ArgumentParser -import ContainerClient +import ContainerAPIClient +import ContainerResource import ContainerizationError import Foundation diff --git a/Sources/ContainerCommands/Volume/VolumeInspect.swift b/Sources/ContainerCommands/Volume/VolumeInspect.swift index 03baf7e7..da65c4cf 100644 --- a/Sources/ContainerCommands/Volume/VolumeInspect.swift +++ b/Sources/ContainerCommands/Volume/VolumeInspect.swift @@ -15,7 +15,8 @@ //===----------------------------------------------------------------------===// import ArgumentParser -import ContainerClient +import ContainerAPIClient +import ContainerResource import Foundation extension Application.VolumeCommand { diff --git a/Sources/ContainerCommands/Volume/VolumeList.swift b/Sources/ContainerCommands/Volume/VolumeList.swift index f4b2331b..60cf861b 100644 --- a/Sources/ContainerCommands/Volume/VolumeList.swift +++ b/Sources/ContainerCommands/Volume/VolumeList.swift @@ -15,7 +15,8 @@ //===----------------------------------------------------------------------===// import ArgumentParser -import ContainerClient +import ContainerAPIClient +import ContainerResource import ContainerizationExtras import Foundation diff --git a/Sources/ContainerCommands/Volume/VolumePrune.swift b/Sources/ContainerCommands/Volume/VolumePrune.swift index 07c4fc69..5d7ebe77 100644 --- a/Sources/ContainerCommands/Volume/VolumePrune.swift +++ b/Sources/ContainerCommands/Volume/VolumePrune.swift @@ -15,7 +15,7 @@ //===----------------------------------------------------------------------===// import ArgumentParser -import ContainerClient +import ContainerAPIClient import Foundation extension Application.VolumeCommand { diff --git a/Sources/ContainerClient/Core/Bundle.swift b/Sources/ContainerResource/Container/Bundle.swift similarity index 98% rename from Sources/ContainerClient/Core/Bundle.swift rename to Sources/ContainerResource/Container/Bundle.swift index cb4c34c0..a2ba7242 100644 --- a/Sources/ContainerClient/Core/Bundle.swift +++ b/Sources/ContainerResource/Container/Bundle.swift @@ -1,5 +1,5 @@ //===----------------------------------------------------------------------===// -// Copyright © 2025-2026 Apple Inc. and the container project authors. +// Copyright © 2026 Apple Inc. and the container project authors. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/Sources/ContainerClient/Core/ContainerConfiguration.swift b/Sources/ContainerResource/Container/ContainerConfiguration.swift similarity index 88% rename from Sources/ContainerClient/Core/ContainerConfiguration.swift rename to Sources/ContainerResource/Container/ContainerConfiguration.swift index 2e45db3b..b0c98f79 100644 --- a/Sources/ContainerClient/Core/ContainerConfiguration.swift +++ b/Sources/ContainerResource/Container/ContainerConfiguration.swift @@ -1,5 +1,5 @@ //===----------------------------------------------------------------------===// -// Copyright © 2025-2026 Apple Inc. and the container project authors. +// Copyright © 2026 Apple Inc. and the container project authors. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -14,7 +14,6 @@ // limitations under the License. //===----------------------------------------------------------------------===// -import ContainerNetworkService import ContainerizationOCI public struct ContainerConfiguration: Sendable, Codable { @@ -83,16 +82,8 @@ public struct ContainerConfiguration: Sendable, Codable { labels = try container.decodeIfPresent([String: String].self, forKey: .labels) ?? [:] sysctls = try container.decodeIfPresent([String: String].self, forKey: .sysctls) ?? [:] - // NOTE: migrates [String] to [AttachmentConfiguration]; remove [String] support in a later release if container.contains(.networks) { - do { - networks = try container.decode([AttachmentConfiguration].self, forKey: .networks) - } catch { - let networkIds = try container.decode([String].self, forKey: .networks) - // Parse old network IDs as simple network names without properties - let parsedNetworks = networkIds.map { Parser.ParsedNetwork(name: $0, macAddress: nil) } - networks = try Utility.getAttachmentConfigurations(containerId: id, networks: parsedNetworks) - } + networks = try container.decode([AttachmentConfiguration].self, forKey: .networks) } else { networks = [] } diff --git a/Sources/ContainerClient/Core/ContainerCreateOptions.swift b/Sources/ContainerResource/Container/ContainerCreateOptions.swift similarity index 93% rename from Sources/ContainerClient/Core/ContainerCreateOptions.swift rename to Sources/ContainerResource/Container/ContainerCreateOptions.swift index c845a9b3..dd9da217 100644 --- a/Sources/ContainerClient/Core/ContainerCreateOptions.swift +++ b/Sources/ContainerResource/Container/ContainerCreateOptions.swift @@ -1,5 +1,5 @@ //===----------------------------------------------------------------------===// -// Copyright © 2025-2026 Apple Inc. and the container project authors. +// Copyright © 2026 Apple Inc. and the container project authors. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/Sources/ContainerClient/Core/ContainerSnapshot.swift b/Sources/ContainerResource/Container/ContainerSnapshot.swift similarity index 93% rename from Sources/ContainerClient/Core/ContainerSnapshot.swift rename to Sources/ContainerResource/Container/ContainerSnapshot.swift index 1601650d..3b5628bb 100644 --- a/Sources/ContainerClient/Core/ContainerSnapshot.swift +++ b/Sources/ContainerResource/Container/ContainerSnapshot.swift @@ -1,5 +1,5 @@ //===----------------------------------------------------------------------===// -// Copyright © 2025-2026 Apple Inc. and the container project authors. +// Copyright © 2026 Apple Inc. and the container project authors. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -14,8 +14,6 @@ // limitations under the License. //===----------------------------------------------------------------------===// -import ContainerNetworkService - /// A snapshot of a container along with its configuration /// and any runtime state information. public struct ContainerSnapshot: Codable, Sendable { diff --git a/Sources/ContainerClient/Core/ContainerStats.swift b/Sources/ContainerResource/Container/ContainerStats.swift similarity index 96% rename from Sources/ContainerClient/Core/ContainerStats.swift rename to Sources/ContainerResource/Container/ContainerStats.swift index 5371ca15..19d53ce8 100644 --- a/Sources/ContainerClient/Core/ContainerStats.swift +++ b/Sources/ContainerResource/Container/ContainerStats.swift @@ -1,5 +1,5 @@ //===----------------------------------------------------------------------===// -// Copyright © 2025-2026 Apple Inc. and the container project authors. +// Copyright © 2026 Apple Inc. and the container project authors. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/Sources/ContainerClient/Core/ContainerStopOptions.swift b/Sources/ContainerResource/Container/ContainerStopOptions.swift similarity index 93% rename from Sources/ContainerClient/Core/ContainerStopOptions.swift rename to Sources/ContainerResource/Container/ContainerStopOptions.swift index b0a1359c..290e66ba 100644 --- a/Sources/ContainerClient/Core/ContainerStopOptions.swift +++ b/Sources/ContainerResource/Container/ContainerStopOptions.swift @@ -1,5 +1,5 @@ //===----------------------------------------------------------------------===// -// Copyright © 2025-2026 Apple Inc. and the container project authors. +// Copyright © 2026 Apple Inc. and the container project authors. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/Sources/ContainerClient/Core/Filesystem.swift b/Sources/ContainerResource/Container/Filesystem.swift similarity index 98% rename from Sources/ContainerClient/Core/Filesystem.swift rename to Sources/ContainerResource/Container/Filesystem.swift index bd941d5d..cd4e1905 100644 --- a/Sources/ContainerClient/Core/Filesystem.swift +++ b/Sources/ContainerResource/Container/Filesystem.swift @@ -1,5 +1,5 @@ //===----------------------------------------------------------------------===// -// Copyright © 2025-2026 Apple Inc. and the container project authors. +// Copyright © 2026 Apple Inc. and the container project authors. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/Sources/ContainerClient/Core/ProcessConfiguration.swift b/Sources/ContainerResource/Container/ProcessConfiguration.swift similarity index 97% rename from Sources/ContainerClient/Core/ProcessConfiguration.swift rename to Sources/ContainerResource/Container/ProcessConfiguration.swift index a0613bcd..73bf7c53 100644 --- a/Sources/ContainerClient/Core/ProcessConfiguration.swift +++ b/Sources/ContainerResource/Container/ProcessConfiguration.swift @@ -1,5 +1,5 @@ //===----------------------------------------------------------------------===// -// Copyright © 2025-2026 Apple Inc. and the container project authors. +// Copyright © 2026 Apple Inc. and the container project authors. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/Sources/ContainerClient/Core/PublishPort.swift b/Sources/ContainerResource/Container/PublishPort.swift similarity index 82% rename from Sources/ContainerClient/Core/PublishPort.swift rename to Sources/ContainerResource/Container/PublishPort.swift index c9d48860..b0ab0b38 100644 --- a/Sources/ContainerClient/Core/PublishPort.swift +++ b/Sources/ContainerResource/Container/PublishPort.swift @@ -1,5 +1,5 @@ //===----------------------------------------------------------------------===// -// Copyright © 2025-2026 Apple Inc. and the container project authors. +// Copyright © 2026 Apple Inc. and the container project authors. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -72,3 +72,19 @@ public struct PublishPort: Sendable, Codable { count = try container.decodeIfPresent(UInt16.self, forKey: .count) ?? 1 } } + +extension [PublishPort] { + public func hasOverlaps() -> Bool { + var hostPorts = Set() + for publishPort in self { + for index in publishPort.hostPort..<(publishPort.hostPort + publishPort.count) { + let hostPortKey = "\(index)/\(publishPort.proto.rawValue)" + guard !hostPorts.contains(hostPortKey) else { + return true + } + hostPorts.insert(hostPortKey) + } + } + return false + } +} diff --git a/Sources/ContainerClient/Core/PublishSocket.swift b/Sources/ContainerResource/Container/PublishSocket.swift similarity index 95% rename from Sources/ContainerClient/Core/PublishSocket.swift rename to Sources/ContainerResource/Container/PublishSocket.swift index 13108493..08ea752b 100644 --- a/Sources/ContainerClient/Core/PublishSocket.swift +++ b/Sources/ContainerResource/Container/PublishSocket.swift @@ -1,5 +1,5 @@ //===----------------------------------------------------------------------===// -// Copyright © 2025-2026 Apple Inc. and the container project authors. +// Copyright © 2026 Apple Inc. and the container project authors. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/Sources/ContainerClient/Core/RuntimeStatus.swift b/Sources/ContainerResource/Container/RuntimeStatus.swift similarity index 93% rename from Sources/ContainerClient/Core/RuntimeStatus.swift rename to Sources/ContainerResource/Container/RuntimeStatus.swift index a3238e69..88900735 100644 --- a/Sources/ContainerClient/Core/RuntimeStatus.swift +++ b/Sources/ContainerResource/Container/RuntimeStatus.swift @@ -1,5 +1,5 @@ //===----------------------------------------------------------------------===// -// Copyright © 2025-2026 Apple Inc. and the container project authors. +// Copyright © 2026 Apple Inc. and the container project authors. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/Sources/ContainerClient/Core/ImageDescription.swift b/Sources/ContainerResource/Image/ImageDescription.swift similarity index 94% rename from Sources/ContainerClient/Core/ImageDescription.swift rename to Sources/ContainerResource/Image/ImageDescription.swift index c8105bf5..a54f73a1 100644 --- a/Sources/ContainerClient/Core/ImageDescription.swift +++ b/Sources/ContainerResource/Image/ImageDescription.swift @@ -1,5 +1,5 @@ //===----------------------------------------------------------------------===// -// Copyright © 2025-2026 Apple Inc. and the container project authors. +// Copyright © 2026 Apple Inc. and the container project authors. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/Sources/ContainerClient/Core/ImageDetail.swift b/Sources/ContainerResource/Image/ImageDetail.swift similarity index 51% rename from Sources/ContainerClient/Core/ImageDetail.swift rename to Sources/ContainerResource/Image/ImageDetail.swift index b8f47a39..cf2d672d 100644 --- a/Sources/ContainerClient/Core/ImageDetail.swift +++ b/Sources/ContainerResource/Image/ImageDetail.swift @@ -1,5 +1,5 @@ //===----------------------------------------------------------------------===// -// Copyright © 2025-2026 Apple Inc. and the container project authors. +// Copyright © 2026 Apple Inc. and the container project authors. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -27,40 +27,16 @@ public struct ImageDetail: Codable { public let config: ContainerizationOCI.Image public let size: Int64 - init(platform: Platform, size: Int64, config: ContainerizationOCI.Image) { + public init(platform: Platform, size: Int64, config: ContainerizationOCI.Image) { self.platform = platform self.config = config self.size = size } } - init(name: String, index: Descriptor, variants: [Variants]) { + public init(name: String, index: Descriptor, variants: [Variants]) { self.name = name self.index = index self.variants = variants } } - -extension ClientImage { - public func details() async throws -> ImageDetail { - let descriptor = try await self.resolved() - let reference = self.reference - var variants: [ImageDetail.Variants] = [] - for desc in try await self.index().manifests { - guard let platform = desc.platform else { - continue - } - let config: ContainerizationOCI.Image - let manifest: ContainerizationOCI.Manifest - do { - config = try await self.config(for: platform) - manifest = try await self.manifest(for: platform) - } catch { - continue - } - let size = desc.size + manifest.config.size + manifest.layers.reduce(0, { (l, r) in l + r.size }) - variants.append(.init(platform: platform, size: size, config: config)) - } - return ImageDetail(name: reference, index: descriptor, variants: variants) - } -} diff --git a/Sources/Services/ContainerNetworkService/Attachment.swift b/Sources/ContainerResource/Network/Attachment.swift similarity index 97% rename from Sources/Services/ContainerNetworkService/Attachment.swift rename to Sources/ContainerResource/Network/Attachment.swift index 070df5f6..a6273052 100644 --- a/Sources/Services/ContainerNetworkService/Attachment.swift +++ b/Sources/ContainerResource/Network/Attachment.swift @@ -1,5 +1,5 @@ //===----------------------------------------------------------------------===// -// Copyright © 2025-2026 Apple Inc. and the container project authors. +// Copyright © 2026 Apple Inc. and the container project authors. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/Sources/Services/ContainerNetworkService/AttachmentConfiguration.swift b/Sources/ContainerResource/Network/AttachmentConfiguration.swift similarity index 95% rename from Sources/Services/ContainerNetworkService/AttachmentConfiguration.swift rename to Sources/ContainerResource/Network/AttachmentConfiguration.swift index 27fc8663..28caf5fe 100644 --- a/Sources/Services/ContainerNetworkService/AttachmentConfiguration.swift +++ b/Sources/ContainerResource/Network/AttachmentConfiguration.swift @@ -1,5 +1,5 @@ //===----------------------------------------------------------------------===// -// Copyright © 2025-2026 Apple Inc. and the container project authors. +// Copyright © 2026 Apple Inc. and the container project authors. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/Sources/Services/ContainerNetworkService/NetworkConfiguration.swift b/Sources/ContainerResource/Network/NetworkConfiguration.swift similarity index 98% rename from Sources/Services/ContainerNetworkService/NetworkConfiguration.swift rename to Sources/ContainerResource/Network/NetworkConfiguration.swift index 622f805b..234a0809 100644 --- a/Sources/Services/ContainerNetworkService/NetworkConfiguration.swift +++ b/Sources/ContainerResource/Network/NetworkConfiguration.swift @@ -1,5 +1,5 @@ //===----------------------------------------------------------------------===// -// Copyright © 2025-2026 Apple Inc. and the container project authors. +// Copyright © 2026 Apple Inc. and the container project authors. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/Sources/Services/ContainerNetworkService/NetworkMode.swift b/Sources/ContainerResource/Network/NetworkMode.swift similarity index 94% rename from Sources/Services/ContainerNetworkService/NetworkMode.swift rename to Sources/ContainerResource/Network/NetworkMode.swift index 483502b7..4b7a4a6e 100644 --- a/Sources/Services/ContainerNetworkService/NetworkMode.swift +++ b/Sources/ContainerResource/Network/NetworkMode.swift @@ -1,5 +1,5 @@ //===----------------------------------------------------------------------===// -// Copyright © 2025-2026 Apple Inc. and the container project authors. +// Copyright © 2026 Apple Inc. and the container project authors. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/Sources/Services/ContainerNetworkService/NetworkState.swift b/Sources/ContainerResource/Network/NetworkState.swift similarity index 96% rename from Sources/Services/ContainerNetworkService/NetworkState.swift rename to Sources/ContainerResource/Network/NetworkState.swift index 354d6c09..13111290 100644 --- a/Sources/Services/ContainerNetworkService/NetworkState.swift +++ b/Sources/ContainerResource/Network/NetworkState.swift @@ -1,5 +1,5 @@ //===----------------------------------------------------------------------===// -// Copyright © 2025-2026 Apple Inc. and the container project authors. +// Copyright © 2026 Apple Inc. and the container project authors. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/Sources/ContainerClient/Core/Volume.swift b/Sources/ContainerResource/Volume/Volume.swift similarity index 98% rename from Sources/ContainerClient/Core/Volume.swift rename to Sources/ContainerResource/Volume/Volume.swift index d7c06dcb..fe4de996 100644 --- a/Sources/ContainerClient/Core/Volume.swift +++ b/Sources/ContainerResource/Volume/Volume.swift @@ -1,5 +1,5 @@ //===----------------------------------------------------------------------===// -// Copyright © 2025-2026 Apple Inc. and the container project authors. +// Copyright © 2026 Apple Inc. and the container project authors. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/Sources/Helpers/APIServer/APIServer+Start.swift b/Sources/Helpers/APIServer/APIServer+Start.swift index 07b883dc..8366a04c 100644 --- a/Sources/Helpers/APIServer/APIServer+Start.swift +++ b/Sources/Helpers/APIServer/APIServer+Start.swift @@ -15,10 +15,11 @@ //===----------------------------------------------------------------------===// import ArgumentParser +import ContainerAPIClient import ContainerAPIService -import ContainerClient import ContainerNetworkService import ContainerPlugin +import ContainerResource import ContainerXPC import DNSServer import Foundation diff --git a/Sources/Helpers/NetworkVmnet/NetworkVmnetHelper+Start.swift b/Sources/Helpers/NetworkVmnet/NetworkVmnetHelper+Start.swift index 141e23e3..f82629fd 100644 --- a/Sources/Helpers/NetworkVmnet/NetworkVmnetHelper+Start.swift +++ b/Sources/Helpers/NetworkVmnet/NetworkVmnetHelper+Start.swift @@ -16,6 +16,8 @@ import ArgumentParser import ContainerNetworkService +import ContainerNetworkServiceClient +import ContainerResource import ContainerXPC import ContainerizationExtras import Foundation diff --git a/Sources/Helpers/RuntimeLinux/IsolatedInterfaceStrategy.swift b/Sources/Helpers/RuntimeLinux/IsolatedInterfaceStrategy.swift index 20706043..9f4c493c 100644 --- a/Sources/Helpers/RuntimeLinux/IsolatedInterfaceStrategy.swift +++ b/Sources/Helpers/RuntimeLinux/IsolatedInterfaceStrategy.swift @@ -14,7 +14,7 @@ // limitations under the License. //===----------------------------------------------------------------------===// -import ContainerNetworkService +import ContainerResource import ContainerSandboxService import ContainerXPC import Containerization diff --git a/Sources/Helpers/RuntimeLinux/NonisolatedInterfaceStrategy.swift b/Sources/Helpers/RuntimeLinux/NonisolatedInterfaceStrategy.swift index 287ebbdf..787ff31d 100644 --- a/Sources/Helpers/RuntimeLinux/NonisolatedInterfaceStrategy.swift +++ b/Sources/Helpers/RuntimeLinux/NonisolatedInterfaceStrategy.swift @@ -14,7 +14,7 @@ // limitations under the License. //===----------------------------------------------------------------------===// -import ContainerNetworkService +import ContainerResource import ContainerSandboxService import ContainerXPC import Containerization diff --git a/Sources/Helpers/RuntimeLinux/RuntimeLinuxHelper+Start.swift b/Sources/Helpers/RuntimeLinux/RuntimeLinuxHelper+Start.swift index fe081b23..55ac5420 100644 --- a/Sources/Helpers/RuntimeLinux/RuntimeLinuxHelper+Start.swift +++ b/Sources/Helpers/RuntimeLinux/RuntimeLinuxHelper+Start.swift @@ -15,9 +15,10 @@ //===----------------------------------------------------------------------===// import ArgumentParser -import ContainerClient import ContainerLog +import ContainerResource import ContainerSandboxService +import ContainerSandboxServiceClient import ContainerXPC import Foundation import Logging diff --git a/Sources/ContainerClient/Arch.swift b/Sources/Services/ContainerAPIService/Client/Arch.swift similarity index 92% rename from Sources/ContainerClient/Arch.swift rename to Sources/Services/ContainerAPIService/Client/Arch.swift index 24489c6f..711c0a3a 100644 --- a/Sources/ContainerClient/Arch.swift +++ b/Sources/Services/ContainerAPIService/Client/Arch.swift @@ -1,5 +1,5 @@ //===----------------------------------------------------------------------===// -// Copyright © 2025-2026 Apple Inc. and the container project authors. +// Copyright © 2026 Apple Inc. and the container project authors. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/Sources/ContainerClient/Archiver.swift b/Sources/Services/ContainerAPIService/Client/Archiver.swift similarity index 99% rename from Sources/ContainerClient/Archiver.swift rename to Sources/Services/ContainerAPIService/Client/Archiver.swift index 5651668b..d4b03972 100644 --- a/Sources/ContainerClient/Archiver.swift +++ b/Sources/Services/ContainerAPIService/Client/Archiver.swift @@ -1,5 +1,5 @@ //===----------------------------------------------------------------------===// -// Copyright © 2025-2026 Apple Inc. and the container project authors. +// Copyright © 2026 Apple Inc. and the container project authors. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/Sources/ContainerClient/Array+Dedupe.swift b/Sources/Services/ContainerAPIService/Client/Array+Dedupe.swift similarity index 92% rename from Sources/ContainerClient/Array+Dedupe.swift rename to Sources/Services/ContainerAPIService/Client/Array+Dedupe.swift index 75a0c758..160a395a 100644 --- a/Sources/ContainerClient/Array+Dedupe.swift +++ b/Sources/Services/ContainerAPIService/Client/Array+Dedupe.swift @@ -1,5 +1,5 @@ //===----------------------------------------------------------------------===// -// Copyright © 2025-2026 Apple Inc. and the container project authors. +// Copyright © 2026 Apple Inc. and the container project authors. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/Sources/ContainerClient/Core/ClientContainer.swift b/Sources/Services/ContainerAPIService/Client/ClientContainer.swift similarity index 99% rename from Sources/ContainerClient/Core/ClientContainer.swift rename to Sources/Services/ContainerAPIService/Client/ClientContainer.swift index 76f91af6..6231506c 100644 --- a/Sources/ContainerClient/Core/ClientContainer.swift +++ b/Sources/Services/ContainerAPIService/Client/ClientContainer.swift @@ -1,5 +1,5 @@ //===----------------------------------------------------------------------===// -// Copyright © 2025-2026 Apple Inc. and the container project authors. +// Copyright © 2026 Apple Inc. and the container project authors. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -14,7 +14,7 @@ // limitations under the License. //===----------------------------------------------------------------------===// -import ContainerNetworkService +import ContainerResource import ContainerXPC import Containerization import ContainerizationError diff --git a/Sources/ContainerClient/Core/ClientDiskUsage.swift b/Sources/Services/ContainerAPIService/Client/ClientDiskUsage.swift similarity index 95% rename from Sources/ContainerClient/Core/ClientDiskUsage.swift rename to Sources/Services/ContainerAPIService/Client/ClientDiskUsage.swift index 30c1391e..9d0a0040 100644 --- a/Sources/ContainerClient/Core/ClientDiskUsage.swift +++ b/Sources/Services/ContainerAPIService/Client/ClientDiskUsage.swift @@ -1,5 +1,5 @@ //===----------------------------------------------------------------------===// -// Copyright © 2025-2026 Apple Inc. and the container project authors. +// Copyright © 2026 Apple Inc. and the container project authors. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/Sources/ContainerClient/Core/ClientHealthCheck.swift b/Sources/Services/ContainerAPIService/Client/ClientHealthCheck.swift similarity index 97% rename from Sources/ContainerClient/Core/ClientHealthCheck.swift rename to Sources/Services/ContainerAPIService/Client/ClientHealthCheck.swift index 2953b08b..f2044500 100644 --- a/Sources/ContainerClient/Core/ClientHealthCheck.swift +++ b/Sources/Services/ContainerAPIService/Client/ClientHealthCheck.swift @@ -1,5 +1,5 @@ //===----------------------------------------------------------------------===// -// Copyright © 2025-2026 Apple Inc. and the container project authors. +// Copyright © 2026 Apple Inc. and the container project authors. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/Sources/ContainerClient/Core/ClientImage.swift b/Sources/Services/ContainerAPIService/Client/ClientImage.swift similarity index 94% rename from Sources/ContainerClient/Core/ClientImage.swift rename to Sources/Services/ContainerAPIService/Client/ClientImage.swift index 76334982..52aa16c0 100644 --- a/Sources/ContainerClient/Core/ClientImage.swift +++ b/Sources/Services/ContainerAPIService/Client/ClientImage.swift @@ -1,5 +1,5 @@ //===----------------------------------------------------------------------===// -// Copyright © 2025-2026 Apple Inc. and the container project authors. +// Copyright © 2026 Apple Inc. and the container project authors. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -16,6 +16,7 @@ import ContainerImagesServiceClient import ContainerPersistence +import ContainerResource import ContainerXPC import Containerization import ContainerizationError @@ -498,3 +499,27 @@ extension ImageDescription { return name } } + +extension ClientImage { + public func details() async throws -> ImageDetail { + let descriptor = try await self.resolved() + let reference = self.reference + var variants: [ImageDetail.Variants] = [] + for desc in try await self.index().manifests { + guard let platform = desc.platform else { + continue + } + let config: ContainerizationOCI.Image + let manifest: ContainerizationOCI.Manifest + do { + config = try await self.config(for: platform) + manifest = try await self.manifest(for: platform) + } catch { + continue + } + let size = desc.size + manifest.config.size + manifest.layers.reduce(0, { (l, r) in l + r.size }) + variants.append(.init(platform: platform, size: size, config: config)) + } + return ImageDetail(name: reference, index: descriptor, variants: variants) + } +} diff --git a/Sources/ContainerClient/Core/ClientKernel.swift b/Sources/Services/ContainerAPIService/Client/ClientKernel.swift similarity index 98% rename from Sources/ContainerClient/Core/ClientKernel.swift rename to Sources/Services/ContainerAPIService/Client/ClientKernel.swift index 81175ae3..3cac4693 100644 --- a/Sources/ContainerClient/Core/ClientKernel.swift +++ b/Sources/Services/ContainerAPIService/Client/ClientKernel.swift @@ -1,5 +1,5 @@ //===----------------------------------------------------------------------===// -// Copyright © 2025-2026 Apple Inc. and the container project authors. +// Copyright © 2026 Apple Inc. and the container project authors. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/Sources/ContainerClient/Core/ClientNetwork.swift b/Sources/Services/ContainerAPIService/Client/ClientNetwork.swift similarity index 97% rename from Sources/ContainerClient/Core/ClientNetwork.swift rename to Sources/Services/ContainerAPIService/Client/ClientNetwork.swift index 4bbcb8a2..d2521314 100644 --- a/Sources/ContainerClient/Core/ClientNetwork.swift +++ b/Sources/Services/ContainerAPIService/Client/ClientNetwork.swift @@ -1,5 +1,5 @@ //===----------------------------------------------------------------------===// -// Copyright © 2025-2026 Apple Inc. and the container project authors. +// Copyright © 2026 Apple Inc. and the container project authors. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -14,7 +14,7 @@ // limitations under the License. //===----------------------------------------------------------------------===// -import ContainerNetworkService +import ContainerResource import ContainerXPC import ContainerizationError import ContainerizationOS diff --git a/Sources/ContainerClient/Core/ClientProcess.swift b/Sources/Services/ContainerAPIService/Client/ClientProcess.swift similarity index 97% rename from Sources/ContainerClient/Core/ClientProcess.swift rename to Sources/Services/ContainerAPIService/Client/ClientProcess.swift index 51f17160..5a5f8543 100644 --- a/Sources/ContainerClient/Core/ClientProcess.swift +++ b/Sources/Services/ContainerAPIService/Client/ClientProcess.swift @@ -1,5 +1,5 @@ //===----------------------------------------------------------------------===// -// Copyright © 2025-2026 Apple Inc. and the container project authors. +// Copyright © 2026 Apple Inc. and the container project authors. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -14,7 +14,6 @@ // limitations under the License. //===----------------------------------------------------------------------===// -import ContainerNetworkService import ContainerXPC import Containerization import ContainerizationError diff --git a/Sources/ContainerClient/Core/ClientVolume.swift b/Sources/Services/ContainerAPIService/Client/ClientVolume.swift similarity index 97% rename from Sources/ContainerClient/Core/ClientVolume.swift rename to Sources/Services/ContainerAPIService/Client/ClientVolume.swift index 25c94c09..8100c412 100644 --- a/Sources/ContainerClient/Core/ClientVolume.swift +++ b/Sources/Services/ContainerAPIService/Client/ClientVolume.swift @@ -1,5 +1,5 @@ //===----------------------------------------------------------------------===// -// Copyright © 2025-2026 Apple Inc. and the container project authors. +// Copyright © 2026 Apple Inc. and the container project authors. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -14,6 +14,7 @@ // limitations under the License. //===----------------------------------------------------------------------===// +import ContainerResource import ContainerXPC import Containerization import Foundation diff --git a/Sources/ContainerClient/Core/Constants.swift b/Sources/Services/ContainerAPIService/Client/Constants.swift similarity index 91% rename from Sources/ContainerClient/Core/Constants.swift rename to Sources/Services/ContainerAPIService/Client/Constants.swift index d5de87f4..2fa2404c 100644 --- a/Sources/ContainerClient/Core/Constants.swift +++ b/Sources/Services/ContainerAPIService/Client/Constants.swift @@ -1,5 +1,5 @@ //===----------------------------------------------------------------------===// -// Copyright © 2025-2026 Apple Inc. and the container project authors. +// Copyright © 2026 Apple Inc. and the container project authors. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/Sources/ContainerClient/ContainerizationProgressAdapter.swift b/Sources/Services/ContainerAPIService/Client/ContainerizationProgressAdapter.swift similarity index 96% rename from Sources/ContainerClient/ContainerizationProgressAdapter.swift rename to Sources/Services/ContainerAPIService/Client/ContainerizationProgressAdapter.swift index 3feb0310..ce407d52 100644 --- a/Sources/ContainerClient/ContainerizationProgressAdapter.swift +++ b/Sources/Services/ContainerAPIService/Client/ContainerizationProgressAdapter.swift @@ -1,5 +1,5 @@ //===----------------------------------------------------------------------===// -// Copyright © 2025-2026 Apple Inc. and the container project authors. +// Copyright © 2026 Apple Inc. and the container project authors. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/Sources/ContainerClient/Core/DiskUsage.swift b/Sources/Services/ContainerAPIService/Client/DiskUsage.swift similarity index 96% rename from Sources/ContainerClient/Core/DiskUsage.swift rename to Sources/Services/ContainerAPIService/Client/DiskUsage.swift index 594245c8..6a9c86c0 100644 --- a/Sources/ContainerClient/Core/DiskUsage.swift +++ b/Sources/Services/ContainerAPIService/Client/DiskUsage.swift @@ -1,5 +1,5 @@ //===----------------------------------------------------------------------===// -// Copyright © 2025-2026 Apple Inc. and the container project authors. +// Copyright © 2026 Apple Inc. and the container project authors. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/Sources/ContainerClient/FileDownloader.swift b/Sources/Services/ContainerAPIService/Client/FileDownloader.swift similarity index 97% rename from Sources/ContainerClient/FileDownloader.swift rename to Sources/Services/ContainerAPIService/Client/FileDownloader.swift index 8024636a..83aabfc5 100644 --- a/Sources/ContainerClient/FileDownloader.swift +++ b/Sources/Services/ContainerAPIService/Client/FileDownloader.swift @@ -1,5 +1,5 @@ //===----------------------------------------------------------------------===// -// Copyright © 2025-2026 Apple Inc. and the container project authors. +// Copyright © 2026 Apple Inc. and the container project authors. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/Sources/ContainerClient/Flags.swift b/Sources/Services/ContainerAPIService/Client/Flags.swift similarity index 99% rename from Sources/ContainerClient/Flags.swift rename to Sources/Services/ContainerAPIService/Client/Flags.swift index 28e210fa..54324829 100644 --- a/Sources/ContainerClient/Flags.swift +++ b/Sources/Services/ContainerAPIService/Client/Flags.swift @@ -1,5 +1,5 @@ //===----------------------------------------------------------------------===// -// Copyright © 2025-2026 Apple Inc. and the container project authors. +// Copyright © 2026 Apple Inc. and the container project authors. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/Sources/ContainerClient/HostDNSResolver.swift b/Sources/Services/ContainerAPIService/Client/HostDNSResolver.swift similarity index 98% rename from Sources/ContainerClient/HostDNSResolver.swift rename to Sources/Services/ContainerAPIService/Client/HostDNSResolver.swift index 5e355b33..fd3fdf5f 100644 --- a/Sources/ContainerClient/HostDNSResolver.swift +++ b/Sources/Services/ContainerAPIService/Client/HostDNSResolver.swift @@ -1,5 +1,5 @@ //===----------------------------------------------------------------------===// -// Copyright © 2025-2026 Apple Inc. and the container project authors. +// Copyright © 2026 Apple Inc. and the container project authors. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/Sources/ContainerClient/Measurement+Parse.swift b/Sources/Services/ContainerAPIService/Client/Measurement+Parse.swift similarity index 97% rename from Sources/ContainerClient/Measurement+Parse.swift rename to Sources/Services/ContainerAPIService/Client/Measurement+Parse.swift index 5db9debe..ae94c3df 100644 --- a/Sources/ContainerClient/Measurement+Parse.swift +++ b/Sources/Services/ContainerAPIService/Client/Measurement+Parse.swift @@ -1,5 +1,5 @@ //===----------------------------------------------------------------------===// -// Copyright © 2025-2026 Apple Inc. and the container project authors. +// Copyright © 2026 Apple Inc. and the container project authors. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/Sources/ContainerClient/Parser.swift b/Sources/Services/ContainerAPIService/Client/Parser.swift similarity index 99% rename from Sources/ContainerClient/Parser.swift rename to Sources/Services/ContainerAPIService/Client/Parser.swift index 29e94f06..ded05f45 100644 --- a/Sources/ContainerClient/Parser.swift +++ b/Sources/Services/ContainerAPIService/Client/Parser.swift @@ -1,5 +1,5 @@ //===----------------------------------------------------------------------===// -// Copyright © 2025-2026 Apple Inc. and the container project authors. +// Copyright © 2026 Apple Inc. and the container project authors. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -14,6 +14,7 @@ // limitations under the License. //===----------------------------------------------------------------------===// +import ContainerResource import Containerization import ContainerizationError import ContainerizationOCI diff --git a/Sources/ContainerClient/ProcessIO.swift b/Sources/Services/ContainerAPIService/Client/ProcessIO.swift similarity index 99% rename from Sources/ContainerClient/ProcessIO.swift rename to Sources/Services/ContainerAPIService/Client/ProcessIO.swift index 368a8e2f..0916bee6 100644 --- a/Sources/ContainerClient/ProcessIO.swift +++ b/Sources/Services/ContainerAPIService/Client/ProcessIO.swift @@ -1,5 +1,5 @@ //===----------------------------------------------------------------------===// -// Copyright © 2025-2026 Apple Inc. and the container project authors. +// Copyright © 2026 Apple Inc. and the container project authors. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/Sources/ContainerClient/ProgressUpdateClient.swift b/Sources/Services/ContainerAPIService/Client/ProgressUpdateClient.swift similarity index 98% rename from Sources/ContainerClient/ProgressUpdateClient.swift rename to Sources/Services/ContainerAPIService/Client/ProgressUpdateClient.swift index 57e72beb..458e318e 100644 --- a/Sources/ContainerClient/ProgressUpdateClient.swift +++ b/Sources/Services/ContainerAPIService/Client/ProgressUpdateClient.swift @@ -1,5 +1,5 @@ //===----------------------------------------------------------------------===// -// Copyright © 2025-2026 Apple Inc. and the container project authors. +// Copyright © 2026 Apple Inc. and the container project authors. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/Sources/ContainerClient/ProgressUpdateService.swift b/Sources/Services/ContainerAPIService/Client/ProgressUpdateService.swift similarity index 98% rename from Sources/ContainerClient/ProgressUpdateService.swift rename to Sources/Services/ContainerAPIService/Client/ProgressUpdateService.swift index 92fccabf..863d4de6 100644 --- a/Sources/ContainerClient/ProgressUpdateService.swift +++ b/Sources/Services/ContainerAPIService/Client/ProgressUpdateService.swift @@ -1,5 +1,5 @@ //===----------------------------------------------------------------------===// -// Copyright © 2025-2026 Apple Inc. and the container project authors. +// Copyright © 2026 Apple Inc. and the container project authors. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/Sources/ContainerClient/RequestScheme.swift b/Sources/Services/ContainerAPIService/Client/RequestScheme.swift similarity index 97% rename from Sources/ContainerClient/RequestScheme.swift rename to Sources/Services/ContainerAPIService/Client/RequestScheme.swift index 647a69a9..b9634ae0 100644 --- a/Sources/ContainerClient/RequestScheme.swift +++ b/Sources/Services/ContainerAPIService/Client/RequestScheme.swift @@ -1,5 +1,5 @@ //===----------------------------------------------------------------------===// -// Copyright © 2025-2026 Apple Inc. and the container project authors. +// Copyright © 2026 Apple Inc. and the container project authors. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/Sources/ContainerClient/SignalThreshold.swift b/Sources/Services/ContainerAPIService/Client/SignalThreshold.swift similarity index 96% rename from Sources/ContainerClient/SignalThreshold.swift rename to Sources/Services/ContainerAPIService/Client/SignalThreshold.swift index 9b1c4cb8..f1db36b8 100644 --- a/Sources/ContainerClient/SignalThreshold.swift +++ b/Sources/Services/ContainerAPIService/Client/SignalThreshold.swift @@ -1,5 +1,5 @@ //===----------------------------------------------------------------------===// -// Copyright © 2025-2026 Apple Inc. and the container project authors. +// Copyright © 2026 Apple Inc. and the container project authors. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/Sources/ContainerClient/String+Extensions.swift b/Sources/Services/ContainerAPIService/Client/String+Extensions.swift similarity index 96% rename from Sources/ContainerClient/String+Extensions.swift rename to Sources/Services/ContainerAPIService/Client/String+Extensions.swift index 3a23e27a..e2adf758 100644 --- a/Sources/ContainerClient/String+Extensions.swift +++ b/Sources/Services/ContainerAPIService/Client/String+Extensions.swift @@ -1,5 +1,5 @@ //===----------------------------------------------------------------------===// -// Copyright © 2025-2026 Apple Inc. and the container project authors. +// Copyright © 2026 Apple Inc. and the container project authors. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/Sources/ContainerClient/Core/SystemHealth.swift b/Sources/Services/ContainerAPIService/Client/SystemHealth.swift similarity index 95% rename from Sources/ContainerClient/Core/SystemHealth.swift rename to Sources/Services/ContainerAPIService/Client/SystemHealth.swift index d8a1136a..11a14526 100644 --- a/Sources/ContainerClient/Core/SystemHealth.swift +++ b/Sources/Services/ContainerAPIService/Client/SystemHealth.swift @@ -1,5 +1,5 @@ //===----------------------------------------------------------------------===// -// Copyright © 2025-2026 Apple Inc. and the container project authors. +// Copyright © 2026 Apple Inc. and the container project authors. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/Sources/ContainerClient/TableOutput.swift b/Sources/Services/ContainerAPIService/Client/TableOutput.swift similarity index 96% rename from Sources/ContainerClient/TableOutput.swift rename to Sources/Services/ContainerAPIService/Client/TableOutput.swift index 25cf3e16..7dc5b20c 100644 --- a/Sources/ContainerClient/TableOutput.swift +++ b/Sources/Services/ContainerAPIService/Client/TableOutput.swift @@ -1,5 +1,5 @@ //===----------------------------------------------------------------------===// -// Copyright © 2025-2026 Apple Inc. and the container project authors. +// Copyright © 2026 Apple Inc. and the container project authors. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/Sources/ContainerClient/Utility.swift b/Sources/Services/ContainerAPIService/Client/Utility.swift similarity index 94% rename from Sources/ContainerClient/Utility.swift rename to Sources/Services/ContainerAPIService/Client/Utility.swift index 15e6f651..73626527 100644 --- a/Sources/ContainerClient/Utility.swift +++ b/Sources/Services/ContainerAPIService/Client/Utility.swift @@ -1,5 +1,5 @@ //===----------------------------------------------------------------------===// -// Copyright © 2025-2026 Apple Inc. and the container project authors. +// Copyright © 2026 Apple Inc. and the container project authors. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -14,8 +14,8 @@ // limitations under the License. //===----------------------------------------------------------------------===// -import ContainerNetworkService import ContainerPersistence +import ContainerResource import Containerization import ContainerizationError import ContainerizationExtras @@ -72,19 +72,6 @@ public struct Utility { } } - public static func validPublishPorts(_ publishPorts: [PublishPort]) throws { - var hostPorts = Set() - for publishPort in publishPorts { - for index in publishPort.hostPort..<(publishPort.hostPort + publishPort.count) { - let hostPortKey = "\(index)/\(publishPort.proto.rawValue)" - guard !hostPorts.contains(hostPortKey) else { - throw ContainerizationError(.invalidArgument, message: "host ports for different publish port specs may not overlap") - } - hostPorts.insert(hostPortKey) - } - } - } - public static func containerConfigFromFlags( id: String, image: String, @@ -243,7 +230,9 @@ public struct Utility { guard config.publishedPorts.count <= publishedPortCountLimit else { throw ContainerizationError(.invalidArgument, message: "cannot exceed more than \(publishedPortCountLimit) port publish descriptors") } - try validPublishPorts(config.publishedPorts) + guard !config.publishedPorts.hasOverlaps() else { + throw ContainerizationError(.invalidArgument, message: "host ports for different publish port specs may not overlap") + } // Parse --publish-socket arguments and add to container configuration // to enable socket forwarding from container to host. diff --git a/Sources/ContainerClient/Core/XPC+.swift b/Sources/Services/ContainerAPIService/Client/XPC+.swift similarity index 97% rename from Sources/ContainerClient/Core/XPC+.swift rename to Sources/Services/ContainerAPIService/Client/XPC+.swift index 7f6459d2..6a196ffc 100644 --- a/Sources/ContainerClient/Core/XPC+.swift +++ b/Sources/Services/ContainerAPIService/Client/XPC+.swift @@ -1,5 +1,5 @@ //===----------------------------------------------------------------------===// -// Copyright © 2025-2026 Apple Inc. and the container project authors. +// Copyright © 2026 Apple Inc. and the container project authors. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -50,8 +50,6 @@ public enum XPCKeys: String { case stopOptions /// Whether to force stop a container when deleting. case forceDelete - /// An endpoint to talk to a sandbox service. - case sandboxServiceEndpoint /// Plugins case pluginName case plugins diff --git a/Sources/Services/ContainerAPIService/Containers/ContainersHarness.swift b/Sources/Services/ContainerAPIService/Server/Containers/ContainersHarness.swift similarity index 98% rename from Sources/Services/ContainerAPIService/Containers/ContainersHarness.swift rename to Sources/Services/ContainerAPIService/Server/Containers/ContainersHarness.swift index 9a5bd148..7aa5f96d 100644 --- a/Sources/Services/ContainerAPIService/Containers/ContainersHarness.swift +++ b/Sources/Services/ContainerAPIService/Server/Containers/ContainersHarness.swift @@ -1,5 +1,5 @@ //===----------------------------------------------------------------------===// -// Copyright © 2025-2026 Apple Inc. and the container project authors. +// Copyright © 2026 Apple Inc. and the container project authors. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -14,7 +14,7 @@ // limitations under the License. //===----------------------------------------------------------------------===// -import ContainerClient +import ContainerResource import ContainerXPC import Containerization import ContainerizationError diff --git a/Sources/Services/ContainerAPIService/Containers/ContainersService.swift b/Sources/Services/ContainerAPIService/Server/Containers/ContainersService.swift similarity index 97% rename from Sources/Services/ContainerAPIService/Containers/ContainersService.swift rename to Sources/Services/ContainerAPIService/Server/Containers/ContainersService.swift index 23ecc958..119233b5 100644 --- a/Sources/Services/ContainerAPIService/Containers/ContainersService.swift +++ b/Sources/Services/ContainerAPIService/Server/Containers/ContainersService.swift @@ -1,5 +1,5 @@ //===----------------------------------------------------------------------===// -// Copyright © 2025-2026 Apple Inc. and the container project authors. +// Copyright © 2026 Apple Inc. and the container project authors. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -15,9 +15,10 @@ //===----------------------------------------------------------------------===// import CVersion -import ContainerClient +import ContainerAPIClient import ContainerPlugin -import ContainerSandboxService +import ContainerResource +import ContainerSandboxServiceClient import ContainerXPC import Containerization import ContainerizationError @@ -80,7 +81,7 @@ public actor ContainersService { var results = [String: ContainerState]() for dir in directories { do { - let bundle = ContainerClient.Bundle(path: dir) + let bundle = ContainerResource.Bundle(path: dir) let config = try bundle.configuration let state = ContainerState( snapshot: .init( @@ -233,7 +234,7 @@ public actor ContainersService { let systemPlatform = kernel.platform let initFs = try await self.getInitBlock(for: systemPlatform.ociPlatform()) - let bundle = try ContainerClient.Bundle.create( + let bundle = try ContainerResource.Bundle.create( path: path, initialFilesystem: initFs, kernel: kernel, @@ -277,7 +278,7 @@ public actor ContainersService { } let path = self.containerRoot.appendingPathComponent(id) - let bundle = ContainerClient.Bundle(path: path) + let bundle = ContainerResource.Bundle(path: path) let config = try bundle.configuration try Self.registerService( plugin: self.runtimePlugins.first { $0.name == config.runtimeHandler }!, @@ -450,7 +451,7 @@ public actor ContainersService { // the bundle is there, and that the files actually exist. do { let path = self.containerRoot.appendingPathComponent(id) - let bundle = ContainerClient.Bundle(path: path) + let bundle = ContainerResource.Bundle(path: path) return [ try FileHandle(forReadingFrom: bundle.containerLog), try FileHandle(forReadingFrom: bundle.bootlog), @@ -533,7 +534,7 @@ public actor ContainersService { self.log.info("Shutting down sandbox service for \(id)") let path = self.containerRoot.appendingPathComponent(id) - let bundle = ContainerClient.Bundle(path: path) + let bundle = ContainerResource.Bundle(path: path) let config = try bundle.configuration let label = Self.fullLaunchdServiceLabel( runtimeName: config.runtimeHandler, @@ -575,7 +576,7 @@ public actor ContainersService { // the OCI runtime. await self.exitMonitor.stopTracking(id: id) let path = self.containerRoot.appendingPathComponent(id) - let bundle = ContainerClient.Bundle(path: path) + let bundle = ContainerResource.Bundle(path: path) let config = try bundle.configuration let label = Self.fullLaunchdServiceLabel( @@ -593,7 +594,7 @@ public actor ContainersService { private func getContainerCreationOptions(id: String) throws -> ContainerCreateOptions { let path = self.containerRoot.appendingPathComponent(id) - let bundle = ContainerClient.Bundle(path: path) + let bundle = ContainerResource.Bundle(path: path) let options: ContainerCreateOptions = try bundle.load(filename: "options.json") return options } diff --git a/Sources/Services/ContainerAPIService/DiskUsage/DiskUsageHarness.swift b/Sources/Services/ContainerAPIService/Server/DiskUsage/DiskUsageHarness.swift similarity index 94% rename from Sources/Services/ContainerAPIService/DiskUsage/DiskUsageHarness.swift rename to Sources/Services/ContainerAPIService/Server/DiskUsage/DiskUsageHarness.swift index 9f4985d8..b111e57a 100644 --- a/Sources/Services/ContainerAPIService/DiskUsage/DiskUsageHarness.swift +++ b/Sources/Services/ContainerAPIService/Server/DiskUsage/DiskUsageHarness.swift @@ -1,5 +1,5 @@ //===----------------------------------------------------------------------===// -// Copyright © 2025-2026 Apple Inc. and the container project authors. +// Copyright © 2026 Apple Inc. and the container project authors. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -14,7 +14,7 @@ // limitations under the License. //===----------------------------------------------------------------------===// -import ContainerClient +import ContainerAPIClient import ContainerXPC import ContainerizationError import Foundation diff --git a/Sources/Services/ContainerAPIService/DiskUsage/DiskUsageService.swift b/Sources/Services/ContainerAPIService/Server/DiskUsage/DiskUsageService.swift similarity index 96% rename from Sources/Services/ContainerAPIService/DiskUsage/DiskUsageService.swift rename to Sources/Services/ContainerAPIService/Server/DiskUsage/DiskUsageService.swift index 4e0483fe..39d43b8d 100644 --- a/Sources/Services/ContainerAPIService/DiskUsage/DiskUsageService.swift +++ b/Sources/Services/ContainerAPIService/Server/DiskUsage/DiskUsageService.swift @@ -1,5 +1,5 @@ //===----------------------------------------------------------------------===// -// Copyright © 2025-2026 Apple Inc. and the container project authors. +// Copyright © 2026 Apple Inc. and the container project authors. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -14,7 +14,7 @@ // limitations under the License. //===----------------------------------------------------------------------===// -import ContainerClient +import ContainerAPIClient import Logging /// Service for calculating disk usage across all resource types diff --git a/Sources/Services/ContainerAPIService/HealthCheck/HealthCheckHarness.swift b/Sources/Services/ContainerAPIService/Server/HealthCheck/HealthCheckHarness.swift similarity index 95% rename from Sources/Services/ContainerAPIService/HealthCheck/HealthCheckHarness.swift rename to Sources/Services/ContainerAPIService/Server/HealthCheck/HealthCheckHarness.swift index b0018257..fdc9232a 100644 --- a/Sources/Services/ContainerAPIService/HealthCheck/HealthCheckHarness.swift +++ b/Sources/Services/ContainerAPIService/Server/HealthCheck/HealthCheckHarness.swift @@ -1,5 +1,5 @@ //===----------------------------------------------------------------------===// -// Copyright © 2025-2026 Apple Inc. and the container project authors. +// Copyright © 2026 Apple Inc. and the container project authors. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -15,7 +15,7 @@ //===----------------------------------------------------------------------===// import CVersion -import ContainerClient +import ContainerAPIClient import ContainerVersion import ContainerXPC import Containerization diff --git a/Sources/Services/ContainerAPIService/Kernel/KernelHarness.swift b/Sources/Services/ContainerAPIService/Server/Kernel/KernelHarness.swift similarity index 97% rename from Sources/Services/ContainerAPIService/Kernel/KernelHarness.swift rename to Sources/Services/ContainerAPIService/Server/Kernel/KernelHarness.swift index a4c1c9f5..d1290577 100644 --- a/Sources/Services/ContainerAPIService/Kernel/KernelHarness.swift +++ b/Sources/Services/ContainerAPIService/Server/Kernel/KernelHarness.swift @@ -1,5 +1,5 @@ //===----------------------------------------------------------------------===// -// Copyright © 2025-2026 Apple Inc. and the container project authors. +// Copyright © 2026 Apple Inc. and the container project authors. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -14,7 +14,7 @@ // limitations under the License. //===----------------------------------------------------------------------===// -import ContainerClient +import ContainerAPIClient import ContainerXPC import Containerization import ContainerizationError diff --git a/Sources/Services/ContainerAPIService/Kernel/KernelService.swift b/Sources/Services/ContainerAPIService/Server/Kernel/KernelService.swift similarity index 96% rename from Sources/Services/ContainerAPIService/Kernel/KernelService.swift rename to Sources/Services/ContainerAPIService/Server/Kernel/KernelService.swift index bd1f23c1..a152a53a 100644 --- a/Sources/Services/ContainerAPIService/Kernel/KernelService.swift +++ b/Sources/Services/ContainerAPIService/Server/Kernel/KernelService.swift @@ -1,5 +1,5 @@ //===----------------------------------------------------------------------===// -// Copyright © 2025-2026 Apple Inc. and the container project authors. +// Copyright © 2026 Apple Inc. and the container project authors. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -14,7 +14,7 @@ // limitations under the License. //===----------------------------------------------------------------------===// -import ContainerClient +import ContainerAPIClient import Containerization import ContainerizationArchive import ContainerizationError @@ -84,7 +84,7 @@ public actor KernelService { if let progressUpdate { downloadProgressUpdate = ProgressTaskCoordinator.handler(for: downloadTask, from: progressUpdate) } - try await ContainerClient.FileDownloader.downloadFile(url: tar, to: tarFile, progressUpdate: downloadProgressUpdate) + try await ContainerAPIClient.FileDownloader.downloadFile(url: tar, to: tarFile, progressUpdate: downloadProgressUpdate) } await taskManager.finish() diff --git a/Sources/Services/ContainerAPIService/Networks/NetworksHarness.swift b/Sources/Services/ContainerAPIService/Server/Networks/NetworksHarness.swift similarity index 95% rename from Sources/Services/ContainerAPIService/Networks/NetworksHarness.swift rename to Sources/Services/ContainerAPIService/Server/Networks/NetworksHarness.swift index a2a7f0ae..00b273dd 100644 --- a/Sources/Services/ContainerAPIService/Networks/NetworksHarness.swift +++ b/Sources/Services/ContainerAPIService/Server/Networks/NetworksHarness.swift @@ -1,5 +1,5 @@ //===----------------------------------------------------------------------===// -// Copyright © 2025-2026 Apple Inc. and the container project authors. +// Copyright © 2026 Apple Inc. and the container project authors. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -14,7 +14,7 @@ // limitations under the License. //===----------------------------------------------------------------------===// -import ContainerNetworkService +import ContainerResource import ContainerXPC import ContainerizationError import ContainerizationOS diff --git a/Sources/Services/ContainerAPIService/Networks/NetworksService.swift b/Sources/Services/ContainerAPIService/Server/Networks/NetworksService.swift similarity index 98% rename from Sources/Services/ContainerAPIService/Networks/NetworksService.swift rename to Sources/Services/ContainerAPIService/Server/Networks/NetworksService.swift index e5ddd2b2..1784a16f 100644 --- a/Sources/Services/ContainerAPIService/Networks/NetworksService.swift +++ b/Sources/Services/ContainerAPIService/Server/Networks/NetworksService.swift @@ -1,5 +1,5 @@ //===----------------------------------------------------------------------===// -// Copyright © 2025-2026 Apple Inc. and the container project authors. +// Copyright © 2026 Apple Inc. and the container project authors. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -14,10 +14,11 @@ // limitations under the License. //===----------------------------------------------------------------------===// -import ContainerClient -import ContainerNetworkService +import ContainerAPIClient +import ContainerNetworkServiceClient import ContainerPersistence import ContainerPlugin +import ContainerResource import Containerization import ContainerizationError import ContainerizationExtras diff --git a/Sources/Services/ContainerAPIService/Plugin/PluginsHarness.swift b/Sources/Services/ContainerAPIService/Server/Plugin/PluginsHarness.swift similarity index 97% rename from Sources/Services/ContainerAPIService/Plugin/PluginsHarness.swift rename to Sources/Services/ContainerAPIService/Server/Plugin/PluginsHarness.swift index 93237921..a811d568 100644 --- a/Sources/Services/ContainerAPIService/Plugin/PluginsHarness.swift +++ b/Sources/Services/ContainerAPIService/Server/Plugin/PluginsHarness.swift @@ -1,5 +1,5 @@ //===----------------------------------------------------------------------===// -// Copyright © 2025-2026 Apple Inc. and the container project authors. +// Copyright © 2026 Apple Inc. and the container project authors. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/Sources/Services/ContainerAPIService/Plugin/PluginsService.swift b/Sources/Services/ContainerAPIService/Server/Plugin/PluginsService.swift similarity index 98% rename from Sources/Services/ContainerAPIService/Plugin/PluginsService.swift rename to Sources/Services/ContainerAPIService/Server/Plugin/PluginsService.swift index 7f053eb0..726ca56d 100644 --- a/Sources/Services/ContainerAPIService/Plugin/PluginsService.swift +++ b/Sources/Services/ContainerAPIService/Server/Plugin/PluginsService.swift @@ -1,5 +1,5 @@ //===----------------------------------------------------------------------===// -// Copyright © 2025-2026 Apple Inc. and the container project authors. +// Copyright © 2026 Apple Inc. and the container project authors. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/Sources/Services/ContainerAPIService/Volumes/VolumesHarness.swift b/Sources/Services/ContainerAPIService/Server/Volumes/VolumesHarness.swift similarity index 97% rename from Sources/Services/ContainerAPIService/Volumes/VolumesHarness.swift rename to Sources/Services/ContainerAPIService/Server/Volumes/VolumesHarness.swift index b77a4600..a0b2c0e8 100644 --- a/Sources/Services/ContainerAPIService/Volumes/VolumesHarness.swift +++ b/Sources/Services/ContainerAPIService/Server/Volumes/VolumesHarness.swift @@ -1,5 +1,5 @@ //===----------------------------------------------------------------------===// -// Copyright © 2025-2026 Apple Inc. and the container project authors. +// Copyright © 2026 Apple Inc. and the container project authors. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -14,7 +14,7 @@ // limitations under the License. //===----------------------------------------------------------------------===// -import ContainerClient +import ContainerAPIClient import ContainerXPC import ContainerizationError import Foundation diff --git a/Sources/Services/ContainerAPIService/Volumes/VolumesService.swift b/Sources/Services/ContainerAPIService/Server/Volumes/VolumesService.swift similarity index 99% rename from Sources/Services/ContainerAPIService/Volumes/VolumesService.swift rename to Sources/Services/ContainerAPIService/Server/Volumes/VolumesService.swift index 567013a9..b03afb65 100644 --- a/Sources/Services/ContainerAPIService/Volumes/VolumesService.swift +++ b/Sources/Services/ContainerAPIService/Server/Volumes/VolumesService.swift @@ -1,5 +1,5 @@ //===----------------------------------------------------------------------===// -// Copyright © 2025-2026 Apple Inc. and the container project authors. +// Copyright © 2026 Apple Inc. and the container project authors. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -14,8 +14,8 @@ // limitations under the License. //===----------------------------------------------------------------------===// -import ContainerClient import ContainerPersistence +import ContainerResource import Containerization import ContainerizationEXT4 import ContainerizationError diff --git a/Sources/Services/ContainerImagesService/Server/ImageService.swift b/Sources/Services/ContainerImagesService/Server/ImageService.swift index c3020902..e37202df 100644 --- a/Sources/Services/ContainerImagesService/Server/ImageService.swift +++ b/Sources/Services/ContainerImagesService/Server/ImageService.swift @@ -14,8 +14,9 @@ // limitations under the License. //===----------------------------------------------------------------------===// -import ContainerClient +import ContainerAPIClient import ContainerImagesServiceClient +import ContainerResource import Containerization import ContainerizationArchive import ContainerizationError diff --git a/Sources/Services/ContainerImagesService/Server/ImagesServiceHarness.swift b/Sources/Services/ContainerImagesService/Server/ImagesServiceHarness.swift index 4cd13686..ba8ef44a 100644 --- a/Sources/Services/ContainerImagesService/Server/ImagesServiceHarness.swift +++ b/Sources/Services/ContainerImagesService/Server/ImagesServiceHarness.swift @@ -14,8 +14,9 @@ // limitations under the License. //===----------------------------------------------------------------------===// -import ContainerClient +import ContainerAPIClient import ContainerImagesServiceClient +import ContainerResource import ContainerXPC import Containerization import ContainerizationError diff --git a/Sources/Services/ContainerImagesService/Server/SnapshotStore.swift b/Sources/Services/ContainerImagesService/Server/SnapshotStore.swift index 403456fe..fd036945 100644 --- a/Sources/Services/ContainerImagesService/Server/SnapshotStore.swift +++ b/Sources/Services/ContainerImagesService/Server/SnapshotStore.swift @@ -14,8 +14,9 @@ // limitations under the License. //===----------------------------------------------------------------------===// -import ContainerClient +import ContainerAPIClient import ContainerPersistence +import ContainerResource import Containerization import ContainerizationError import ContainerizationExtras diff --git a/Sources/Services/ContainerNetworkService/NetworkClient.swift b/Sources/Services/ContainerNetworkService/Client/NetworkClient.swift similarity index 92% rename from Sources/Services/ContainerNetworkService/NetworkClient.swift rename to Sources/Services/ContainerNetworkService/Client/NetworkClient.swift index d043dfe9..b6195b8e 100644 --- a/Sources/Services/ContainerNetworkService/NetworkClient.swift +++ b/Sources/Services/ContainerNetworkService/Client/NetworkClient.swift @@ -1,5 +1,5 @@ //===----------------------------------------------------------------------===// -// Copyright © 2025-2026 Apple Inc. and the container project authors. +// Copyright © 2026 Apple Inc. and the container project authors. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -14,6 +14,7 @@ // limitations under the License. //===----------------------------------------------------------------------===// +import ContainerResource import ContainerXPC import ContainerizationError import Foundation @@ -96,18 +97,18 @@ extension NetworkClient { } extension XPCMessage { - func additionalData() -> XPCMessage? { + public func additionalData() -> XPCMessage? { guard let additionalData = xpc_dictionary_get_dictionary(self.underlying, NetworkKeys.additionalData.rawValue) else { return nil } return XPCMessage(object: additionalData) } - func allocatorDisabled() throws -> Bool { + public func allocatorDisabled() throws -> Bool { self.bool(key: NetworkKeys.allocatorDisabled.rawValue) } - func attachment() throws -> Attachment { + public func attachment() throws -> Attachment { let data = self.dataNoCopy(key: NetworkKeys.attachment.rawValue) guard let data else { throw ContainerizationError(.invalidArgument, message: "no network attachment snapshot data in message") @@ -115,7 +116,7 @@ extension XPCMessage { return try JSONDecoder().decode(Attachment.self, from: data) } - func hostname() throws -> String { + public func hostname() throws -> String { let hostname = self.string(key: NetworkKeys.hostname.rawValue) guard let hostname else { throw ContainerizationError(.invalidArgument, message: "no hostname data in message") @@ -123,7 +124,7 @@ extension XPCMessage { return hostname } - func state() throws -> NetworkState { + public func state() throws -> NetworkState { let data = self.dataNoCopy(key: NetworkKeys.state.rawValue) guard let data else { throw ContainerizationError(.invalidArgument, message: "no network snapshot data in message") diff --git a/Sources/Services/ContainerNetworkService/NetworkKeys.swift b/Sources/Services/ContainerNetworkService/Client/NetworkKeys.swift similarity index 92% rename from Sources/Services/ContainerNetworkService/NetworkKeys.swift rename to Sources/Services/ContainerNetworkService/Client/NetworkKeys.swift index 5bc33cae..cc7715a3 100644 --- a/Sources/Services/ContainerNetworkService/NetworkKeys.swift +++ b/Sources/Services/ContainerNetworkService/Client/NetworkKeys.swift @@ -1,5 +1,5 @@ //===----------------------------------------------------------------------===// -// Copyright © 2025-2026 Apple Inc. and the container project authors. +// Copyright © 2026 Apple Inc. and the container project authors. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/Sources/Services/ContainerNetworkService/NetworkRoutes.swift b/Sources/Services/ContainerNetworkService/Client/NetworkRoutes.swift similarity index 94% rename from Sources/Services/ContainerNetworkService/NetworkRoutes.swift rename to Sources/Services/ContainerNetworkService/Client/NetworkRoutes.swift index 17ffc5dc..edfbec4a 100644 --- a/Sources/Services/ContainerNetworkService/NetworkRoutes.swift +++ b/Sources/Services/ContainerNetworkService/Client/NetworkRoutes.swift @@ -1,5 +1,5 @@ //===----------------------------------------------------------------------===// -// Copyright © 2025-2026 Apple Inc. and the container project authors. +// Copyright © 2026 Apple Inc. and the container project authors. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/Sources/Services/ContainerNetworkService/AllocationOnlyVmnetNetwork.swift b/Sources/Services/ContainerNetworkService/Server/AllocationOnlyVmnetNetwork.swift similarity index 96% rename from Sources/Services/ContainerNetworkService/AllocationOnlyVmnetNetwork.swift rename to Sources/Services/ContainerNetworkService/Server/AllocationOnlyVmnetNetwork.swift index 3c2d06d4..94ea426d 100644 --- a/Sources/Services/ContainerNetworkService/AllocationOnlyVmnetNetwork.swift +++ b/Sources/Services/ContainerNetworkService/Server/AllocationOnlyVmnetNetwork.swift @@ -1,5 +1,5 @@ //===----------------------------------------------------------------------===// -// Copyright © 2025-2026 Apple Inc. and the container project authors. +// Copyright © 2026 Apple Inc. and the container project authors. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -15,6 +15,7 @@ //===----------------------------------------------------------------------===// import ContainerPersistence +import ContainerResource import ContainerXPC import ContainerizationError import ContainerizationExtras diff --git a/Sources/Services/ContainerNetworkService/AttachmentAllocator.swift b/Sources/Services/ContainerNetworkService/Server/AttachmentAllocator.swift similarity index 96% rename from Sources/Services/ContainerNetworkService/AttachmentAllocator.swift rename to Sources/Services/ContainerNetworkService/Server/AttachmentAllocator.swift index a95e8831..d52438c9 100644 --- a/Sources/Services/ContainerNetworkService/AttachmentAllocator.swift +++ b/Sources/Services/ContainerNetworkService/Server/AttachmentAllocator.swift @@ -1,5 +1,5 @@ //===----------------------------------------------------------------------===// -// Copyright © 2025-2026 Apple Inc. and the container project authors. +// Copyright © 2026 Apple Inc. and the container project authors. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/Sources/Services/ContainerNetworkService/Network.swift b/Sources/Services/ContainerNetworkService/Server/Network.swift similarity index 92% rename from Sources/Services/ContainerNetworkService/Network.swift rename to Sources/Services/ContainerNetworkService/Server/Network.swift index c0566b33..9be7e098 100644 --- a/Sources/Services/ContainerNetworkService/Network.swift +++ b/Sources/Services/ContainerNetworkService/Server/Network.swift @@ -1,5 +1,5 @@ //===----------------------------------------------------------------------===// -// Copyright © 2025-2026 Apple Inc. and the container project authors. +// Copyright © 2026 Apple Inc. and the container project authors. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -14,6 +14,7 @@ // limitations under the License. //===----------------------------------------------------------------------===// +import ContainerResource import ContainerXPC /// Defines common characteristics and operations for a network. diff --git a/Sources/Services/ContainerNetworkService/NetworkService.swift b/Sources/Services/ContainerNetworkService/Server/NetworkService.swift similarity index 97% rename from Sources/Services/ContainerNetworkService/NetworkService.swift rename to Sources/Services/ContainerNetworkService/Server/NetworkService.swift index b889d9c5..057f415c 100644 --- a/Sources/Services/ContainerNetworkService/NetworkService.swift +++ b/Sources/Services/ContainerNetworkService/Server/NetworkService.swift @@ -1,5 +1,5 @@ //===----------------------------------------------------------------------===// -// Copyright © 2025-2026 Apple Inc. and the container project authors. +// Copyright © 2026 Apple Inc. and the container project authors. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -14,6 +14,8 @@ // limitations under the License. //===----------------------------------------------------------------------===// +import ContainerNetworkServiceClient +import ContainerResource import ContainerXPC import ContainerizationError import ContainerizationExtras diff --git a/Sources/Services/ContainerNetworkService/ReservedVmnetNetwork.swift b/Sources/Services/ContainerNetworkService/Server/ReservedVmnetNetwork.swift similarity index 98% rename from Sources/Services/ContainerNetworkService/ReservedVmnetNetwork.swift rename to Sources/Services/ContainerNetworkService/Server/ReservedVmnetNetwork.swift index ab5792e9..ff130bbe 100644 --- a/Sources/Services/ContainerNetworkService/ReservedVmnetNetwork.swift +++ b/Sources/Services/ContainerNetworkService/Server/ReservedVmnetNetwork.swift @@ -1,5 +1,5 @@ //===----------------------------------------------------------------------===// -// Copyright © 2025-2026 Apple Inc. and the container project authors. +// Copyright © 2026 Apple Inc. and the container project authors. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -15,6 +15,7 @@ //===----------------------------------------------------------------------===// import ContainerPersistence +import ContainerResource import ContainerXPC import Containerization import ContainerizationError diff --git a/Sources/Services/ContainerSandboxService/Client/Bundle+Log.swift b/Sources/Services/ContainerSandboxService/Client/Bundle+Log.swift new file mode 100644 index 00000000..72cc27d8 --- /dev/null +++ b/Sources/Services/ContainerSandboxService/Client/Bundle+Log.swift @@ -0,0 +1,25 @@ +//===----------------------------------------------------------------------===// +// Copyright © 2026 Apple Inc. and the container project authors. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +//===----------------------------------------------------------------------===// + +import ContainerResource +import Foundation + +extension ContainerResource.Bundle { + /// The pathname for the workload log file. + public var containerLog: URL { + path.appendingPathComponent("stdio.log") + } +} diff --git a/Sources/ContainerClient/ExitMonitor.swift b/Sources/Services/ContainerSandboxService/Client/ExitMonitor.swift similarity index 98% rename from Sources/ContainerClient/ExitMonitor.swift rename to Sources/Services/ContainerSandboxService/Client/ExitMonitor.swift index 4fa14603..6ac2fa9e 100644 --- a/Sources/ContainerClient/ExitMonitor.swift +++ b/Sources/Services/ContainerSandboxService/Client/ExitMonitor.swift @@ -1,5 +1,5 @@ //===----------------------------------------------------------------------===// -// Copyright © 2025-2026 Apple Inc. and the container project authors. +// Copyright © 2026 Apple Inc. and the container project authors. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/Sources/ContainerClient/SandboxClient.swift b/Sources/Services/ContainerSandboxService/Client/SandboxClient.swift similarity index 85% rename from Sources/ContainerClient/SandboxClient.swift rename to Sources/Services/ContainerSandboxService/Client/SandboxClient.swift index e459a91c..ca61eee4 100644 --- a/Sources/ContainerClient/SandboxClient.swift +++ b/Sources/Services/ContainerSandboxService/Client/SandboxClient.swift @@ -1,5 +1,5 @@ //===----------------------------------------------------------------------===// -// Copyright © 2025-2026 Apple Inc. and the container project authors. +// Copyright © 2026 Apple Inc. and the container project authors. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -14,6 +14,7 @@ // limitations under the License. //===----------------------------------------------------------------------===// +import ContainerResource import ContainerXPC import Containerization import ContainerizationError @@ -60,7 +61,7 @@ public struct SandboxClient: Sendable { cause: error ) } - guard let endpoint = response.endpoint(key: .sandboxServiceEndpoint) else { + guard let endpoint = response.endpoint(key: SandboxKeys.sandboxServiceEndpoint.rawValue) else { throw ContainerizationError( .internalError, message: "failed to get endpoint for sandbox service" @@ -79,7 +80,7 @@ extension SandboxClient { let request = XPCMessage(route: SandboxRoutes.bootstrap.rawValue) for (i, h) in stdio.enumerated() { - let key: XPCKeys = try { + let key: SandboxKeys = try { switch i { case 0: .stdin case 1: .stdout @@ -90,7 +91,7 @@ extension SandboxClient { }() if let h { - request.set(key: key, value: h) + request.set(key: key.rawValue, value: h) } } @@ -122,12 +123,12 @@ extension SandboxClient { public func createProcess(_ id: String, config: ProcessConfiguration, stdio: [FileHandle?]) async throws { let request = XPCMessage(route: SandboxRoutes.createProcess.rawValue) - request.set(key: .id, value: id) + request.set(key: SandboxKeys.id.rawValue, value: id) let data = try JSONEncoder().encode(config) - request.set(key: .processConfig, value: data) + request.set(key: SandboxKeys.processConfig.rawValue, value: data) for (i, h) in stdio.enumerated() { - let key: XPCKeys = try { + let key: SandboxKeys = try { switch i { case 0: .stdin case 1: .stdout @@ -138,7 +139,7 @@ extension SandboxClient { }() if let h { - request.set(key: key, value: h) + request.set(key: key.rawValue, value: h) } } @@ -155,7 +156,7 @@ extension SandboxClient { public func startProcess(_ id: String) async throws { let request = XPCMessage(route: SandboxRoutes.start.rawValue) - request.set(key: .id, value: id) + request.set(key: SandboxKeys.id.rawValue, value: id) do { try await self.client.send(request) } catch { @@ -171,7 +172,7 @@ extension SandboxClient { let request = XPCMessage(route: SandboxRoutes.stop.rawValue) let data = try JSONEncoder().encode(options) - request.set(key: .stopOptions, value: data) + request.set(key: SandboxKeys.stopOptions.rawValue, value: data) let responseTimeout = Duration(.seconds(Int64(options.timeoutInSeconds + 1))) do { @@ -187,8 +188,8 @@ extension SandboxClient { public func kill(_ id: String, signal: Int64) async throws { let request = XPCMessage(route: SandboxRoutes.kill.rawValue) - request.set(key: .id, value: id) - request.set(key: .signal, value: signal) + request.set(key: SandboxKeys.id.rawValue, value: id) + request.set(key: SandboxKeys.signal.rawValue, value: signal) do { try await self.client.send(request) @@ -203,9 +204,9 @@ extension SandboxClient { public func resize(_ id: String, size: Terminal.Size) async throws { let request = XPCMessage(route: SandboxRoutes.resize.rawValue) - request.set(key: .id, value: id) - request.set(key: .width, value: UInt64(size.width)) - request.set(key: .height, value: UInt64(size.height)) + request.set(key: SandboxKeys.id.rawValue, value: id) + request.set(key: SandboxKeys.width.rawValue, value: UInt64(size.width)) + request.set(key: SandboxKeys.height.rawValue, value: UInt64(size.height)) do { try await self.client.send(request) @@ -220,7 +221,7 @@ extension SandboxClient { public func wait(_ id: String) async throws -> ExitStatus { let request = XPCMessage(route: SandboxRoutes.wait.rawValue) - request.set(key: .id, value: id) + request.set(key: SandboxKeys.id.rawValue, value: id) let response: XPCMessage do { @@ -232,14 +233,14 @@ extension SandboxClient { cause: error ) } - let code = response.int64(key: .exitCode) - let date = response.date(key: .exitedAt) + let code = response.int64(key: SandboxKeys.exitCode.rawValue) + let date = response.date(key: SandboxKeys.exitedAt.rawValue) return ExitStatus(exitCode: Int32(code), exitedAt: date) } public func dial(_ port: UInt32) async throws -> FileHandle { let request = XPCMessage(route: SandboxRoutes.dial.rawValue) - request.set(key: .port, value: UInt64(port)) + request.set(key: SandboxKeys.port.rawValue, value: UInt64(port)) let response: XPCMessage do { @@ -251,7 +252,7 @@ extension SandboxClient { cause: error ) } - guard let fh = response.fileHandle(key: .fd) else { + guard let fh = response.fileHandle(key: SandboxKeys.fd.rawValue) else { throw ContainerizationError( .internalError, message: "failed to get fd for vsock port \(port)" @@ -288,7 +289,7 @@ extension SandboxClient { ) } - guard let data = response.dataNoCopy(key: .statistics) else { + guard let data = response.dataNoCopy(key: SandboxKeys.statistics.rawValue) else { throw ContainerizationError( .internalError, message: "no statistics data returned" @@ -301,7 +302,7 @@ extension SandboxClient { extension XPCMessage { public func id() throws -> String { - let id = self.string(key: .id) + let id = self.string(key: SandboxKeys.id.rawValue) guard let id else { throw ContainerizationError( .invalidArgument, @@ -312,7 +313,7 @@ extension XPCMessage { } func sandboxSnapshot() throws -> SandboxSnapshot { - let data = self.dataNoCopy(key: .snapshot) + let data = self.dataNoCopy(key: SandboxKeys.snapshot.rawValue) guard let data else { throw ContainerizationError( .invalidArgument, diff --git a/Sources/Services/ContainerSandboxService/Client/SandboxKeys.swift b/Sources/Services/ContainerSandboxService/Client/SandboxKeys.swift new file mode 100644 index 00000000..2cb5b5ff --- /dev/null +++ b/Sources/Services/ContainerSandboxService/Client/SandboxKeys.swift @@ -0,0 +1,45 @@ +//===----------------------------------------------------------------------===// +// Copyright © 2026 Apple Inc. and the container project authors. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +//===----------------------------------------------------------------------===// + +public enum SandboxKeys: String { + /// ID key. + case id + /// Vsock port number key. + case port + /// Exit code for a process + case exitCode + /// Exit timestamp for a process + case exitedAt + /// FD to a container resource key. + case fd + /// Options for stopping a container key. + case stopOptions + /// An endpoint to talk to a sandbox service. + case sandboxServiceEndpoint + + /// Process request keys. + case signal + case snapshot + case stdin + case stdout + case stderr + case width + case height + case processConfig + + /// Container statistics + case statistics +} diff --git a/Sources/ContainerClient/SandboxRoutes.swift b/Sources/Services/ContainerSandboxService/Client/SandboxRoutes.swift similarity index 96% rename from Sources/ContainerClient/SandboxRoutes.swift rename to Sources/Services/ContainerSandboxService/Client/SandboxRoutes.swift index 61b60ad0..79af080f 100644 --- a/Sources/ContainerClient/SandboxRoutes.swift +++ b/Sources/Services/ContainerSandboxService/Client/SandboxRoutes.swift @@ -1,5 +1,5 @@ //===----------------------------------------------------------------------===// -// Copyright © 2025-2026 Apple Inc. and the container project authors. +// Copyright © 2026 Apple Inc. and the container project authors. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/Sources/ContainerClient/SandboxSnapshot.swift b/Sources/Services/ContainerSandboxService/Client/SandboxSnapshot.swift similarity index 92% rename from Sources/ContainerClient/SandboxSnapshot.swift rename to Sources/Services/ContainerSandboxService/Client/SandboxSnapshot.swift index b48ce5e4..1ba312b8 100644 --- a/Sources/ContainerClient/SandboxSnapshot.swift +++ b/Sources/Services/ContainerSandboxService/Client/SandboxSnapshot.swift @@ -1,5 +1,5 @@ //===----------------------------------------------------------------------===// -// Copyright © 2025-2026 Apple Inc. and the container project authors. +// Copyright © 2026 Apple Inc. and the container project authors. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -14,7 +14,7 @@ // limitations under the License. //===----------------------------------------------------------------------===// -import ContainerNetworkService +import ContainerResource /// A snapshot of a sandbox and its resources. public struct SandboxSnapshot: Codable, Sendable { diff --git a/Sources/Services/ContainerSandboxService/InterfaceStrategy.swift b/Sources/Services/ContainerSandboxService/Server/InterfaceStrategy.swift similarity index 93% rename from Sources/Services/ContainerSandboxService/InterfaceStrategy.swift rename to Sources/Services/ContainerSandboxService/Server/InterfaceStrategy.swift index b564d6f2..1fae0a78 100644 --- a/Sources/Services/ContainerSandboxService/InterfaceStrategy.swift +++ b/Sources/Services/ContainerSandboxService/Server/InterfaceStrategy.swift @@ -1,5 +1,5 @@ //===----------------------------------------------------------------------===// -// Copyright © 2025-2026 Apple Inc. and the container project authors. +// Copyright © 2026 Apple Inc. and the container project authors. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -14,7 +14,7 @@ // limitations under the License. //===----------------------------------------------------------------------===// -import ContainerNetworkService +import ContainerResource import ContainerXPC import Containerization diff --git a/Sources/Services/ContainerSandboxService/SandboxService.swift b/Sources/Services/ContainerSandboxService/Server/SandboxService.swift similarity index 96% rename from Sources/Services/ContainerSandboxService/SandboxService.swift rename to Sources/Services/ContainerSandboxService/Server/SandboxService.swift index fc168036..d5d8a008 100644 --- a/Sources/Services/ContainerSandboxService/SandboxService.swift +++ b/Sources/Services/ContainerSandboxService/Server/SandboxService.swift @@ -1,5 +1,5 @@ //===----------------------------------------------------------------------===// -// Copyright © 2025-2026 Apple Inc. and the container project authors. +// Copyright © 2026 Apple Inc. and the container project authors. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -14,9 +14,10 @@ // limitations under the License. //===----------------------------------------------------------------------===// -import ContainerClient -import ContainerNetworkService +import ContainerNetworkServiceClient import ContainerPersistence +import ContainerResource +import ContainerSandboxServiceClient import ContainerXPC import Containerization import ContainerizationError @@ -94,7 +95,7 @@ public actor SandboxService { self.log.info("`createEndpoint` xpc handler") let endpoint = xpc_endpoint_create(self.connection) let reply = message.reply() - reply.set(key: .sandboxServiceEndpoint, value: endpoint) + reply.set(key: SandboxKeys.sandboxServiceEndpoint.rawValue, value: endpoint) return reply } @@ -115,7 +116,7 @@ public actor SandboxService { ) } - let bundle = ContainerClient.Bundle(path: self.root) + let bundle = ContainerResource.Bundle(path: self.root) try bundle.createLogFile() var config = try bundle.configuration @@ -290,7 +291,7 @@ public actor SandboxService { let reply = message.reply() let data = try JSONEncoder().encode(containerStats) - reply.set(key: .statistics, value: data) + reply.set(key: SandboxKeys.statistics.rawValue, value: data) return reply } } @@ -512,8 +513,8 @@ public actor SandboxService { case .running: let id = try message.id() let ctr = try getContainer() - let width = message.uint64(key: .width) - let height = message.uint64(key: .height) + let width = message.uint64(key: SandboxKeys.width.rawValue) + let height = message.uint64(key: SandboxKeys.height.rawValue) if id != ctr.container.id { guard let processInfo = self.processes[id] else { @@ -563,7 +564,7 @@ public actor SandboxService { @Sendable public func wait(_ message: XPCMessage) async throws -> XPCMessage { self.log.info("`wait` xpc handler") - guard let id = message.string(key: .id) else { + guard let id = message.string(key: SandboxKeys.id.rawValue) else { throw ContainerizationError(.invalidArgument, message: "missing id in wait xpc message") } @@ -592,7 +593,7 @@ public actor SandboxService { } if let cachedCode { let reply = message.reply() - reply.set(key: .exitCode, value: Int64(cachedCode)) + reply.set(key: SandboxKeys.exitCode.rawValue, value: Int64(cachedCode)) return reply } @@ -601,8 +602,8 @@ public actor SandboxService { self.addWaiter(id: id, cont: cc) } let reply = message.reply() - reply.set(key: .exitCode, value: Int64(exitStatus.exitCode)) - reply.set(key: .exitedAt, value: exitStatus.exitedAt) + reply.set(key: SandboxKeys.exitCode.rawValue, value: Int64(exitStatus.exitCode)) + reply.set(key: SandboxKeys.exitedAt.rawValue, value: exitStatus.exitedAt) return reply } @@ -619,7 +620,7 @@ public actor SandboxService { self.log.info("`dial` xpc handler") switch self.state { case .running, .booted: - let port = message.uint64(key: .port) + let port = message.uint64(key: SandboxKeys.port.rawValue) guard port > 0 else { throw ContainerizationError( .invalidArgument, @@ -631,7 +632,7 @@ public actor SandboxService { let fh = try await ctr.container.dialVsock(port: UInt32(port)) let reply = message.reply() - reply.set(key: .fd, value: fh) + reply.set(key: SandboxKeys.fd.rawValue, value: fh) return reply default: throw ContainerizationError( @@ -705,7 +706,10 @@ public actor SandboxService { private func startSocketForwarders(containerIpAddress: String, publishedPorts: [PublishPort]) async throws { var forwarders: [SocketForwarderResult] = [] - try Utility.validPublishPorts(publishedPorts) + guard !publishedPorts.hasOverlaps() else { + throw ContainerizationError(.invalidArgument, message: "host ports for different publish port specs may not overlap") + } + try await withThrowingTaskGroup(of: SocketForwarderResult.self) { group in for publishedPort in publishedPorts { for index in 0.. Int64 { - self.int64(key: .signal) + self.int64(key: SandboxKeys.signal.rawValue) } fileprivate func stopOptions() throws -> ContainerStopOptions { - guard let data = self.dataNoCopy(key: .stopOptions) else { + guard let data = self.dataNoCopy(key: SandboxKeys.stopOptions.rawValue) else { throw ContainerizationError(.invalidArgument, message: "empty StopOptions") } return try JSONDecoder().decode(ContainerStopOptions.self, from: data) @@ -1032,41 +1036,36 @@ extension XPCMessage { fileprivate func setState(_ state: SandboxSnapshot) throws { let data = try JSONEncoder().encode(state) - self.set(key: .snapshot, value: data) + self.set(key: SandboxKeys.snapshot.rawValue, value: data) } fileprivate func stdio() -> [FileHandle?] { var handles = [FileHandle?](repeating: nil, count: 3) - if let stdin = self.fileHandle(key: .stdin) { + if let stdin = self.fileHandle(key: SandboxKeys.stdin.rawValue) { handles[0] = stdin } - if let stdout = self.fileHandle(key: .stdout) { + if let stdout = self.fileHandle(key: SandboxKeys.stdout.rawValue) { handles[1] = stdout } - if let stderr = self.fileHandle(key: .stderr) { + if let stderr = self.fileHandle(key: SandboxKeys.stderr.rawValue) { handles[2] = stderr } return handles } fileprivate func setFileHandle(_ handle: FileHandle) { - self.set(key: .fd, value: handle) + self.set(key: SandboxKeys.fd.rawValue, value: handle) } fileprivate func processConfig() throws -> ProcessConfiguration { - guard let data = self.dataNoCopy(key: .processConfig) else { + guard let data = self.dataNoCopy(key: SandboxKeys.processConfig.rawValue) else { throw ContainerizationError(.invalidArgument, message: "empty process configuration") } return try JSONDecoder().decode(ProcessConfiguration.self, from: data) } } -extension ContainerClient.Bundle { - /// The pathname for the workload log file. - public var containerLog: URL { - path.appendingPathComponent("stdio.log") - } - +extension ContainerResource.Bundle { func createLogFile() throws { // Create the log file we'll write stdio to. // O_TRUNC resolves a log delay issue on restarted containers by force-updating internal state @@ -1243,7 +1242,7 @@ extension SandboxService { let container: LinuxContainer let config: ContainerConfiguration let attachments: [Attachment] - let bundle: ContainerClient.Bundle + let bundle: ContainerResource.Bundle let io: (in: FileHandle?, out: MultiWriter?, err: MultiWriter?) } diff --git a/Tests/CLITests/Subcommands/Containers/TestCLIStats.swift b/Tests/CLITests/Subcommands/Containers/TestCLIStats.swift index e8dda270..08c69a00 100644 --- a/Tests/CLITests/Subcommands/Containers/TestCLIStats.swift +++ b/Tests/CLITests/Subcommands/Containers/TestCLIStats.swift @@ -14,7 +14,7 @@ // limitations under the License. //===----------------------------------------------------------------------===// -import ContainerClient +import ContainerResource import Foundation import Testing diff --git a/Tests/CLITests/Subcommands/Images/TestCLIImagesCommand.swift b/Tests/CLITests/Subcommands/Images/TestCLIImagesCommand.swift index 7187c49a..32993d98 100644 --- a/Tests/CLITests/Subcommands/Images/TestCLIImagesCommand.swift +++ b/Tests/CLITests/Subcommands/Images/TestCLIImagesCommand.swift @@ -14,7 +14,7 @@ // limitations under the License. //===----------------------------------------------------------------------===// -import ContainerClient +import ContainerAPIClient import ContainerizationOCI import Foundation import Testing diff --git a/Tests/CLITests/Subcommands/Networks/TestCLINetwork.swift b/Tests/CLITests/Subcommands/Networks/TestCLINetwork.swift index c447e2c9..894ec931 100644 --- a/Tests/CLITests/Subcommands/Networks/TestCLINetwork.swift +++ b/Tests/CLITests/Subcommands/Networks/TestCLINetwork.swift @@ -15,7 +15,7 @@ //===----------------------------------------------------------------------===// import AsyncHTTPClient -import ContainerClient +import ContainerAPIClient import ContainerizationError import ContainerizationExtras import ContainerizationOS diff --git a/Tests/CLITests/Subcommands/Run/TestCLIRunCommand.swift b/Tests/CLITests/Subcommands/Run/TestCLIRunCommand.swift index ba627369..70f83969 100644 --- a/Tests/CLITests/Subcommands/Run/TestCLIRunCommand.swift +++ b/Tests/CLITests/Subcommands/Run/TestCLIRunCommand.swift @@ -15,7 +15,7 @@ //===----------------------------------------------------------------------===// import AsyncHTTPClient -import ContainerClient +import ContainerAPIClient import ContainerizationExtras import ContainerizationOS import Foundation diff --git a/Tests/CLITests/Subcommands/System/TestKernelSet.swift b/Tests/CLITests/Subcommands/System/TestKernelSet.swift index 1c371c55..c7e90cb6 100644 --- a/Tests/CLITests/Subcommands/System/TestKernelSet.swift +++ b/Tests/CLITests/Subcommands/System/TestKernelSet.swift @@ -14,7 +14,7 @@ // limitations under the License. //===----------------------------------------------------------------------===// -import ContainerClient +import ContainerAPIClient import ContainerPersistence import ContainerizationArchive import Foundation @@ -81,7 +81,7 @@ class TestCLIKernelSet: CLITest { try await withTempDir { tempDir in // manually download the tar file let localTarPath = tempDir.appending(path: remoteTar.lastPathComponent) - try await ContainerClient.FileDownloader.downloadFile(url: remoteTar, to: localTarPath) + try await ContainerAPIClient.FileDownloader.downloadFile(url: remoteTar, to: localTarPath) let extraArgs: [String] = [ "--tar", @@ -113,7 +113,7 @@ class TestCLIKernelSet: CLITest { try await withTempDir { tempDir in // manually download the tar file let localTarPath = tempDir.appending(path: remoteTar.lastPathComponent) - try await ContainerClient.FileDownloader.downloadFile(url: remoteTar, to: localTarPath) + try await ContainerAPIClient.FileDownloader.downloadFile(url: remoteTar, to: localTarPath) // extract just the file we want let targetPath = tempDir.appending(path: URL(string: defaultBinaryPath)!.lastPathComponent) diff --git a/Tests/CLITests/Subcommands/Volumes/TestCLIAnonymousVolumes.swift b/Tests/CLITests/Subcommands/Volumes/TestCLIAnonymousVolumes.swift index 68a3f18a..b16b9739 100644 --- a/Tests/CLITests/Subcommands/Volumes/TestCLIAnonymousVolumes.swift +++ b/Tests/CLITests/Subcommands/Volumes/TestCLIAnonymousVolumes.swift @@ -14,7 +14,7 @@ // limitations under the License. //===----------------------------------------------------------------------===// -import ContainerClient +import ContainerResource import Foundation import Testing diff --git a/Tests/CLITests/Subcommands/Volumes/TestCLIVolumes.swift b/Tests/CLITests/Subcommands/Volumes/TestCLIVolumes.swift index 30be7a8c..c46a594d 100644 --- a/Tests/CLITests/Subcommands/Volumes/TestCLIVolumes.swift +++ b/Tests/CLITests/Subcommands/Volumes/TestCLIVolumes.swift @@ -14,7 +14,7 @@ // limitations under the License. //===----------------------------------------------------------------------===// -import ContainerClient +import ContainerAPIClient import Foundation import Testing diff --git a/Tests/CLITests/TestCLINoParallelCases.swift b/Tests/CLITests/TestCLINoParallelCases.swift index eb6e3091..2d6f5d1a 100644 --- a/Tests/CLITests/TestCLINoParallelCases.swift +++ b/Tests/CLITests/TestCLINoParallelCases.swift @@ -14,7 +14,7 @@ // limitations under the License. //===----------------------------------------------------------------------===// -import ContainerClient +import ContainerAPIClient import ContainerizationOCI import Foundation import Testing diff --git a/Tests/CLITests/Utilities/CLITest.swift b/Tests/CLITests/Utilities/CLITest.swift index 1f2df183..4ccd71a5 100644 --- a/Tests/CLITests/Utilities/CLITest.swift +++ b/Tests/CLITests/Utilities/CLITest.swift @@ -15,8 +15,7 @@ //===----------------------------------------------------------------------===// import AsyncHTTPClient -import ContainerClient -import ContainerNetworkService +import ContainerResource import Containerization import ContainerizationOS import Foundation @@ -305,7 +304,7 @@ class CLITest { struct inspectOutput: Codable { let status: String let configuration: ContainerConfiguration - let networks: [ContainerNetworkService.Attachment] + let networks: [ContainerResource.Attachment] } func getContainerStatus(_ name: String) throws -> String { diff --git a/Tests/ContainerClientTests/DiskUsageTests.swift b/Tests/ContainerAPIClientTests/DiskUsageTests.swift similarity index 97% rename from Tests/ContainerClientTests/DiskUsageTests.swift rename to Tests/ContainerAPIClientTests/DiskUsageTests.swift index 9d9fefaf..793ad9da 100644 --- a/Tests/ContainerClientTests/DiskUsageTests.swift +++ b/Tests/ContainerAPIClientTests/DiskUsageTests.swift @@ -1,5 +1,5 @@ //===----------------------------------------------------------------------===// -// Copyright © 2025-2026 Apple Inc. and the container project authors. +// Copyright © 2026 Apple Inc. and the container project authors. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -17,7 +17,7 @@ import Foundation import Testing -@testable import ContainerClient +@testable import ContainerAPIClient struct DiskUsageTests { diff --git a/Tests/ContainerClientTests/HostDNSResolverTest.swift b/Tests/ContainerAPIClientTests/HostDNSResolverTest.swift similarity index 97% rename from Tests/ContainerClientTests/HostDNSResolverTest.swift rename to Tests/ContainerAPIClientTests/HostDNSResolverTest.swift index d5e57604..7f72d741 100644 --- a/Tests/ContainerClientTests/HostDNSResolverTest.swift +++ b/Tests/ContainerAPIClientTests/HostDNSResolverTest.swift @@ -1,5 +1,5 @@ //===----------------------------------------------------------------------===// -// Copyright © 2025-2026 Apple Inc. and the container project authors. +// Copyright © 2026 Apple Inc. and the container project authors. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -18,7 +18,7 @@ import ContainerizationError import Foundation import Testing -@testable import ContainerClient +@testable import ContainerAPIClient struct HostDNSResolverTest { @Test diff --git a/Tests/ContainerClientTests/Measurement+ParseTests.swift b/Tests/ContainerAPIClientTests/Measurement+ParseTests.swift similarity index 98% rename from Tests/ContainerClientTests/Measurement+ParseTests.swift rename to Tests/ContainerAPIClientTests/Measurement+ParseTests.swift index 9cde2c66..4214a7d9 100644 --- a/Tests/ContainerClientTests/Measurement+ParseTests.swift +++ b/Tests/ContainerAPIClientTests/Measurement+ParseTests.swift @@ -1,5 +1,5 @@ //===----------------------------------------------------------------------===// -// Copyright © 2025-2026 Apple Inc. and the container project authors. +// Copyright © 2026 Apple Inc. and the container project authors. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -17,7 +17,7 @@ import Foundation import Testing -@testable import ContainerClient +@testable import ContainerAPIClient struct MeasurementParseTests { diff --git a/Tests/ContainerClientTests/ParserTest.swift b/Tests/ContainerAPIClientTests/ParserTest.swift similarity index 99% rename from Tests/ContainerClientTests/ParserTest.swift rename to Tests/ContainerAPIClientTests/ParserTest.swift index f54527fd..9c35a6b9 100644 --- a/Tests/ContainerClientTests/ParserTest.swift +++ b/Tests/ContainerAPIClientTests/ParserTest.swift @@ -1,5 +1,5 @@ //===----------------------------------------------------------------------===// -// Copyright © 2025-2026 Apple Inc. and the container project authors. +// Copyright © 2026 Apple Inc. and the container project authors. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -18,7 +18,7 @@ import ContainerizationError import Foundation import Testing -@testable import ContainerClient +@testable import ContainerAPIClient struct ParserTest { @Test diff --git a/Tests/ContainerClientTests/RequestSchemeTests.swift b/Tests/ContainerAPIClientTests/RequestSchemeTests.swift similarity index 96% rename from Tests/ContainerClientTests/RequestSchemeTests.swift rename to Tests/ContainerAPIClientTests/RequestSchemeTests.swift index cfdf3c50..0219335b 100644 --- a/Tests/ContainerClientTests/RequestSchemeTests.swift +++ b/Tests/ContainerAPIClientTests/RequestSchemeTests.swift @@ -1,5 +1,5 @@ //===----------------------------------------------------------------------===// -// Copyright © 2025-2026 Apple Inc. and the container project authors. +// Copyright © 2026 Apple Inc. and the container project authors. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -19,7 +19,7 @@ import ContainerizationError import Foundation import Testing -@testable import ContainerClient +@testable import ContainerAPIClient struct RequestSchemeTests { static let defaultDnsDomain = DefaultsStore.get(key: .defaultDNSDomain) diff --git a/Tests/ContainerClientTests/UtilityTests.swift b/Tests/ContainerAPIClientTests/UtilityTests.swift similarity index 70% rename from Tests/ContainerClientTests/UtilityTests.swift rename to Tests/ContainerAPIClientTests/UtilityTests.swift index 032e4860..e9dfeda0 100644 --- a/Tests/ContainerClientTests/UtilityTests.swift +++ b/Tests/ContainerAPIClientTests/UtilityTests.swift @@ -1,5 +1,5 @@ //===----------------------------------------------------------------------===// -// Copyright © 2025-2026 Apple Inc. and the container project authors. +// Copyright © 2026 Apple Inc. and the container project authors. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -14,11 +14,12 @@ // limitations under the License. //===----------------------------------------------------------------------===// +import ContainerResource import ContainerizationError import Foundation import Testing -@testable import ContainerClient +@testable import ContainerAPIClient struct UtilityTests { @@ -90,44 +91,21 @@ struct UtilityTests { } @Test - func testPublishPortsNonOverlapping() throws { - let result = try Parser.publishPorts([ - "8080-8179:9000-9099/tcp", - "8180-8279:9100-9199/tcp", + func testPublishPortParser() throws { + let ports = try Parser.publishPorts([ + "127.0.0.1:8000:9080", + "8080-8179:9000-9099/udp", ]) - #expect(result.count == 2) - try Utility.validPublishPorts(result) - } - - @Test - func testPublishPortsOverlapping() throws { - let result = try Parser.publishPorts([ - "9000-9100:8080-8180/tcp", - "9100-9199:8180-8279/tcp", - ]) - #expect(result.count == 2) - #expect { - try Utility.validPublishPorts(result) - } throws: { error in - guard let error = error as? ContainerizationError else { - return false - } - return error.description.contains("port specs may not overlap") - } - - } - - @Test - func testPublishPortsSamePortDifferentProtocols() throws { - let result = try Parser.publishPorts([ - "8080:8080/tcp", - "8080:8080/udp", - "1024-2048:1024-2048/tcp", - "1024-2048:1024-2048/udp", - "8081:8081", - "8081:8081/udp", - ]) - #expect(result.count == 6) - try Utility.validPublishPorts(result) + #expect(ports.count == 2) + #expect(ports[0].hostAddress == "127.0.0.1") + #expect(ports[0].hostPort == 8000) + #expect(ports[0].containerPort == 9080) + #expect(ports[0].proto == .tcp) + #expect(ports[0].count == 1) + #expect(ports[1].hostAddress == "0.0.0.0") + #expect(ports[1].hostPort == 8080) + #expect(ports[1].containerPort == 9000) + #expect(ports[1].proto == .udp) + #expect(ports[1].count == 100) } } diff --git a/Tests/ContainerNetworkServiceTests/NetworkConfigurationTest.swift b/Tests/ContainerResourceTests/NetworkConfigurationTest.swift similarity index 97% rename from Tests/ContainerNetworkServiceTests/NetworkConfigurationTest.swift rename to Tests/ContainerResourceTests/NetworkConfigurationTest.swift index f2003435..b0802a02 100644 --- a/Tests/ContainerNetworkServiceTests/NetworkConfigurationTest.swift +++ b/Tests/ContainerResourceTests/NetworkConfigurationTest.swift @@ -1,5 +1,5 @@ //===----------------------------------------------------------------------===// -// Copyright © 2025-2026 Apple Inc. and the container project authors. +// Copyright © 2026 Apple Inc. and the container project authors. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -18,7 +18,7 @@ import ContainerizationError import ContainerizationExtras import Testing -@testable import ContainerNetworkService +@testable import ContainerResource struct NetworkConfigurationTest { @Test func testValidationOkDefaults() throws { diff --git a/Tests/ContainerResourceTests/PublishPortTests.swift b/Tests/ContainerResourceTests/PublishPortTests.swift new file mode 100644 index 00000000..69cc93d9 --- /dev/null +++ b/Tests/ContainerResourceTests/PublishPortTests.swift @@ -0,0 +1,51 @@ +//===----------------------------------------------------------------------===// +// Copyright © 2026 Apple Inc. and the container project authors. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +//===----------------------------------------------------------------------===// + +import Foundation +import Testing + +@testable import ContainerResource + +struct PublshPortTests { + @Test + func testPublishPortsNonOverlapping() throws { + let ports = [ + PublishPort(hostAddress: "0.0.0.0", hostPort: 9000, containerPort: 8080, proto: .tcp, count: 100), + PublishPort(hostAddress: "0.0.0.0", hostPort: 9100, containerPort: 8180, proto: .tcp, count: 100), + ] + #expect(!ports.hasOverlaps()) + } + + @Test + func testPublishPortsOverlapping() throws { + let ports = [ + PublishPort(hostAddress: "0.0.0.0", hostPort: 9000, containerPort: 8080, proto: .tcp, count: 101), + PublishPort(hostAddress: "0.0.0.0", hostPort: 9100, containerPort: 8180, proto: .tcp, count: 100), + ] + #expect(ports.hasOverlaps()) + } + + @Test + func testPublishPortsSamePortDifferentProtocols() throws { + let ports = [ + PublishPort(hostAddress: "0.0.0.0", hostPort: 8080, containerPort: 8080, proto: .tcp, count: 1), + PublishPort(hostAddress: "0.0.0.0", hostPort: 8080, containerPort: 8080, proto: .udp, count: 1), + PublishPort(hostAddress: "0.0.0.0", hostPort: 1024, containerPort: 1024, proto: .tcp, count: 1025), + PublishPort(hostAddress: "0.0.0.0", hostPort: 1024, containerPort: 1024, proto: .udp, count: 1025), + ] + #expect(!ports.hasOverlaps()) + } +} diff --git a/Tests/ContainerClientTests/VolumeValidationTests.swift b/Tests/ContainerResourceTests/VolumeValidationTests.swift similarity index 98% rename from Tests/ContainerClientTests/VolumeValidationTests.swift rename to Tests/ContainerResourceTests/VolumeValidationTests.swift index 30c40ad2..0e86411b 100644 --- a/Tests/ContainerClientTests/VolumeValidationTests.swift +++ b/Tests/ContainerResourceTests/VolumeValidationTests.swift @@ -1,5 +1,5 @@ //===----------------------------------------------------------------------===// -// Copyright © 2025-2026 Apple Inc. and the container project authors. +// Copyright © 2026 Apple Inc. and the container project authors. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -17,7 +17,7 @@ import Foundation import Testing -@testable import ContainerClient +@testable import ContainerResource struct VolumeValidationTests { diff --git a/scripts/make-docs.sh b/scripts/make-docs.sh index ccd47f2f..f134b81b 100755 --- a/scripts/make-docs.sh +++ b/scripts/make-docs.sh @@ -16,10 +16,15 @@ opts=() opts+=("--allow-writing-to-directory" "$1") opts+=("generate-documentation") +opts+=("--target" "ContainerAPIService") +opts+=("--target" "ContainerAPIClient") opts+=("--target" "ContainerSandboxService") +opts+=("--target" "ContainerSandboxServiceClient") opts+=("--target" "ContainerNetworkService") +opts+=("--target" "ContainerNetworkServiceClient") opts+=("--target" "ContainerImagesService") -opts+=("--target" "ContainerClient") +opts+=("--target" "ContainerImagesServiceClient") +opts+=("--target" "ContainerResource") opts+=("--target" "ContainerLog") opts+=("--target" "ContainerPlugin") opts+=("--target" "ContainerXPC")