mirror of
https://github.com/moby/moby.git
synced 2026-01-11 18:51:37 +00:00
daemon/container: remove NewState() constructor
This constructor did not do anything other than creating an empty struct for an exported type. While we should look at initializing with a proper state, we currently do not, so let's not pretend we do some magic here, and leave it for a future exercise to create a proper constructor if we need one. Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
committed by
Rob Murray
parent
d06f0d008d
commit
ee4b7a8374
@@ -143,7 +143,7 @@ type localLogCacheMeta struct {
|
|||||||
func NewBaseContainer(id, root string) *Container {
|
func NewBaseContainer(id, root string) *Container {
|
||||||
return &Container{
|
return &Container{
|
||||||
ID: id,
|
ID: id,
|
||||||
State: NewState(),
|
State: &State{},
|
||||||
ExecCommands: NewExecStore(),
|
ExecCommands: NewExecStore(),
|
||||||
Root: root,
|
Root: root,
|
||||||
MountPoints: make(map[string]*volumemounts.MountPoint),
|
MountPoints: make(map[string]*volumemounts.MountPoint),
|
||||||
|
|||||||
@@ -78,11 +78,6 @@ func (s StateStatus) Err() error {
|
|||||||
return s.err
|
return s.err
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewState creates a default state object.
|
|
||||||
func NewState() *State {
|
|
||||||
return &State{}
|
|
||||||
}
|
|
||||||
|
|
||||||
// String returns a human-readable description of the state
|
// String returns a human-readable description of the state
|
||||||
func (s *State) String() string {
|
func (s *State) String() string {
|
||||||
if s.Running {
|
if s.Running {
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ type mockTask struct {
|
|||||||
func (t *mockTask) Pid() uint32 { return t.pid }
|
func (t *mockTask) Pid() uint32 { return t.pid }
|
||||||
|
|
||||||
func TestStateRunStop(t *testing.T) {
|
func TestStateRunStop(t *testing.T) {
|
||||||
s := NewState()
|
s := &State{}
|
||||||
|
|
||||||
// Begin another wait with WaitConditionRemoved. It should complete
|
// Begin another wait with WaitConditionRemoved. It should complete
|
||||||
// within 200 milliseconds.
|
// within 200 milliseconds.
|
||||||
@@ -110,7 +110,7 @@ func TestStateRunStop(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestStateTimeoutWait(t *testing.T) {
|
func TestStateTimeoutWait(t *testing.T) {
|
||||||
s := NewState()
|
s := &State{}
|
||||||
|
|
||||||
s.Lock()
|
s.Lock()
|
||||||
s.SetRunning(nil, nil, time.Now())
|
s.SetRunning(nil, nil, time.Now())
|
||||||
@@ -159,7 +159,7 @@ func TestStateTimeoutWait(t *testing.T) {
|
|||||||
|
|
||||||
// Related issue: #39352
|
// Related issue: #39352
|
||||||
func TestCorrectStateWaitResultAfterRestart(t *testing.T) {
|
func TestCorrectStateWaitResultAfterRestart(t *testing.T) {
|
||||||
s := NewState()
|
s := &State{}
|
||||||
|
|
||||||
s.Lock()
|
s.Lock()
|
||||||
s.SetRunning(nil, nil, time.Now())
|
s.SetRunning(nil, nil, time.Now())
|
||||||
|
|||||||
@@ -52,8 +52,7 @@ func TestContainerDelete(t *testing.T) {
|
|||||||
doc: "restarting container",
|
doc: "restarting container",
|
||||||
errMsg: "container is restarting: stop the container before removing or force remove",
|
errMsg: "container is restarting: stop the container before removing or force remove",
|
||||||
initContainer: func() *container.Container {
|
initContainer: func() *container.Container {
|
||||||
c := newContainerWithState(container.NewState())
|
c := newContainerWithState(&container.State{Running: true, StartedAt: time.Now()})
|
||||||
c.State.SetRunning(nil, nil, time.Now())
|
|
||||||
c.State.SetRestarting(&container.ExitStatus{})
|
c.State.SetRestarting(&container.ExitStatus{})
|
||||||
return c
|
return c
|
||||||
},
|
},
|
||||||
@@ -82,7 +81,7 @@ func TestContainerDelete(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestContainerDoubleDelete(t *testing.T) {
|
func TestContainerDoubleDelete(t *testing.T) {
|
||||||
c := newContainerWithState(container.NewState())
|
c := newContainerWithState(&container.State{})
|
||||||
|
|
||||||
// Mark the container as having a delete in progress
|
// Mark the container as having a delete in progress
|
||||||
c.State.SetRemovalInProgress()
|
c.State.SetRemovalInProgress()
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ func TestGetInspectData(t *testing.T) {
|
|||||||
c := &container.Container{
|
c := &container.Container{
|
||||||
ID: "inspect-me",
|
ID: "inspect-me",
|
||||||
HostConfig: &containertypes.HostConfig{},
|
HostConfig: &containertypes.HostConfig{},
|
||||||
State: container.NewState(),
|
State: &container.State{},
|
||||||
ExecCommands: container.NewExecStore(),
|
ExecCommands: container.NewExecStore(),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1029,7 +1029,7 @@ func (d *Daemon) TamperWithContainerConfig(t testing.TB, containerID string, tam
|
|||||||
assert.NilError(t, json.Unmarshal(configBytes, &c))
|
assert.NilError(t, json.Unmarshal(configBytes, &c))
|
||||||
assert.NilError(t, json.Unmarshal(hostConfigBytes, &c.HostConfig))
|
assert.NilError(t, json.Unmarshal(hostConfigBytes, &c.HostConfig))
|
||||||
|
|
||||||
c.State = container.NewState()
|
c.State = &container.State{}
|
||||||
tamper(&c)
|
tamper(&c)
|
||||||
|
|
||||||
configBytes, err = json.Marshal(&c)
|
configBytes, err = json.Marshal(&c)
|
||||||
|
|||||||
Reference in New Issue
Block a user