Merge pull request #390 from xueweiz/make

Fix build tags manipulation in Makefile
This commit is contained in:
Kubernetes Prow Robot
2019-11-26 15:13:20 -08:00
committed by GitHub
6 changed files with 27 additions and 10 deletions

View File

@@ -29,3 +29,5 @@ script:
- BUILD_TAGS="disable_system_stats_monitor" make test
- make clean && BUILD_TAGS="disable_stackdriver_exporter" make
- BUILD_TAGS="disable_stackdriver_exporter" make test
- make clean && ENABLE_JOURNALD=0 make
- ENABLE_JOURNALD=0 make test

View File

@@ -21,6 +21,9 @@ RUN clean-install libsystemd0 bash
RUN test -h /etc/localtime && rm -f /etc/localtime && cp /usr/share/zoneinfo/UTC /etc/localtime || true
ADD ./bin/node-problem-detector /node-problem-detector
# Below command depends on ENABLE_JOURNAL=1.
ADD ./bin/log-counter /home/kubernetes/bin/log-counter
ADD config /config
ENTRYPOINT ["/node-problem-detector", "--system-log-monitors=/config/kernel-monitor.json"]

View File

@@ -60,7 +60,7 @@ BASEIMAGE:=k8s.gcr.io/debian-base-amd64:v1.0.0
CGO_ENABLED:=0
# Construct the "-tags" parameter used by "go build".
BUILD_TAGS?=""
BUILD_TAGS?=
ifeq ($(ENABLE_JOURNALD), 1)
# Enable journald build tag.
BUILD_TAGS:=$(BUILD_TAGS) journald
@@ -71,14 +71,11 @@ ifeq ($(ENABLE_JOURNALD), 1)
# statically linked application.
CGO_ENABLED:=1
endif
ifneq ($(BUILD_TAGS), "")
BUILD_TAGS:=-tags "$(BUILD_TAGS)"
endif
vet:
GO111MODULE=on go list -mod vendor $(BUILD_TAGS) ./... | \
GO111MODULE=on go list -mod vendor -tags "$(BUILD_TAGS)" ./... | \
grep -v "./vendor/*" | \
GO111MODULE=on xargs go vet -mod vendor $(BUILD_TAGS)
GO111MODULE=on xargs go vet -mod vendor -tags "$(BUILD_TAGS)"
fmt:
find . -type f -name "*.go" | grep -v "./vendor/*" | xargs gofmt -s -w -l
@@ -87,29 +84,38 @@ version:
@echo $(VERSION)
./bin/log-counter: $(PKG_SOURCES)
ifeq ($(ENABLE_JOURNALD), 1)
CGO_ENABLED=$(CGO_ENABLED) GOOS=linux GO111MODULE=on go build \
-mod vendor \
-o bin/log-counter \
-ldflags '-X $(PKG)/pkg/version.version=$(VERSION)' \
$(BUILD_TAGS) \
-tags "$(BUILD_TAGS)" \
cmd/logcounter/log_counter.go
else
echo "Warning: log-counter requires journald, skipping."
endif
./bin/node-problem-detector: $(PKG_SOURCES)
CGO_ENABLED=$(CGO_ENABLED) GOOS=linux GO111MODULE=on go build \
-mod vendor \
-o bin/node-problem-detector \
-ldflags '-X $(PKG)/pkg/version.version=$(VERSION)' \
$(BUILD_TAGS) \
-tags "$(BUILD_TAGS)" \
./cmd/nodeproblemdetector
Dockerfile: Dockerfile.in
sed -e 's|@BASEIMAGE@|$(BASEIMAGE)|g' $< >$@
ifneq ($(ENABLE_JOURNALD), 1)
sed -i '/Below command depends on ENABLE_JOURNAL=1/,+2d' $@
echo "Warning: log-counter requires journald, skipping."
endif
test: vet fmt
GO111MODULE=on go test -mod vendor -timeout=1m -v -race -short $(BUILD_TAGS) ./...
GO111MODULE=on go test -mod vendor -timeout=1m -v -race -short -tags "$(BUILD_TAGS)" ./...
e2e-test: vet fmt build-tar
GO111MODULE=on go test -mod vendor -timeout=10m -v $(BUILD_TAGS) \
GO111MODULE=on go test -mod vendor -timeout=10m -v -tags "$(BUILD_TAGS)" \
./test/e2e/metriconly/... \
-project=$(PROJECT) -zone=$(ZONE) \
-image=$(VM_IMAGE) -image-family=$(IMAGE_FAMILY) -image-project=$(IMAGE_PROJECT) \

View File

@@ -1,3 +1,5 @@
// +build journald
/*
Copyright 2018 The Kubernetes Authors All rights reserved.

View File

@@ -1,3 +1,5 @@
// +build journald
/*
Copyright 2018 The Kubernetes Authors All rights reserved.

View File

@@ -1,3 +1,5 @@
// +build journald
/*
Copyright 2018 The Kubernetes Authors All rights reserved.