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

Commit

Permalink
api: add sandbox Delete API
Browse files Browse the repository at this point in the history
By exporting the existing sandbox delete() function.

Signed-off-by: Peng Tao <[email protected]>
  • Loading branch information
bergwolf committed Apr 24, 2018
1 parent 5165de0 commit ef89131
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 4 deletions.
2 changes: 1 addition & 1 deletion virtcontainers/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down
1 change: 1 addition & 0 deletions virtcontainers/interfaces.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ type VCSandbox interface {
Pause() error
Resume() error
Release() error
Delete() error
}

// VCContainer is the Container interface
Expand Down
5 changes: 5 additions & 0 deletions virtcontainers/pkg/vcmock/sandbox.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
4 changes: 2 additions & 2 deletions virtcontainers/sandbox.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion virtcontainers/sandbox_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -605,7 +605,7 @@ func TestSandboxSetSandboxAndContainerState(t *testing.T) {
}

// clean up
err = p.delete()
err = p.Delete()
if err != nil {
t.Fatal(err)
}
Expand Down

0 comments on commit ef89131

Please sign in to comment.