Skip to content

Commit

Permalink
Fixing tc image and more (#107)
Browse files Browse the repository at this point in the history
* use go mod; autoremove fixes #97; pull tc image (default) fixes #40

* fix running go test with race detection (go 1.11 requires gcc)
  • Loading branch information
alexei-led authored Nov 15, 2018
1 parent 9482f6b commit 0c2dbec
Show file tree
Hide file tree
Showing 3,692 changed files with 42,957 additions and 584,402 deletions.
The diff you're trying to view is too large. We only load the first 3000 changed files.
105 changes: 0 additions & 105 deletions Gopkg.lock

This file was deleted.

119 changes: 0 additions & 119 deletions Gopkg.toml

This file was deleted.

2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.6.0
0.6.1
4 changes: 4 additions & 0 deletions cmd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -303,6 +303,10 @@ func initializeCLICommands() []cli.Command {
Name: "tc-image",
Usage: "Docker image with tc (iproute2 package); try 'gaiadocker/iproute2'",
},
cli.BoolTFlag{
Name: "pull-image",
Usage: "try to pull tc-image",
},
},
Usage: "emulate the properties of wide area networks",
ArgsUsage: fmt.Sprintf("containers (name, list of names, or RE2 regex if prefixed with %q", Re2Prefix),
Expand Down
14 changes: 10 additions & 4 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,11 +1,17 @@
#
# ----- Go Builder Image ------
#
FROM golang:1.11-alpine AS builder
FROM golang:1.11 AS builder

# curl git bash
RUN apt-get update && apt-get install -y --no-install-recommends \
curl \
git \
bash \
&& rm -rf /var/lib/apt/lists/*

# github-release - Github Release and upload artifacts
# go-junit-report - convert Go test into junit.xml format
RUN apk add --no-cache git bash curl || apk update && apk upgrade
RUN go get -v github.com/aktau/github-release && \
go get -v github.com/jstemmer/go-junit-report

Expand Down Expand Up @@ -64,10 +70,10 @@ ARG TAG_MESSAGE
ARG GITHUB_TOKEN

# build pumba for all platforms
RUN if [[ "$RELEASE" == true ]]; then VERSION=$(cat VERSION) hack/xbuild.sh; fi
RUN if [ $RELEASE = true ]; then VERSION=$(cat VERSION) hack/xbuild.sh; fi

# release to GitHub
RUN if [[ "$RELEASE" == true ]]; then hack/github_release.sh alexei-led pumba; fi
RUN if [ $RELEASE = true ]; then hack/github_release.sh alexei-led pumba; fi

#
# ------ Pumba runtime image ------
Expand Down
17 changes: 17 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
module github.com/alexei-led/pumba

require (
github.com/Microsoft/go-winio v0.4.11 // indirect
github.com/docker/distribution v2.6.2+incompatible // indirect
github.com/docker/docker v1.13.1
github.com/docker/go-connections v0.4.0
github.com/docker/go-units v0.3.3 // indirect
github.com/johntdyer/slack-go v0.0.0-20180213144715-95fac1160b22 // indirect
github.com/johntdyer/slackrus v0.0.0-20180518184837-f7aae3243a07
github.com/pkg/errors v0.8.0 // indirect
github.com/sirupsen/logrus v1.2.0
github.com/stevvooe/resumable v0.0.0-20180830230917-22b14a53ba50 // indirect
github.com/stretchr/testify v1.2.2
github.com/urfave/cli v1.20.0
golang.org/x/net v0.0.0-20181113165502-88d92db4c548
)
38 changes: 38 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
github.com/Microsoft/go-winio v0.4.11 h1:zoIOcVf0xPN1tnMVbTtEdI+P8OofVk3NObnwOQ6nK2Q=
github.com/Microsoft/go-winio v0.4.11/go.mod h1:VhR8bwka0BXejwEJY73c50VrPtXAaKcyvVC4A4RozmA=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/docker/distribution v2.6.2+incompatible h1:4FI6af79dfCS/CYb+RRtkSHw3q1L/bnDjG1PcPZtQhM=
github.com/docker/distribution v2.6.2+incompatible/go.mod h1:J2gT2udsDAN96Uj4KfcMRqY0/ypR+oyYUYmja8H+y+w=
github.com/docker/docker v1.13.1 h1:5VBhsO6ckUxB0A8CE5LlUJdXzik9cbEbBTQ/ggeml7M=
github.com/docker/docker v1.13.1/go.mod h1:eEKB0N0r5NX/I1kEveEz05bcu8tLC/8azJZsviup8Sk=
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.3.3 h1:Xk8S3Xj5sLGlG5g67hJmYMmUgXv5N4PhkjJHHqrwnTk=
github.com/docker/go-units v0.3.3/go.mod h1:fgPhTUdO+D/Jk86RDLlptpiXQzgHJF7gydDDbaIK4Dk=
github.com/johntdyer/slack-go v0.0.0-20180213144715-95fac1160b22 h1:jKUP9TQ0c7X3w6+IPyMit07RE42MtTWNd77sN2cHngQ=
github.com/johntdyer/slack-go v0.0.0-20180213144715-95fac1160b22/go.mod h1:u0Jo4f2dNlTJeeOywkM6bLwxq6gC3pZ9rEFHn3AhTdk=
github.com/johntdyer/slackrus v0.0.0-20180518184837-f7aae3243a07 h1:+kBG/8rjCa6vxJZbUjAiE4MQmBEBYc8nLEb51frnvBY=
github.com/johntdyer/slackrus v0.0.0-20180518184837-f7aae3243a07/go.mod h1:j1kV/8f3jowErEq4XyeypkCdvg5EeHkf0YCKCcq5Ybo=
github.com/konsorten/go-windows-terminal-sequences v1.0.1 h1:mweAR1A6xJ3oS2pRaGiHgQ4OO8tzTaLawm8vnODuwDk=
github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ=
github.com/pkg/errors v0.8.0 h1:WdK/asTD0HN+q6hsWO3/vpuAkAr+tw6aNJNDFFf0+qw=
github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/sirupsen/logrus v1.2.0 h1:juTguoYk5qI21pwyTXY3B3Y5cOTH3ZUyZCg1v/mihuo=
github.com/sirupsen/logrus v1.2.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo=
github.com/stevvooe/resumable v0.0.0-20180830230917-22b14a53ba50 h1:4bT0pPowCpQImewr+BjzfUKcuFW+KVyB8d1OF3b6oTI=
github.com/stevvooe/resumable v0.0.0-20180830230917-22b14a53ba50/go.mod h1:1pdIZTAHUz+HDKDVZ++5xg/duPlhKAIzw9qy42CWYp4=
github.com/stretchr/objx v0.1.1 h1:2vfRuCMp5sSVIDSqO8oNnWJq7mPa6KVP3iPIwFBuy8A=
github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/testify v1.2.2 h1:bSDNvY7ZPG5RlJ8otE/7V6gMiyenm9RtJ7IUVIAoJ1w=
github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
github.com/urfave/cli v1.20.0 h1:fDqGv3UG/4jbVl/QkFwEdddtEDjh/5Ov6X+0B/3bPaw=
github.com/urfave/cli v1.20.0/go.mod h1:70zkFmudgCuE/ngEzBv17Jvp/497gISqfk5gWijbERA=
golang.org/x/crypto v0.0.0-20180904163835-0709b304e793 h1:u+LnwYTOOW7Ukr/fppxEb1Nwz0AtPflrblfvUudpo+I=
golang.org/x/crypto v0.0.0-20180904163835-0709b304e793/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
golang.org/x/net v0.0.0-20181113165502-88d92db4c548 h1:lqFnrcY5rM6XXZ41MVa5mTlOBrBYultJDG1orIvlqPA=
golang.org/x/net v0.0.0-20181113165502-88d92db4c548/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33 h1:I6FyU15t786LL7oL/hn43zqTuEGr4PN7F4XJ1p4E3Y8=
golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
2 changes: 1 addition & 1 deletion hack/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
go_build() {
[ -d "${DIST}" ] && rm -rf "${DIST:?}/*"
[ -d "${DIST}" ] || mkdir -p "${DIST}"
CGO_ENABLED=0 go build \
CGO_ENABLED=0 GO111MODULE=on go build -mod vendor \
-ldflags "-s -w -X main.Version=${VERSION} -X main.GitCommit=${VCS_COMMIT_ID} -X main.GitBranch=${VCS_BRANCH_NAME} -X main.BuildTime=${BUILDTIME}" \
-v -o "${DIST}/pumba" ./cmd
}
Expand Down
2 changes: 1 addition & 1 deletion hack/github_release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ if [ -z "$TAG_MESSAGE" ]; then
fi
fi

if [[ "$DEBUG" = true ]]; then
if [ $DEBUG = true ]; then
echo "release --name \"v${RELEASE_TAG}\" --tag \"${RELEASE_TAG}\" --description \"${TAG_MESSAGE}\""
exit 0
fi
Expand Down
11 changes: 11 additions & 0 deletions hack/mockgen.Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
FROM golang:1.10-alpine

RUN apk add --no-cache git

RUN mkdir -p /go/src/github.com/alexei-led/pumba
WORKDIR /go/src/github.com/alexei-led/pumba
RUN go get github.com/vektra/mockery/.../

ENV CGO_ENABLED=0

ENTRYPOINT [ "/go/bin/mockery" ]
5 changes: 3 additions & 2 deletions hack/mockgen.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
#!/bin/sh

# get mockery tool
go get -u github.com/vektra/mockery/.../
# build Docker with mockery
docker build -t local/mockery -f hack/mockgen.Dockerfile .
alias mockery="docker run -it --rm -v ${PWD}:/go/src/github.com/alexei-led/pumba local/mockery"

# (re)generate mock for Docker APIClient interface
mockery -name APIClient -dir vendor/github.com/docker/docker/client
Expand Down
7 changes: 6 additions & 1 deletion hack/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,17 @@ mode=atomic

OS=$(uname)
race_flag="-race"
cgo_flag=1
if [ "$OS" = "Linux" ]; then
# check Alpine - alpine does not support race test
if [ -f "/etc/alpine-release" ]; then
race_flag=""
cgo_flag=0
fi
fi
if [ "$race_flag" != "" ]; then
echo "testing with race detection ..."
fi

generate_cover_data() {
[ -d "${COVER}" ] && rm -rf "${COVER:?}/*"
Expand All @@ -40,7 +45,7 @@ generate_cover_data() {
for pkg in "${pkgs[@]}"; do
f="${COVER}/$(echo $pkg | tr / -).cover"
tout="${COVER}/$(echo $pkg | tr / -)_tests.out"
CGO_ENABLED=0 go test -v $race_flag -covermode="$mode" -coverprofile="$f" "$pkg" | tee "$tout"
CGO_ENABLED=$cgo_flag go test -v $race_flag -covermode="$mode" -coverprofile="$f" "$pkg" | tee "$tout"
done

echo "mode: $mode" >"$profile"
Expand Down
Loading

0 comments on commit 0c2dbec

Please sign in to comment.