Skip to content

Commit

Permalink
change docker client package
Browse files Browse the repository at this point in the history
  • Loading branch information
karimra committed Sep 4, 2020
1 parent d9334de commit 91dea3b
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 15 deletions.
4 changes: 3 additions & 1 deletion clab/clab.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package clab

import "docker.io/go-docker"
import (
docker "github.com/docker/engine/client"
)

var debug bool

Expand Down
25 changes: 11 additions & 14 deletions clab/docker.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ import (
"strings"
"time"

"docker.io/go-docker/api/types"
"docker.io/go-docker/api/types/container"
"docker.io/go-docker/api/types/network"
"github.com/docker/docker/api/types"
"github.com/docker/docker/api/types/container"
"github.com/docker/docker/api/types/network"
log "github.com/sirupsen/logrus"
)

Expand Down Expand Up @@ -51,13 +51,13 @@ func (c *cLab) CreateBridge(ctx context.Context) (err error) {
networkOptions := types.NetworkCreate{
CheckDuplicate: true,
Driver: "bridge",
Scope: "local",
EnableIPv6: true,
IPAM: ipam,
Internal: false,
Attachable: false,
Ingress: false,
ConfigOnly: false,
//Scope: "local",
EnableIPv6: true,
IPAM: ipam,
Internal: false,
Attachable: false,
//Ingress: false,
//ConfigOnly: false,
}

var bridgeName string
Expand All @@ -70,7 +70,7 @@ func (c *cLab) CreateBridge(ctx context.Context) (err error) {
log.Debugf("Container network %s already exists", c.Conf.DockerInfo.Bridge)
nctx, cancel := context.WithTimeout(ctx, 10*time.Second)
defer cancel()
netResource, err := c.DockerClient.NetworkInspect(nctx, c.Conf.DockerInfo.Bridge, types.NetworkInspectOptions{})
netResource, err := c.DockerClient.NetworkInspect(nctx, c.Conf.DockerInfo.Bridge) //, types.NetworkInspectOptions{})
if err != nil {
return err
}
Expand Down Expand Up @@ -124,7 +124,6 @@ func (c *cLab) CreateBridge(ctx context.Context) (err error) {
return nil
}


// DeleteBridge deletes a docker bridge
func (c *cLab) DeleteBridge(ctx context.Context) (err error) {
nctx, cancel := context.WithTimeout(ctx, 10*time.Second)
Expand Down Expand Up @@ -187,7 +186,6 @@ func (c *cLab) CreateContainer(ctx context.Context, name string, node *Node) (er
return c.InspectContainer(ctx, node.LongName, node)
}


// StartContainer starts a docker container
func (c *cLab) StartContainer(ctx context.Context, name string, node *Node) (err error) {
log.Debug("Start container: ", name)
Expand Down Expand Up @@ -235,7 +233,6 @@ func (c *cLab) DeleteContainer(ctx context.Context, name string, node *Node) (er
return nil
}


// InspectContainer inspects a docker container
func (c *cLab) InspectContainer(ctx context.Context, id string, node *Node) (err error) {
nctx, cancel := context.WithTimeout(ctx, 10*time.Second)
Expand Down
2 changes: 2 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ require (
github.com/Microsoft/go-winio v0.4.14 // indirect
github.com/awalterschulze/gographviz v2.0.1+incompatible
github.com/docker/distribution v2.7.1+incompatible // indirect
github.com/docker/docker v1.13.1
github.com/docker/engine v1.13.1
github.com/docker/go-connections v0.4.0 // indirect
github.com/docker/go-units v0.4.0 // indirect
github.com/gogo/protobuf v1.3.1 // indirect
Expand Down
3 changes: 3 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@ github.com/dgryski/go-sip13 v0.0.0-20181026042036-e10d5fee7954/go.mod h1:vAd38F8
github.com/docker/distribution v2.7.1+incompatible h1:a5mlkVzth6W5A4fOsS3D2EO5BUmsJpcB+cRlLU7cSug=
github.com/docker/distribution v2.7.1+incompatible/go.mod h1:J2gT2udsDAN96Uj4KfcMRqY0/ypR+oyYUYmja8H+y+w=
github.com/docker/docker v1.13.1 h1:IkZjBSIc8hBjLpqeAbeE5mca5mNgeatLHBy3GO78BWo=
github.com/docker/docker v1.13.1/go.mod h1:eEKB0N0r5NX/I1kEveEz05bcu8tLC/8azJZsviup8Sk=
github.com/docker/engine v1.13.1 h1:Cks33UT9YBW5Xyc3MtGDq2IPgqfJtJ+qkFaxc2b0Euc=
github.com/docker/engine v1.13.1/go.mod h1:3CPr2caMgTHxxIAZgEMd3uLYPDlRvPqCpyeRf6ncPcY=
github.com/docker/go-connections v0.4.0 h1:El9xVISelRB7BuFusrZozjnkIM5YnzCViNKohAFqRJQ=
github.com/docker/go-connections v0.4.0/go.mod h1:Gbd7IOopHjR8Iph03tsViu4nIes5XhDvyHbTtUxmeec=
github.com/docker/go-units v0.4.0 h1:3uh0PgVws3nIA0Q+MwDC8yjEPf9zjRfZZWXZYDct3Tw=
Expand Down

0 comments on commit 91dea3b

Please sign in to comment.