telegraf/Makefile

156 lines
3.7 KiB
Makefile
Raw Permalink Normal View History

ifeq ($(OS), Windows_NT)
VERSION := $(shell git describe --exact-match --tags 2>nul)
2018-07-12 05:57:46 +00:00
HOME := $(HOMEPATH)
CGO_ENABLED ?= 0
export CGO_ENABLED
2018-07-12 05:57:46 +00:00
else
VERSION := $(shell git describe --exact-match --tags 2>/dev/null)
endif
2017-08-03 18:54:05 +00:00
PREFIX := /usr/local
BRANCH := $(shell git rev-parse --abbrev-ref HEAD)
COMMIT := $(shell git rev-parse --short HEAD)
GOFILES ?= $(shell git ls-files '*.go')
GOFMT ?= $(shell gofmt -l -s $(filter-out plugins/parsers/influx/machine.go, $(GOFILES)))
2018-04-10 22:35:58 +00:00
BUILDFLAGS ?=
2018-02-01 23:05:39 +00:00
ifdef GOBIN
PATH := $(GOBIN):$(PATH)
2018-07-12 05:57:46 +00:00
else
PATH := $(subst :,/bin:,$(shell go env GOPATH))/bin:$(PATH)
endif
2017-08-10 23:33:31 +00:00
LDFLAGS := $(LDFLAGS) -X main.commit=$(COMMIT) -X main.branch=$(BRANCH)
ifdef VERSION
LDFLAGS += -X main.version=$(VERSION)
endif
.PHONY: all
2017-08-09 18:47:55 +00:00
all:
@$(MAKE) --no-print-directory deps
@$(MAKE) --no-print-directory telegraf
2017-08-03 18:54:05 +00:00
.PHONY: deps
2017-08-03 18:54:05 +00:00
deps:
go mod download
2017-08-03 18:54:05 +00:00
.PHONY: telegraf
2017-08-03 18:54:05 +00:00
telegraf:
2018-05-04 21:08:23 +00:00
go build -ldflags "$(LDFLAGS)" ./cmd/telegraf
.PHONY: go-install
2017-08-03 18:54:05 +00:00
go-install:
2017-08-07 22:47:20 +00:00
go install -ldflags "-w -s $(LDFLAGS)" ./cmd/telegraf
.PHONY: install
2017-08-03 18:54:05 +00:00
install: telegraf
mkdir -p $(DESTDIR)$(PREFIX)/bin/
cp telegraf $(DESTDIR)$(PREFIX)/bin/
.PHONY: test
2017-08-03 18:54:05 +00:00
test:
go test -short ./...
.PHONY: fmt
2018-02-01 23:05:39 +00:00
fmt:
@gofmt -s -w $(filter-out plugins/parsers/influx/machine.go, $(GOFILES))
2018-02-01 23:05:39 +00:00
.PHONY: fmtcheck
2018-02-01 23:05:39 +00:00
fmtcheck:
2018-04-10 22:35:58 +00:00
@if [ ! -z "$(GOFMT)" ]; then \
2018-02-01 23:05:39 +00:00
echo "[ERROR] gofmt has found errors in the following files:" ; \
echo "$(GOFMT)" ; \
echo "" ;\
echo "Run make fmt to fix them." ; \
exit 1 ;\
fi
.PHONY: test-windows
2017-08-03 18:54:05 +00:00
test-windows:
2018-06-22 00:46:58 +00:00
go test -short ./plugins/inputs/ping/...
go test -short ./plugins/inputs/win_perf_counters/...
go test -short ./plugins/inputs/win_services/...
go test -short ./plugins/inputs/procstat/...
go test -short ./plugins/inputs/ntpq/...
go test -short ./plugins/processors/port_name/...
2017-08-03 18:54:05 +00:00
.PHONY: vet
2018-02-01 23:05:39 +00:00
vet:
@echo 'go vet $$(go list ./... | grep -v ./plugins/parsers/influx)'
2018-04-10 22:35:58 +00:00
@go vet $$(go list ./... | grep -v ./plugins/parsers/influx) ; if [ $$? -ne 0 ]; then \
2018-02-01 23:05:39 +00:00
echo ""; \
echo "go vet has found suspicious constructs. Please remediate any reported errors"; \
echo "to fix them before submitting code for review."; \
exit 1; \
fi
.PHONY: tidy
tidy:
go mod verify
go mod tidy
@if ! git diff --quiet go.mod go.sum; then \
echo "please run go mod tidy and check in changes"; \
exit 1; \
fi
.PHONY: check
check: fmtcheck vet
@$(MAKE) --no-print-directory tidy
2018-04-02 21:13:15 +00:00
.PHONY: test-all
2018-04-02 21:13:15 +00:00
test-all: fmtcheck vet
2017-08-03 18:54:05 +00:00
go test ./...
.PHONY: check-deps
check-deps:
./scripts/check-deps.sh
.PHONY: package
package:
./scripts/build.py --package --platform=all --arch=all
2017-11-07 21:54:36 +00:00
.PHONY: package-release
package-release:
./scripts/build.py --release --package --platform=all --arch=all \
--upload --bucket=dl.influxdata.com/telegraf/releases
.PHONY: package-nightly
package-nightly:
./scripts/build.py --nightly --package --platform=all --arch=all \
--upload --bucket=dl.influxdata.com/telegraf/nightlies
.PHONY: clean
2017-08-03 18:54:05 +00:00
clean:
2018-02-01 23:05:39 +00:00
rm -f telegraf
rm -f telegraf.exe
.PHONY: docker-image
docker-image:
docker build -f scripts/stretch.docker -t "telegraf:$(COMMIT)" .
plugins/parsers/influx/machine.go: plugins/parsers/influx/machine.go.rl
ragel -Z -G2 $^ -o $@
.PHONY: static
static:
@echo "Building static linux binary..."
@CGO_ENABLED=0 \
GOOS=linux \
GOARCH=amd64 \
go build -ldflags "$(LDFLAGS)" ./cmd/telegraf
.PHONY: plugin-%
plugin-%:
@echo "Starting dev environment for $${$(@)} input plugin..."
@docker-compose -f plugins/inputs/$${$(@)}/dev/docker-compose.yml up
.PHONY: ci-1.13
ci-1.13:
docker build -t quay.io/influxdb/telegraf-ci:1.13.8 - < scripts/ci-1.13.docker
docker push quay.io/influxdb/telegraf-ci:1.13.8
.PHONY: ci-1.12
2019-05-30 22:21:25 +00:00
ci-1.12:
docker build -t quay.io/influxdb/telegraf-ci:1.12.17 - < scripts/ci-1.12.docker
docker push quay.io/influxdb/telegraf-ci:1.12.17