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 // Env is the container's KEY=value environment as created. It may hold
25 // secret values: compare it in memory only, never persist or log it.
26 Env []string
27}
28
29// ContainerVolumeMount describes a mounted volume-like resource on a container.
30type ContainerVolumeMount struct {
31 Name string
32 Type string
33 Source string
34 Destination string
35 ReadOnly bool
36}
37
38// NetworkInfo represents network configuration and state.
39type NetworkInfo struct {
40 ID string
41 Name string
42 Driver string
43 Containers []string
44 Labels map[string]string
45}
46
47// NetworkConfig holds options for creating a container network.
48type NetworkConfig struct {
49 Driver string
50 Internal bool
51 Labels map[string]string
52}
53
54// Attachment represents an attached service container.
55type Attachment struct {
56 Name string
57 Image string
58 ContainerID string
59 Status string
60 Network string
61 Ports []int
62}
63
64// RouteInfo combines route configuration with runtime state.
65type RouteInfo struct {
66 Domain string
67 Image string
68 ContainerID string
69 ContainerStatus string
70 Network string
71 Attachments []Attachment
72}
73
74// ContainerPortPublish describes an explicit host port binding for a container port.
75type ContainerPortPublish struct {
76 HostIP string
77 HostPort int
78 ContainerPort int
79 Protocol NetworkProtocol
80}
81
82// ContainerBackendPort identifies one protocol-specific container port
83// for grouped backend-bind inspection.
84type ContainerBackendPort struct {
85 ContainerPort int
86 Protocol NetworkProtocol
87}
88
89// ContainerBackendBind is an observed protocol-specific host binding.
90type ContainerBackendBind struct {
91 ContainerPort int
92 HostPort int
93 Protocol NetworkProtocol
94}
95
96// ContainerBind is one ephemeral host bind mount for a container. Source is a
97// resolved host path produced by administrative policy: it is never persisted
98// and never logged by the runtime adapter. Destination is the container path.
99type ContainerBind struct {
100 Name string
101 Source string
102 Destination string
103 ReadOnly bool
104}
105
106// ContainerConfig holds configuration for creating a container.
107type ContainerConfig struct {
108 Image string
109 Name string
110 Env []string
111 Ports []int
112 PortPublishes []ContainerPortPublish
113 Labels map[string]string
114 WorkingDir string
115 Cmd []string
116 Entrypoint []string
117 AutoRemove bool
118 RestartPolicy string
119 Volumes map[string]string // map[containerPath]volumeName
120 ReadOnlyVolumes map[string]string // containerPath -> volumeName (mounted read-only)
121 Binds []ContainerBind // ephemeral resolved host binds, keyed by destination
122 // CDIDevices holds explicit CDI device IDs resolved from administrative
123 // device policy at activation time. It is ephemeral like Binds: never
124 // persisted, never logged by the runtime adapter.
125 CDIDevices []string // ephemeral resolved CDI IDs, encoded as one native CDI DeviceRequest
126 NetworkMode string // Network to join
127 Hostname string // Container hostname for DNS
128 Aliases []string // Additional network aliases
129 MemoryLimit int64 // Memory limit in bytes (0 = no limit)
130 NanoCPUs int64 // CPU quota in nanoseconds (1e9 = 1 core, 0 = no limit)
131 PidsLimit int64 // Max number of PIDs (0 = no limit)
132 ReadOnlyRootFS bool // Mount container root filesystem read-only
133 User string // User to run as
134 CapDrop []string // Linux capabilities to drop; nil uses runtime compat defaults
135 CapAdd []string // Linux capabilities to add; nil uses runtime compat defaults
136}
137
138// ContainerStatus represents the current state of a container.
139type ContainerStatus string
140
141const (
142 ContainerStatusRunning ContainerStatus = "running"
143 ContainerStatusStopped ContainerStatus = "stopped"
144 ContainerStatusCreated ContainerStatus = "created"
145 ContainerStatusExited ContainerStatus = "exited"
146 ContainerStatusPaused ContainerStatus = "paused"
147 ContainerStatusUnknown ContainerStatus = "unknown"
148)
149
150const (
151 RestartPolicyAlways = "always"
152)