feat(domain): add Created field to Container struct
Map container creation time from Docker API responses in both ListContainers (unix timestamp) and InspectContainer (RFC3339Nano).
- commit
- 20af81247e87e9dcfb54b07085ce40f060e8ebf1
- author
- brice · · 2026-03-24 08:31 UTC
- committer
- brice · · 2026-03-25 05:38 UTC
- parent
- e46f9aa
- signature
- GPG Verified
CD88F9E564E0102646FB6077A1A07C7C7C3E349D· arch-gpg Verified for the committer email
2 files · +7 -0
M internal/adapters/out/docker/runtime.go +4 -0
| @@ -364,6 +364,7 @@ func (r *Runtime) ListContainers(ctx context.Context, all bool) ([]*domain.Conta | |||
| 364 | 364 | Status: c.State, // Use State (e.g., "running") not Status (e.g., "Up 2 days") | |
| 365 | 365 | Ports: ports, | |
| 366 | 366 | Labels: c.Labels, | |
| 367 | + | Created: time.Unix(c.Created, 0), | |
| 367 | 368 | }) | |
| 368 | 369 | } | |
| 369 | 370 | ||
| @@ -402,6 +403,8 @@ func (r *Runtime) InspectContainer(ctx context.Context, containerID string) (*do | |||
| 402 | 403 | // Get container name (remove leading slash) | |
| 403 | 404 | name := strings.TrimPrefix(resp.Name, "/") | |
| 404 | 405 | ||
| 406 | + | created, _ := time.Parse(time.RFC3339Nano, resp.Created) | |
| 407 | + | ||
| 405 | 408 | return &domain.Container{ | |
| 406 | 409 | ID: resp.ID, | |
| 407 | 410 | Image: resp.Config.Image, | |
| @@ -411,6 +414,7 @@ func (r *Runtime) InspectContainer(ctx context.Context, containerID string) (*do | |||
| 411 | 414 | ExitCode: resp.State.ExitCode, | |
| 412 | 415 | Ports: ports, | |
| 413 | 416 | Labels: resp.Config.Labels, | |
| 417 | + | Created: created, | |
| 414 | 418 | }, nil | |
| 415 | 419 | } | |
| 416 | 420 | ||
| @@ -364,6 +364,7 @@ func (r *Runtime) ListContainers(ctx context.Context, all bool) ([]*domain.Conta | |||||
| 364 | Status: c.State, // Use State (e.g., "running") not Status (e.g., "Up 2 days") | 364 | Status: c.State, // Use State (e.g., "running") not Status (e.g., "Up 2 days") | ||
| 365 | Ports: ports, | 365 | Ports: ports, | ||
| 366 | Labels: c.Labels, | 366 | Labels: c.Labels, | ||
| 367 | + | Created: time.Unix(c.Created, 0), | |||
| 367 | }) | 368 | }) | ||
| 368 | } | 369 | } | ||
| 369 | 370 | ||||
| @@ -402,6 +403,8 @@ func (r *Runtime) InspectContainer(ctx context.Context, containerID string) (*do | |||||
| 402 | // Get container name (remove leading slash) | 403 | // Get container name (remove leading slash) | ||
| 403 | name := strings.TrimPrefix(resp.Name, "/") | 404 | name := strings.TrimPrefix(resp.Name, "/") | ||
| 404 | 405 | ||||
| 406 | + | created, _ := time.Parse(time.RFC3339Nano, resp.Created) | |||
| 407 | + | ||||
| 405 | return &domain.Container{ | 408 | return &domain.Container{ | ||
| 406 | ID: resp.ID, | 409 | ID: resp.ID, | ||
| 407 | Image: resp.Config.Image, | 410 | Image: resp.Config.Image, | ||
| @@ -411,6 +414,7 @@ func (r *Runtime) InspectContainer(ctx context.Context, containerID string) (*do | |||||
| 411 | ExitCode: resp.State.ExitCode, | 414 | ExitCode: resp.State.ExitCode, | ||
| 412 | Ports: ports, | 415 | Ports: ports, | ||
| 413 | Labels: resp.Config.Labels, | 416 | Labels: resp.Config.Labels, | ||
| 417 | + | Created: created, | |||
| 414 | }, nil | 418 | }, nil | ||
| 415 | } | 419 | } | ||
| 416 | 420 | ||||
M internal/domain/container.go +3 -0
| @@ -2,6 +2,8 @@ | |||
| 2 | 2 | // These types are used throughout the application and have no tags or framework dependencies. | |
| 3 | 3 | package domain | |
| 4 | 4 | ||
| 5 | + | import "time" | |
| 6 | + | ||
| 5 | 7 | // Container represents a running container in the system. | |
| 6 | 8 | type Container struct { | |
| 7 | 9 | ID string | |
| @@ -12,6 +14,7 @@ type Container struct { | |||
| 12 | 14 | ExitCode int | |
| 13 | 15 | Ports []int | |
| 14 | 16 | Labels map[string]string | |
| 17 | + | Created time.Time | |
| 15 | 18 | } | |
| 16 | 19 | ||
| 17 | 20 | // NetworkInfo represents network configuration and state. | |
| @@ -2,6 +2,8 @@ | |||||
| 2 | // These types are used throughout the application and have no tags or framework dependencies. | 2 | // These types are used throughout the application and have no tags or framework dependencies. | ||
| 3 | package domain | 3 | package domain | ||
| 4 | 4 | ||||
| 5 | + | import "time" | |||
| 6 | + | ||||
| 5 | // Container represents a running container in the system. | 7 | // Container represents a running container in the system. | ||
| 6 | type Container struct { | 8 | type Container struct { | ||
| 7 | ID string | 9 | ID string | ||
| @@ -12,6 +14,7 @@ type Container struct { | |||||
| 12 | ExitCode int | 14 | ExitCode int | ||
| 13 | Ports []int | 15 | Ports []int | ||
| 14 | Labels map[string]string | 16 | Labels map[string]string | ||
| 17 | + | Created time.Time | |||
| 15 | } | 18 | } | ||
| 16 | 19 | ||||
| 17 | // NetworkInfo represents network configuration and state. | 20 | // NetworkInfo represents network configuration and state. | ||