container.go RawHistoryFolder
1// Package domain contains pure business types without external dependencies.
2// These types are used throughout the application and have no tags or framework dependencies.
3package domain
4
5import "time"
6
7// Container represents a running container in the system.
8type Container struct {
9 ID string
10 Image string
11 ImageID string // Docker image ID (sha256 digest) used to detect redundant deploys
12 Name string
13 Status string
14 ExitCode int
15 Ports []int
16 Labels map[string]string
17 VolumeMounts []ContainerVolumeMount
18 Created time.Time
19 // StartedAt is the start timestamp of the current execution. Zero
20 // when the container never started or the runtime reports none.
21 // Readiness scoping uses it so log markers from a previous
22 // execution of the same container ID cannot satisfy a probe.
23 StartedAt time.Time
24}
25
26// ContainerVolumeMount describes a mounted volume-like resource on a container.
27type ContainerVolumeMount struct {
28 Name string
29 Type string
30 Source string
31 Destination string
32 ReadOnly bool
33}
34
35// NetworkInfo represents network configuration and state.
36type NetworkInfo struct {
37 ID string
38 Name string
39 Driver string
40 Containers []string
41 Labels map[string]string
42}
43
44// NetworkConfig holds options for creating a container network.
45type NetworkConfig struct {
46 Driver string
47 Internal bool
48 Labels map[string]string
49}
50
51// Attachment represents an attached service container.
52type Attachment struct {
53 Name string
54 Image string
55 ContainerID string
56 Status string
57 Network string
58 Ports []int
59}
60
61// RouteInfo combines route configuration with runtime state.
62type RouteInfo struct {
63 Domain string
64 Image string
65 ContainerID string
66 ContainerStatus string
67 Network string
68 Attachments []Attachment
69}
70
71// ContainerPortPublish describes an explicit host port binding for a container port.
72type ContainerPortPublish struct {
73 HostIP string
74 HostPort int
75 ContainerPort int
76 Protocol NetworkProtocol
77}
78
79// ContainerBackendPort identifies one protocol-specific container port
80// for grouped backend-bind inspection.
81type ContainerBackendPort struct {
82 ContainerPort int
83 Protocol NetworkProtocol
84}
85
86// ContainerBackendBind is an observed protocol-specific host binding.
87type ContainerBackendBind struct {
88 ContainerPort int
89 HostPort int
90 Protocol NetworkProtocol
91}
92
93// ContainerBind is one ephemeral host bind mount for a container. Source is a
94// resolved host path produced by administrative policy: it is never persisted
95// and never logged by the runtime adapter. Destination is the container path.
96type ContainerBind struct {
97 Name string
98 Source string
99 Destination string
100 ReadOnly bool
101}
102
103// ContainerConfig holds configuration for creating a container.
104type ContainerConfig struct {
105 Image string
106 Name string
107 Env []string
108 Ports []int
109 PortPublishes []ContainerPortPublish
110 Labels map[string]string
111 WorkingDir string
112 Cmd []string
113 Entrypoint []string
114 AutoRemove bool
115 RestartPolicy string
116 Volumes map[string]string // map[containerPath]volumeName
117 ReadOnlyVolumes map[string]string // containerPath -> volumeName (mounted read-only)
118 Binds []ContainerBind // ephemeral resolved host binds, keyed by destination
119 // CDIDevices holds explicit CDI device IDs resolved from administrative
120 // device policy at activation time. It is ephemeral like Binds: never
121 // persisted, never logged by the runtime adapter.
122 CDIDevices []string // ephemeral resolved CDI IDs, encoded as one native CDI DeviceRequest
123 NetworkMode string // Network to join
124 Hostname string // Container hostname for DNS
125 Aliases []string // Additional network aliases
126 MemoryLimit int64 // Memory limit in bytes (0 = no limit)
127 NanoCPUs int64 // CPU quota in nanoseconds (1e9 = 1 core, 0 = no limit)
128 PidsLimit int64 // Max number of PIDs (0 = no limit)
129 ReadOnlyRootFS bool // Mount container root filesystem read-only
130 User string // User to run as
131 CapDrop []string // Linux capabilities to drop; nil uses runtime compat defaults
132 CapAdd []string // Linux capabilities to add; nil uses runtime compat defaults
133}
134
135// ContainerStatus represents the current state of a container.
136type ContainerStatus string
137
138const (
139 ContainerStatusRunning ContainerStatus = "running"
140 ContainerStatusStopped ContainerStatus = "stopped"
141 ContainerStatusCreated ContainerStatus = "created"
142 ContainerStatusExited ContainerStatus = "exited"
143 ContainerStatusPaused ContainerStatus = "paused"
144 ContainerStatusUnknown ContainerStatus = "unknown"
145)
146
147const (
148 RestartPolicyAlways = "always"
149)