Skip to content

Commit 84ffc64

Browse files
committed
api/types: move ContainerState to api/types/image
This moves the `ContainerState` type to the container package, renames it to `State`, and deprecates the old location. Signed-off-by: Sebastiaan van Stijn <[email protected]>
1 parent 7053007 commit 84ffc64

4 files changed

Lines changed: 24 additions & 19 deletions

File tree

api/types/container/container.go

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,3 +88,20 @@ type MountPoint struct {
8888
// This field is not used on Windows.
8989
Propagation mount.Propagation
9090
}
91+
92+
// State stores container's running state
93+
// it's part of ContainerJSONBase and will return by "inspect" command
94+
type State struct {
95+
Status string // String representation of the container state. Can be one of "created", "running", "paused", "restarting", "removing", "exited", or "dead"
96+
Running bool
97+
Paused bool
98+
Restarting bool
99+
OOMKilled bool
100+
Dead bool
101+
Pid int
102+
ExitCode int
103+
Error string
104+
StartedAt string
105+
FinishedAt string
106+
Health *Health `json:",omitempty"`
107+
}

api/types/types.go

Lines changed: 1 addition & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -87,31 +87,14 @@ type Version struct {
8787
BuildTime string `json:",omitempty"`
8888
}
8989

90-
// ContainerState stores container's running state
91-
// it's part of ContainerJSONBase and will return by "inspect" command
92-
type ContainerState struct {
93-
Status string // String representation of the container state. Can be one of "created", "running", "paused", "restarting", "removing", "exited", or "dead"
94-
Running bool
95-
Paused bool
96-
Restarting bool
97-
OOMKilled bool
98-
Dead bool
99-
Pid int
100-
ExitCode int
101-
Error string
102-
StartedAt string
103-
FinishedAt string
104-
Health *container.Health `json:",omitempty"`
105-
}
106-
10790
// ContainerJSONBase contains response of Engine API:
10891
// GET "/containers/{name:.*}/json"
10992
type ContainerJSONBase struct {
11093
ID string `json:"Id"`
11194
Created string
11295
Path string
11396
Args []string
114-
State *ContainerState
97+
State *container.State
11598
Image string
11699
ResolvConfPath string
117100
HostnamePath string

api/types/types_deprecated.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -210,6 +210,11 @@ type ContainerNode struct {
210210
Labels map[string]string
211211
}
212212

213+
// ContainerState stores container's running state
214+
//
215+
// Deprecated: use [container.State].
216+
type ContainerState = container.State
217+
213218
// NetworkSettings exposes the network settings in the api.
214219
//
215220
// Deprecated: use [container.NetworkSettings].

daemon/inspect.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ func (daemon *Daemon) getInspectData(daemonCfg *config.Config, container *contai
146146
}
147147
}
148148

149-
containerState := &types.ContainerState{
149+
containerState := &containertypes.State{
150150
Status: container.State.StateString(),
151151
Running: container.State.Running,
152152
Paused: container.State.Paused,

0 commit comments

Comments
 (0)