mirror of
https://github.com/kata-containers/kata-containers.git
synced 2025-09-14 05:19:21 +00:00
runtime: delete unused sub-commands.
This PR delete codes not used anymore. Fixes: #332 Signed-off-by: bin liu <bin@hyper.sh>
This commit is contained in:
File diff suppressed because it is too large
Load Diff
@@ -873,11 +873,17 @@ func Example_createAndStartSandbox() {
|
||||
Containers: []vc.ContainerConfig{container},
|
||||
}
|
||||
|
||||
_, err := vc.RunSandbox(sandboxConfig)
|
||||
// Create the sandbox
|
||||
s, err := vc.CreateSandbox(context.Background(), sandboxConfig, nil)
|
||||
if err != nil {
|
||||
fmt.Printf("Could not run sandbox: %s", err)
|
||||
fmt.Printf("Could not create sandbox: %s", err)
|
||||
return
|
||||
}
|
||||
|
||||
return
|
||||
// Start the sandbox
|
||||
err = s.Start()
|
||||
if err != nil {
|
||||
fmt.Printf("Could not start sandbox: %s", err)
|
||||
}
|
||||
}
|
||||
```
|
||||
|
@@ -63,8 +63,16 @@ func Example_createAndStartSandbox() {
|
||||
Containers: []vc.ContainerConfig{container},
|
||||
}
|
||||
|
||||
_, err := vc.RunSandbox(context.Background(), sandboxConfig, nil)
|
||||
// Create the sandbox
|
||||
s, err := vc.CreateSandbox(context.Background(), sandboxConfig, nil)
|
||||
if err != nil {
|
||||
fmt.Printf("Could not run sandbox: %s", err)
|
||||
fmt.Printf("Could not create sandbox: %s", err)
|
||||
return
|
||||
}
|
||||
|
||||
// Start the sandbox
|
||||
err = s.Start()
|
||||
if err != nil {
|
||||
fmt.Printf("Could not start sandbox: %s", err)
|
||||
}
|
||||
}
|
||||
|
@@ -11,13 +11,7 @@ package virtcontainers
|
||||
|
||||
import (
|
||||
"context"
|
||||
"syscall"
|
||||
|
||||
"github.com/kata-containers/kata-containers/src/runtime/virtcontainers/device/api"
|
||||
"github.com/kata-containers/kata-containers/src/runtime/virtcontainers/device/config"
|
||||
vcTypes "github.com/kata-containers/kata-containers/src/runtime/virtcontainers/pkg/types"
|
||||
"github.com/kata-containers/kata-containers/src/runtime/virtcontainers/types"
|
||||
specs "github.com/opencontainers/runtime-spec/specs-go"
|
||||
"github.com/sirupsen/logrus"
|
||||
)
|
||||
|
||||
@@ -41,137 +35,6 @@ func (impl *VCImpl) CreateSandbox(ctx context.Context, sandboxConfig SandboxConf
|
||||
return CreateSandbox(ctx, sandboxConfig, impl.factory)
|
||||
}
|
||||
|
||||
// DeleteSandbox implements the VC function of the same name.
|
||||
func (impl *VCImpl) DeleteSandbox(ctx context.Context, sandboxID string) (VCSandbox, error) {
|
||||
return DeleteSandbox(ctx, sandboxID)
|
||||
}
|
||||
|
||||
// StartSandbox implements the VC function of the same name.
|
||||
func (impl *VCImpl) StartSandbox(ctx context.Context, sandboxID string) (VCSandbox, error) {
|
||||
return StartSandbox(ctx, sandboxID)
|
||||
}
|
||||
|
||||
// StopSandbox implements the VC function of the same name.
|
||||
func (impl *VCImpl) StopSandbox(ctx context.Context, sandboxID string, force bool) (VCSandbox, error) {
|
||||
return StopSandbox(ctx, sandboxID, force)
|
||||
}
|
||||
|
||||
// RunSandbox implements the VC function of the same name.
|
||||
func (impl *VCImpl) RunSandbox(ctx context.Context, sandboxConfig SandboxConfig) (VCSandbox, error) {
|
||||
return RunSandbox(ctx, sandboxConfig, impl.factory)
|
||||
}
|
||||
|
||||
// ListSandbox implements the VC function of the same name.
|
||||
func (impl *VCImpl) ListSandbox(ctx context.Context) ([]SandboxStatus, error) {
|
||||
return ListSandbox(ctx)
|
||||
}
|
||||
|
||||
// FetchSandbox will find out and connect to an existing sandbox and
|
||||
// return the sandbox structure.
|
||||
func (impl *VCImpl) FetchSandbox(ctx context.Context, sandboxID string) (VCSandbox, error) {
|
||||
return FetchSandbox(ctx, sandboxID)
|
||||
}
|
||||
|
||||
// StatusSandbox implements the VC function of the same name.
|
||||
func (impl *VCImpl) StatusSandbox(ctx context.Context, sandboxID string) (SandboxStatus, error) {
|
||||
return StatusSandbox(ctx, sandboxID)
|
||||
}
|
||||
|
||||
// CreateContainer implements the VC function of the same name.
|
||||
func (impl *VCImpl) CreateContainer(ctx context.Context, sandboxID string, containerConfig ContainerConfig) (VCSandbox, VCContainer, error) {
|
||||
return CreateContainer(ctx, sandboxID, containerConfig)
|
||||
}
|
||||
|
||||
// DeleteContainer implements the VC function of the same name.
|
||||
func (impl *VCImpl) DeleteContainer(ctx context.Context, sandboxID, containerID string) (VCContainer, error) {
|
||||
return DeleteContainer(ctx, sandboxID, containerID)
|
||||
}
|
||||
|
||||
// StartContainer implements the VC function of the same name.
|
||||
func (impl *VCImpl) StartContainer(ctx context.Context, sandboxID, containerID string) (VCContainer, error) {
|
||||
return StartContainer(ctx, sandboxID, containerID)
|
||||
}
|
||||
|
||||
// StopContainer implements the VC function of the same name.
|
||||
func (impl *VCImpl) StopContainer(ctx context.Context, sandboxID, containerID string) (VCContainer, error) {
|
||||
return StopContainer(ctx, sandboxID, containerID)
|
||||
}
|
||||
|
||||
// EnterContainer implements the VC function of the same name.
|
||||
func (impl *VCImpl) EnterContainer(ctx context.Context, sandboxID, containerID string, cmd types.Cmd) (VCSandbox, VCContainer, *Process, error) {
|
||||
return EnterContainer(ctx, sandboxID, containerID, cmd)
|
||||
}
|
||||
|
||||
// StatusContainer implements the VC function of the same name.
|
||||
func (impl *VCImpl) StatusContainer(ctx context.Context, sandboxID, containerID string) (ContainerStatus, error) {
|
||||
return StatusContainer(ctx, sandboxID, containerID)
|
||||
}
|
||||
|
||||
// StatsContainer implements the VC function of the same name.
|
||||
func (impl *VCImpl) StatsContainer(ctx context.Context, sandboxID, containerID string) (ContainerStats, error) {
|
||||
return StatsContainer(ctx, sandboxID, containerID)
|
||||
}
|
||||
|
||||
// StatsSandbox implements the VC function of the same name.
|
||||
func (impl *VCImpl) StatsSandbox(ctx context.Context, sandboxID string) (SandboxStats, []ContainerStats, error) {
|
||||
return StatsSandbox(ctx, sandboxID)
|
||||
}
|
||||
|
||||
// KillContainer implements the VC function of the same name.
|
||||
func (impl *VCImpl) KillContainer(ctx context.Context, sandboxID, containerID string, signal syscall.Signal, all bool) error {
|
||||
return KillContainer(ctx, sandboxID, containerID, signal, all)
|
||||
}
|
||||
|
||||
// ProcessListContainer implements the VC function of the same name.
|
||||
func (impl *VCImpl) ProcessListContainer(ctx context.Context, sandboxID, containerID string, options ProcessListOptions) (ProcessList, error) {
|
||||
return ProcessListContainer(ctx, sandboxID, containerID, options)
|
||||
}
|
||||
|
||||
// UpdateContainer implements the VC function of the same name.
|
||||
func (impl *VCImpl) UpdateContainer(ctx context.Context, sandboxID, containerID string, resources specs.LinuxResources) error {
|
||||
return UpdateContainer(ctx, sandboxID, containerID, resources)
|
||||
}
|
||||
|
||||
// PauseContainer implements the VC function of the same name.
|
||||
func (impl *VCImpl) PauseContainer(ctx context.Context, sandboxID, containerID string) error {
|
||||
return PauseContainer(ctx, sandboxID, containerID)
|
||||
}
|
||||
|
||||
// ResumeContainer implements the VC function of the same name.
|
||||
func (impl *VCImpl) ResumeContainer(ctx context.Context, sandboxID, containerID string) error {
|
||||
return ResumeContainer(ctx, sandboxID, containerID)
|
||||
}
|
||||
|
||||
// AddDevice will add a device to sandbox
|
||||
func (impl *VCImpl) AddDevice(ctx context.Context, sandboxID string, info config.DeviceInfo) (api.Device, error) {
|
||||
return AddDevice(ctx, sandboxID, info)
|
||||
}
|
||||
|
||||
// AddInterface implements the VC function of the same name.
|
||||
func (impl *VCImpl) AddInterface(ctx context.Context, sandboxID string, inf *vcTypes.Interface) (*vcTypes.Interface, error) {
|
||||
return AddInterface(ctx, sandboxID, inf)
|
||||
}
|
||||
|
||||
// RemoveInterface implements the VC function of the same name.
|
||||
func (impl *VCImpl) RemoveInterface(ctx context.Context, sandboxID string, inf *vcTypes.Interface) (*vcTypes.Interface, error) {
|
||||
return RemoveInterface(ctx, sandboxID, inf)
|
||||
}
|
||||
|
||||
// ListInterfaces implements the VC function of the same name.
|
||||
func (impl *VCImpl) ListInterfaces(ctx context.Context, sandboxID string) ([]*vcTypes.Interface, error) {
|
||||
return ListInterfaces(ctx, sandboxID)
|
||||
}
|
||||
|
||||
// UpdateRoutes implements the VC function of the same name.
|
||||
func (impl *VCImpl) UpdateRoutes(ctx context.Context, sandboxID string, routes []*vcTypes.Route) ([]*vcTypes.Route, error) {
|
||||
return UpdateRoutes(ctx, sandboxID, routes)
|
||||
}
|
||||
|
||||
// ListRoutes implements the VC function of the same name.
|
||||
func (impl *VCImpl) ListRoutes(ctx context.Context, sandboxID string) ([]*vcTypes.Route, error) {
|
||||
return ListRoutes(ctx, sandboxID)
|
||||
}
|
||||
|
||||
// CleanupContaienr is used by shimv2 to stop and delete a container exclusively, once there is no container
|
||||
// in the sandbox left, do stop the sandbox and delete it. Those serial operations will be done exclusively by
|
||||
// locking the sandbox.
|
||||
|
@@ -24,36 +24,6 @@ type VC interface {
|
||||
SetFactory(ctx context.Context, factory Factory)
|
||||
|
||||
CreateSandbox(ctx context.Context, sandboxConfig SandboxConfig) (VCSandbox, error)
|
||||
DeleteSandbox(ctx context.Context, sandboxID string) (VCSandbox, error)
|
||||
FetchSandbox(ctx context.Context, sandboxID string) (VCSandbox, error)
|
||||
ListSandbox(ctx context.Context) ([]SandboxStatus, error)
|
||||
RunSandbox(ctx context.Context, sandboxConfig SandboxConfig) (VCSandbox, error)
|
||||
StartSandbox(ctx context.Context, sandboxID string) (VCSandbox, error)
|
||||
StatusSandbox(ctx context.Context, sandboxID string) (SandboxStatus, error)
|
||||
StopSandbox(ctx context.Context, sandboxID string, force bool) (VCSandbox, error)
|
||||
|
||||
CreateContainer(ctx context.Context, sandboxID string, containerConfig ContainerConfig) (VCSandbox, VCContainer, error)
|
||||
DeleteContainer(ctx context.Context, sandboxID, containerID string) (VCContainer, error)
|
||||
EnterContainer(ctx context.Context, sandboxID, containerID string, cmd types.Cmd) (VCSandbox, VCContainer, *Process, error)
|
||||
KillContainer(ctx context.Context, sandboxID, containerID string, signal syscall.Signal, all bool) error
|
||||
StartContainer(ctx context.Context, sandboxID, containerID string) (VCContainer, error)
|
||||
StatusContainer(ctx context.Context, sandboxID, containerID string) (ContainerStatus, error)
|
||||
StatsContainer(ctx context.Context, sandboxID, containerID string) (ContainerStats, error)
|
||||
StatsSandbox(ctx context.Context, sandboxID string) (SandboxStats, []ContainerStats, error)
|
||||
StopContainer(ctx context.Context, sandboxID, containerID string) (VCContainer, error)
|
||||
ProcessListContainer(ctx context.Context, sandboxID, containerID string, options ProcessListOptions) (ProcessList, error)
|
||||
UpdateContainer(ctx context.Context, sandboxID, containerID string, resources specs.LinuxResources) error
|
||||
PauseContainer(ctx context.Context, sandboxID, containerID string) error
|
||||
ResumeContainer(ctx context.Context, sandboxID, containerID string) error
|
||||
|
||||
AddDevice(ctx context.Context, sandboxID string, info config.DeviceInfo) (api.Device, error)
|
||||
|
||||
AddInterface(ctx context.Context, sandboxID string, inf *vcTypes.Interface) (*vcTypes.Interface, error)
|
||||
RemoveInterface(ctx context.Context, sandboxID string, inf *vcTypes.Interface) (*vcTypes.Interface, error)
|
||||
ListInterfaces(ctx context.Context, sandboxID string) ([]*vcTypes.Interface, error)
|
||||
UpdateRoutes(ctx context.Context, sandboxID string, routes []*vcTypes.Route) ([]*vcTypes.Route, error)
|
||||
ListRoutes(ctx context.Context, sandboxID string) ([]*vcTypes.Route, error)
|
||||
|
||||
CleanupContainer(ctx context.Context, sandboxID, containerID string, force bool) error
|
||||
}
|
||||
|
||||
|
@@ -6,6 +6,7 @@
|
||||
package vcmock
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"io"
|
||||
"syscall"
|
||||
|
||||
@@ -95,7 +96,10 @@ func (s *Sandbox) Delete() error {
|
||||
|
||||
// CreateContainer implements the VCSandbox function of the same name.
|
||||
func (s *Sandbox) CreateContainer(conf vc.ContainerConfig) (vc.VCContainer, error) {
|
||||
return &Container{}, nil
|
||||
if s.CreateContainerFunc != nil {
|
||||
return s.CreateContainerFunc(conf)
|
||||
}
|
||||
return nil, fmt.Errorf("%s: %s (%+v): sandboxID: %v, containerConfig: %v", mockErrorPrefix, getSelf(), s, s.MockID, conf)
|
||||
}
|
||||
|
||||
// DeleteContainer implements the VCSandbox function of the same name.
|
||||
|
@@ -24,5 +24,8 @@ func getSelf() string {
|
||||
// IsMockError returns true if the specified error was generated by this
|
||||
// package.
|
||||
func IsMockError(err error) bool {
|
||||
if err == nil {
|
||||
return false
|
||||
}
|
||||
return strings.HasPrefix(err.Error(), mockErrorPrefix)
|
||||
}
|
||||
|
Reference in New Issue
Block a user