|
1 | | -.PHONY: all container push clean node-problem-detector vet fmt version |
| 1 | +.PHONY: all build-container build-tar build push-container push-tar push clean vet fmt version |
2 | 2 |
|
3 | | -all: push |
| 3 | +all: build |
4 | 4 |
|
5 | 5 | VERSION := $(shell git describe --tags --dirty) |
6 | 6 |
|
7 | 7 | TAG ?= $(VERSION) |
8 | 8 |
|
9 | | -PROJ = google_containers |
| 9 | +UPLOAD_PATH ?= gs://kubernetes-release |
| 10 | +# Trim the trailing '/' in the path |
| 11 | +UPLOAD_PATH := $(shell echo $(UPLOAD_PATH) | sed '$$s/\/*$$//') |
| 12 | + |
| 13 | +PROJ ?= google_containers |
10 | 14 |
|
11 | 15 | PKG := k8s.io/node-problem-detector |
12 | 16 |
|
13 | 17 | PKG_SOURCES := $(shell find pkg cmd -name '*.go') |
14 | 18 |
|
| 19 | +TARBALL := node-problem-detector-$(VERSION).tar.gz |
| 20 | + |
| 21 | +IMAGE := gcr.io/$(PROJ)/node-problem-detector:$(TAG) |
| 22 | + |
15 | 23 | vet: |
16 | 24 | go list ./... | grep -v "./vendor/*" | xargs go vet |
17 | 25 |
|
|
21 | 29 | version: |
22 | 30 | @echo $(VERSION) |
23 | 31 |
|
24 | | -node-problem-detector: $(PKG_SOURCES) fmt vet |
25 | | - GOOS=linux go build -o node-problem-detector \ |
| 32 | +./bin/node-problem-detector: $(PKG_SOURCES) |
| 33 | + GOOS=linux go build -o bin/node-problem-detector \ |
26 | 34 | -ldflags '-w -extldflags "-static" -X $(PKG)/pkg/version.version=$(VERSION)' \ |
27 | 35 | cmd/node_problem_detector.go |
28 | 36 |
|
29 | | -test: |
| 37 | +test: vet fmt |
30 | 38 | go test -timeout=1m -v -race ./pkg/... |
31 | 39 |
|
32 | | -container: node-problem-detector |
33 | | - docker build -t gcr.io/$(PROJ)/node-problem-detector:$(TAG) . |
| 40 | +build-container: ./bin/node-problem-detector |
| 41 | + docker build -t $(IMAGE) . |
| 42 | + |
| 43 | +build-tar: ./bin/node-problem-detector |
| 44 | + tar -zcvf $(TARBALL) bin/ config/ |
| 45 | + sha1sum $(TARBALL) |
| 46 | + md5sum $(TARBALL) |
| 47 | + |
| 48 | +build: build-container build-tar |
| 49 | + |
| 50 | +push-container: build-container |
| 51 | + gcloud docker push $(IMAGE) |
| 52 | + |
| 53 | +push-tar: build-tar |
| 54 | + gsutil cp $(TARBALL) $(UPLOAD_PATH)/node-problem-detector/ |
34 | 55 |
|
35 | | -push: container |
36 | | - gcloud docker push gcr.io/$(PROJ)/node-problem-detector:$(TAG) |
| 56 | +push: push-container push-tar |
37 | 57 |
|
38 | 58 | clean: |
39 | | - rm -f node-problem-detector |
| 59 | + rm -f bin/node-problem-detector |
| 60 | + rm -f node-problem-detector-*.tar.gz |
0 commit comments