From 6f7aa960839f239ff7660dcb73c639758e49c6d2 Mon Sep 17 00:00:00 2001 From: Yuryshev Date: Thu, 14 Mar 2019 13:18:16 +0300 Subject: [PATCH 01/10] Some improvements for Makefile: 1. make goals: build, clean, install - incorporated from README.md 2. build options: OPTS=GO111MODULE=on --- .gitignore | 7 ++++++ Makefile | 72 +++++++++++++++++++++++++++++++++++++++++++++--------- 2 files changed, 68 insertions(+), 11 deletions(-) diff --git a/.gitignore b/.gitignore index 793b9b9bc5..ba8cde020a 100644 --- a/.gitignore +++ b/.gitignore @@ -16,3 +16,10 @@ pkg/node/apps/ pkg/node/bar/ pkg/node/foo/ + + +/manager-node +/skywire-node +/skywire-cli +/manager-node +/therealssh-cli diff --git a/Makefile b/Makefile index ecf2473bc3..757330cc9e 100644 --- a/Makefile +++ b/Makefile @@ -1,24 +1,74 @@ +OPTS=GO111MODULE=on + +build: dep apps bin + +clean: + rm -rf ./apps + rm -f ./skywire-node ./skywire-cli ./manager-node ./thereallssh-cli + +install: + ${OPTS} go install ./cmd/skywire-node ./cmd/skywire-cli ./cmd/manager-node ./cmd/therealssh-cli + lint: ## Run linters. Use make install-linters first. - # GO111MODULE=on vendorcheck ./... # TODO: fix vendor check - GO111MODULE=on golangci-lint run -c .golangci.yml ./... + # ${OPTS} vendorcheck ./... # TODO: fix vendor check + ${OPTS} golangci-lint run -c .golangci.yml ./... # The govet version in golangci-lint is out of date and has spurious warnings, run it separately - GO111MODULE=on go vet -all ./... + ${OPTS} go vet -all ./... install-linters: ## Install linters GO111MODULE=off go get -u github.com/FiloSottile/vendorcheck # For some reason this install method is not recommended, see https://github.com/golangci/golangci-lint#install # However, they suggest `curl ... | bash` which we should not do - GO111MODULE=on go get -u github.com/golangci/golangci-lint/cmd/golangci-lint - GO111MODULE=on go get -u golang.org/x/tools/cmd/goimports + ${OPTS} go get -u github.com/golangci/golangci-lint/cmd/golangci-lint + ${OPTS} go get -u golang.org/x/tools/cmd/goimports format: ## Formats the code. Must have goimports installed (use make install-linters). - GO111MODULE=on goimports -w -local github.com/skycoin/skywire ./pkg - GO111MODULE=on goimports -w -local github.com/skycoin/skywire ./cmd - GO111MODULE=on goimports -w -local github.com/skycoin/skywire ./internal + ${OPTS} goimports -w -local github.com/skycoin/skywire ./pkg + ${OPTS} goimports -w -local github.com/skycoin/skywire ./cmd + ${OPTS} goimports -w -local github.com/skycoin/skywire ./internal dep: ## sorts dependencies - GO111MODULE=on go mod vendor -v + ${OPTS} go mod vendor -v test: ## Run tests for net - GO111MODULE=on go test -race -tags no_ci -cover -timeout=5m ./internal/... - GO111MODULE=on go test -race -tags no_ci -cover -timeout=5m ./pkg/... + ${OPTS} go test -race -tags no_ci -cover -timeout=5m ./internal/... + ${OPTS} go test -race -tags no_ci -cover -timeout=5m ./pkg/... + + +build: apps bin + +# Apps +apps: chat helloworld therealproxy therealproxy-client therealssh thereallssh-client + +chat: + ${OPTS} go build -o ./apps/chat.v1.0 ./cmd/apps/chat + +helloworld: + ${OPTS} go build -o ./apps/helloworld.v1.0 ./cmd/apps/helloworld + +therealproxy: + ${OPTS} go build -o ./apps/therealproxy.v1.0 ./cmd/apps/therealproxy + +therealproxy-client: + ${OPTS} go build -o ./apps/therealproxy-client.v1.0 ./cmd/apps/therealproxy-client + +therealssh: + ${OPTS} go build -o ./apps/therealssh.v1.0 ./cmd/apps/therealssh + +thereallssh-client: + ${OPTS} go build -o ./apps/therealssh-client.v1.0 ./cmd/apps/therealssh-client + +# Bin +bin: skywire-node skywire-cli manager-node therealssh-cli + +skywire-node: + ${OPTS} go build -o ./skywire-node ./cmd/skywire-node + +skywire-cli: + ${OPTS} go build -o ./skywire-cli ./cmd/skywire-cli + +manager-node: + ${OPTS} go build -o ./manager-node ./cmd/manager-node + +therealssh-cli: + ${OPTS} go build -o ./therealssh-cli ./cmd/therealssh-cli From 99bd30a60ab673786b0217b4b359bd06101732a9 Mon Sep 17 00:00:00 2001 From: Yuryshev Date: Thu, 14 Mar 2019 16:05:36 +0300 Subject: [PATCH 02/10] Created goals for running dockerized `skywire-node`: - `make node` - will create and start dockerized `skywire-node` - `make refresh-node` - stops containerized `skywire-node`, copies `skywire-node` binary and starts dockerized `skywire-node` again Docker creation can be customized with: DOCKER_IMAGE=buildpack-deps:stretch-scm # docker image to use for running skywire-node. `golang` is OK too DOCKER_NETWORK=SKYNET DOCKER_NODE=SKY01 --- .gitignore | 1 + Makefile | 35 ++++++++++++++++++++++++++++++++++- 2 files changed, 35 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index ba8cde020a..0e7250e17d 100644 --- a/.gitignore +++ b/.gitignore @@ -23,3 +23,4 @@ pkg/node/foo/ /skywire-cli /manager-node /therealssh-cli +/node diff --git a/Makefile b/Makefile index 757330cc9e..30ccf8bd45 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,8 @@ -OPTS=GO111MODULE=on +OPTS=GO111MODULE=on +DOCKER_IMAGE=buildpack-deps:stretch-scm # docker image to use for running skywire-node. `golang` is OK too +DOCKER_NETWORK=SKYNET +DOCKER_NODE=SKY01 + build: dep apps bin @@ -72,3 +76,32 @@ manager-node: therealssh-cli: ${OPTS} go build -o ./therealssh-cli ./cmd/therealssh-cli + +# Node + +docker-clean: + -docker network rm ${DOCKER_NETWORK} + -docker container rm --force ${DOCKER_NODE} + +docker-network: + -docker network create ${DOCKER_NETWORK} + +docker-volume: build + mkdir -p ./node + cp ./skywire-node ./node + cp -r ./apps ./node/apps + ./skywire-cli config ./node/skywire.json + cat ./node/skywire.json|grep static_public_key |cut -d ':' -f2 |tr -d '"'','' ' > ./node/PK + +node: docker-clean docker-network docker-volume + docker run -d -v $(shell pwd)/node:/sky --network=${DOCKER_NETWORK} --name=${DOCKER_NODE} ${DOCKER_IMAGE} bash -c "cd /sky && ./skywire-node" + +run: + ./skywire-node + +node-stop: + -docker container stop ${DOCKER_NODE} + +refresh-node: node-stop + cp ./skywire-node ./node + docker container start ${DOCKER_NODE} \ No newline at end of file From 4d2e0addbbad4c6f57b791cd75829ee2ff72da82 Mon Sep 17 00:00:00 2001 From: Yuryshev Date: Thu, 14 Mar 2019 16:32:31 +0300 Subject: [PATCH 03/10] Added possibility to customize `make ` with environment variables E.g. ``` DOCKER_NETWORK=SKYNET_DEV DOCKER_IMAGE=golang DOCKER_NODE=SKY42 make node ``` --- Makefile | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Makefile b/Makefile index 30ccf8bd45..d126c24fc1 100644 --- a/Makefile +++ b/Makefile @@ -1,7 +1,7 @@ -OPTS=GO111MODULE=on -DOCKER_IMAGE=buildpack-deps:stretch-scm # docker image to use for running skywire-node. `golang` is OK too -DOCKER_NETWORK=SKYNET -DOCKER_NODE=SKY01 +OPTS?=GO111MODULE=on +DOCKER_IMAGE?=buildpack-deps:stretch-scm # docker image to use for running skywire-node. `golang` is OK too +DOCKER_NETWORK?=SKYNET +DOCKER_NODE?=SKY01 build: dep apps bin From 7121cc675442dbac130648257ddf14af6fc3c47e Mon Sep 17 00:00:00 2001 From: Yuryshev Date: Thu, 14 Mar 2019 22:06:59 +0300 Subject: [PATCH 04/10] Creation of skywire-runner image 1. Added skywire-runner.Dockerfile to create slim (74.3MB) image for running skywire 2. Added `make docker-image` for creating this image 3. `make docker-image` is a subgoal for make node. skywire-runner - is default docker image --- Makefile | 7 +++++-- skywire-runner.Dockerfile | 7 +++++++ 2 files changed, 12 insertions(+), 2 deletions(-) create mode 100644 skywire-runner.Dockerfile diff --git a/Makefile b/Makefile index d126c24fc1..fc6dc0c058 100644 --- a/Makefile +++ b/Makefile @@ -1,5 +1,5 @@ OPTS?=GO111MODULE=on -DOCKER_IMAGE?=buildpack-deps:stretch-scm # docker image to use for running skywire-node. `golang` is OK too +DOCKER_IMAGE?=skywire-runner # buildpack-deps:stretch-scm # docker image to use for running skywire-node. `golang` is OK too DOCKER_NETWORK?=SKYNET DOCKER_NODE?=SKY01 @@ -79,6 +79,9 @@ therealssh-cli: # Node +docker-image: + docker image build --tag=skywire-runner --rm - < skywire-runner.Dockerfile + docker-clean: -docker network rm ${DOCKER_NETWORK} -docker container rm --force ${DOCKER_NODE} @@ -93,7 +96,7 @@ docker-volume: build ./skywire-cli config ./node/skywire.json cat ./node/skywire.json|grep static_public_key |cut -d ':' -f2 |tr -d '"'','' ' > ./node/PK -node: docker-clean docker-network docker-volume +node: docker-clean docker-image docker-network docker-volume docker run -d -v $(shell pwd)/node:/sky --network=${DOCKER_NETWORK} --name=${DOCKER_NODE} ${DOCKER_IMAGE} bash -c "cd /sky && ./skywire-node" run: diff --git a/skywire-runner.Dockerfile b/skywire-runner.Dockerfile new file mode 100644 index 0000000000..b22dd75fc4 --- /dev/null +++ b/skywire-runner.Dockerfile @@ -0,0 +1,7 @@ +FROM debian:stretch-slim + +RUN apt-get update && apt-get install -y --no-install-recommends \ + ca-certificates \ + curl \ + wget \ + && rm -rf /var/lib/apt/lists/* From 8a5323d786e106474394230da26c708c51a44fea Mon Sep 17 00:00:00 2001 From: Yuryshev Date: Fri, 15 Mar 2019 08:39:18 +0300 Subject: [PATCH 05/10] Commited changes in modules after `make install-linters && make dep` --- go.mod | 19 ++++---- go.sum | 20 +++++++++ .../mattn/go-isatty/isatty_android.go | 6 +++ .../github.com/sirupsen/logrus/CHANGELOG.md | 25 +++++++++++ vendor/github.com/sirupsen/logrus/README.md | 1 + vendor/github.com/sirupsen/logrus/alt_exit.go | 18 ++++++-- vendor/github.com/sirupsen/logrus/entry.go | 33 ++++++++++---- vendor/github.com/sirupsen/logrus/exported.go | 6 +++ .../sirupsen/logrus/json_formatter.go | 22 ++++++++-- vendor/github.com/sirupsen/logrus/logger.go | 12 +++++- vendor/github.com/sirupsen/logrus/logrus.go | 2 +- .../sirupsen/logrus/text_formatter.go | 43 +++++++++++++------ vendor/golang.org/x/sys/cpu/cpu_aix_ppc64.go | 30 +++++++++++++ .../golang.org/x/sys/cpu/cpu_other_ppc64x.go | 12 ------ vendor/golang.org/x/sys/unix/mkall.sh | 4 +- vendor/golang.org/x/sys/unix/syscall_aix.go | 2 + .../x/sys/unix/zsyscall_aix_ppc64.go | 8 ++++ .../x/sys/unix/zsyscall_aix_ppc64_gc.go | 10 +++++ .../x/sys/unix/zsyscall_aix_ppc64_gccgo.go | 9 ++++ vendor/modules.txt | 10 ++--- 20 files changed, 231 insertions(+), 61 deletions(-) create mode 100644 vendor/golang.org/x/sys/cpu/cpu_aix_ppc64.go delete mode 100644 vendor/golang.org/x/sys/cpu/cpu_other_ppc64x.go diff --git a/go.mod b/go.mod index 8af6b1bf92..a495d60161 100644 --- a/go.mod +++ b/go.mod @@ -26,7 +26,7 @@ require ( github.com/go-toolsmith/typep v1.0.0 // indirect github.com/gogo/protobuf v1.2.1 // indirect github.com/golang/lint v0.0.0-20190301231843-5614ed5bae6f // indirect - github.com/golang/protobuf v1.3.0 // indirect + github.com/golang/protobuf v1.3.1 // indirect github.com/golang/snappy v0.0.1 // indirect github.com/golangci/errcheck v0.0.0-20181223084120-ef45e06d44b6 // indirect github.com/golangci/go-tools v0.0.0-20190124090046-35a9f45a5db0 // indirect @@ -49,12 +49,13 @@ require ( github.com/konsorten/go-windows-terminal-sequences v1.0.2 // indirect github.com/kr/pty v1.1.3 github.com/mattn/go-colorable v0.1.1 // indirect - github.com/mattn/go-isatty v0.0.6 // indirect + github.com/mattn/go-isatty v0.0.7 // indirect github.com/mgutz/ansi v0.0.0-20170206155736-9520e82c474b // indirect github.com/microcosm-cc/bluemonday v1.0.2 // indirect github.com/mitchellh/go-homedir v1.1.0 github.com/nbutton23/zxcvbn-go v0.0.0-20180912185939-ae427f1e4c1d // indirect github.com/onsi/ginkgo v1.8.0 // indirect + github.com/onsi/gomega v1.5.0 // indirect github.com/openzipkin/zipkin-go v0.1.5 // indirect github.com/pkg/errors v0.8.1 // indirect github.com/prometheus/client_model v0.0.0-20190129233127-fd36f4220a90 // indirect @@ -77,29 +78,29 @@ require ( github.com/shurcooL/reactions v0.0.0-20181222204718-145cd5e7f3d1 // indirect github.com/shurcooL/sanitized_anchor_name v1.0.0 // indirect github.com/shurcooL/webdavfs v0.0.0-20181215192745-5988b2d638f6 // indirect - github.com/sirupsen/logrus v1.3.0 // indirect + github.com/sirupsen/logrus v1.4.0 // indirect github.com/skycoin/skycoin v0.25.1 github.com/spf13/afero v1.2.1 // indirect github.com/spf13/cobra v0.0.3 github.com/spf13/jwalterweatherman v1.1.0 // indirect - github.com/spf13/viper v1.3.1 // indirect + github.com/spf13/viper v1.3.2 // indirect github.com/stretchr/testify v1.3.0 github.com/ugorji/go/codec v0.0.0-20190309163734-c4a1c341dc93 // indirect go.etcd.io/bbolt v1.3.2 go.opencensus.io v0.19.1 // indirect go4.org v0.0.0-20190218023631-ce4c26f7be8e // indirect golang.org/x/build v0.0.0-20190309003043-4067b185a9c7 // indirect - golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2 + golang.org/x/crypto v0.0.0-20190313024323-a1f597ede03a golang.org/x/exp v0.0.0-20190306152737-a1d7652674e8 // indirect golang.org/x/lint v0.0.0-20190301231843-5614ed5bae6f // indirect - golang.org/x/net v0.0.0-20190310074541-c10a0554eabf + golang.org/x/net v0.0.0-20190313220215-9f648a60d977 golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421 // indirect golang.org/x/perf v0.0.0-20190306144031-151b6387e3f2 // indirect - golang.org/x/sys v0.0.0-20190310054646-10058d7d4faa // indirect + golang.org/x/sys v0.0.0-20190312061237-fead79001313 // indirect golang.org/x/time v0.0.0-20190308202827-9d24e82272b4 // indirect - golang.org/x/tools v0.0.0-20190308174544-00c44ba9c14f // indirect + golang.org/x/tools v0.0.0-20190315044204-8b67d361bba2 // indirect google.golang.org/genproto v0.0.0-20190307195333-5fe7a883aa19 // indirect honnef.co/go/tools v0.0.0-20190215041234-466a0476246c // indirect - mvdan.cc/unparam v0.0.0-20190213212834-da01123e7b4f // indirect + mvdan.cc/unparam v0.0.0-20190310220240-1b9ccfa71afe // indirect sourcegraph.com/sqs/pbtypes v1.0.0 // indirect ) diff --git a/go.sum b/go.sum index d0e4dd2a1f..28dc0a2255 100644 --- a/go.sum +++ b/go.sum @@ -109,6 +109,7 @@ github.com/golang/mock v1.2.0 h1:28o5sBqPkBsMGnC6b4MvE2TzSr5/AT4c/1fLqVGIwlk= github.com/golang/mock v1.2.0/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A= github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= github.com/golang/protobuf v1.3.0/go.mod h1:Qd/q+1AKNOZr9uGQzbzCmRO6sUih6GTPZv6a1/R87v0= +github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= github.com/golang/snappy v0.0.0-20180518054509-2e65f85255db/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q= github.com/golang/snappy v0.0.1/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q= github.com/golangci/check v0.0.0-20180506172741-cfe4005ccda2 h1:23T5iq8rbUYlhpt5DB4XJkc6BU31uODLD1o1gKvZmD0= @@ -220,6 +221,8 @@ github.com/mattn/go-isatty v0.0.4/go.mod h1:M+lRXTBqGeGNdLjl/ufCoiOlB5xdOkqRJdNx github.com/mattn/go-isatty v0.0.5/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hdxcsrc5s= github.com/mattn/go-isatty v0.0.6 h1:SrwhHcpV4nWrMGdNcC2kXpMfcBVYGDuTArqyhocJgvA= github.com/mattn/go-isatty v0.0.6/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hdxcsrc5s= +github.com/mattn/go-isatty v0.0.7 h1:UvyT9uN+3r7yLEYSlJsbQGdsaB/a0DlgWP3pql6iwOc= +github.com/mattn/go-isatty v0.0.7/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hdxcsrc5s= github.com/mattn/goveralls v0.0.2/go.mod h1:8d1ZMHsd7fW6IRPKQh46F2WRpyib5/X4FOpevwGNQEw= github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0= github.com/mgutz/ansi v0.0.0-20170206155736-9520e82c474b h1:j7+1HpAFS1zy5+Q4qx1fWh90gTKwiN4QCGoY9TWyyO4= @@ -235,6 +238,7 @@ github.com/mitchellh/mapstructure v1.1.2 h1:fmNYVwqnSfB9mZU6OS2O6GsXM+wcskZDuKQz github.com/mitchellh/mapstructure v1.1.2/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y= github.com/mozilla/tls-observatory v0.0.0-20180409132520-8791a200eb40/go.mod h1:SrKMQvPiws7F7iqYp8/TX+IhxCYhzr6N/1yb8cwHsGk= github.com/mozilla/tls-observatory v0.0.0-20190213200604-ab2edce230fc/go.mod h1:SrKMQvPiws7F7iqYp8/TX+IhxCYhzr6N/1yb8cwHsGk= +github.com/mozilla/tls-observatory v0.0.0-20190313211306-43961c0c7a1f/go.mod h1:SrKMQvPiws7F7iqYp8/TX+IhxCYhzr6N/1yb8cwHsGk= github.com/mwitkow/go-conntrack v0.0.0-20161129095857-cc309e4a2223/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U= github.com/nbutton23/zxcvbn-go v0.0.0-20160627004424-a22cb81b2ecd/go.mod h1:o96djdrsSGy3AWPyBgZMAGfxZNfgntdJG+11KU4QvbU= github.com/nbutton23/zxcvbn-go v0.0.0-20171102151520-eafdab6b0663/go.mod h1:o96djdrsSGy3AWPyBgZMAGfxZNfgntdJG+11KU4QvbU= @@ -249,6 +253,7 @@ github.com/onsi/ginkgo v1.8.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+W github.com/onsi/gomega v0.0.0-20170829124025-dcabb60a477c/go.mod h1:C1qb7wdrVGGVU+Z6iS04AVkA3Q65CEZX59MT0QO5uiA= github.com/onsi/gomega v1.4.2/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1CpauHY= github.com/onsi/gomega v1.4.3/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1CpauHY= +github.com/onsi/gomega v1.5.0/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1CpauHY= github.com/openzipkin/zipkin-go v0.1.1/go.mod h1:NtoC/o8u3JlF1lSlyPNswIbeQH9bJTmOf0Erfk+hxe8= github.com/openzipkin/zipkin-go v0.1.3/go.mod h1:NtoC/o8u3JlF1lSlyPNswIbeQH9bJTmOf0Erfk+hxe8= github.com/openzipkin/zipkin-go v0.1.5/go.mod h1:8NDCjKHoHW1XOp/vf3lClHem0b91r4433B67KXyKXAQ= @@ -330,6 +335,8 @@ github.com/sirupsen/logrus v1.0.5/go.mod h1:pMByvHTf9Beacp5x1UXfOR9xyW/9antXMhjM github.com/sirupsen/logrus v1.2.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo= github.com/sirupsen/logrus v1.3.0 h1:hI/7Q+DtNZ2kINb6qt/lS+IyXnHQe9e90POfeewL/ME= github.com/sirupsen/logrus v1.3.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo= +github.com/sirupsen/logrus v1.4.0 h1:yKenngtzGh+cUSSh6GWbxW2abRqhYUSR/t/6+2QqNvE= +github.com/sirupsen/logrus v1.4.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo= github.com/skycoin/skycoin v0.25.1 h1:4tYXHiTX00pFydjUWHmqSnAYfrJ59xsa9pfmEu7tki8= github.com/skycoin/skycoin v0.25.1/go.mod h1:78nHjQzd8KG0jJJVL/j0xMmrihXi70ti63fh8vXScJw= github.com/sourcegraph/annotate v0.0.0-20160123013949-f4cad6c6324d/go.mod h1:UdhH50NIW0fCiwBSr0co2m7BnFLdv4fQTgdqdJTHFeE= @@ -354,6 +361,8 @@ github.com/spf13/pflag v1.0.3/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnIn github.com/spf13/viper v1.0.2/go.mod h1:A8kyI5cUJhb8N+3pkfONlcEcZbueH6nhAm0Fq7SrnBM= github.com/spf13/viper v1.3.1 h1:5+8j8FTpnFV4nEImW/ofkzEt8VoOiLXxdYIDsB73T38= github.com/spf13/viper v1.3.1/go.mod h1:ZiWeW+zYFKm7srdB9IoDzzZXaJaI5eL9QjNiN/DMA2s= +github.com/spf13/viper v1.3.2 h1:VUFqw5KcqRf7i70GOzW7N+Q7+gxVBkSSqiXB12+JQ4M= +github.com/spf13/viper v1.3.2/go.mod h1:ZiWeW+zYFKm7srdB9IoDzzZXaJaI5eL9QjNiN/DMA2s= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= @@ -380,6 +389,8 @@ golang.org/x/crypto v0.0.0-20190219172222-a4c6cb3142f2 h1:NwxKRvbkH5MsNkvOtPZi3/ golang.org/x/crypto v0.0.0-20190219172222-a4c6cb3142f2/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2 h1:VklqNMn3ovrHsnt90PveolxSbWFaJdECFbxSq0Mqo2M= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= +golang.org/x/crypto v0.0.0-20190313024323-a1f597ede03a h1:YX8ljsm6wXlHZO+aRz9Exqr0evNhKRNe5K/gi+zKh4U= +golang.org/x/crypto v0.0.0-20190313024323-a1f597ede03a/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190306152737-a1d7652674e8/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/lint v0.0.0-20180702182130-06c8688daad7/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= @@ -402,6 +413,9 @@ golang.org/x/net v0.0.0-20190213061140-3a22650c66bd h1:HuTn7WObtcDo9uEEU7rEqL0jY golang.org/x/net v0.0.0-20190213061140-3a22650c66bd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20190310074541-c10a0554eabf h1:J7RqX9u0J9ZB37CGaFc2VC+QZZT6E6jnDbrboEFVo0U= golang.org/x/net v0.0.0-20190310074541-c10a0554eabf/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= +golang.org/x/net v0.0.0-20190313220215-9f648a60d977 h1:actzWV6iWn3GLqN8dZjzsB+CLt+gaV2+wsxroxiQI8I= +golang.org/x/net v0.0.0-20190313220215-9f648a60d977/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= golang.org/x/oauth2 v0.0.0-20181017192945-9dcd33a902f4/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= golang.org/x/oauth2 v0.0.0-20181120190819-8f65e3013eba/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= @@ -429,6 +443,8 @@ golang.org/x/sys v0.0.0-20190220154126-629670e5acc5/go.mod h1:STP8DvDyc/dI5b8T5h golang.org/x/sys v0.0.0-20190222072716-a9d3bda3a223/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190310054646-10058d7d4faa h1:lqti/xP+yD/6zH5TqEwx2MilNIJY5Vbc6Qr8J3qyPIQ= golang.org/x/sys v0.0.0-20190310054646-10058d7d4faa/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20190312061237-fead79001313 h1:pczuHS43Cp2ktBEEmLwScxgjWsBSzdaQiKzUyf3DTTc= +golang.org/x/sys v0.0.0-20190312061237-fead79001313/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/text v0.0.0-20170915090833-1cbadb444a80/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.0 h1:g61tztE5qeGQ89tm6NTjjM9VPIm088od1l6aSorWRWg= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= @@ -454,6 +470,8 @@ golang.org/x/tools v0.0.0-20190213192042-740235f6c0d8/go.mod h1:n7NCudcB/nEzxVGm golang.org/x/tools v0.0.0-20190226205152-f727befe758c/go.mod h1:9Yl7xja0Znq3iFh3HoIrodX9oNMXvdceNzlUR8zjMvY= golang.org/x/tools v0.0.0-20190308174544-00c44ba9c14f h1:SUQ6L9W8e5xt2GFO9s+i18JGITAfem+a0AQuFU8Ls74= golang.org/x/tools v0.0.0-20190308174544-00c44ba9c14f/go.mod h1:25r3+/G6/xytQM8iWZKq3Hn0kr0rgFKPUNVEL/dr3z4= +golang.org/x/tools v0.0.0-20190315044204-8b67d361bba2 h1:UW7QBl+AuPLMXy5g3iGofcPmCH+CajjwwKguuuJCS3E= +golang.org/x/tools v0.0.0-20190315044204-8b67d361bba2/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= google.golang.org/api v0.0.0-20180910000450-7ca32eb868bf/go.mod h1:4mhQ8q/RsB7i+udVvVy5NUi08OU8ZlA0gRVgrF7VFY0= google.golang.org/api v0.0.0-20181030000543-1d582fd0359e/go.mod h1:4mhQ8q/RsB7i+udVvVy5NUi08OU8ZlA0gRVgrF7VFY0= google.golang.org/api v0.0.0-20181220000619-583d854617af/go.mod h1:4mhQ8q/RsB7i+udVvVy5NUi08OU8ZlA0gRVgrF7VFY0= @@ -502,6 +520,8 @@ mvdan.cc/lint v0.0.0-20170908181259-adc824a0674b/go.mod h1:2odslEg/xrtNQqCYg2/jC mvdan.cc/unparam v0.0.0-20190124213536-fbb59629db34/go.mod h1:H6SUd1XjIs+qQCyskXg5OFSrilMRUkD8ePJpHKDPaeY= mvdan.cc/unparam v0.0.0-20190213212834-da01123e7b4f h1:XvwkLMTuxURoI2xB1vHtkP05pWiEJyZWbA9z2NWeJuo= mvdan.cc/unparam v0.0.0-20190213212834-da01123e7b4f/go.mod h1:BnhuWBAqxH3+J5bDybdxgw5ZfS+DsVd4iylsKQePN8o= +mvdan.cc/unparam v0.0.0-20190310220240-1b9ccfa71afe h1:Ekmnp+NcP2joadI9pbK4Bva87QKZSeY7le//oiMrc9g= +mvdan.cc/unparam v0.0.0-20190310220240-1b9ccfa71afe/go.mod h1:BnhuWBAqxH3+J5bDybdxgw5ZfS+DsVd4iylsKQePN8o= sourcegraph.com/sourcegraph/go-diff v0.5.0/go.mod h1:kuch7UrkMzY0X+p9CRK03kfuPQ2zzQcaEFbx8wA8rck= sourcegraph.com/sourcegraph/go-diff v0.5.1-0.20190210232911-dee78e514455 h1:qoQ5Kt+Zm+GXBtz49YwD3juBhr/E0U25jO6bBzxW6NI= sourcegraph.com/sourcegraph/go-diff v0.5.1-0.20190210232911-dee78e514455/go.mod h1:kuch7UrkMzY0X+p9CRK03kfuPQ2zzQcaEFbx8wA8rck= diff --git a/vendor/github.com/mattn/go-isatty/isatty_android.go b/vendor/github.com/mattn/go-isatty/isatty_android.go index fe559a4939..d3567cb5bf 100644 --- a/vendor/github.com/mattn/go-isatty/isatty_android.go +++ b/vendor/github.com/mattn/go-isatty/isatty_android.go @@ -15,3 +15,9 @@ func IsTerminal(fd uintptr) bool { _, _, err := syscall.Syscall6(syscall.SYS_IOCTL, fd, ioctlReadTermios, uintptr(unsafe.Pointer(&termios)), 0, 0, 0) return err == 0 } + +// IsCygwinTerminal return true if the file descriptor is a cygwin or msys2 +// terminal. This is also always false on this environment. +func IsCygwinTerminal(fd uintptr) bool { + return false +} diff --git a/vendor/github.com/sirupsen/logrus/CHANGELOG.md b/vendor/github.com/sirupsen/logrus/CHANGELOG.md index cb85d9f9f6..9978b415a4 100644 --- a/vendor/github.com/sirupsen/logrus/CHANGELOG.md +++ b/vendor/github.com/sirupsen/logrus/CHANGELOG.md @@ -1,3 +1,28 @@ +# 1.4.0 +This new release introduces: + * Add `DeferExitHandler`, similar to `RegisterExitHandler` but prepending the handler to the list of handlers (semantically like `defer`) (#848). + * Add `CallerPrettyfier` to `JSONFormatter` and `TextFormatter (#909, #911) + * Add `Entry.WithContext()` and `Entry.Context`, to set a context on entries to be used e.g. in hooks (#919). + +Fixes: + * Fix wrong method calls `Logger.Print` and `Logger.Warningln` (#893). + * Update `Entry.Logf` to not do string formatting unless the log level is enabled (#903) + * Fix infinite recursion on unknown `Level.String()` (#907) + * Fix race condition in `getCaller` (#916). + + +# 1.3.0 +This new release introduces: + * Log, Logf, Logln functions for Logger and Entry that take a Level + +Fixes: + * Building prometheus node_exporter on AIX (#840) + * Race condition in TextFormatter (#468) + * Travis CI import path (#868) + * Remove coloured output on Windows (#862) + * Pointer to func as field in JSONFormatter (#870) + * Properly marshal Levels (#873) + # 1.2.0 This new release introduces: * A new method `SetReportCaller` in the `Logger` to enable the file, line and calling function from which the trace has been issued diff --git a/vendor/github.com/sirupsen/logrus/README.md b/vendor/github.com/sirupsen/logrus/README.md index 3987310551..a4796eb07d 100644 --- a/vendor/github.com/sirupsen/logrus/README.md +++ b/vendor/github.com/sirupsen/logrus/README.md @@ -365,6 +365,7 @@ Third party logging formatters: * [`logstash`](https://github.com/bshuster-repo/logrus-logstash-hook). Logs fields as [Logstash](http://logstash.net) Events. * [`prefixed`](https://github.com/x-cray/logrus-prefixed-formatter). Displays log entry source along with alternative layout. * [`zalgo`](https://github.com/aybabtme/logzalgo). Invoking the P͉̫o̳̼̊w̖͈̰͎e̬͔̭͂r͚̼̹̲ ̫͓͉̳͈ō̠͕͖̚f̝͍̠ ͕̲̞͖͑Z̖̫̤̫ͪa͉̬͈̗l͖͎g̳̥o̰̥̅!̣͔̲̻͊̄ ̙̘̦̹̦. +* [`nested-logrus-formatter`](https://github.com/antonfisher/nested-logrus-formatter). Converts logrus fields to a nested structure. You can define your formatter by implementing the `Formatter` interface, requiring a `Format` method. `Format` takes an `*Entry`. `entry.Data` is a diff --git a/vendor/github.com/sirupsen/logrus/alt_exit.go b/vendor/github.com/sirupsen/logrus/alt_exit.go index 8af90637a9..8fd189e1cc 100644 --- a/vendor/github.com/sirupsen/logrus/alt_exit.go +++ b/vendor/github.com/sirupsen/logrus/alt_exit.go @@ -51,9 +51,9 @@ func Exit(code int) { os.Exit(code) } -// RegisterExitHandler adds a Logrus Exit handler, call logrus.Exit to invoke -// all handlers. The handlers will also be invoked when any Fatal log entry is -// made. +// RegisterExitHandler appends a Logrus Exit handler to the list of handlers, +// call logrus.Exit to invoke all handlers. The handlers will also be invoked when +// any Fatal log entry is made. // // This method is useful when a caller wishes to use logrus to log a fatal // message but also needs to gracefully shutdown. An example usecase could be @@ -62,3 +62,15 @@ func Exit(code int) { func RegisterExitHandler(handler func()) { handlers = append(handlers, handler) } + +// DeferExitHandler prepends a Logrus Exit handler to the list of handlers, +// call logrus.Exit to invoke all handlers. The handlers will also be invoked when +// any Fatal log entry is made. +// +// This method is useful when a caller wishes to use logrus to log a fatal +// message but also needs to gracefully shutdown. An example usecase could be +// closing database connections, or sending a alert that the application is +// closing. +func DeferExitHandler(handler func()) { + handlers = append([]func(){handler}, handlers...) +} diff --git a/vendor/github.com/sirupsen/logrus/entry.go b/vendor/github.com/sirupsen/logrus/entry.go index df6d188def..3d2c9e0fbb 100644 --- a/vendor/github.com/sirupsen/logrus/entry.go +++ b/vendor/github.com/sirupsen/logrus/entry.go @@ -2,6 +2,7 @@ package logrus import ( "bytes" + "context" "fmt" "os" "reflect" @@ -69,6 +70,9 @@ type Entry struct { // When formatter is called in entry.log(), a Buffer may be set to entry Buffer *bytes.Buffer + // Contains the context set by the user. Useful for hook processing etc. + Context context.Context + // err may contain a field formatting error err string } @@ -97,6 +101,12 @@ func (entry *Entry) WithError(err error) *Entry { return entry.WithField(ErrorKey, err) } +// Add a context to the Entry. +func (entry *Entry) WithContext(ctx context.Context) *Entry { + entry.Context = ctx + return entry +} + // Add a single field to the Entry. func (entry *Entry) WithField(key string, value interface{}) *Entry { return entry.WithFields(Fields{key: value}) @@ -130,12 +140,12 @@ func (entry *Entry) WithFields(fields Fields) *Entry { data[k] = v } } - return &Entry{Logger: entry.Logger, Data: data, Time: entry.Time, err: fieldErr} + return &Entry{Logger: entry.Logger, Data: data, Time: entry.Time, err: fieldErr, Context: entry.Context} } // Overrides the time of the Entry. func (entry *Entry) WithTime(t time.Time) *Entry { - return &Entry{Logger: entry.Logger, Data: entry.Data, Time: t, err: entry.err} + return &Entry{Logger: entry.Logger, Data: entry.Data, Time: t, err: entry.err, Context: entry.Context} } // getPackageName reduces a fully qualified function name to the package name @@ -156,20 +166,23 @@ func getPackageName(f string) string { // getCaller retrieves the name of the first non-logrus calling function func getCaller() *runtime.Frame { - // Restrict the lookback frames to avoid runaway lookups - pcs := make([]uintptr, maximumCallerDepth) - depth := runtime.Callers(minimumCallerDepth, pcs) - frames := runtime.CallersFrames(pcs[:depth]) // cache this package's fully-qualified name callerInitOnce.Do(func() { - logrusPackage = getPackageName(runtime.FuncForPC(pcs[0]).Name()) + pcs := make([]uintptr, 2) + _ = runtime.Callers(0, pcs) + logrusPackage = getPackageName(runtime.FuncForPC(pcs[1]).Name()) // now that we have the cache, we can skip a minimum count of known-logrus functions - // XXX this is dubious, the number of frames may vary store an entry in a logger interface + // XXX this is dubious, the number of frames may vary minimumCallerDepth = knownLogrusFrames }) + // Restrict the lookback frames to avoid runaway lookups + pcs := make([]uintptr, maximumCallerDepth) + depth := runtime.Callers(minimumCallerDepth, pcs) + frames := runtime.CallersFrames(pcs[:depth]) + for f, again := frames.Next(); again; f, again = frames.Next() { pkg := getPackageName(f.Function) @@ -298,7 +311,9 @@ func (entry *Entry) Panic(args ...interface{}) { // Entry Printf family functions func (entry *Entry) Logf(level Level, format string, args ...interface{}) { - entry.Log(level, fmt.Sprintf(format, args...)) + if entry.Logger.IsLevelEnabled(level) { + entry.Log(level, fmt.Sprintf(format, args...)) + } } func (entry *Entry) Tracef(format string, args ...interface{}) { diff --git a/vendor/github.com/sirupsen/logrus/exported.go b/vendor/github.com/sirupsen/logrus/exported.go index 7342613c37..62fc2f2193 100644 --- a/vendor/github.com/sirupsen/logrus/exported.go +++ b/vendor/github.com/sirupsen/logrus/exported.go @@ -1,6 +1,7 @@ package logrus import ( + "context" "io" "time" ) @@ -55,6 +56,11 @@ func WithError(err error) *Entry { return std.WithField(ErrorKey, err) } +// WithContext creates an entry from the standard logger and adds a context to it. +func WithContext(ctx context.Context) *Entry { + return std.WithContext(ctx) +} + // WithField creates an entry from the standard logger and adds a field to // it. If you want multiple fields, use `WithFields`. // diff --git a/vendor/github.com/sirupsen/logrus/json_formatter.go b/vendor/github.com/sirupsen/logrus/json_formatter.go index 2605753599..098a21a067 100644 --- a/vendor/github.com/sirupsen/logrus/json_formatter.go +++ b/vendor/github.com/sirupsen/logrus/json_formatter.go @@ -4,6 +4,7 @@ import ( "bytes" "encoding/json" "fmt" + "runtime" ) type fieldKey string @@ -42,6 +43,12 @@ type JSONFormatter struct { // } FieldMap FieldMap + // CallerPrettyfier can be set by the user to modify the content + // of the function and file keys in the json data when ReportCaller is + // activated. If any of the returned value is the empty string the + // corresponding key will be removed from json fields. + CallerPrettyfier func(*runtime.Frame) (function string, file string) + // PrettyPrint will indent all json logs PrettyPrint bool } @@ -82,8 +89,17 @@ func (f *JSONFormatter) Format(entry *Entry) ([]byte, error) { data[f.FieldMap.resolve(FieldKeyMsg)] = entry.Message data[f.FieldMap.resolve(FieldKeyLevel)] = entry.Level.String() if entry.HasCaller() { - data[f.FieldMap.resolve(FieldKeyFunc)] = entry.Caller.Function - data[f.FieldMap.resolve(FieldKeyFile)] = fmt.Sprintf("%s:%d", entry.Caller.File, entry.Caller.Line) + funcVal := entry.Caller.Function + fileVal := fmt.Sprintf("%s:%d", entry.Caller.File, entry.Caller.Line) + if f.CallerPrettyfier != nil { + funcVal, fileVal = f.CallerPrettyfier(entry.Caller) + } + if funcVal != "" { + data[f.FieldMap.resolve(FieldKeyFunc)] = funcVal + } + if fileVal != "" { + data[f.FieldMap.resolve(FieldKeyFile)] = fileVal + } } var b *bytes.Buffer @@ -98,7 +114,7 @@ func (f *JSONFormatter) Format(entry *Entry) ([]byte, error) { encoder.SetIndent("", " ") } if err := encoder.Encode(data); err != nil { - return nil, fmt.Errorf("Failed to marshal fields to JSON, %v", err) + return nil, fmt.Errorf("failed to marshal fields to JSON, %v", err) } return b.Bytes(), nil diff --git a/vendor/github.com/sirupsen/logrus/logger.go b/vendor/github.com/sirupsen/logrus/logger.go index 9bf64e22ae..c0c0b1e559 100644 --- a/vendor/github.com/sirupsen/logrus/logger.go +++ b/vendor/github.com/sirupsen/logrus/logger.go @@ -1,6 +1,7 @@ package logrus import ( + "context" "io" "os" "sync" @@ -124,6 +125,13 @@ func (logger *Logger) WithError(err error) *Entry { return entry.WithError(err) } +// Add a context to the log entry. +func (logger *Logger) WithContext(ctx context.Context) *Entry { + entry := logger.newEntry() + defer logger.releaseEntry(entry) + return entry.WithContext(ctx) +} + // Overrides the time of the log entry. func (logger *Logger) WithTime(t time.Time) *Entry { entry := logger.newEntry() @@ -200,7 +208,7 @@ func (logger *Logger) Info(args ...interface{}) { func (logger *Logger) Print(args ...interface{}) { entry := logger.newEntry() - entry.Info(args...) + entry.Print(args...) logger.releaseEntry(entry) } @@ -256,7 +264,7 @@ func (logger *Logger) Warnln(args ...interface{}) { } func (logger *Logger) Warningln(args ...interface{}) { - logger.Warn(args...) + logger.Warnln(args...) } func (logger *Logger) Errorln(args ...interface{}) { diff --git a/vendor/github.com/sirupsen/logrus/logrus.go b/vendor/github.com/sirupsen/logrus/logrus.go index c1ca889902..8644761f73 100644 --- a/vendor/github.com/sirupsen/logrus/logrus.go +++ b/vendor/github.com/sirupsen/logrus/logrus.go @@ -74,7 +74,7 @@ func (level Level) MarshalText() ([]byte, error) { return []byte("panic"), nil } - return nil, fmt.Errorf("not a valid lorus level %q", level) + return nil, fmt.Errorf("not a valid logrus level %d", level) } // A constant exposing all logging levels diff --git a/vendor/github.com/sirupsen/logrus/text_formatter.go b/vendor/github.com/sirupsen/logrus/text_formatter.go index fb21649c9a..b3b1a30cab 100644 --- a/vendor/github.com/sirupsen/logrus/text_formatter.go +++ b/vendor/github.com/sirupsen/logrus/text_formatter.go @@ -12,18 +12,13 @@ import ( ) const ( - nocolor = 0 - red = 31 - green = 32 - yellow = 33 - blue = 36 - gray = 37 + red = 31 + yellow = 33 + blue = 36 + gray = 37 ) -var ( - baseTimestamp time.Time - emptyFieldMap FieldMap -) +var baseTimestamp time.Time func init() { baseTimestamp = time.Now() @@ -77,6 +72,12 @@ type TextFormatter struct { // FieldKeyMsg: "@message"}} FieldMap FieldMap + // CallerPrettyfier can be set by the user to modify the content + // of the function and file keys in the json data when ReportCaller is + // activated. If any of the returned value is the empty string the + // corresponding key will be removed from json fields. + CallerPrettyfier func(*runtime.Frame) (function string, file string) + terminalInitOnce sync.Once } @@ -118,6 +119,8 @@ func (f *TextFormatter) Format(entry *Entry) ([]byte, error) { keys = append(keys, k) } + var funcVal, fileVal string + fixedKeys := make([]string, 0, 4+len(data)) if !f.DisableTimestamp { fixedKeys = append(fixedKeys, f.FieldMap.resolve(FieldKeyTime)) @@ -132,6 +135,12 @@ func (f *TextFormatter) Format(entry *Entry) ([]byte, error) { if entry.HasCaller() { fixedKeys = append(fixedKeys, f.FieldMap.resolve(FieldKeyFunc), f.FieldMap.resolve(FieldKeyFile)) + if f.CallerPrettyfier != nil { + funcVal, fileVal = f.CallerPrettyfier(entry.Caller) + } else { + funcVal = entry.Caller.Function + fileVal = fmt.Sprintf("%s:%d", entry.Caller.File, entry.Caller.Line) + } } if !f.DisableSorting { @@ -166,6 +175,7 @@ func (f *TextFormatter) Format(entry *Entry) ([]byte, error) { if f.isColored() { f.printColored(b, entry, keys, data, timestampFormat) } else { + for _, key := range fixedKeys { var value interface{} switch { @@ -178,9 +188,9 @@ func (f *TextFormatter) Format(entry *Entry) ([]byte, error) { case key == f.FieldMap.resolve(FieldKeyLogrusError): value = entry.err case key == f.FieldMap.resolve(FieldKeyFunc) && entry.HasCaller(): - value = entry.Caller.Function + value = funcVal case key == f.FieldMap.resolve(FieldKeyFile) && entry.HasCaller(): - value = fmt.Sprintf("%s:%d", entry.Caller.File, entry.Caller.Line) + value = fileVal default: value = data[key] } @@ -217,8 +227,13 @@ func (f *TextFormatter) printColored(b *bytes.Buffer, entry *Entry, keys []strin caller := "" if entry.HasCaller() { - caller = fmt.Sprintf("%s:%d %s()", - entry.Caller.File, entry.Caller.Line, entry.Caller.Function) + funcVal := fmt.Sprintf("%s()", entry.Caller.Function) + fileVal := fmt.Sprintf("%s:%d", entry.Caller.File, entry.Caller.Line) + + if f.CallerPrettyfier != nil { + funcVal, fileVal = f.CallerPrettyfier(entry.Caller) + } + caller = fileVal + " " + funcVal } if f.DisableTimestamp { diff --git a/vendor/golang.org/x/sys/cpu/cpu_aix_ppc64.go b/vendor/golang.org/x/sys/cpu/cpu_aix_ppc64.go new file mode 100644 index 0000000000..d8c26a048d --- /dev/null +++ b/vendor/golang.org/x/sys/cpu/cpu_aix_ppc64.go @@ -0,0 +1,30 @@ +// Copyright 2019 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// +build aix,ppc64 + +package cpu + +import "golang.org/x/sys/unix" + +const cacheLineSize = 128 + +const ( + // getsystemcfg constants + _SC_IMPL = 2 + _IMPL_POWER8 = 0x10000 + _IMPL_POWER9 = 0x20000 +) + +func init() { + impl := unix.Getsystemcfg(_SC_IMPL) + if impl&_IMPL_POWER8 != 0 { + PPC64.IsPOWER8 = true + } + if impl&_IMPL_POWER9 != 0 { + PPC64.IsPOWER9 = true + } + + Initialized = true +} diff --git a/vendor/golang.org/x/sys/cpu/cpu_other_ppc64x.go b/vendor/golang.org/x/sys/cpu/cpu_other_ppc64x.go deleted file mode 100644 index 3053b4b987..0000000000 --- a/vendor/golang.org/x/sys/cpu/cpu_other_ppc64x.go +++ /dev/null @@ -1,12 +0,0 @@ -// Copyright 2019 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// +build !linux -// +build ppc64 ppc64le - -package cpu - -const cacheLineSize = 128 - -func doinit() {} diff --git a/vendor/golang.org/x/sys/unix/mkall.sh b/vendor/golang.org/x/sys/unix/mkall.sh index 75152f99b2..1e5c59d0dd 100644 --- a/vendor/golang.org/x/sys/unix/mkall.sh +++ b/vendor/golang.org/x/sys/unix/mkall.sh @@ -207,8 +207,6 @@ esac esac if [ -n "$mksysctl" ]; then echo "$mksysctl |gofmt >$zsysctl"; fi if [ -n "$mksysnum" ]; then echo "$mksysnum |gofmt >zsysnum_$GOOSARCH.go"; fi - if [ -n "$mktypes" ]; then - echo "$mktypes types_$GOOS.go | go run mkpost.go > ztypes_$GOOSARCH.go"; + if [ -n "$mktypes" ]; then echo "$mktypes types_$GOOS.go | go run mkpost.go > ztypes_$GOOSARCH.go"; fi if [ -n "$mkasm" ]; then echo "$mkasm $GOARCH"; fi - fi ) | $run diff --git a/vendor/golang.org/x/sys/unix/syscall_aix.go b/vendor/golang.org/x/sys/unix/syscall_aix.go index a76826f443..fd83d87509 100644 --- a/vendor/golang.org/x/sys/unix/syscall_aix.go +++ b/vendor/golang.org/x/sys/unix/syscall_aix.go @@ -545,3 +545,5 @@ func Poll(fds []PollFd, timeout int) (n int, err error) { //sys gettimeofday(tv *Timeval, tzp *Timezone) (err error) //sysnb Time(t *Time_t) (tt Time_t, err error) //sys Utime(path string, buf *Utimbuf) (err error) + +//sys Getsystemcfg(label int) (n uint64) diff --git a/vendor/golang.org/x/sys/unix/zsyscall_aix_ppc64.go b/vendor/golang.org/x/sys/unix/zsyscall_aix_ppc64.go index e645a05cbe..52802bfc17 100644 --- a/vendor/golang.org/x/sys/unix/zsyscall_aix_ppc64.go +++ b/vendor/golang.org/x/sys/unix/zsyscall_aix_ppc64.go @@ -1367,6 +1367,14 @@ func Utime(path string, buf *Utimbuf) (err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT +func Getsystemcfg(label int) (n uint64) { + r0, _ := callgetsystemcfg(label) + n = uint64(r0) + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + func Getrlimit(resource int, rlim *Rlimit) (err error) { _, e1 := callgetrlimit(resource, uintptr(unsafe.Pointer(rlim))) if e1 != 0 { diff --git a/vendor/golang.org/x/sys/unix/zsyscall_aix_ppc64_gc.go b/vendor/golang.org/x/sys/unix/zsyscall_aix_ppc64_gc.go index 0b8eb72102..a2b24e4a43 100644 --- a/vendor/golang.org/x/sys/unix/zsyscall_aix_ppc64_gc.go +++ b/vendor/golang.org/x/sys/unix/zsyscall_aix_ppc64_gc.go @@ -120,6 +120,7 @@ import ( //go:cgo_import_dynamic libc_gettimeofday gettimeofday "libc.a/shr_64.o" //go:cgo_import_dynamic libc_time time "libc.a/shr_64.o" //go:cgo_import_dynamic libc_utime utime "libc.a/shr_64.o" +//go:cgo_import_dynamic libc_getsystemcfg getsystemcfg "libc.a/shr_64.o" //go:cgo_import_dynamic libc_getrlimit getrlimit "libc.a/shr_64.o" //go:cgo_import_dynamic libc_setrlimit setrlimit "libc.a/shr_64.o" //go:cgo_import_dynamic libc_lseek lseek "libc.a/shr_64.o" @@ -235,6 +236,7 @@ import ( //go:linkname libc_gettimeofday libc_gettimeofday //go:linkname libc_time libc_time //go:linkname libc_utime libc_utime +//go:linkname libc_getsystemcfg libc_getsystemcfg //go:linkname libc_getrlimit libc_getrlimit //go:linkname libc_setrlimit libc_setrlimit //go:linkname libc_lseek libc_lseek @@ -353,6 +355,7 @@ var ( libc_gettimeofday, libc_time, libc_utime, + libc_getsystemcfg, libc_getrlimit, libc_setrlimit, libc_lseek, @@ -1135,6 +1138,13 @@ func callutime(_p0 uintptr, buf uintptr) (r1 uintptr, e1 Errno) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT +func callgetsystemcfg(label int) (r1 uintptr, e1 Errno) { + r1, _, e1 = syscall6(uintptr(unsafe.Pointer(&libc_getsystemcfg)), 1, uintptr(label), 0, 0, 0, 0, 0) + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + func callgetrlimit(resource int, rlim uintptr) (r1 uintptr, e1 Errno) { r1, _, e1 = rawSyscall6(uintptr(unsafe.Pointer(&libc_getrlimit)), 2, uintptr(resource), rlim, 0, 0, 0, 0) return diff --git a/vendor/golang.org/x/sys/unix/zsyscall_aix_ppc64_gccgo.go b/vendor/golang.org/x/sys/unix/zsyscall_aix_ppc64_gccgo.go index e88a442787..5491c89e96 100644 --- a/vendor/golang.org/x/sys/unix/zsyscall_aix_ppc64_gccgo.go +++ b/vendor/golang.org/x/sys/unix/zsyscall_aix_ppc64_gccgo.go @@ -118,6 +118,7 @@ int poll(uintptr_t, int, int); int gettimeofday(uintptr_t, uintptr_t); int time(uintptr_t); int utime(uintptr_t, uintptr_t); +unsigned long long getsystemcfg(int); int getrlimit(int, uintptr_t); int setrlimit(int, uintptr_t); long long lseek(int, long long, int); @@ -1011,6 +1012,14 @@ func callutime(_p0 uintptr, buf uintptr) (r1 uintptr, e1 Errno) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT +func callgetsystemcfg(label int) (r1 uintptr, e1 Errno) { + r1 = uintptr(C.getsystemcfg(C.int(label))) + e1 = syscall.GetErrno() + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + func callgetrlimit(resource int, rlim uintptr) (r1 uintptr, e1 Errno) { r1 = uintptr(C.getrlimit(C.int(resource), C.uintptr_t(rlim))) e1 = syscall.GetErrno() diff --git a/vendor/modules.txt b/vendor/modules.txt index 7ba6af922c..54b36c7890 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -19,7 +19,7 @@ github.com/konsorten/go-windows-terminal-sequences github.com/kr/pty # github.com/mattn/go-colorable v0.1.1 github.com/mattn/go-colorable -# github.com/mattn/go-isatty v0.0.6 +# github.com/mattn/go-isatty v0.0.7 github.com/mattn/go-isatty # github.com/mgutz/ansi v0.0.0-20170206155736-9520e82c474b github.com/mgutz/ansi @@ -27,7 +27,7 @@ github.com/mgutz/ansi github.com/mitchellh/go-homedir # github.com/pmezard/go-difflib v1.0.0 github.com/pmezard/go-difflib/difflib -# github.com/sirupsen/logrus v1.3.0 +# github.com/sirupsen/logrus v1.4.0 github.com/sirupsen/logrus # github.com/skycoin/skycoin v0.25.1 github.com/skycoin/skycoin/src/util/logging @@ -45,7 +45,7 @@ github.com/stretchr/testify/assert github.com/stretchr/testify/require # go.etcd.io/bbolt v1.3.2 go.etcd.io/bbolt -# golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2 +# golang.org/x/crypto v0.0.0-20190313024323-a1f597ede03a golang.org/x/crypto/ssh/terminal golang.org/x/crypto/blake2b golang.org/x/crypto/blake2s @@ -54,11 +54,11 @@ golang.org/x/crypto/curve25519 golang.org/x/crypto/internal/chacha20 golang.org/x/crypto/internal/subtle golang.org/x/crypto/poly1305 -# golang.org/x/net v0.0.0-20190310074541-c10a0554eabf +# golang.org/x/net v0.0.0-20190313220215-9f648a60d977 golang.org/x/net/context golang.org/x/net/proxy golang.org/x/net/internal/socks -# golang.org/x/sys v0.0.0-20190310054646-10058d7d4faa +# golang.org/x/sys v0.0.0-20190312061237-fead79001313 golang.org/x/sys/unix golang.org/x/sys/windows golang.org/x/sys/cpu From efe6dd6eec0df41ac02d6a39c25f3558dbadf545 Mon Sep 17 00:00:00 2001 From: Yuryshev Date: Fri, 15 Mar 2019 11:30:56 +0300 Subject: [PATCH 06/10] started to edit --- README.md | 77 +++++++++++++++++++++++++++++++++---------------------- 1 file changed, 47 insertions(+), 30 deletions(-) diff --git a/README.md b/README.md index a4379dac33..5786d3b074 100644 --- a/README.md +++ b/README.md @@ -38,23 +38,23 @@ $ git clone https://github.com/skycoin/skywire $ cd skywire $ git checkout mainnet + +# Build + +```bash +make # this will install all dependencies and build binaries +``` + # Install skywire-node, skywire-cli, manager-node and therealssh-cli -$ GO111MODULE=on go install ./cmd/skywire-node ./cmd/skywire-cli ./cmd/manager-node ./cmd/therealssh-cli - -# Setup run folder. -mkdir skywire -mkdir apps - -# Build apps. -$ GO111MODULE=on go build -o ./apps/chat.v1.0 ./cmd/apps/chat -$ GO111MODULE=on go build -o ./apps/helloworld.v1.0 ./cmd/apps/helloworld -$ GO111MODULE=on go build -o ./apps/therealproxy.v1.0 ./cmd/apps/therealproxy -$ GO111MODULE=on go build -o ./apps/therealproxy-client.v1.0 ./cmd/apps/therealproxy-client -$ GO111MODULE=on go build -o ./apps/therealssh.v1.0 ./cmd/apps/therealssh -$ GO111MODULE=on go build -o ./apps/therealssh-client.v1.0 ./cmd/apps/therealssh-client - -# Generate default json config. -$ skywire-cli config + +```bash +make install +``` + +# Generate default json config + +```bash +skywire-cli config ``` ### Run `skywire-node` @@ -66,6 +66,12 @@ $ skywire-cli config $ skywire-node skywire.json ``` +### Run `skywire-node` in docker container + +```bash +make node +``` + ### Run `skywire-cli` The `skywire-cli` tool is used to control the `skywire-node`. Refer to the help menu for usage: @@ -74,25 +80,36 @@ The `skywire-cli` tool is used to control the `skywire-node`. Refer to the help $ skywire-cli -h # Command Line Interface for skywire -# +# # Usage: # skywire-cli [command] -# +# # Available Commands: -# app app management operations -# config Generate default config file -# help Help about any command -# messaging-discovery manage operations with messaging discovery api -# route-finder manage operations with route finder api -# routing-rules manages operations with routing rules -# transport-discovery manage operations with transport discovery api -# transports manages transports related operations -# +# add-rule adds a new routing rule +# add-transport adds a new transport +# apps lists apps running on the node +# config Generate default config file +# find-routes lists available routes between two nodes via route finder service +# find-transport finds and lists transport(s) of given transport ID or edge public key from transport discovery +# help Help about any command +# list-rules lists the local node's routing rules +# list-transports lists the available transports with optional filter flags +# messaging manage operations with messaging services +# rm-rule removes a routing rule via route ID key +# rm-transport removes transport with given id +# rule returns a routing rule via route ID key +# set-app-autostart sets the autostart flag for an app of given name +# start-app starts an app of given name +# stop-app stops an app of given name +# transport returns summary of given transport by id +# transport-types lists transport types used by the local node +# # Flags: # -h, --help help for skywire-cli # --rpc string RPC server address (default "localhost:3435") -# +# # Use "skywire-cli [command] --help" for more information about a command. + ``` ### Apps @@ -112,7 +129,7 @@ Transports can be established via the `skywire-cli`. ```bash # Establish transport to `0276ad1c5e77d7945ad6343a3c36a8014f463653b3375b6e02ebeaa3a21d89e881`. -$ skywire-cli transports add 0276ad1c5e77d7945ad6343a3c36a8014f463653b3375b6e02ebeaa3a21d89e881 +$ skywire-cli add-transport 0276ad1c5e77d7945ad6343a3c36a8014f463653b3375b6e02ebeaa3a21d89e881 # List established transports. $ skywire-cli transports list @@ -146,4 +163,4 @@ func (app *App) Close() error {} ## Updater -This software comes with an updater, which is located in this repo: https://github.com/skycoin/skywire-updater. Follow the instructions in the README.md for further information. It can be used with a CLI for now and will be usable with the manager interface. +This software comes with an updater, which is located in this repo: https://github.com/skycoin/skywire-updater. Follow the instructions in the README.md for further information. It can be used with a CLI for now and will be usable with the manager interface. From 243c462912f99e9b80a0a6cecfd43e27ce673bc6 Mon Sep 17 00:00:00 2001 From: Yuryshev Date: Fri, 15 Mar 2019 12:45:31 +0300 Subject: [PATCH 07/10] Altered build of dockerized node. Instead of just copying host binaries now it recompiles it with DOCKER_OPTIONS variable. Default value of DOCKER_OPTIONS=GO111MODULES=on GOOS=linux --- Makefile | 58 +++++++++++++++++++++++--------------------------------- 1 file changed, 24 insertions(+), 34 deletions(-) diff --git a/Makefile b/Makefile index fc6dc0c058..393060ad57 100644 --- a/Makefile +++ b/Makefile @@ -1,8 +1,8 @@ OPTS?=GO111MODULE=on -DOCKER_IMAGE?=skywire-runner # buildpack-deps:stretch-scm # docker image to use for running skywire-node. `golang` is OK too +DOCKER_IMAGE?=skywire-runner # docker image to use for running skywire-node.`golang`, `buildpack-deps:stretch-scm` is OK too DOCKER_NETWORK?=SKYNET -DOCKER_NODE?=SKY01 - +DOCKER_NODE?=SKY01 +DOCKER_OPTS?=GO111MODULE=on GOOS=linux # go options for compiling for docker container build: dep apps bin @@ -39,42 +39,22 @@ test: ## Run tests for net ${OPTS} go test -race -tags no_ci -cover -timeout=5m ./pkg/... -build: apps bin +build: host-apps bin # Apps -apps: chat helloworld therealproxy therealproxy-client therealssh thereallssh-client - -chat: - ${OPTS} go build -o ./apps/chat.v1.0 ./cmd/apps/chat - -helloworld: +host-apps: + ${OPTS} go build -o ./apps/chat.v1.0 ./cmd/apps/chat ${OPTS} go build -o ./apps/helloworld.v1.0 ./cmd/apps/helloworld - -therealproxy: ${OPTS} go build -o ./apps/therealproxy.v1.0 ./cmd/apps/therealproxy - -therealproxy-client: ${OPTS} go build -o ./apps/therealproxy-client.v1.0 ./cmd/apps/therealproxy-client - -therealssh: ${OPTS} go build -o ./apps/therealssh.v1.0 ./cmd/apps/therealssh - -thereallssh-client: ${OPTS} go build -o ./apps/therealssh-client.v1.0 ./cmd/apps/therealssh-client # Bin -bin: skywire-node skywire-cli manager-node therealssh-cli - -skywire-node: +bin: ${OPTS} go build -o ./skywire-node ./cmd/skywire-node - -skywire-cli: ${OPTS} go build -o ./skywire-cli ./cmd/skywire-cli - -manager-node: ${OPTS} go build -o ./manager-node ./cmd/manager-node - -therealssh-cli: ${OPTS} go build -o ./therealssh-cli ./cmd/therealssh-cli # Node @@ -89,12 +69,22 @@ docker-clean: docker-network: -docker network create ${DOCKER_NETWORK} -docker-volume: build - mkdir -p ./node - cp ./skywire-node ./node - cp -r ./apps ./node/apps +docker-apps: + -${DOCKER_OPTS} go build -o ./node/apps/chat.v1.0 ./cmd/apps/chat + -${DOCKER_OPTS} go build -o ./node/apps/helloworld.v1.0 ./cmd/apps/helloworld + -${DOCKER_OPTS} go build -o ./node/apps/therealproxy.v1.0 ./cmd/apps/therealproxy + -${DOCKER_OPTS} go build -o ./node/apps/therealproxy-client.v1.0 ./cmd/apps/therealproxy-client + -${DOCKER_OPTS} go build -o ./node/apps/therealssh.v1.0 ./cmd/apps/therealssh + -${DOCKER_OPTS} go build -o ./node/apps/therealssh-client.v1.0 ./cmd/apps/therealssh-client + +docker-bin: + ${DOCKER_OPTS} go build -o ./node/skywire-node ./cmd/skywire-node + + +docker-volume: docker-apps docker-bin bin ./skywire-cli config ./node/skywire.json cat ./node/skywire.json|grep static_public_key |cut -d ':' -f2 |tr -d '"'','' ' > ./node/PK + cat ./node/PK node: docker-clean docker-image docker-network docker-volume docker run -d -v $(shell pwd)/node:/sky --network=${DOCKER_NETWORK} --name=${DOCKER_NODE} ${DOCKER_IMAGE} bash -c "cd /sky && ./skywire-node" @@ -105,6 +95,6 @@ run: node-stop: -docker container stop ${DOCKER_NODE} -refresh-node: node-stop - cp ./skywire-node ./node - docker container start ${DOCKER_NODE} \ No newline at end of file +refresh-node: node-stop docker-bin + # cp ./skywire-node ./node + docker container start ${DOCKER_NODE} From d5f67d340405aa14e17c35c88caad2a0924d668e Mon Sep 17 00:00:00 2001 From: Yuryshev Date: Fri, 15 Mar 2019 14:47:06 +0300 Subject: [PATCH 08/10] 1. Simplified sections of build, install instructions 2. Described usage of dockerized `skywire-node` 3. Actualized sections with skywire-cli 4. Fixed typo in Makefile - there was double declaration of `make build` --- Makefile | 4 +-- README.md | 77 ++++++++++++++++++++++++++++++++++++++++++++++++++++--- 2 files changed, 75 insertions(+), 6 deletions(-) diff --git a/Makefile b/Makefile index 393060ad57..348ca9d87a 100644 --- a/Makefile +++ b/Makefile @@ -4,7 +4,7 @@ DOCKER_NETWORK?=SKYNET DOCKER_NODE?=SKY01 DOCKER_OPTS?=GO111MODULE=on GOOS=linux # go options for compiling for docker container -build: dep apps bin +build: dep host-apps bin clean: rm -rf ./apps @@ -39,8 +39,6 @@ test: ## Run tests for net ${OPTS} go test -race -tags no_ci -cover -timeout=5m ./pkg/... -build: host-apps bin - # Apps host-apps: ${OPTS} go build -o ./apps/chat.v1.0 ./cmd/apps/chat diff --git a/README.md b/README.md index 5786d3b074..137d884fdf 100644 --- a/README.md +++ b/README.md @@ -37,18 +37,27 @@ Skywire requires a version of [golang](https://golang.org/) with [go modules](ht $ git clone https://github.com/skycoin/skywire $ cd skywire $ git checkout mainnet +# Build +$ make # installs all dependencies, build binaries and apps +``` +#### Note: Environment variable OPTS -# Build +Build can be customized with environment variable `OPTS` with default value `GO111MODULE=on` + +E.g. ```bash -make # this will install all dependencies and build binaries +$ export OPTS="GO111MODULE=on GOOS=darwin" +$ make +# or +$ OPTS="GSO111MODULE=on GOOS=linux GOARCH=arm" make ``` # Install skywire-node, skywire-cli, manager-node and therealssh-cli ```bash -make install +$ make install # compiles and installs all binaries ``` # Generate default json config @@ -164,3 +173,65 @@ func (app *App) Close() error {} ## Updater This software comes with an updater, which is located in this repo: https://github.com/skycoin/skywire-updater. Follow the instructions in the README.md for further information. It can be used with a CLI for now and will be usable with the manager interface. + +## Running skywire in docker containers + +There are two make goals for running in development environment dockerized `skywire-node`. + +### Run dockerized `skywire-node` + +```bash +$ make node +``` + +This will: + +- create docker image `skywire-runner` for running `skywire-node` +- create docker network `SKYNET` (can be customized) +- create docker volume ./node with linux binaries and apps +- create container `SKY01` and starts it (can be customized) + +### Refresh and restart `SKY01` + +```bash +$ make refresh-node +``` + +This will: + + - stops running node + - recompiles `skywire-node` for container + - start node again + +### Customization of dockers + +#### 1. DOCKER_IMAGE + +Docker image for running `skywire-node`. + +Default value: `skywire-runner` (built with `make docker-image`) + +Other images can be used. +E.g. + +```bash +DOCKER_IMAGE=golang make node #buildpack-deps:stretch-scm is OK too +``` + +#### 2.DOCKER_NETWORK + +Name of virtual network for `skywire-node` + +Default value: SKYNET + +#### 3. DOCKER_NODE + +Name of container for `skywire-node` + +Default value: SKY01 + +#### 4. DOCKER_OPTS + +`go build` options for binaries and apps in container. + +Default value: "GO111MODULE=on GOOS=linux" From dea194b0c5f0e49d64c3017c49a0e9caf5c2a5d7 Mon Sep 17 00:00:00 2001 From: Yuryshev Date: Fri, 15 Mar 2019 17:02:55 +0300 Subject: [PATCH 09/10] Added description of ./node structure. Added Recipes section --- README.md | 114 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 114 insertions(+) diff --git a/README.md b/README.md index 137d884fdf..cb6d05d226 100644 --- a/README.md +++ b/README.md @@ -191,6 +191,40 @@ This will: - create docker volume ./node with linux binaries and apps - create container `SKY01` and starts it (can be customized) +#### Structure of `./node` + +```bash +./node +├── apps # node `apps` compiled with DOCKER_OPTS +│   ├── chat.v1.0 # +│   ├── helloworld.v1.0 # +│   ├── therealproxy-client.v1.0 # +│   ├── therealproxy.v1.0 # +│   ├── therealssh-client.v1.0 # +│   └── therealssh.v1.0 # +├── local # **Created inside docker** +│   ├── chat # according to "local_path" in skywire.json +│   ├── therealproxy # +│   └── therealssh # +├── PK # contains public key of node +├── skywire # db & logs. **Created inside docker** +│   ├── routing.db # +│   └── transport_logs # +├── skywire.json # config of node +└── skywire-node # `skywire-node binary` compiled with DOCKER_OPTS +``` + +Directory `./node` is mounted as docker volume for `skywire-node` container. + +Inside docker container it is mounted on `/sky` + +Structure of `./node` partially replicates structure of project root directory. + +Note that files created inside docker container has ownership `root:root`, +so in case you want to `rm -rf ./node` (or other file operations) - you will need `sudo` it. + +Look at "Recipes: Creating new dockerized node" for further details. + ### Refresh and restart `SKY01` ```bash @@ -235,3 +269,83 @@ Default value: SKY01 `go build` options for binaries and apps in container. Default value: "GO111MODULE=on GOOS=linux" + +### Dockerized `skywire-node` recipes + +#### 1. Get Public Key of node + +```bash +# you need `jq` (https://stedolan.github.io/jq/) for this: +$ cat ./node/skywire.json |jq -r ".node.static_public_key" +# 029be6fa68c13e9222553035cc1636d98fb36a888aa569d9ce8aa58caa2c651b45 +# or without `jq`: +$ cat ./node/skywire.json|grep static_public_key |cut -d ':' -f2 |tr -d '"'','' ' +# 029be6fa68c13e9222553035cc1636d98fb36a888aa569d9ce8aa58caa2c651b45 +# or just: +$ cat ./node/PK # this file is created during `make docker-volume` +# 029be6fa68c13e9222553035cc1636d98fb36a888aa569d9ce8aa58caa2c651b45 +``` + +#### 2. Open in browser containerized `chat` application + +```bash +# you need `jq` (https://stedolan.github.io/jq/) for this: +$ firefox http://$(docker inspect SKY01 |jq -r ".[0].NetworkSettings.Networks.SKYNET.IPAddress"):8000 +``` + +#### 3. Create new dockerize `skywire-nodes` + +In case you need more dockerized nodes or maybe it's needed to customize node +let's look how to create new node. + +```bash +# 1. We need a folder for docker volume +$ mkdir /tmp/SKYNODE +# 2. compile `skywire-node` +$ GO111MODULE=on GOOS=linux go build -o /tmp/SKYNODE/skywire-node ./cmd/skywire-node +# 3. compile apps +$ GO111MODULE=on GOOS=linux go build -o /tmp/SKYNODE/apps/chat.v1.0 ./cmd/apps/chat +$ GO111MODULE=on GOOS=linux go build -o /tmp/SKYNODE/apps/helloworld.v1.0 ./cmd/apps/helloworld +$ GO111MODULE=on GOOS=linux go build -o /tmp/SKYNODE/apps/therealproxy.v1.0 ./cmd/apps/therealproxy +$ GO111MODULE=on GOOS=linux go build -o /tmp/SKYNODE/apps/therealssh.v1.0 ./cmd/apps/therealssh +$ GO111MODULE=on GOOS=linux go build -o /tmp/SKYNODE/apps/therealssh-client.v1.0 ./cmd/apps/therealssh-client +# 4. Create skywire.json for node +$ skywire-cli config /tmp/SKYNODE/skywire.json +# 2019/03/15 16:43:49 Done! +$ tree /tmp/SKYNODE +# /tmp/SKYNODE +# ├── apps +# │   ├── chat.v1.0 +# │   ├── helloworld.v1.0 +# │   ├── therealproxy.v1.0 +# │   ├── therealssh-client.v1.0 +# │   └── therealssh.v1.0 +# ├── skywire.json +# └── skywire-node +# So far so good. We prepared docker volume. Now we can: +$ docker run -it -v /tmp/SKYNODE:/sky --network=SKYNET --name=SKYNODE skywire-runner bash -c "cd /sky && ./skywire-node" +# [2019-03-15T13:55:08Z] INFO [messenger]: Opened new link with the server # 02a49bc0aa1b5b78f638e9189be4ed095bac5d6839c828465a8350f80ac07629c0 +# [2019-03-15T13:55:08Z] INFO [messenger]: Updating discovery entry +# [2019-03-15T13:55:10Z] INFO [skywire]: Connected to messaging servers +# [2019-03-15T13:55:10Z] INFO [skywire]: Starting chat.v1.0 +# [2019-03-15T13:55:10Z] INFO [skywire]: Starting RPC interface on 127.0.0.1:3435 +# [2019-03-15T13:55:10Z] INFO [skywire]: Starting therealproxy.v1.0 +# [2019-03-15T13:55:10Z] INFO [skywire]: Starting therealssh.v1.0 +# [2019-03-15T13:55:10Z] INFO [skywire]: Starting packet router +# [2019-03-15T13:55:10Z] INFO [router]: Starting router +# [2019-03-15T13:55:10Z] INFO [trmanager]: Starting transport manager +# [2019-03-15T13:55:10Z] INFO [router]: Got new App request with type Init: {"app-name":"chat",# "app-version":"1.0","protocol-version":"0.0.1"} +# [2019-03-15T13:55:10Z] INFO [router]: Handshaked new connection with the app chat.v1.0 +# [2019-03-15T13:55:10Z] INFO [chat.v1.0]: 2019/03/15 13:55:10 Serving HTTP on :8000 +# [2019-03-15T13:55:10Z] INFO [router]: Got new App request with type Init: {"app-name":"therealssh",# "app-version":"1.0","protocol-version":"0.0.1"} +# [2019-03-15T13:55:10Z] INFO [router]: Handshaked new connection with the app therealssh.v1.0 +# [2019-03-15T13:55:10Z] INFO [router]: Got new App request with type Init: {"app-name":"therealproxy",# "app-version":"1.0","protocol-version":"0.0.1"} +# [2019-03-15T13:55:10Z] INFO [router]: Handshaked new connection with the app therealproxy.v1.0 +``` + +Note that in this example docker is running in non-detached mode - it could be useful in some scenarios. + +Instead of skywire-runner you can use: + +- `golang`, `buildpack-deps:stretch-scm` "as is" +- and `debian`, `ubuntu` - after `apt-get install ca-certificates` in them. Look in `skywire-runner.Dockerfile` for example From 99b1c1654c8fed8092a6144e8274df18c07ff0c0 Mon Sep 17 00:00:00 2001 From: Yuryshev Date: Fri, 15 Mar 2019 20:04:16 +0300 Subject: [PATCH 10/10] Removed mentions of jq. Substituted recipes with --format option --- README.md | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index cb6d05d226..4ac92b750b 100644 --- a/README.md +++ b/README.md @@ -275,10 +275,6 @@ Default value: "GO111MODULE=on GOOS=linux" #### 1. Get Public Key of node ```bash -# you need `jq` (https://stedolan.github.io/jq/) for this: -$ cat ./node/skywire.json |jq -r ".node.static_public_key" -# 029be6fa68c13e9222553035cc1636d98fb36a888aa569d9ce8aa58caa2c651b45 -# or without `jq`: $ cat ./node/skywire.json|grep static_public_key |cut -d ':' -f2 |tr -d '"'','' ' # 029be6fa68c13e9222553035cc1636d98fb36a888aa569d9ce8aa58caa2c651b45 # or just: @@ -286,14 +282,20 @@ $ cat ./node/PK # this file is created during `make docker-volume` # 029be6fa68c13e9222553035cc1636d98fb36a888aa569d9ce8aa58caa2c651b45 ``` -#### 2. Open in browser containerized `chat` application +#### 2. Get an IP of node + +```bash +$ docker inspect -f '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' SKY01 +# 192.168.112 +``` + +#### 3. Open in browser containerized `chat` application ```bash -# you need `jq` (https://stedolan.github.io/jq/) for this: -$ firefox http://$(docker inspect SKY01 |jq -r ".[0].NetworkSettings.Networks.SKYNET.IPAddress"):8000 +$ firefox http://$(docker inspect -f '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' SKY01):8000 ``` -#### 3. Create new dockerize `skywire-nodes` +#### 4. Create new dockerize `skywire-nodes` In case you need more dockerized nodes or maybe it's needed to customize node let's look how to create new node. @@ -301,7 +303,7 @@ let's look how to create new node. ```bash # 1. We need a folder for docker volume $ mkdir /tmp/SKYNODE -# 2. compile `skywire-node` +# 2. compile `skywire-node` $ GO111MODULE=on GOOS=linux go build -o /tmp/SKYNODE/skywire-node ./cmd/skywire-node # 3. compile apps $ GO111MODULE=on GOOS=linux go build -o /tmp/SKYNODE/apps/chat.v1.0 ./cmd/apps/chat