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