Skip to content

Commit

Permalink
runtime: Replace use of vcTypes with pbTypes for network
Browse files Browse the repository at this point in the history
This applies the same kind of changes that Peng Tao introduced in
5b15e9e to the newly restored interfaces.

Fixes: kata-containers#722

Signed-off-by: Christophe de Dinechin <dinechin@redhat.com>
  • Loading branch information
c3d committed Nov 16, 2021
1 parent a9d89b3 commit 766ead2
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 16 deletions.
10 changes: 5 additions & 5 deletions src/runtime/cmd/kata-runtime/network.go
Expand Up @@ -11,7 +11,7 @@ import (
"fmt"
"os"

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/urfave/cli"
Expand Down Expand Up @@ -152,7 +152,7 @@ func networkModifyCommand(ctx context.Context, containerID, input string, opType
}
switch opType {
case interfaceType:
var inf, resultingInf *vcTypes.Interface
var inf, resultingInf *pbTypes.Interface
if err = json.NewDecoder(f).Decode(&inf); err != nil {
return err
}
Expand All @@ -171,7 +171,7 @@ func networkModifyCommand(ctx context.Context, containerID, input string, opType
}
json.NewEncoder(output).Encode(resultingInf)
case routeType:
var routes, resultingRoutes []*vcTypes.Route
var routes, resultingRoutes []*pbTypes.Route
if err = json.NewDecoder(f).Decode(&routes); err != nil {
return err
}
Expand Down Expand Up @@ -209,15 +209,15 @@ func networkListCommand(ctx context.Context, containerID string, opType networkT

switch opType {
case interfaceType:
var interfaces []*vcTypes.Interface
var interfaces []*pbTypes.Interface
interfaces, err = vci.ListInterfaces(ctx, sandboxID)
if err != nil {
kataLog.WithField("existing-interfaces", fmt.Sprintf("%+v", interfaces)).
WithError(err).Error("list interfaces failed")
}
json.NewEncoder(file).Encode(interfaces)
case routeType:
var routes []*vcTypes.Route
var routes []*pbTypes.Route
routes, err = vci.ListRoutes(ctx, sandboxID)
if err != nil {
kataLog.WithField("resulting-routes", fmt.Sprintf("%+v", routes)).
Expand Down
12 changes: 6 additions & 6 deletions src/runtime/virtcontainers/implementation.go
Expand Up @@ -15,7 +15,7 @@ import (

"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"
Expand Down Expand Up @@ -148,27 +148,27 @@ func (impl *VCImpl) AddDevice(ctx context.Context, sandboxID string, info config
}

// AddInterface implements the VC function of the same name.
func (impl *VCImpl) AddInterface(ctx context.Context, sandboxID string, inf *vcTypes.Interface) (*vcTypes.Interface, error) {
func (impl *VCImpl) AddInterface(ctx context.Context, sandboxID string, inf *pbTypes.Interface) (*pbTypes.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) {
func (impl *VCImpl) RemoveInterface(ctx context.Context, sandboxID string, inf *pbTypes.Interface) (*pbTypes.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) {
func (impl *VCImpl) ListInterfaces(ctx context.Context, sandboxID string) ([]*pbTypes.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) {
func (impl *VCImpl) UpdateRoutes(ctx context.Context, sandboxID string, routes []*pbTypes.Route) ([]*pbTypes.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) {
func (impl *VCImpl) ListRoutes(ctx context.Context, sandboxID string) ([]*pbTypes.Route, error) {
return ListRoutes(ctx, sandboxID)
}

Expand Down
10 changes: 5 additions & 5 deletions src/runtime/virtcontainers/interfaces.go
Expand Up @@ -48,11 +48,11 @@ type VC interface {

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)
AddInterface(ctx context.Context, sandboxID string, inf *pbTypes.Interface) (*pbTypes.Interface, error)
RemoveInterface(ctx context.Context, sandboxID string, inf *pbTypes.Interface) (*pbTypes.Interface, error)
ListInterfaces(ctx context.Context, sandboxID string) ([]*pbTypes.Interface, error)
UpdateRoutes(ctx context.Context, sandboxID string, routes []*pbTypes.Route) ([]*pbTypes.Route, error)
ListRoutes(ctx context.Context, sandboxID string) ([]*pbTypes.Route, error)

CleanupContainer(ctx context.Context, sandboxID, containerID string, force bool) error
}
Expand Down

0 comments on commit 766ead2

Please sign in to comment.