mirror of
https://github.com/aljazceru/kata-containers.git
synced 2026-02-23 15:34:28 +01:00
runtime: consolidate types definition
We do not need the vc types translation for network data structures. Just use the protocol buffer definitions. Fixes: #415 Signed-off-by: Peng Tao <bergwolf@hyper.sh>
This commit is contained in:
@@ -1,49 +0,0 @@
|
||||
// Copyright 2018 Intel Corporation.
|
||||
//
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
//
|
||||
|
||||
package types
|
||||
|
||||
// IPAddress describes an IP address.
|
||||
type IPAddress struct {
|
||||
Family int
|
||||
Address string
|
||||
Mask string
|
||||
}
|
||||
|
||||
// Interface describes a network interface.
|
||||
type Interface struct {
|
||||
Device string
|
||||
Name string
|
||||
IPAddresses []*IPAddress
|
||||
Mtu uint64
|
||||
RawFlags uint32
|
||||
HwAddr string
|
||||
// pciAddr is the PCI address in the format "bridgeAddr/deviceAddr".
|
||||
// Here, bridgeAddr is the address at which the bridge is attached on the root bus,
|
||||
// while deviceAddr is the address at which the network device is attached on the bridge.
|
||||
PciAddr string
|
||||
// LinkType defines the type of interface described by this structure.
|
||||
// The expected values are the one that are defined by the netlink
|
||||
// library, regarding each type of link. Here is a non exhaustive
|
||||
// list: "veth", "macvtap", "vlan", "macvlan", "tap", ...
|
||||
LinkType string
|
||||
}
|
||||
|
||||
// Route describes a network route.
|
||||
type Route struct {
|
||||
Dest string
|
||||
Gateway string
|
||||
Device string
|
||||
Source string
|
||||
Scope uint32
|
||||
}
|
||||
|
||||
type ARPNeighbor struct {
|
||||
ToIPAddress *IPAddress
|
||||
Device string
|
||||
LLAddr string
|
||||
State int
|
||||
Flags int
|
||||
}
|
||||
@@ -23,7 +23,7 @@ import (
|
||||
vc "github.com/kata-containers/kata-containers/src/runtime/virtcontainers"
|
||||
"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"
|
||||
pbTypes "github.com/kata-containers/kata-containers/src/runtime/virtcontainers/pkg/agent/protocols"
|
||||
"github.com/kata-containers/kata-containers/src/runtime/virtcontainers/types"
|
||||
specs "github.com/opencontainers/runtime-spec/specs-go"
|
||||
"github.com/sirupsen/logrus"
|
||||
@@ -246,7 +246,7 @@ func (m *VCMock) AddDevice(ctx context.Context, sandboxID string, info config.De
|
||||
}
|
||||
|
||||
// AddInterface implements the VC function of the same name.
|
||||
func (m *VCMock) AddInterface(ctx context.Context, sandboxID string, inf *vcTypes.Interface) (*vcTypes.Interface, error) {
|
||||
func (m *VCMock) AddInterface(ctx context.Context, sandboxID string, inf *pbTypes.Interface) (*pbTypes.Interface, error) {
|
||||
if m.AddInterfaceFunc != nil {
|
||||
return m.AddInterfaceFunc(ctx, sandboxID, inf)
|
||||
}
|
||||
@@ -255,7 +255,7 @@ func (m *VCMock) AddInterface(ctx context.Context, sandboxID string, inf *vcType
|
||||
}
|
||||
|
||||
// RemoveInterface implements the VC function of the same name.
|
||||
func (m *VCMock) RemoveInterface(ctx context.Context, sandboxID string, inf *vcTypes.Interface) (*vcTypes.Interface, error) {
|
||||
func (m *VCMock) RemoveInterface(ctx context.Context, sandboxID string, inf *pbTypes.Interface) (*pbTypes.Interface, error) {
|
||||
if m.RemoveInterfaceFunc != nil {
|
||||
return m.RemoveInterfaceFunc(ctx, sandboxID, inf)
|
||||
}
|
||||
@@ -264,7 +264,7 @@ func (m *VCMock) RemoveInterface(ctx context.Context, sandboxID string, inf *vcT
|
||||
}
|
||||
|
||||
// ListInterfaces implements the VC function of the same name.
|
||||
func (m *VCMock) ListInterfaces(ctx context.Context, sandboxID string) ([]*vcTypes.Interface, error) {
|
||||
func (m *VCMock) ListInterfaces(ctx context.Context, sandboxID string) ([]*pbTypes.Interface, error) {
|
||||
if m.ListInterfacesFunc != nil {
|
||||
return m.ListInterfacesFunc(ctx, sandboxID)
|
||||
}
|
||||
@@ -273,7 +273,7 @@ func (m *VCMock) ListInterfaces(ctx context.Context, sandboxID string) ([]*vcTyp
|
||||
}
|
||||
|
||||
// UpdateRoutes implements the VC function of the same name.
|
||||
func (m *VCMock) UpdateRoutes(ctx context.Context, sandboxID string, routes []*vcTypes.Route) ([]*vcTypes.Route, error) {
|
||||
func (m *VCMock) UpdateRoutes(ctx context.Context, sandboxID string, routes []*pbTypes.Route) ([]*pbTypes.Route, error) {
|
||||
if m.UpdateRoutesFunc != nil {
|
||||
return m.UpdateRoutesFunc(ctx, sandboxID, routes)
|
||||
}
|
||||
@@ -282,7 +282,7 @@ func (m *VCMock) UpdateRoutes(ctx context.Context, sandboxID string, routes []*v
|
||||
}
|
||||
|
||||
// ListRoutes implements the VC function of the same name.
|
||||
func (m *VCMock) ListRoutes(ctx context.Context, sandboxID string) ([]*vcTypes.Route, error) {
|
||||
func (m *VCMock) ListRoutes(ctx context.Context, sandboxID string) ([]*pbTypes.Route, error) {
|
||||
if m.ListRoutesFunc != nil {
|
||||
return m.ListRoutesFunc(ctx, sandboxID)
|
||||
}
|
||||
|
||||
@@ -13,7 +13,7 @@ import (
|
||||
|
||||
vc "github.com/kata-containers/kata-containers/src/runtime/virtcontainers"
|
||||
"github.com/kata-containers/kata-containers/src/runtime/virtcontainers/factory"
|
||||
vcTypes "github.com/kata-containers/kata-containers/src/runtime/virtcontainers/pkg/types"
|
||||
pbTypes "github.com/kata-containers/kata-containers/src/runtime/virtcontainers/pkg/agent/protocols"
|
||||
"github.com/kata-containers/kata-containers/src/runtime/virtcontainers/types"
|
||||
"github.com/sirupsen/logrus"
|
||||
"github.com/stretchr/testify/assert"
|
||||
@@ -694,7 +694,7 @@ func TestVCMockAddInterface(t *testing.T) {
|
||||
assert.Error(err)
|
||||
assert.True(IsMockError(err))
|
||||
|
||||
m.AddInterfaceFunc = func(ctx context.Context, sid string, inf *vcTypes.Interface) (*vcTypes.Interface, error) {
|
||||
m.AddInterfaceFunc = func(ctx context.Context, sid string, inf *pbTypes.Interface) (*pbTypes.Interface, error) {
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
@@ -721,7 +721,7 @@ func TestVCMockRemoveInterface(t *testing.T) {
|
||||
assert.Error(err)
|
||||
assert.True(IsMockError(err))
|
||||
|
||||
m.RemoveInterfaceFunc = func(ctx context.Context, sid string, inf *vcTypes.Interface) (*vcTypes.Interface, error) {
|
||||
m.RemoveInterfaceFunc = func(ctx context.Context, sid string, inf *pbTypes.Interface) (*pbTypes.Interface, error) {
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
@@ -748,7 +748,7 @@ func TestVCMockListInterfaces(t *testing.T) {
|
||||
assert.Error(err)
|
||||
assert.True(IsMockError(err))
|
||||
|
||||
m.ListInterfacesFunc = func(ctx context.Context, sid string) ([]*vcTypes.Interface, error) {
|
||||
m.ListInterfacesFunc = func(ctx context.Context, sid string) ([]*pbTypes.Interface, error) {
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
@@ -775,7 +775,7 @@ func TestVCMockUpdateRoutes(t *testing.T) {
|
||||
assert.Error(err)
|
||||
assert.True(IsMockError(err))
|
||||
|
||||
m.UpdateRoutesFunc = func(ctx context.Context, sid string, routes []*vcTypes.Route) ([]*vcTypes.Route, error) {
|
||||
m.UpdateRoutesFunc = func(ctx context.Context, sid string, routes []*pbTypes.Route) ([]*pbTypes.Route, error) {
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
@@ -802,7 +802,7 @@ func TestVCMockListRoutes(t *testing.T) {
|
||||
assert.Error(err)
|
||||
assert.True(IsMockError(err))
|
||||
|
||||
m.ListRoutesFunc = func(ctx context.Context, sid string) ([]*vcTypes.Route, error) {
|
||||
m.ListRoutesFunc = func(ctx context.Context, sid string) ([]*pbTypes.Route, error) {
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
|
||||
@@ -13,7 +13,7 @@ import (
|
||||
vc "github.com/kata-containers/kata-containers/src/runtime/virtcontainers"
|
||||
"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"
|
||||
pbTypes "github.com/kata-containers/kata-containers/src/runtime/virtcontainers/pkg/agent/protocols"
|
||||
"github.com/kata-containers/kata-containers/src/runtime/virtcontainers/types"
|
||||
specs "github.com/opencontainers/runtime-spec/specs-go"
|
||||
)
|
||||
@@ -196,27 +196,27 @@ func (s *Sandbox) AddDevice(info config.DeviceInfo) (api.Device, error) {
|
||||
}
|
||||
|
||||
// AddInterface implements the VCSandbox function of the same name.
|
||||
func (s *Sandbox) AddInterface(inf *vcTypes.Interface) (*vcTypes.Interface, error) {
|
||||
func (s *Sandbox) AddInterface(inf *pbTypes.Interface) (*pbTypes.Interface, error) {
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
// RemoveInterface implements the VCSandbox function of the same name.
|
||||
func (s *Sandbox) RemoveInterface(inf *vcTypes.Interface) (*vcTypes.Interface, error) {
|
||||
func (s *Sandbox) RemoveInterface(inf *pbTypes.Interface) (*pbTypes.Interface, error) {
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
// ListInterfaces implements the VCSandbox function of the same name.
|
||||
func (s *Sandbox) ListInterfaces() ([]*vcTypes.Interface, error) {
|
||||
func (s *Sandbox) ListInterfaces() ([]*pbTypes.Interface, error) {
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
// UpdateRoutes implements the VCSandbox function of the same name.
|
||||
func (s *Sandbox) UpdateRoutes(routes []*vcTypes.Route) ([]*vcTypes.Route, error) {
|
||||
func (s *Sandbox) UpdateRoutes(routes []*pbTypes.Route) ([]*pbTypes.Route, error) {
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
// ListRoutes implements the VCSandbox function of the same name.
|
||||
func (s *Sandbox) ListRoutes() ([]*vcTypes.Route, error) {
|
||||
func (s *Sandbox) ListRoutes() ([]*pbTypes.Route, error) {
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
|
||||
@@ -13,7 +13,7 @@ import (
|
||||
vc "github.com/kata-containers/kata-containers/src/runtime/virtcontainers"
|
||||
"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"
|
||||
pbTypes "github.com/kata-containers/kata-containers/src/runtime/virtcontainers/pkg/agent/protocols"
|
||||
"github.com/kata-containers/kata-containers/src/runtime/virtcontainers/types"
|
||||
specs "github.com/opencontainers/runtime-spec/specs-go"
|
||||
"github.com/sirupsen/logrus"
|
||||
@@ -59,11 +59,11 @@ type Sandbox struct {
|
||||
WinsizeProcessFunc func(containerID, processID string, height, width uint32) error
|
||||
IOStreamFunc func(containerID, processID string) (io.WriteCloser, io.Reader, io.Reader, error)
|
||||
AddDeviceFunc func(info config.DeviceInfo) (api.Device, error)
|
||||
AddInterfaceFunc func(inf *vcTypes.Interface) (*vcTypes.Interface, error)
|
||||
RemoveInterfaceFunc func(inf *vcTypes.Interface) (*vcTypes.Interface, error)
|
||||
ListInterfacesFunc func() ([]*vcTypes.Interface, error)
|
||||
UpdateRoutesFunc func(routes []*vcTypes.Route) ([]*vcTypes.Route, error)
|
||||
ListRoutesFunc func() ([]*vcTypes.Route, error)
|
||||
AddInterfaceFunc func(inf *pbTypes.Interface) (*pbTypes.Interface, error)
|
||||
RemoveInterfaceFunc func(inf *pbTypes.Interface) (*pbTypes.Interface, error)
|
||||
ListInterfacesFunc func() ([]*pbTypes.Interface, error)
|
||||
UpdateRoutesFunc func(routes []*pbTypes.Route) ([]*pbTypes.Route, error)
|
||||
ListRoutesFunc func() ([]*pbTypes.Route, error)
|
||||
UpdateRuntimeMetricsFunc func() error
|
||||
GetAgentMetricsFunc func() (string, error)
|
||||
StatsFunc func() (vc.SandboxStats, error)
|
||||
@@ -111,10 +111,10 @@ type VCMock struct {
|
||||
|
||||
AddDeviceFunc func(ctx context.Context, sandboxID string, info config.DeviceInfo) (api.Device, error)
|
||||
|
||||
AddInterfaceFunc func(ctx context.Context, sandboxID string, inf *vcTypes.Interface) (*vcTypes.Interface, error)
|
||||
RemoveInterfaceFunc func(ctx context.Context, sandboxID string, inf *vcTypes.Interface) (*vcTypes.Interface, error)
|
||||
ListInterfacesFunc func(ctx context.Context, sandboxID string) ([]*vcTypes.Interface, error)
|
||||
UpdateRoutesFunc func(ctx context.Context, sandboxID string, routes []*vcTypes.Route) ([]*vcTypes.Route, error)
|
||||
ListRoutesFunc func(ctx context.Context, sandboxID string) ([]*vcTypes.Route, error)
|
||||
AddInterfaceFunc func(ctx context.Context, sandboxID string, inf *pbTypes.Interface) (*pbTypes.Interface, error)
|
||||
RemoveInterfaceFunc func(ctx context.Context, sandboxID string, inf *pbTypes.Interface) (*pbTypes.Interface, error)
|
||||
ListInterfacesFunc func(ctx context.Context, sandboxID string) ([]*pbTypes.Interface, error)
|
||||
UpdateRoutesFunc func(ctx context.Context, sandboxID string, routes []*pbTypes.Route) ([]*pbTypes.Route, error)
|
||||
ListRoutesFunc func(ctx context.Context, sandboxID string) ([]*pbTypes.Route, error)
|
||||
CleanupContainerFunc func(ctx context.Context, sandboxID, containerID string, force bool) error
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user