mirror of
https://github.com/apple/container.git
synced 2026-09-27 09:26:46 -04:00
[container]: add startedDate field (#1018)
- Closes #302. - Closes #336 (obsoletes this PR).
This commit is contained in:
@@ -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)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user