From 55fa1a24b97abb9c13dbe6689e681c4b6dab6d50 Mon Sep 17 00:00:00 2001 From: Matt Jaffee Date: Tue, 14 Feb 2017 13:38:58 -0600 Subject: [PATCH 1/9] modify pilosactl import to allow it to read from stdin pass a "-" argument for stdin --- pilosactl/import.go | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/pilosactl/import.go b/pilosactl/import.go index 6a278fe9a..9d4ad63f4 100644 --- a/pilosactl/import.go +++ b/pilosactl/import.go @@ -128,15 +128,22 @@ func (cmd *ImportCommand) Run(ctx context.Context) error { func (cmd *ImportCommand) importPath(ctx context.Context, path string) error { a := make([]pilosa.Bit, 0, cmd.BufferSize) - // Open file for reading. - f, err := os.Open(path) - if err != nil { - return err - } - defer f.Close() + var r *csv.Reader + + if path != "-" { + // Open file for reading. + f, err := os.Open(path) + if err != nil { + return err + } + defer f.Close() + + // Read rows as bits. + r = csv.NewReader(f) + } else { + r = csv.NewReader(cmd.Stdin) + } - // Read rows as bits. - r := csv.NewReader(f) r.FieldsPerRecord = -1 rnum := 0 for { From 65ab8725213bf39b0426bba1fe19739263bc8832 Mon Sep 17 00:00:00 2001 From: Cody Soyland Date: Tue, 14 Feb 2017 11:32:42 -0600 Subject: [PATCH 2/9] Add .travis.yml --- .travis.yml | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .travis.yml diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 000000000..7b465b700 --- /dev/null +++ b/.travis.yml @@ -0,0 +1,5 @@ +language: go +go: + - 1.7.x + - master +script: go test $(go list ./... | grep -v vendor) From 5e30496c504331ba81b24f1959cf8405f0646868 Mon Sep 17 00:00:00 2001 From: Cody Soyland Date: Wed, 15 Feb 2017 14:50:48 -0600 Subject: [PATCH 3/9] Ignore vendor directory in .gitignore --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 25442a3da..cd99c1b06 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ default.etcd/ *.test +vendor From 2d09731dfdecd2861144a1c86bd33eeadcedb0b5 Mon Sep 17 00:00:00 2001 From: Cody Soyland Date: Thu, 16 Feb 2017 15:16:32 -0600 Subject: [PATCH 4/9] Add Makefile and versioning/build time in pilosa/pilosactl --- Makefile | 47 +++++++++++++++++++++++++++++++++++++------ cmd/pilosa/main.go | 12 ++++++++--- cmd/pilosactl/main.go | 15 ++++++++++++++ 3 files changed, 65 insertions(+), 9 deletions(-) diff --git a/Makefile b/Makefile index 61abf2026..62d6fe2f1 100644 --- a/Makefile +++ b/Makefile @@ -1,10 +1,45 @@ -.PHONY: vendor +.PHONY: glide vendor-update docker pilosa pilosactl crossbuild install -default: +GLIDE := $(shell command -v glide 2>/dev/null) +VERSION := $(shell git describe --tags) +IDENTIFIER := $(VERSION)-$(GOOS)-$(GOARCH) +CLONE_URL=github.com/pilosa/pilosa +BUILD_TIME=`date -u +%FT%T%z` +LDFLAGS=-ldflags "-X main.Version=$(VERSION) -X main.BuildTime=$(BUILD_TIME)" -vendor: - godep save ./... - cp -r $(GOPATH)/src/github.com/gogo/protobuf/proto/testdata vendor/github.com/gogo/protobuf/proto/testdata +default: test pilosa pilosactl -docker: +$(GLIDE): + curl https://glide.sh/get | sh + touch $(GLIDE) + +glide: $(GLIDE) + +vendor: $(GLIDE) glide.yaml + glide install + +glide.lock: $(GLIDE) glide.yaml + glide update + +vendor-update: glide.lock + +test: vendor + go test $(shell cd $(GOPATH)/src/$(CLONE_URL); go list ./... | grep -v vendor) + +pilosa: vendor + go build $(LDFLAGS) $(FLAGS) $(CLONE_URL)/cmd/pilosa + +pilosactl: vendor + go build $(LDFLAGS) $(FLAGS) $(CLONE_URL)/cmd/pilosactl + +crossbuild: vendor + mkdir -p build/pilosa-$(IDENTIFIER) + make pilosa FLAGS="-o build/pilosa-$(IDENTIFIER)/pilosa" + make pilosactl FLAGS="-o build/pilosa-$(IDENTIFIER)/pilosactl" + +install: vendor + go install $(LDFLAGS) $(FLAGS) $(CLONE_URL)/cmd/pilosa + go install $(LDFLAGS) $(FLAGS) $(CLONE_URL)/cmd/pilosactl + +docker: vendor docker build -t pilosa:latest . diff --git a/cmd/pilosa/main.go b/cmd/pilosa/main.go index bcd3ee453..4f7474996 100644 --- a/cmd/pilosa/main.go +++ b/cmd/pilosa/main.go @@ -17,13 +17,19 @@ import ( "github.com/pilosa/pilosa" ) -// Version holds the version information passed in at compile time. -var Version string +// Version and BuildTime hold the version/build time information passed in at compile time. +var ( + Version string + BuildTime string +) func init() { if Version == "" { Version = "v0.0.0" } + if BuildTime == "" { + BuildTime = "not recorded" + } rand.Seed(time.Now().UTC().UnixNano()) } @@ -36,7 +42,7 @@ const ( func main() { m := NewMain() m.Server.Handler.Version = Version - fmt.Fprintf(m.Stderr, "Pilosa %s\n", Version) + fmt.Fprintf(m.Stderr, "Pilosa %s, build time %s\n", Version, BuildTime) // Parse command line arguments. if err := m.ParseFlags(os.Args[1:]); err != nil { diff --git a/cmd/pilosactl/main.go b/cmd/pilosactl/main.go index 331459c31..08a86c708 100644 --- a/cmd/pilosactl/main.go +++ b/cmd/pilosactl/main.go @@ -42,11 +42,26 @@ var ( // ErrPathRequired is returned when executing a command without a required path. ErrPathRequired = errors.New("path required") + Version string + BuildTime string ) +func init() { + if Version == "" { + Version = "v0.0.0" + } + if BuildTime == "" { + BuildTime = "not recorded" + } + + rand.Seed(time.Now().UTC().UnixNano()) +} + func main() { m := NewMain() + fmt.Fprintf(m.Stderr, "Pilosactl %s, build time %s\n", Version, BuildTime) + // Parse command line arguments. if err := m.ParseFlags(os.Args[1:]); err == flag.ErrHelp { os.Exit(2) From 823984e4ed58a2acdde3fc895a13a07398468137 Mon Sep 17 00:00:00 2001 From: Cody Soyland Date: Thu, 16 Feb 2017 15:22:47 -0600 Subject: [PATCH 5/9] Update travis.ci to use `make test` --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 7b465b700..cc3f2cb0b 100644 --- a/.travis.yml +++ b/.travis.yml @@ -2,4 +2,4 @@ language: go go: - 1.7.x - master -script: go test $(go list ./... | grep -v vendor) +script: make test From d9b71bba212dddb40fb12f1219239fa3e7ce38d5 Mon Sep 17 00:00:00 2001 From: Cody Soyland Date: Thu, 16 Feb 2017 15:43:17 -0600 Subject: [PATCH 6/9] Fix glide initial install --- Makefile | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/Makefile b/Makefile index 62d6fe2f1..6df41b05c 100644 --- a/Makefile +++ b/Makefile @@ -9,16 +9,15 @@ LDFLAGS=-ldflags "-X main.Version=$(VERSION) -X main.BuildTime=$(BUILD_TIME)" default: test pilosa pilosactl -$(GLIDE): +glide: +ifndef GLIDE curl https://glide.sh/get | sh - touch $(GLIDE) +endif -glide: $(GLIDE) - -vendor: $(GLIDE) glide.yaml +vendor: glide glide.yaml glide install -glide.lock: $(GLIDE) glide.yaml +glide.lock: glide glide.yaml glide update vendor-update: glide.lock From be873afe2b263889e651eec61dfbbf3985893196 Mon Sep 17 00:00:00 2001 From: Cody Soyland Date: Thu, 16 Feb 2017 15:47:05 -0600 Subject: [PATCH 7/9] Add GOPATH/bin to Makefile for Travis CI --- Makefile | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 6df41b05c..09b5616be 100644 --- a/Makefile +++ b/Makefile @@ -9,7 +9,10 @@ LDFLAGS=-ldflags "-X main.Version=$(VERSION) -X main.BuildTime=$(BUILD_TIME)" default: test pilosa pilosactl -glide: +$(GOPATH)/bin: + mkdir $(GOPATH)/bin + +glide: $(GOPATH)/bin ifndef GLIDE curl https://glide.sh/get | sh endif From 07133c78097947d4c207d635f489554166a60886 Mon Sep 17 00:00:00 2001 From: Cody Soyland Date: Thu, 16 Feb 2017 16:06:05 -0600 Subject: [PATCH 8/9] Add Slack notifications for Travis CI --- .travis.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.travis.yml b/.travis.yml index cc3f2cb0b..cea0d3d1a 100644 --- a/.travis.yml +++ b/.travis.yml @@ -3,3 +3,6 @@ go: - 1.7.x - master script: make test +notifications: + slack: + secure: k0m8IqQIjb8L5b1plR9+w4hGo5iWlGtrR9nxvPsHL7gShwez74dpHCmFUCjR/uJoZa5Xq6849IWmiBB71ZHE/wNVN60HpMeui9VKkYvUDVpgBuqoIo969ySPDyQo4jNsk0wRRv/dG5/wXo7ArY8qOp5UDjdVuEf4nEbDlBtKjo0A2W8qXBTdZ5EJ3VeP5nrtrT7knuWxXgeUyVmLkpnUaLgkY7icvH6evqkftfcb56n3l5ulKtlQkI/ij2XCUK+5xtNB9m0e1QbiqIFS7sjwlSly/GCstPVnTEp4oHNHE7LtS6TJ8lgRV90Qy6LPtROjbSdfVjhJ5cYKus8DdddSfcsm2qgHCHQThyYtVAfOXaFPYPb50WXEu3HOckHk1tYChfkdxwEGdn/cN8/xxa7Khd7T/+SaS1B4CPxOFp0ie+rD4lF6IhApmpr/UwtiW6srHcPB04lF5mioYWmyS2eyGKTzSZR82nifg5KYUgBL1FjywQDYb8t9QaAn/6svu08k4H29TBnYpOQWREb38pYmEnMtRqiRmbfQL6IyV8405TJkl/PZmIElX6IQGjf53M1KoFdCUuTL1we6rh8gen5zRVUwmM6BJxkVt4NJ2wGkrXg/HD3feYCMrv+DY3lfDN7tADx90lPb+ukmanB8oSIQHLuLCJ2XcFixEC3QSvVlnH0= From 8258ffbea4782b0e7fe64b7b530ce8ef01088563 Mon Sep 17 00:00:00 2001 From: Cody Soyland Date: Fri, 17 Feb 2017 16:55:01 -0600 Subject: [PATCH 9/9] Remove random seed call that was accidentally committed --- cmd/pilosactl/main.go | 2 -- 1 file changed, 2 deletions(-) diff --git a/cmd/pilosactl/main.go b/cmd/pilosactl/main.go index 08a86c708..bb22d14ac 100644 --- a/cmd/pilosactl/main.go +++ b/cmd/pilosactl/main.go @@ -53,8 +53,6 @@ func init() { if BuildTime == "" { BuildTime = "not recorded" } - - rand.Seed(time.Now().UTC().UnixNano()) } func main() {