github.com/kata-containers/runtime@v0.0.0-20210505125100-04f29832a923/virtcontainers/pkg/vcmock/sandbox.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  	"io"
    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  )
    19  
    20  // ID implements the VCSandbox function of the same name.
    21  func (s *Sandbox) ID() string {
    22  	return s.MockID
    23  }
    24  
    25  // Annotations implements the VCSandbox function of the same name.
    26  func (s *Sandbox) Annotations(key string) (string, error) {
    27  	return s.MockAnnotations[key], nil
    28  }
    29  
    30  // SetAnnotations implements the VCSandbox function of the same name.
    31  func (s *Sandbox) SetAnnotations(annotations map[string]string) error {
    32  	return nil
    33  }
    34  
    35  // GetAnnotations implements the VCSandbox function of the same name.
    36  func (s *Sandbox) GetAnnotations() map[string]string {
    37  	return s.MockAnnotations
    38  }
    39  
    40  // GetNetNs returns the network namespace of the current sandbox.
    41  func (s *Sandbox) GetNetNs() string {
    42  	return s.MockNetNs
    43  }
    44  
    45  // GetAllContainers implements the VCSandbox function of the same name.
    46  func (s *Sandbox) GetAllContainers() []vc.VCContainer {
    47  	var ifa = make([]vc.VCContainer, len(s.MockContainers))
    48  
    49  	for i, v := range s.MockContainers {
    50  		ifa[i] = v
    51  	}
    52  
    53  	return ifa
    54  }
    55  
    56  // GetContainer implements the VCSandbox function of the same name.
    57  func (s *Sandbox) GetContainer(containerID string) vc.VCContainer {
    58  	for _, c := range s.MockContainers {
    59  		if c.MockID == containerID {
    60  			return c
    61  		}
    62  	}
    63  	return &Container{}
    64  }
    65  
    66  // Release implements the VCSandbox function of the same name.
    67  func (s *Sandbox) Release() error {
    68  	return nil
    69  }
    70  
    71  // Start implements the VCSandbox function of the same name.
    72  func (s *Sandbox) Start() error {
    73  	return nil
    74  }
    75  
    76  // Stop implements the VCSandbox function of the same name.
    77  func (s *Sandbox) Stop(force bool) error {
    78  	return nil
    79  }
    80  
    81  // Pause implements the VCSandbox function of the same name.
    82  func (s *Sandbox) Pause() error {
    83  	return nil
    84  }
    85  
    86  // Resume implements the VCSandbox function of the same name.
    87  func (s *Sandbox) Resume() error {
    88  	return nil
    89  }
    90  
    91  // Delete implements the VCSandbox function of the same name.
    92  func (s *Sandbox) Delete() error {
    93  	return nil
    94  }
    95  
    96  // CreateContainer implements the VCSandbox function of the same name.
    97  func (s *Sandbox) CreateContainer(conf vc.ContainerConfig) (vc.VCContainer, error) {
    98  	return &Container{}, nil
    99  }
   100  
   101  // DeleteContainer implements the VCSandbox function of the same name.
   102  func (s *Sandbox) DeleteContainer(contID string) (vc.VCContainer, error) {
   103  	return &Container{}, nil
   104  }
   105  
   106  // StartContainer implements the VCSandbox function of the same name.
   107  func (s *Sandbox) StartContainer(contID string) (vc.VCContainer, error) {
   108  	return &Container{}, nil
   109  }
   110  
   111  // StopContainer implements the VCSandbox function of the same name.
   112  func (s *Sandbox) StopContainer(contID string, force bool) (vc.VCContainer, error) {
   113  	return &Container{}, nil
   114  }
   115  
   116  // KillContainer implements the VCSandbox function of the same name.
   117  func (s *Sandbox) KillContainer(contID string, signal syscall.Signal, all bool) error {
   118  	return nil
   119  }
   120  
   121  // StatusContainer implements the VCSandbox function of the same name.
   122  func (s *Sandbox) StatusContainer(contID string) (vc.ContainerStatus, error) {
   123  	return vc.ContainerStatus{}, nil
   124  }
   125  
   126  // StatsContainer implements the VCSandbox function of the same name.
   127  func (s *Sandbox) StatsContainer(contID string) (vc.ContainerStats, error) {
   128  	return vc.ContainerStats{}, nil
   129  }
   130  
   131  // PauseContainer implements the VCSandbox function of the same name.
   132  func (s *Sandbox) PauseContainer(contID string) error {
   133  	return nil
   134  }
   135  
   136  // ResumeContainer implements the VCSandbox function of the same name.
   137  func (s *Sandbox) ResumeContainer(contID string) error {
   138  	return nil
   139  }
   140  
   141  // Status implements the VCSandbox function of the same name.
   142  func (s *Sandbox) Status() vc.SandboxStatus {
   143  	return vc.SandboxStatus{}
   144  }
   145  
   146  // EnterContainer implements the VCSandbox function of the same name.
   147  func (s *Sandbox) EnterContainer(containerID string, cmd types.Cmd) (vc.VCContainer, *vc.Process, error) {
   148  	return &Container{}, &vc.Process{}, nil
   149  }
   150  
   151  // Monitor implements the VCSandbox function of the same name.
   152  func (s *Sandbox) Monitor() (chan error, error) {
   153  	return nil, nil
   154  }
   155  
   156  // UpdateContainer implements the VCSandbox function of the same name.
   157  func (s *Sandbox) UpdateContainer(containerID string, resources specs.LinuxResources) error {
   158  	return nil
   159  }
   160  
   161  // ProcessListContainer implements the VCSandbox function of the same name.
   162  func (s *Sandbox) ProcessListContainer(containerID string, options vc.ProcessListOptions) (vc.ProcessList, error) {
   163  	return nil, nil
   164  }
   165  
   166  // WaitProcess implements the VCSandbox function of the same name.
   167  func (s *Sandbox) WaitProcess(containerID, processID string) (int32, error) {
   168  	return 0, nil
   169  }
   170  
   171  // SignalProcess implements the VCSandbox function of the same name.
   172  func (s *Sandbox) SignalProcess(containerID, processID string, signal syscall.Signal, all bool) error {
   173  	return nil
   174  }
   175  
   176  // WinsizeProcess implements the VCSandbox function of the same name.
   177  func (s *Sandbox) WinsizeProcess(containerID, processID string, height, width uint32) error {
   178  	return nil
   179  }
   180  
   181  // IOStream implements the VCSandbox function of the same name.
   182  func (s *Sandbox) IOStream(containerID, processID string) (io.WriteCloser, io.Reader, io.Reader, error) {
   183  	return nil, nil, nil, nil
   184  }
   185  
   186  // AddDevice adds a device to sandbox
   187  func (s *Sandbox) AddDevice(info config.DeviceInfo) (api.Device, error) {
   188  	return nil, nil
   189  }
   190  
   191  // AddInterface implements the VCSandbox function of the same name.
   192  func (s *Sandbox) AddInterface(inf *vcTypes.Interface) (*vcTypes.Interface, error) {
   193  	return nil, nil
   194  }
   195  
   196  // RemoveInterface implements the VCSandbox function of the same name.
   197  func (s *Sandbox) RemoveInterface(inf *vcTypes.Interface) (*vcTypes.Interface, error) {
   198  	return nil, nil
   199  }
   200  
   201  // ListInterfaces implements the VCSandbox function of the same name.
   202  func (s *Sandbox) ListInterfaces() ([]*vcTypes.Interface, error) {
   203  	return nil, nil
   204  }
   205  
   206  // UpdateRoutes implements the VCSandbox function of the same name.
   207  func (s *Sandbox) UpdateRoutes(routes []*vcTypes.Route) ([]*vcTypes.Route, error) {
   208  	return nil, nil
   209  }
   210  
   211  // ListRoutes implements the VCSandbox function of the same name.
   212  func (s *Sandbox) ListRoutes() ([]*vcTypes.Route, error) {
   213  	return nil, nil
   214  }
   215  
   216  func (s *Sandbox) GetOOMEvent() (string, error) {
   217  	return "", nil
   218  }