Files
kata-containers/virtcontainers/pkg/vcmock/sandbox.go
Peng Tao eb23771d5a api: add sandbox release API
It disconnects the agent connection and removes the sandbox
from global sandbox list.

A new option `LongLiveConn` is also added to kata
agent's configuration. When set, the API caller is expected
to call sandbox.Release() to drop the agent connection explicitly.

`proxyBuiltIn` is moved out of agent state because we can always
retrieve it from sandbox config instead.

Fixes: #217

Signed-off-by: Peng Tao <bergwolf@gmail.com>
2018-04-24 15:30:53 +08:00

57 lines
1.3 KiB
Go

// Copyright (c) 2017 Intel Corporation
//
// SPDX-License-Identifier: Apache-2.0
//
package vcmock
import (
vc "github.com/kata-containers/runtime/virtcontainers"
)
// ID implements the VCSandbox function of the same name.
func (p *Sandbox) ID() string {
return p.MockID
}
// Annotations implements the VCSandbox function of the same name.
func (p *Sandbox) Annotations(key string) (string, error) {
return p.MockAnnotations[key], nil
}
// SetAnnotations implements the VCSandbox function of the same name.
func (p *Sandbox) SetAnnotations(annotations map[string]string) error {
return nil
}
// GetAnnotations implements the VCSandbox function of the same name.
func (p *Sandbox) GetAnnotations() map[string]string {
return p.MockAnnotations
}
// GetAllContainers implements the VCSandbox function of the same name.
func (p *Sandbox) GetAllContainers() []vc.VCContainer {
var ifa = make([]vc.VCContainer, len(p.MockContainers))
for i, v := range p.MockContainers {
ifa[i] = v
}
return ifa
}
// GetContainer implements the VCSandbox function of the same name.
func (p *Sandbox) GetContainer(containerID string) vc.VCContainer {
for _, c := range p.MockContainers {
if c.MockID == containerID {
return c
}
}
return &Container{}
}
// Release implements the VCSandbox function of the same name.
func (p *Sandbox) Release() error {
return nil
}