Skip to content

Commit

Permalink
fixed staticcheck and implemented host mode
Browse files Browse the repository at this point in the history
  • Loading branch information
steiler committed May 27, 2021
1 parent d9e885f commit 5221623
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions runtime/containerd/containerd.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ import (
"github.com/docker/go-units"
"github.com/google/shlex"
"github.com/opencontainers/runtime-spec/specs-go"
runtimespec "github.com/opencontainers/runtime-spec/specs-go"
log "github.com/sirupsen/logrus"
"github.com/srl-labs/containerlab/types"
"github.com/srl-labs/containerlab/utils"
Expand Down Expand Up @@ -113,7 +112,13 @@ func (c *ContainerdRuntime) CreateContainer(ctx context.Context, node *types.Nod

switch node.NetworkMode {
case "host":
opts = append(opts, oci.WithHostNamespace(specs.NetworkNamespace), oci.WithHostHostsFile, oci.WithHostResolvconf)
opts = append(opts,
oci.WithHostNamespace(specs.NetworkNamespace),
oci.WithHostHostsFile,
oci.WithHostResolvconf)
default:
// TODO: NETWORK

}

_, err = c.client.NewContainer(
Expand Down Expand Up @@ -145,9 +150,9 @@ func (c *ContainerdRuntime) CreateContainer(ctx context.Context, node *types.Nod
}

func WithSysctls(sysctls map[string]string) oci.SpecOpts {
return func(ctx context.Context, client oci.Client, c *containers.Container, s *runtimespec.Spec) error {
return func(ctx context.Context, client oci.Client, c *containers.Container, s *specs.Spec) error {
if s.Linux == nil {
s.Linux = &runtimespec.Linux{}
s.Linux = &specs.Linux{}
}
if s.Linux.Sysctl == nil {
s.Linux.Sysctl = make(map[string]string)
Expand Down

0 comments on commit 5221623

Please sign in to comment.