[container]: add startedDate field (#1018)

- Closes #302.
- Closes #336 (obsoletes this PR).
This commit is contained in:
Saehej Kang
2026-01-07 16:53:33 -08:00
committed by GitHub
parent db8932ab0f
commit 9d06475aaf
4 changed files with 21 additions and 4 deletions
@@ -43,16 +43,21 @@ public struct ClientContainer: Sendable, Codable {
/// Network allocated to the container.
public let networks: [Attachment]
/// When the container was started.
public let startedDate: Date?
package init(configuration: ContainerConfiguration) {
self.configuration = configuration
self.status = .stopped
self.networks = []
self.startedDate = nil
}
init(snapshot: ContainerSnapshot) {
self.configuration = snapshot.configuration
self.status = snapshot.status
self.networks = snapshot.networks
self.startedDate = snapshot.startedDate
}
}
@@ -87,7 +87,8 @@ public actor ContainersService {
snapshot: .init(
configuration: config,
status: .stopped,
networks: []
networks: [],
startedDate: nil
)
)
results[config.id] = state
@@ -249,7 +250,8 @@ public actor ContainersService {
let snapshot = ContainerSnapshot(
configuration: configuration,
status: .stopped,
networks: []
networks: [],
startedDate: nil
)
await self.setContainerState(configuration.id, ContainerState(snapshot: snapshot), context: context)
} catch {
@@ -371,6 +373,7 @@ public actor ContainersService {
let sandboxSnapshot = try await client.state()
state.snapshot.status = .running
state.snapshot.networks = sandboxSnapshot.networks
state.snapshot.startedDate = Date()
await self.setContainerState(id, state, context: context)
}
}