Skip to content
This repository has been archived by the owner on May 12, 2021. It is now read-only.

Commit

Permalink
Merge pull request #1507 from bergwolf/state
Browse files Browse the repository at this point in the history
split sandbox/container state
  • Loading branch information
Julio Montes authored Apr 11, 2019
2 parents 6d81e44 + c414599 commit dd5c6aa
Show file tree
Hide file tree
Showing 25 changed files with 176 additions and 169 deletions.
4 changes: 2 additions & 2 deletions cli/delete.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ func delete(ctx context.Context, containerID string, force bool) error {
}

forceStop := false
if oci.StateToOCIState(status.State) == oci.StateRunning {
if oci.StateToOCIState(status.State.State) == oci.StateRunning {
if !force {
return fmt.Errorf("Container still running, should be stopped")
}
Expand Down Expand Up @@ -140,7 +140,7 @@ func deleteSandbox(ctx context.Context, sandboxID string) error {
return err
}

if oci.StateToOCIState(status.State) != oci.StateStopped {
if oci.StateToOCIState(status.State.State) != oci.StateStopped {
if _, err := vci.StopSandbox(ctx, sandboxID); err != nil {
return err
}
Expand Down
18 changes: 9 additions & 9 deletions cli/delete_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ func TestDeleteSandbox(t *testing.T) {
vcAnnotations.ContainerTypeKey: string(vc.PodSandbox),
vcAnnotations.ConfigJSONKey: configJSON,
},
State: types.State{
State: types.ContainerState{
State: "ready",
},
}, nil
Expand All @@ -185,7 +185,7 @@ func TestDeleteSandbox(t *testing.T) {
testingImpl.StatusSandboxFunc = func(ctx context.Context, sandboxID string) (vc.SandboxStatus, error) {
return vc.SandboxStatus{
ID: sandbox.ID(),
State: types.State{
State: types.SandboxState{
State: types.StateReady,
},
}, nil
Expand Down Expand Up @@ -246,7 +246,7 @@ func TestDeleteInvalidContainerType(t *testing.T) {
vcAnnotations.ContainerTypeKey: "InvalidType",
vcAnnotations.ConfigJSONKey: configJSON,
},
State: types.State{
State: types.ContainerState{
State: "created",
},
}, nil
Expand Down Expand Up @@ -285,7 +285,7 @@ func TestDeleteSandboxRunning(t *testing.T) {
vcAnnotations.ContainerTypeKey: string(vc.PodSandbox),
vcAnnotations.ConfigJSONKey: configJSON,
},
State: types.State{
State: types.ContainerState{
State: "running",
},
}, nil
Expand All @@ -303,7 +303,7 @@ func TestDeleteSandboxRunning(t *testing.T) {
testingImpl.StatusSandboxFunc = func(ctx context.Context, sandboxID string) (vc.SandboxStatus, error) {
return vc.SandboxStatus{
ID: sandbox.ID(),
State: types.State{
State: types.SandboxState{
State: types.StateRunning,
},
}, nil
Expand Down Expand Up @@ -365,7 +365,7 @@ func TestDeleteRunningContainer(t *testing.T) {
vcAnnotations.ContainerTypeKey: string(vc.PodContainer),
vcAnnotations.ConfigJSONKey: configJSON,
},
State: types.State{
State: types.ContainerState{
State: "running",
},
}, nil
Expand Down Expand Up @@ -448,7 +448,7 @@ func TestDeleteContainer(t *testing.T) {
vcAnnotations.ContainerTypeKey: string(vc.PodContainer),
vcAnnotations.ConfigJSONKey: configJSON,
},
State: types.State{
State: types.ContainerState{
State: "ready",
},
}, nil
Expand Down Expand Up @@ -548,7 +548,7 @@ func TestDeleteCLIFunctionSuccess(t *testing.T) {
vcAnnotations.ContainerTypeKey: string(vc.PodSandbox),
vcAnnotations.ConfigJSONKey: configJSON,
},
State: types.State{
State: types.ContainerState{
State: "ready",
},
}, nil
Expand All @@ -557,7 +557,7 @@ func TestDeleteCLIFunctionSuccess(t *testing.T) {
testingImpl.StatusSandboxFunc = func(ctx context.Context, sandboxID string) (vc.SandboxStatus, error) {
return vc.SandboxStatus{
ID: sandbox.ID(),
State: types.State{
State: types.SandboxState{
State: types.StateReady,
},
}, nil
Expand Down
2 changes: 1 addition & 1 deletion cli/events_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ func TestEventsCLISuccessful(t *testing.T) {
Annotations: map[string]string{
vcAnnotations.ContainerTypeKey: string(vc.PodContainer),
},
State: types.State{
State: types.ContainerState{
State: types.StateRunning,
},
}, nil
Expand Down
22 changes: 11 additions & 11 deletions cli/exec_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ func TestExecuteErrors(t *testing.T) {
}

testingImpl.StatusContainerFunc = func(ctx context.Context, sandboxID, containerID string) (vc.ContainerStatus, error) {
return newSingleContainerStatus(testContainerID, types.State{}, annotations), nil
return newSingleContainerStatus(testContainerID, types.ContainerState{}, annotations), nil
}

defer func() {
Expand All @@ -100,7 +100,7 @@ func TestExecuteErrors(t *testing.T) {
vcAnnotations.ConfigJSONKey: configJSON,
}

containerState := types.State{}
containerState := types.ContainerState{}
testingImpl.StatusContainerFunc = func(ctx context.Context, sandboxID, containerID string) (vc.ContainerStatus, error) {
return newSingleContainerStatus(testContainerID, containerState, annotations), nil
}
Expand All @@ -110,7 +110,7 @@ func TestExecuteErrors(t *testing.T) {
assert.False(vcmock.IsMockError(err))

// Container paused
containerState = types.State{
containerState = types.ContainerState{
State: types.StatePaused,
}
testingImpl.StatusContainerFunc = func(ctx context.Context, sandboxID, containerID string) (vc.ContainerStatus, error) {
Expand All @@ -122,7 +122,7 @@ func TestExecuteErrors(t *testing.T) {
assert.False(vcmock.IsMockError(err))

// Container stopped
containerState = types.State{
containerState = types.ContainerState{
State: types.StateStopped,
}
testingImpl.StatusContainerFunc = func(ctx context.Context, sandboxID, containerID string) (vc.ContainerStatus, error) {
Expand Down Expand Up @@ -159,7 +159,7 @@ func TestExecuteErrorReadingProcessJson(t *testing.T) {
vcAnnotations.ConfigJSONKey: configJSON,
}

state := types.State{
state := types.ContainerState{
State: types.StateRunning,
}

Expand Down Expand Up @@ -208,7 +208,7 @@ func TestExecuteErrorOpeningConsole(t *testing.T) {
vcAnnotations.ConfigJSONKey: configJSON,
}

state := types.State{
state := types.ContainerState{
State: types.StateRunning,
}

Expand Down Expand Up @@ -275,7 +275,7 @@ func TestExecuteWithFlags(t *testing.T) {
vcAnnotations.ConfigJSONKey: configJSON,
}

state := types.State{
state := types.ContainerState{
State: types.StateRunning,
}

Expand Down Expand Up @@ -365,7 +365,7 @@ func TestExecuteWithFlagsDetached(t *testing.T) {
vcAnnotations.ConfigJSONKey: configJSON,
}

state := types.State{
state := types.ContainerState{
State: types.StateRunning,
}

Expand Down Expand Up @@ -444,7 +444,7 @@ func TestExecuteWithInvalidProcessJson(t *testing.T) {
vcAnnotations.ConfigJSONKey: configJSON,
}

state := types.State{
state := types.ContainerState{
State: types.StateRunning,
}

Expand Down Expand Up @@ -496,7 +496,7 @@ func TestExecuteWithValidProcessJson(t *testing.T) {
vcAnnotations.ConfigJSONKey: configJSON,
}

state := types.State{
state := types.ContainerState{
State: types.StateRunning,
}

Expand Down Expand Up @@ -597,7 +597,7 @@ func TestExecuteWithEmptyEnvironmentValue(t *testing.T) {
vcAnnotations.ConfigJSONKey: configJSON,
}

state := types.State{
state := types.ContainerState{
State: types.StateRunning,
}

Expand Down
18 changes: 9 additions & 9 deletions cli/kill_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ func TestProcessSignal(t *testing.T) {
func testKillCLIFunctionTerminationSignalSuccessful(t *testing.T, sig string) {
assert := assert.New(t)

state := types.State{
state := types.ContainerState{
State: types.StateRunning,
}

Expand Down Expand Up @@ -123,7 +123,7 @@ func TestKillCLIFunctionSigtermSuccessful(t *testing.T) {
func TestKillCLIFunctionNotTerminationSignalSuccessful(t *testing.T) {
assert := assert.New(t)

state := types.State{
state := types.ContainerState{
State: types.StateRunning,
}

Expand Down Expand Up @@ -151,7 +151,7 @@ func TestKillCLIFunctionNotTerminationSignalSuccessful(t *testing.T) {
func TestKillCLIFunctionNoSignalSuccessful(t *testing.T) {
assert := assert.New(t)

state := types.State{
state := types.ContainerState{
State: types.StateRunning,
}

Expand Down Expand Up @@ -201,7 +201,7 @@ func TestKillCLIFunctionNoSignalSuccessful(t *testing.T) {
func TestKillCLIFunctionEnableAllSuccessful(t *testing.T) {
assert := assert.New(t)

state := types.State{
state := types.ContainerState{
State: types.StateRunning,
}

Expand Down Expand Up @@ -289,7 +289,7 @@ func TestKillCLIFunctionContainerNotExistFailure(t *testing.T) {
func TestKillCLIFunctionInvalidSignalFailure(t *testing.T) {
assert := assert.New(t)

state := types.State{
state := types.ContainerState{
State: types.StateRunning,
}

Expand Down Expand Up @@ -317,7 +317,7 @@ func TestKillCLIFunctionInvalidSignalFailure(t *testing.T) {
func TestKillCLIFunctionStatePausedSuccessful(t *testing.T) {
assert := assert.New(t)

state := types.State{
state := types.ContainerState{
State: types.StatePaused,
}

Expand Down Expand Up @@ -348,7 +348,7 @@ func TestKillCLIFunctionStatePausedSuccessful(t *testing.T) {
func TestKillCLIFunctionInvalidStateStoppedFailure(t *testing.T) {
assert := assert.New(t)

state := types.State{
state := types.ContainerState{
State: types.StateStopped,
}

Expand Down Expand Up @@ -376,7 +376,7 @@ func TestKillCLIFunctionInvalidStateStoppedFailure(t *testing.T) {
func TestKillCLIFunctionKillContainerFailure(t *testing.T) {
assert := assert.New(t)

state := types.State{
state := types.ContainerState{
State: types.StateRunning,
}

Expand All @@ -401,7 +401,7 @@ func TestKillCLIFunctionKillContainerFailure(t *testing.T) {
func TestKillCLIFunctionInvalidStateStoppedAllSuccess(t *testing.T) {
assert := assert.New(t)

state := types.State{
state := types.ContainerState{
State: types.StateStopped,
}

Expand Down
2 changes: 1 addition & 1 deletion cli/main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -445,7 +445,7 @@ func writeOCIConfigFile(spec oci.CompatOCISpec, configPath string) error {
return ioutil.WriteFile(configPath, bytes, testFileMode)
}

func newSingleContainerStatus(containerID string, containerState types.State, annotations map[string]string) vc.ContainerStatus {
func newSingleContainerStatus(containerID string, containerState types.ContainerState, annotations map[string]string) vc.ContainerStatus {
return vc.ContainerStatus{
ID: containerID,
State: containerState,
Expand Down
2 changes: 1 addition & 1 deletion cli/network_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ var (
func TestNetworkCliFunction(t *testing.T) {
assert := assert.New(t)

state := types.State{
state := types.ContainerState{
State: types.StateRunning,
}

Expand Down
8 changes: 4 additions & 4 deletions cli/pause_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ var (
func TestPauseCLIFunctionSuccessful(t *testing.T) {
assert := assert.New(t)

state := types.State{
state := types.ContainerState{
State: types.StateRunning,
}

Expand Down Expand Up @@ -78,7 +78,7 @@ func TestPauseCLIFunctionContainerNotExistFailure(t *testing.T) {
func TestPauseCLIFunctionPauseContainerFailure(t *testing.T) {
assert := assert.New(t)

state := types.State{
state := types.ContainerState{
State: types.StateRunning,
}

Expand All @@ -103,7 +103,7 @@ func TestPauseCLIFunctionPauseContainerFailure(t *testing.T) {
func TestResumeCLIFunctionSuccessful(t *testing.T) {
assert := assert.New(t)

state := types.State{
state := types.ContainerState{
State: types.StateRunning,
}

Expand Down Expand Up @@ -150,7 +150,7 @@ func TestResumeCLIFunctionContainerNotExistFailure(t *testing.T) {
func TestResumeCLIFunctionPauseContainerFailure(t *testing.T) {
assert := assert.New(t)

state := types.State{
state := types.ContainerState{
State: types.StateRunning,
}

Expand Down
2 changes: 1 addition & 1 deletion cli/ps_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ func TestPSSuccessful(t *testing.T) {

testingImpl.StatusContainerFunc = func(ctx context.Context, sandboxID, containerID string) (vc.ContainerStatus, error) {
return vc.ContainerStatus{
State: types.State{
State: types.ContainerState{
State: types.StateRunning,
},
ID: sandbox.ID(),
Expand Down
4 changes: 2 additions & 2 deletions cli/update_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ func TestUpdateCLIFailure(t *testing.T) {
Annotations: map[string]string{
vcAnnotations.ContainerTypeKey: string(vc.PodContainer),
},
State: types.State{
State: types.ContainerState{
State: types.StateRunning,
},
}, nil
Expand Down Expand Up @@ -168,7 +168,7 @@ func TestUpdateCLISuccessful(t *testing.T) {
Annotations: map[string]string{
vcAnnotations.ContainerTypeKey: string(vc.PodContainer),
},
State: types.State{
State: types.ContainerState{
State: types.StateRunning,
},
}, nil
Expand Down
Loading

0 comments on commit dd5c6aa

Please sign in to comment.