github.com/kata-containers/runtime@v0.0.0-20210505125100-04f29832a923/virtcontainers/pkg/vcmock/types.go (about) 1 // Copyright (c) 2017 Intel Corporation 2 // 3 // SPDX-License-Identifier: Apache-2.0 4 // 5 6 package vcmock 7 8 import ( 9 "context" 10 "syscall" 11 12 vc "github.com/kata-containers/runtime/virtcontainers" 13 "github.com/kata-containers/runtime/virtcontainers/device/api" 14 "github.com/kata-containers/runtime/virtcontainers/device/config" 15 vcTypes "github.com/kata-containers/runtime/virtcontainers/pkg/types" 16 "github.com/kata-containers/runtime/virtcontainers/types" 17 specs "github.com/opencontainers/runtime-spec/specs-go" 18 "github.com/sirupsen/logrus" 19 ) 20 21 // Sandbox is a fake Sandbox type used for testing 22 type Sandbox struct { 23 MockID string 24 MockURL string 25 MockAnnotations map[string]string 26 MockContainers []*Container 27 MockNetNs string 28 } 29 30 // Container is a fake Container type used for testing 31 type Container struct { 32 MockID string 33 MockURL string 34 MockToken string 35 MockProcess vc.Process 36 MockPid int 37 MockSandbox *Sandbox 38 MockAnnotations map[string]string 39 } 40 41 // VCMock is a type that provides an implementation of the VC interface. 42 // It is used for testing. 43 type VCMock struct { 44 SetLoggerFunc func(ctx context.Context, logger *logrus.Entry) 45 SetFactoryFunc func(ctx context.Context, factory vc.Factory) 46 47 CreateSandboxFunc func(ctx context.Context, sandboxConfig vc.SandboxConfig) (vc.VCSandbox, error) 48 DeleteSandboxFunc func(ctx context.Context, sandboxID string) (vc.VCSandbox, error) 49 ListSandboxFunc func(ctx context.Context) ([]vc.SandboxStatus, error) 50 FetchSandboxFunc func(ctx context.Context, sandboxID string) (vc.VCSandbox, error) 51 RunSandboxFunc func(ctx context.Context, sandboxConfig vc.SandboxConfig) (vc.VCSandbox, error) 52 StartSandboxFunc func(ctx context.Context, sandboxID string) (vc.VCSandbox, error) 53 StatusSandboxFunc func(ctx context.Context, sandboxID string) (vc.SandboxStatus, error) 54 StatsContainerFunc func(ctx context.Context, sandboxID, containerID string) (vc.ContainerStats, error) 55 StatsSandboxFunc func(ctx context.Context, sandboxID string) (vc.SandboxStats, []vc.ContainerStats, error) 56 StopSandboxFunc func(ctx context.Context, sandboxID string, force bool) (vc.VCSandbox, error) 57 58 CreateContainerFunc func(ctx context.Context, sandboxID string, containerConfig vc.ContainerConfig) (vc.VCSandbox, vc.VCContainer, error) 59 DeleteContainerFunc func(ctx context.Context, sandboxID, containerID string) (vc.VCContainer, error) 60 EnterContainerFunc func(ctx context.Context, sandboxID, containerID string, cmd types.Cmd) (vc.VCSandbox, vc.VCContainer, *vc.Process, error) 61 KillContainerFunc func(ctx context.Context, sandboxID, containerID string, signal syscall.Signal, all bool) error 62 StartContainerFunc func(ctx context.Context, sandboxID, containerID string) (vc.VCContainer, error) 63 StatusContainerFunc func(ctx context.Context, sandboxID, containerID string) (vc.ContainerStatus, error) 64 StopContainerFunc func(ctx context.Context, sandboxID, containerID string) (vc.VCContainer, error) 65 ProcessListContainerFunc func(ctx context.Context, sandboxID, containerID string, options vc.ProcessListOptions) (vc.ProcessList, error) 66 UpdateContainerFunc func(ctx context.Context, sandboxID, containerID string, resources specs.LinuxResources) error 67 PauseContainerFunc func(ctx context.Context, sandboxID, containerID string) error 68 ResumeContainerFunc func(ctx context.Context, sandboxID, containerID string) error 69 70 AddDeviceFunc func(ctx context.Context, sandboxID string, info config.DeviceInfo) (api.Device, error) 71 72 AddInterfaceFunc func(ctx context.Context, sandboxID string, inf *vcTypes.Interface) (*vcTypes.Interface, error) 73 RemoveInterfaceFunc func(ctx context.Context, sandboxID string, inf *vcTypes.Interface) (*vcTypes.Interface, error) 74 ListInterfacesFunc func(ctx context.Context, sandboxID string) ([]*vcTypes.Interface, error) 75 UpdateRoutesFunc func(ctx context.Context, sandboxID string, routes []*vcTypes.Route) ([]*vcTypes.Route, error) 76 ListRoutesFunc func(ctx context.Context, sandboxID string) ([]*vcTypes.Route, error) 77 CleanupContainerFunc func(ctx context.Context, sandboxID, containerID string, force bool) error 78 }