2018-10-08 13:17:05 +02:00
|
|
|
.PHONY: clean test check build.local build.linux build.osx build.docker build.push
|
|
|
|
|
|
|
|
BINARY ?= kube-metrics-adapter
|
|
|
|
VERSION ?= $(shell git describe --tags --always --dirty)
|
2018-10-14 11:37:58 +02:00
|
|
|
IMAGE ?= registry-write.opensource.zalan.do/teapot/$(BINARY)
|
2018-10-08 13:17:05 +02:00
|
|
|
TAG ?= $(VERSION)
|
|
|
|
SOURCES = $(shell find . -name '*.go')
|
|
|
|
DOCKERFILE ?= Dockerfile
|
|
|
|
GOPKGS = $(shell go list ./...)
|
|
|
|
BUILD_FLAGS ?= -v
|
|
|
|
LDFLAGS ?= -X main.version=$(VERSION) -w -s
|
|
|
|
|
|
|
|
default: build.local
|
|
|
|
|
|
|
|
clean:
|
|
|
|
rm -rf build
|
|
|
|
|
|
|
|
test:
|
|
|
|
go test -v $(GOPKGS)
|
|
|
|
|
|
|
|
check:
|
2019-11-25 10:55:38 +01:00
|
|
|
go mod download
|
|
|
|
golangci-lint run --timeout=2m ./...
|
2018-10-08 13:17:05 +02:00
|
|
|
|
|
|
|
build.local: build/$(BINARY)
|
|
|
|
build.linux: build/linux/$(BINARY)
|
|
|
|
build.osx: build/osx/$(BINARY)
|
|
|
|
|
|
|
|
build/$(BINARY): go.mod $(SOURCES)
|
|
|
|
CGO_ENABLED=0 go build -o build/$(BINARY) $(BUILD_FLAGS) -ldflags "$(LDFLAGS)" .
|
|
|
|
|
|
|
|
build/linux/$(BINARY): go.mod $(SOURCES)
|
|
|
|
GOOS=linux GOARCH=amd64 CGO_ENABLED=0 go build $(BUILD_FLAGS) -o build/linux/$(BINARY) -ldflags "$(LDFLAGS)" .
|
|
|
|
|
|
|
|
build/osx/$(BINARY): go.mod $(SOURCES)
|
|
|
|
GOOS=darwin GOARCH=amd64 CGO_ENABLED=0 go build $(BUILD_FLAGS) -o build/osx/$(BINARY) -ldflags "$(LDFLAGS)" .
|
|
|
|
|
|
|
|
build.docker: build.linux
|
|
|
|
docker build --rm -t "$(IMAGE):$(TAG)" -f $(DOCKERFILE) .
|
|
|
|
|
|
|
|
build.push: build.docker
|
|
|
|
docker push "$(IMAGE):$(TAG)"
|