Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: use govendor to depend on libnetwork #1445

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
6 changes: 3 additions & 3 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,15 @@ jobs:
- run:
name: use markdownlint v0.4.0 to lint markdown file (https://github.com/markdownlint/markdownlint)
command: |
find ./ -name "*.md" | grep -v vendor | grep -v extra | grep -v commandline | grep -v .github | grep -v swagger | grep -v api | xargs mdl -r ~MD010,~MD013,~MD024,~MD029,~MD033,~MD036
find ./ -name "*.md" | grep -v vendor | grep -v commandline | grep -v .github | grep -v swagger | grep -v api | xargs mdl -r ~MD010,~MD013,~MD024,~MD029,~MD033,~MD036
- run:
name: use opensource tool client9/misspell to correct commonly misspelled English words
command: |
find ./* -name "*" | grep -v extra | grep -v vendor | xargs misspell -error
find ./* -name "*" | grep -v vendor | xargs misspell -error
- run:
name: use ShellCheck (https://github.com/koalaman/shellcheck) to check the validateness of shell scripts in pouch repo
command: |
find ./ -name "*.sh" | grep -v vendor | grep -v extra | xargs shellcheck
find ./ -name "*.sh" | grep -v vendor | xargs shellcheck

code-check:
docker:
Expand Down
10 changes: 5 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
GOBUILD=go build
GOCLEAN=go clean
GOTEST=go test
GOPACKAGES=$(shell go list ./... | grep -v /vendor/ | grep -v /extra/ | sed 's/^_//')
GOPACKAGES=$(shell go list ./... | grep -v /vendor/ | sed 's/^_//')

# Binary name of CLI and Daemon
BINARY_NAME=pouchd
Copy link
Collaborator

@rudyfly rudyfly Jun 7, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

make pre in hack/build should be deleted libnetwork into GOPATH

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, but what do you suggest for this line in Makefile?

Expand Down Expand Up @@ -45,18 +45,18 @@ check: pre fmt lint vet validate-swagger
fmt: ## run go fmt
@echo $@
@which gofmt
@test -z "$$(gofmt -s -l . 2>/dev/null | grep -Fv 'vendor/' | grep -Fv 'extra/' | grep -v ".pb.go$$" | tee /dev/stderr)" || \
@test -z "$$(gofmt -s -l . 2>/dev/null | grep -Fv 'vendor/' | grep -v ".pb.go$$" | tee /dev/stderr)" || \
(echo "please format Go code with 'gofmt -s -w'" && false)
@test -z "$$(find . -path ./vendor -prune -o ! -path ./extra -prune -o ! -name timestamp.proto ! -name duration.proto -name '*.proto' -type f -exec grep -Hn -e "^ " {} \; | tee /dev/stderr)" || \
@test -z "$$(find . -path ./vendor -prune -o ! -name timestamp.proto ! -name duration.proto -name '*.proto' -type f -exec grep -Hn -e "^ " {} \; | tee /dev/stderr)" || \
(echo "please indent proto files with tabs only" && false)
@test -z "$$(find . -path ./vendor -prune -o ! -path ./extra -prune -o -name '*.proto' -type f -exec grep -Hn "Meta meta = " {} \; | grep -v '(gogoproto.nullable) = false' | tee /dev/stderr)" || \
@test -z "$$(find . -path ./vendor -prune -o -name '*.proto' -type f -exec grep -Hn "Meta meta = " {} \; | grep -v '(gogoproto.nullable) = false' | tee /dev/stderr)" || \
(echo "meta fields in proto files must have option (gogoproto.nullable) = false" && false)

.PHONY: lint
lint: ## run go lint
@echo $@
@which golint
@test -z "$$(golint ./... | grep -Fv 'vendor/' | grep -Fv 'extra' | grep -v ".pb.go:" | tee /dev/stderr)"
@test -z "$$(golint ./... | grep -Fv 'vendor/' | grep -v ".pb.go:" | tee /dev/stderr)"

.PHONY: vet
vet: ## run go vet
Expand Down
20 changes: 1 addition & 19 deletions daemon/mgr/network.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import (
"net"
"path"
"strings"
"time"

apitypes "github.com/alibaba/pouch/apis/types"
"github.com/alibaba/pouch/daemon/config"
Expand All @@ -16,7 +15,6 @@ import (
"github.com/alibaba/pouch/pkg/meta"
"github.com/alibaba/pouch/pkg/randomid"

netlog "github.com/Sirupsen/logrus"
"github.com/docker/go-connections/nat"
"github.com/docker/libnetwork"
nwconfig "github.com/docker/libnetwork/config"
Expand Down Expand Up @@ -75,8 +73,6 @@ func NewNetworkManager(cfg *config.Config, store *meta.Store, ctrMgr ContainerMg
cfg.NetworkConfig.ExecRoot = network.DefaultExecRoot
}

initNetworkLog(cfg)

// get active sandboxes
ctrs, err := ctrMgr.List(context.Background(),
func(c *Container) bool {
Expand Down Expand Up @@ -489,7 +485,7 @@ func networkOptions(create apitypes.NetworkCreateConfig) ([]libnetwork.NetworkOp
nwOptions = append(nwOptions, libnetwork.NetworkOptionDriverOpts(networkCreate.Options))

if create.Name == "ingress" {
nwOptions = append(nwOptions, libnetwork.NetworkOptionIngress())
nwOptions = append(nwOptions, libnetwork.NetworkOptionIngress(true))
}

if networkCreate.Internal {
Expand Down Expand Up @@ -542,20 +538,6 @@ func (nm *NetworkManager) getNetworkSandbox(id string) libnetwork.Sandbox {
return sb
}

// libnetwork's logrus version is different from pouchd,
// so we need to set libnetwork's logrus addintionly.
func initNetworkLog(cfg *config.Config) {
if cfg.Debug {
netlog.SetLevel(netlog.DebugLevel)
}

formatter := &netlog.TextFormatter{
FullTimestamp: true,
TimestampFormat: time.RFC3339Nano,
}
netlog.SetFormatter(formatter)
}

func endpointOptions(n libnetwork.Network, endpoint *types.Endpoint) ([]libnetwork.EndpointOption, error) {
var createOptions []libnetwork.EndpointOption
epConfig := endpoint.EndpointConfig
Expand Down
6 changes: 2 additions & 4 deletions docs/test/test.md
Original file line number Diff line number Diff line change
Expand Up @@ -95,13 +95,11 @@ Then copy or clone pouch source code to the GOPATH:
/go/src/github.com/alibaba/pouch
```

The following steps are also needed to make sure libnetwork package could be found:
Make a build folder to use later:

```
BUILDPATH=/tmp/pouchbuild
mkdir -p $BUILDPATH/src/github.com/docker
cp -r /go/src/github.com/alibaba/pouch/extra/libnetwork $BUILDPATH/src/github.com/docker/libnetwork
export GOPATH=$GOPATH:$BUILDPATH:$BUILDPATH/src/github.com/docker/libnetwork/Godeps/_workspace
export GOPATH=$GOPATH:$BUILDPATH
```

And please notice that files in `/tmp` directory may be deleted after reboot.
Expand Down
1 change: 0 additions & 1 deletion extra/libnetwork/.dockerignore

This file was deleted.

39 changes: 0 additions & 39 deletions extra/libnetwork/.gitignore

This file was deleted.

7 changes: 0 additions & 7 deletions extra/libnetwork/Dockerfile.build

This file was deleted.

Loading