makefile improvements
This commit is contained in:
parent
6b0c104d05
commit
75e6bfa55c
28
Makefile
28
Makefile
|
|
@ -1,7 +1,12 @@
|
||||||
.PHONY: clean local linux macos docker push scm-source.json
|
.PHONY: clean local linux macos docker push scm-source.json
|
||||||
|
|
||||||
|
ifeq ($(RACE),1)
|
||||||
|
GOFLAGS=-race
|
||||||
|
endif
|
||||||
|
|
||||||
BINARY ?= postgres-operator
|
BINARY ?= postgres-operator
|
||||||
BUILD_FLAGS ?= -i
|
BUILD_FLAGS ?= -i -v
|
||||||
|
LDFLAGS ?= -X=main.version=$(VERSION)
|
||||||
DOCKERFILE = docker/Dockerfile
|
DOCKERFILE = docker/Dockerfile
|
||||||
IMAGE ?= pierone.example.com/acid/$(BINARY)
|
IMAGE ?= pierone.example.com/acid/$(BINARY)
|
||||||
TAG ?= $(VERSION)
|
TAG ?= $(VERSION)
|
||||||
|
|
@ -11,6 +16,8 @@ GITSTATUS = $(shell git status --porcelain || echo "no changes")
|
||||||
SOURCES = cmd/main.go
|
SOURCES = cmd/main.go
|
||||||
VERSION ?= $(shell git describe --tags --always --dirty)
|
VERSION ?= $(shell git describe --tags --always --dirty)
|
||||||
IMAGE ?= pierone.example.com/acid/$(BINARY)
|
IMAGE ?= pierone.example.com/acid/$(BINARY)
|
||||||
|
DIRS := cmd pkg
|
||||||
|
PKG := `go list ./... | grep -v /vendor/`
|
||||||
|
|
||||||
default: local
|
default: local
|
||||||
|
|
||||||
|
|
@ -22,13 +29,13 @@ linux: build/linux/${BINARY}
|
||||||
macos: build/macos/${BINARY}
|
macos: build/macos/${BINARY}
|
||||||
|
|
||||||
build/${BINARY}: ${SOURCES}
|
build/${BINARY}: ${SOURCES}
|
||||||
go build -o $@ $(BUILD_FLAGS) $^
|
go build -o $@ $(BUILD_FLAGS) -ldflags "$(LDFLAGS)" $^
|
||||||
|
|
||||||
build/linux/${BINARY}: ${SOURCES}
|
build/linux/${BINARY}: ${SOURCES}
|
||||||
GOOS=linux GOARCH=amd64 go build -o $@ ${BUILD_FLAGS} $^
|
GOOS=linux GOARCH=amd64 go build -o $@ ${BUILD_FLAGS} -ldflags "$(LDFLAGS)" $^
|
||||||
|
|
||||||
build/macos/${BINARY}: ${SOURCES}
|
build/macos/${BINARY}: ${SOURCES}
|
||||||
GOOS=darwin GOARCH=amd64 go build -o $@ ${BUILD_FLAGS} $^
|
GOOS=darwin GOARCH=amd64 go build -o $@ ${BUILD_FLAGS} -ldflags "$(LDFLAGS)" $^
|
||||||
|
|
||||||
docker-context: scm-source.json linux
|
docker-context: scm-source.json linux
|
||||||
mkdir -p docker/build/
|
mkdir -p docker/build/
|
||||||
|
|
@ -43,3 +50,16 @@ push:
|
||||||
scm-source.json: .git
|
scm-source.json: .git
|
||||||
echo '{\n "url": "$(GITURL)",\n "revision": "$(GITHEAD)",\n "author": "$(USER)",\n "status": "$(GITSTATUS)"\n}' > scm-source.json
|
echo '{\n "url": "$(GITURL)",\n "revision": "$(GITHEAD)",\n "author": "$(USER)",\n "status": "$(GITSTATUS)"\n}' > scm-source.json
|
||||||
|
|
||||||
|
tools:
|
||||||
|
@go get -u honnef.co/go/staticcheck/cmd/staticcheck
|
||||||
|
@go get -u github.com/Masterminds/glide
|
||||||
|
|
||||||
|
fmt:
|
||||||
|
@gofmt -l -w -s $(DIRS)
|
||||||
|
|
||||||
|
vet:
|
||||||
|
@go vet $(PKG)
|
||||||
|
@$(GOPATH)/bin/staticcheck $(PKG)
|
||||||
|
|
||||||
|
deps:
|
||||||
|
@$(GOPATH)/bin/glide install
|
||||||
22
README.md
22
README.md
|
|
@ -13,27 +13,25 @@
|
||||||
$ export GOPATH=~/git/go
|
$ export GOPATH=~/git/go
|
||||||
$ mkdir -p ${GOPATH}/src/github.bus.zalan.do/acid/
|
$ mkdir -p ${GOPATH}/src/github.bus.zalan.do/acid/
|
||||||
$ cd ${GOPATH}/src/github.bus.zalan.do/acid/ && git clone https://github.bus.zalan.do/acid/postgres-operator -b prototype
|
$ cd ${GOPATH}/src/github.bus.zalan.do/acid/ && git clone https://github.bus.zalan.do/acid/postgres-operator -b prototype
|
||||||
|
|
||||||
### Install Glide on OS X
|
|
||||||
|
|
||||||
$ brew install glide
|
### Install Glide and Staticcheck
|
||||||
|
|
||||||
### Install Glide on Ubuntu
|
$ make tools
|
||||||
|
|
||||||
# sudo add-apt-repository ppa:masterminds/glide && sudo apt-get update
|
|
||||||
# sudo apt-get install glide
|
|
||||||
|
|
||||||
### Install dependencies with Glide
|
### Install dependencies with Glide
|
||||||
|
|
||||||
$ glide update && glide install
|
$ make deps
|
||||||
|
|
||||||
### Build dependencies
|
### Build dependencies
|
||||||
|
|
||||||
$ go build -i -v cmd
|
$ go build -i -v cmd
|
||||||
|
|
||||||
### Run operator (outside kubernetes cluster)
|
## Run operator (as a pod)
|
||||||
|
|
||||||
$ go run cmd/main.go
|
$ docker build -t postgres-operator:0.1 .
|
||||||
|
$ kubectl create -f postgres-operator.yaml
|
||||||
|
|
||||||
|
If you are building docker image by yourself on OS X make sure postgres-operator is compiled with GOOS=linux flag
|
||||||
|
|
||||||
### Check if ThirdPartyResource has been registered
|
### Check if ThirdPartyResource has been registered
|
||||||
|
|
||||||
|
|
@ -45,7 +43,7 @@
|
||||||
|
|
||||||
### Create a new spilo cluster
|
### Create a new spilo cluster
|
||||||
|
|
||||||
$ kubectl create -f testcluster.yaml
|
$ kubectl create -f manifests/testspilo.yaml
|
||||||
|
|
||||||
### Watch Pods being created
|
### Watch Pods being created
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -9,5 +9,4 @@ mkdir -p "$team_repo"
|
||||||
ln -s "$PWD" "$project_dir"
|
ln -s "$PWD" "$project_dir"
|
||||||
cd "$project_dir"
|
cd "$project_dir"
|
||||||
|
|
||||||
glide install
|
make deps clean docker push
|
||||||
make clean docker push
|
|
||||||
|
|
|
||||||
|
|
@ -13,6 +13,7 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
var options controller.Options
|
var options controller.Options
|
||||||
|
var version string
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
pflag.StringVar(&options.KubeConfig, "kubeconfig", "", "Path to kubeconfig file with authorization and master location information.")
|
pflag.StringVar(&options.KubeConfig, "kubeconfig", "", "Path to kubeconfig file with authorization and master location information.")
|
||||||
|
|
@ -22,6 +23,7 @@ func init() {
|
||||||
func main() {
|
func main() {
|
||||||
// Set logging output to standard console out
|
// Set logging output to standard console out
|
||||||
log.SetOutput(os.Stdout)
|
log.SetOutput(os.Stdout)
|
||||||
|
log.Printf("Spilo operator %s\n", version)
|
||||||
|
|
||||||
pflag.CommandLine.AddGoFlagSet(flag.CommandLine)
|
pflag.CommandLine.AddGoFlagSet(flag.CommandLine)
|
||||||
pflag.Parse()
|
pflag.Parse()
|
||||||
|
|
@ -32,8 +34,8 @@ func main() {
|
||||||
|
|
||||||
wg := &sync.WaitGroup{} // Goroutines can add themselves to this to be waited on
|
wg := &sync.WaitGroup{} // Goroutines can add themselves to this to be waited on
|
||||||
|
|
||||||
spiloOperator := controller.New(options)
|
c := controller.New(options)
|
||||||
spiloOperator.Run(stop, wg)
|
c.Run(stop, wg)
|
||||||
|
|
||||||
sig := <-sigs // Wait for signals (this hangs until a signal arrives)
|
sig := <-sigs // Wait for signals (this hangs until a signal arrives)
|
||||||
log.Printf("Shutting down... %+v", sig)
|
log.Printf("Shutting down... %+v", sig)
|
||||||
|
|
|
||||||
|
|
@ -3,4 +3,4 @@ MAINTAINER Team ACID @ Zalando <team-acid@zalando.de>
|
||||||
|
|
||||||
COPY build/* /
|
COPY build/* /
|
||||||
|
|
||||||
ENTRYPOINT ["/postres-operator"]
|
ENTRYPOINT ["/postgres-operator"]
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
hash: c45b505f8cf3c9b967a7244e0a675ae11c158d0168496bed18a43270e2cebfe9
|
hash: 19831a9408f172d009617c781ea65141606a216aa8e238797e102c511f4afb1f
|
||||||
updated: 2017-01-09T11:28:31.075588565+01:00
|
updated: 2017-01-27T13:24:40.647376238+01:00
|
||||||
imports:
|
imports:
|
||||||
- name: cloud.google.com/go
|
- name: cloud.google.com/go
|
||||||
version: 3b1ae45394a234c385be014e9a488f2bb6eef821
|
version: 3b1ae45394a234c385be014e9a488f2bb6eef821
|
||||||
|
|
@ -9,7 +9,7 @@ imports:
|
||||||
- name: github.com/blang/semver
|
- name: github.com/blang/semver
|
||||||
version: 31b736133b98f26d5e078ec9eb591666edfd091f
|
version: 31b736133b98f26d5e078ec9eb591666edfd091f
|
||||||
- name: github.com/coreos/etcd
|
- name: github.com/coreos/etcd
|
||||||
version: 3d5ba43211beec7fbb1472634a9c3b464581658a
|
version: 8ba2897a21e4fc51b298ca553d251318425f93ae
|
||||||
subpackages:
|
subpackages:
|
||||||
- client
|
- client
|
||||||
- pkg/pathutil
|
- pkg/pathutil
|
||||||
|
|
@ -25,7 +25,6 @@ imports:
|
||||||
- name: github.com/coreos/pkg
|
- name: github.com/coreos/pkg
|
||||||
version: fa29b1d70f0beaddd4c7021607cc3c3be8ce94b8
|
version: fa29b1d70f0beaddd4c7021607cc3c3be8ce94b8
|
||||||
subpackages:
|
subpackages:
|
||||||
- capnslog
|
|
||||||
- health
|
- health
|
||||||
- httputil
|
- httputil
|
||||||
- timeutil
|
- timeutil
|
||||||
|
|
@ -54,16 +53,15 @@ imports:
|
||||||
- name: github.com/go-openapi/swag
|
- name: github.com/go-openapi/swag
|
||||||
version: 1d0bd113de87027671077d3c71eb3ac5d7dbba72
|
version: 1d0bd113de87027671077d3c71eb3ac5d7dbba72
|
||||||
- name: github.com/gogo/protobuf
|
- name: github.com/gogo/protobuf
|
||||||
version: 8d70fb3182befc465c4a1eac8ad4d38ff49778e2
|
version: e18d7aa8f8c624c915db340349aad4c49b10d173
|
||||||
subpackages:
|
subpackages:
|
||||||
- proto
|
- proto
|
||||||
- sortkeys
|
- sortkeys
|
||||||
- name: github.com/golang/glog
|
- name: github.com/golang/glog
|
||||||
version: 44145f04b68cf362d9c4df2182967c2275eaefed
|
version: 44145f04b68cf362d9c4df2182967c2275eaefed
|
||||||
- name: github.com/golang/protobuf
|
- name: github.com/golang/protobuf
|
||||||
version: 4bd1920723d7b7c925de087aa32e2187708897f7
|
version: 8616e8ee5e20a1704615e6c8d7afcdac06087a67
|
||||||
subpackages:
|
subpackages:
|
||||||
- jsonpb
|
|
||||||
- proto
|
- proto
|
||||||
- name: github.com/google/gofuzz
|
- name: github.com/google/gofuzz
|
||||||
version: bbcb9da2d746f8bdbd6a936686a0a6067ada0ec5
|
version: bbcb9da2d746f8bdbd6a936686a0a6067ada0ec5
|
||||||
|
|
@ -72,7 +70,7 @@ imports:
|
||||||
- name: github.com/imdario/mergo
|
- name: github.com/imdario/mergo
|
||||||
version: 6633656539c1639d9d78127b7d47c622b5d7b6dc
|
version: 6633656539c1639d9d78127b7d47c622b5d7b6dc
|
||||||
- name: github.com/jonboulle/clockwork
|
- name: github.com/jonboulle/clockwork
|
||||||
version: 2eee05ed794112d45db504eb05aa693efd2b8b09
|
version: 72f9bd7c4e0c2a40055ab3d0f09654f730cce982
|
||||||
- name: github.com/mailru/easyjson
|
- name: github.com/mailru/easyjson
|
||||||
version: d5b7844b561a7bc640052f1b935f7b800330d7e0
|
version: d5b7844b561a7bc640052f1b935f7b800330d7e0
|
||||||
subpackages:
|
subpackages:
|
||||||
|
|
@ -92,19 +90,18 @@ imports:
|
||||||
subpackages:
|
subpackages:
|
||||||
- codec
|
- codec
|
||||||
- name: golang.org/x/crypto
|
- name: golang.org/x/crypto
|
||||||
version: 1351f936d976c60a0a48d728281922cf63eafb8d
|
version: 1f22c0103821b9390939b6776727195525381532
|
||||||
subpackages:
|
subpackages:
|
||||||
- bcrypt
|
|
||||||
- blowfish
|
|
||||||
- ssh/terminal
|
- ssh/terminal
|
||||||
- name: golang.org/x/net
|
- name: golang.org/x/net
|
||||||
version: 6acef71eb69611914f7a30939ea9f6e194c78172
|
version: e90d6d0afc4c315a0d87a568ae68577cc15149a0
|
||||||
subpackages:
|
subpackages:
|
||||||
- context
|
- context
|
||||||
- context/ctxhttp
|
- context/ctxhttp
|
||||||
- http2
|
- http2
|
||||||
- http2/hpack
|
- http2/hpack
|
||||||
- idna
|
- idna
|
||||||
|
- lex/httplex
|
||||||
- name: golang.org/x/oauth2
|
- name: golang.org/x/oauth2
|
||||||
version: 3c3a985cb79f52a3190fbc056984415ca6763d01
|
version: 3c3a985cb79f52a3190fbc056984415ca6763d01
|
||||||
subpackages:
|
subpackages:
|
||||||
|
|
|
||||||
|
|
@ -67,8 +67,6 @@ func New(options Options) *SpiloOperator {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (o *SpiloOperator) Run(stopCh <-chan struct{}, wg *sync.WaitGroup) {
|
func (o *SpiloOperator) Run(stopCh <-chan struct{}, wg *sync.WaitGroup) {
|
||||||
log.Printf("Spilo operator %v\n", VERSION)
|
|
||||||
|
|
||||||
go o.Controller.Run(stopCh, wg)
|
go o.Controller.Run(stopCh, wg)
|
||||||
|
|
||||||
log.Println("Started working in background")
|
log.Println("Started working in background")
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue