From cb244fb800871a71f99ce400d7f63ee166e0df16 Mon Sep 17 00:00:00 2001 From: the-redback Date: Tue, 2 Apr 2019 17:14:18 +0600 Subject: [PATCH] build binary in go1.10 xref: https://github.com/kubedb/project/issues/449 --- .gitignore | 3 +++ Gopkg.lock | 17 +++++++++++++++++ Gopkg.toml | 34 ++++++++++++++++++++++++++++++++++ Makefile | 15 +++++++++++++++ peer-finder.go | 3 +-- 5 files changed, 70 insertions(+), 2 deletions(-) create mode 100644 .gitignore create mode 100644 Gopkg.lock create mode 100644 Gopkg.toml diff --git a/.gitignore b/.gitignore new file mode 100644 index 00000000..bd4a54f6 --- /dev/null +++ b/.gitignore @@ -0,0 +1,3 @@ +.idea/ +peer-finder +vendor/ diff --git a/Gopkg.lock b/Gopkg.lock new file mode 100644 index 00000000..975d4f01 --- /dev/null +++ b/Gopkg.lock @@ -0,0 +1,17 @@ +# This file is autogenerated, do not edit; changes may be undone by the next 'dep ensure'. + + +[[projects]] + branch = "master" + digest = "1:f5fb6c4c9e14909a66efe7d3e49403234cd52523eb3997c5753a880635e8be2d" + name = "k8s.io/apimachinery" + packages = ["pkg/util/sets"] + pruneopts = "UT" + revision = "91ffda0f6be27b20a4ab1b54df88b68210775fd9" + +[solve-meta] + analyzer-name = "dep" + analyzer-version = 1 + input-imports = ["k8s.io/apimachinery/pkg/util/sets"] + solver-name = "gps-cdcl" + solver-version = 1 diff --git a/Gopkg.toml b/Gopkg.toml new file mode 100644 index 00000000..1353813d --- /dev/null +++ b/Gopkg.toml @@ -0,0 +1,34 @@ +# Gopkg.toml example +# +# Refer to https://golang.github.io/dep/docs/Gopkg.toml.html +# for detailed Gopkg.toml documentation. +# +# required = ["github.com/user/thing/cmd/thing"] +# ignored = ["github.com/user/project/pkgX", "bitbucket.org/user/project/pkgA/pkgY"] +# +# [[constraint]] +# name = "github.com/user/project" +# version = "1.0.0" +# +# [[constraint]] +# name = "github.com/user/project2" +# branch = "dev" +# source = "github.com/myfork/project2" +# +# [[override]] +# name = "github.com/x/y" +# version = "2.4.0" +# +# [prune] +# non-go = false +# go-tests = true +# unused-packages = true + + +[[constraint]] + branch = "master" + name = "k8s.io/apimachinery" + +[prune] + go-tests = true + unused-packages = true diff --git a/Makefile b/Makefile index a450c056..5b56b9ef 100644 --- a/Makefile +++ b/Makefile @@ -12,6 +12,8 @@ # See the License for the specific language governing permissions and # limitations under the License. +PKG = kmodules.xyz/peer-finder + all: push TAG = 0.1 @@ -31,3 +33,16 @@ push: container clean: rm -f peer-finder + +build: clean + dep ensure -v + docker run \ + --rm \ + -u $$(id -u):$$(id -g) \ + -v /tmp:/.cache \ + -v "$$(pwd):/go/src/$(PKG)" \ + -w /go/src/$(PKG) \ + -e GOOS=linux \ + -e GOARCH=amd64 \ + golang:1.10 \ + go build diff --git a/peer-finder.go b/peer-finder.go index 9547c73d..0005f2f3 100644 --- a/peer-finder.go +++ b/peer-finder.go @@ -65,8 +65,7 @@ func shellOut(sendStdin, script string) { cmd := exec.Command("bash", "-c", fmt.Sprintf("echo -e '%v' | %v", sendStdin, script)) cmd.Stdout = os.Stdout cmd.Stderr = os.Stderr - err := cmd.Run() - if err != nil { + if err := cmd.Run(); err != nil { log.Fatalf("Failed to execute %v:, err: %v", script, err) } }