api: add sandbox Delete API

By exporting the existing sandbox delete() function.

Signed-off-by: Peng Tao <bergwolf@gmail.com>
This commit is contained in:
Peng Tao 2018-04-18 11:43:43 +08:00
parent 5165de0d76
commit ef89131b85
5 changed files with 10 additions and 4 deletions

View File

@ -85,7 +85,7 @@ func DeleteSandbox(sandboxID string) (VCSandbox, error) {
}
// Delete it.
if err := p.delete(); err != nil {
if err := p.Delete(); err != nil {
return nil, err
}

View File

@ -49,6 +49,7 @@ type VCSandbox interface {
Pause() error
Resume() error
Release() error
Delete() error
}
// VCContainer is the Container interface

View File

@ -64,3 +64,8 @@ func (p *Sandbox) Pause() error {
func (p *Sandbox) Resume() error {
return nil
}
// Delete implements the VCSandbox function of the same name.
func (p *Sandbox) Delete() error {
return nil
}

View File

@ -765,9 +765,9 @@ func (s *Sandbox) removeContainer(containerID string) error {
containerID, s.id)
}
// delete deletes an already created sandbox.
// Delete deletes an already created sandbox.
// The VM in which the sandbox is running will be shut down.
func (s *Sandbox) delete() error {
func (s *Sandbox) Delete() error {
if s.state.State != StateReady &&
s.state.State != StatePaused &&
s.state.State != StateStopped {

View File

@ -605,7 +605,7 @@ func TestSandboxSetSandboxAndContainerState(t *testing.T) {
}
// clean up
err = p.delete()
err = p.Delete()
if err != nil {
t.Fatal(err)
}