Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
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
16 changes: 9 additions & 7 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 @@ -203,14 +204,14 @@ public struct ComposeUp: AsyncParsableCommand, @unchecked Sendable {
let containerName = "\(projectName)-\(serviceName)"

let deadline = Date().addingTimeInterval(timeout)
let client = ContainerClient()

while Date() < deadline {
let container = try? await ClientContainer.get(id: containerName)
try await Task.sleep(nanoseconds: UInt64(interval * 1_000_000_000))
let container = try? await client.get(id: containerName)
if container?.status == .running {
return
}

try await Task.sleep(nanoseconds: UInt64(interval * 1_000_000_000))
}

throw NSError(
Expand All @@ -226,16 +227,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
Loading
Loading