Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
update to container 0.10 and switch to ContainerClient
ClientContainer has been changed to ContainerClient. See PR: apple/container#1139
  • Loading branch information
Mcrich23 committed Mar 10, 2026
commit 4b6c5b93a47939dd13526ebd81274ba523aaba47
63 changes: 36 additions & 27 deletions Package.resolved

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Sources/Container-Compose/Application.swift
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import ArgumentParser

public struct Main: AsyncParsableCommand {
private static let commandName: String = "container-compose"
private static let version: String = "0.9.0"
private static let version: String = "0.10.0"
public static var versionString: String {
"\(commandName) version \(version)"
}
Expand Down
9 changes: 6 additions & 3 deletions Sources/Container-Compose/Commands/ComposeDown.swift
Original file line number Diff line number Diff line change
Expand Up @@ -119,20 +119,23 @@ public struct ComposeDown: AsyncParsableCommand {
}

print("Stopping container: \(containerName)")
guard let container = try? await ClientContainer.get(id: containerName) else {

let client = ContainerClient()

guard let container = try? await client.get(id: containerName) else {
print("Warning: Container '\(containerName)' not found, skipping.")
continue
}

do {
try await container.stop()
try await client.stop(id: container.id)
print("Successfully stopped container: \(containerName)")
} catch {
print("Error Stopping Container: \(error)")
}
if remove {
do {
try await container.delete()
try await client.delete(id: container.id)
print("Successfully removed container: \(containerName)")
} catch {
print("Error Removing Container: \(error)")
Expand Down
13 changes: 8 additions & 5 deletions Sources/Container-Compose/Commands/ComposeUp.swift
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,8 @@ public struct ComposeUp: AsyncParsableCommand, @unchecked Sendable {

let containerName = "\(projectName)-\(serviceName)"

let container = try await ClientContainer.get(id: containerName)
let client = ContainerClient()
let container = try await client.get(id: containerName)
let ip = container.networks.compactMap { $0.ipv4Gateway.description }.first

return ip
Expand All @@ -205,7 +206,8 @@ public struct ComposeUp: AsyncParsableCommand, @unchecked Sendable {
let deadline = Date().addingTimeInterval(timeout)

while Date() < deadline {
let container = try? await ClientContainer.get(id: containerName)
let client = ContainerClient()
let container = try? await client.get(id: containerName)
if container?.status == .running {
return
}
Expand All @@ -226,16 +228,17 @@ public struct ComposeUp: AsyncParsableCommand, @unchecked Sendable {

for container in containers {
print("Stopping container: \(container)")
guard let container = try? await ClientContainer.get(id: container) else { continue }
let client = ContainerClient()
guard let container = try? await client.get(id: container) else { continue }

do {
try await container.stop()
try await client.stop(id: container.id)
} catch {
print("Error Stopping Container: \(error)")
}
if remove {
do {
try await container.delete()
try await client.delete(id: container.id)
} catch {
print("Error Removing Container: \(error)")
}
Expand Down
8 changes: 4 additions & 4 deletions Tests/Container-Compose-DynamicTests/ComposeDownTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ struct ComposeDownTests {
])
try await composeUp.run()

var containers = try await ClientContainer.list()
var containers = try await ContainerClient().list()
.filter({
$0.configuration.id.contains(project.name)
})
Expand All @@ -49,7 +49,7 @@ struct ComposeDownTests {
var composeDown = try ComposeDown.parse(["--cwd", project.base.path(percentEncoded: false)])
try await composeDown.run()

containers = try await ClientContainer.list()
containers = try await ContainerClient().list()
.filter({
$0.configuration.id.contains(project.name)
})
Expand All @@ -75,7 +75,7 @@ struct ComposeDownTests {
])
try await composeUp.run()

var containers = try await ClientContainer.list()
var containers = try await ContainerClient().list()
.filter({
$0.configuration.id.contains(containerName)
})
Expand All @@ -91,7 +91,7 @@ struct ComposeDownTests {
var composeDown = try ComposeDown.parse(["--cwd", project.base.path(percentEncoded: false)])
try await composeDown.run()

containers = try await ClientContainer.list()
containers = try await ContainerClient().list()
.filter({
$0.configuration.id.contains(containerName)
})
Expand Down
16 changes: 9 additions & 7 deletions Tests/Container-Compose-DynamicTests/ComposeUpTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,9 @@ struct ComposeUpTests {
try await composeUp.run()

// Get these containers
let containers = try await ClientContainer.list()
let client = ContainerClient()

let containers = try await client.list()
.filter({
$0.configuration.id.contains(tempLocation.deletingLastPathComponent().lastPathComponent)
})
Expand Down Expand Up @@ -96,7 +98,7 @@ struct ComposeUpTests {
// try await composeUp.run()
//
// // Get the containers created by this compose file
// let containers = try await ClientContainer.list()
// let containers = try await ContainerClient().list()
// .filter({
// $0.configuration.id.contains(folderName)
// })
Expand Down Expand Up @@ -175,7 +177,7 @@ struct ComposeUpTests {
// try await composeUp.run()
//
// // Get the containers created by this compose file
// let containers = try await ClientContainer.list()
// let containers = try await ContainerClient().list()
// .filter({
// $0.configuration.id.contains(folderName)
// })
Expand All @@ -195,7 +197,7 @@ struct ComposeUpTests {
try await composeUp.run()

// Get the containers created by this compose file
let containers = try await ClientContainer.list()
let containers = try await ContainerClient().list()
.filter {
$0.configuration.id.contains(folderName)
}
Expand Down Expand Up @@ -257,7 +259,7 @@ struct ComposeUpTests {
var composeUp = try ComposeUp.parse(["-d", "--cwd", tempLocation.deletingLastPathComponent().path(percentEncoded: false)])
try await composeUp.run()

let containers = try await ClientContainer.list()
let containers = try await ContainerClient().list()
.filter { $0.configuration.id.contains(folderName) }

guard let appContainer = containers.first(where: { $0.configuration.id == "\(folderName)-app" }) else {
Expand All @@ -284,7 +286,7 @@ struct ComposeUpTests {
var composeUp = try ComposeUp.parse(["-d", "--cwd", project.base.path(percentEncoded: false)])
try await composeUp.run()

var containers = try await ClientContainer.list()
var containers = try await ContainerClient().list()
.filter({
$0.configuration.id.contains(project.name)
})
Expand All @@ -299,7 +301,7 @@ struct ComposeUpTests {
var composeDown = try ComposeDown.parse(["--cwd", project.base.path(percentEncoded: false)])
try await composeDown.run()

containers = try await ClientContainer.list()
containers = try await ContainerClient().list()
.filter({
$0.configuration.id.contains(project.name)
})
Expand Down