mirror of
https://github.com/kata-containers/kata-containers.git
synced 2025-06-29 08:47:56 +00:00
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:
parent
5165de0d76
commit
ef89131b85
@ -85,7 +85,7 @@ func DeleteSandbox(sandboxID string) (VCSandbox, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Delete it.
|
// Delete it.
|
||||||
if err := p.delete(); err != nil {
|
if err := p.Delete(); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -49,6 +49,7 @@ type VCSandbox interface {
|
|||||||
Pause() error
|
Pause() error
|
||||||
Resume() error
|
Resume() error
|
||||||
Release() error
|
Release() error
|
||||||
|
Delete() error
|
||||||
}
|
}
|
||||||
|
|
||||||
// VCContainer is the Container interface
|
// VCContainer is the Container interface
|
||||||
|
@ -64,3 +64,8 @@ func (p *Sandbox) Pause() error {
|
|||||||
func (p *Sandbox) Resume() error {
|
func (p *Sandbox) Resume() error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Delete implements the VCSandbox function of the same name.
|
||||||
|
func (p *Sandbox) Delete() error {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
@ -765,9 +765,9 @@ func (s *Sandbox) removeContainer(containerID string) error {
|
|||||||
containerID, s.id)
|
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.
|
// 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 &&
|
if s.state.State != StateReady &&
|
||||||
s.state.State != StatePaused &&
|
s.state.State != StatePaused &&
|
||||||
s.state.State != StateStopped {
|
s.state.State != StateStopped {
|
||||||
|
@ -605,7 +605,7 @@ func TestSandboxSetSandboxAndContainerState(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// clean up
|
// clean up
|
||||||
err = p.delete()
|
err = p.Delete()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user