2019-01-23 01:24:59 +00:00
|
|
|
export GOOS=windows
|
2020-07-30 23:36:58 +00:00
|
|
|
export DOCKER_IMAGE_NAME ?= windows-exporter
|
|
|
|
export DOCKER_REPO ?= ghcr.io/prometheus-community
|
|
|
|
|
|
|
|
VERSION?=$(shell cat VERSION)
|
|
|
|
DOCKER?=docker
|
|
|
|
|
|
|
|
# Image Variables for Hostprocess Container
|
|
|
|
# Windows image build is heavily influenced by https://github.com/kubernetes/kubernetes/blob/master/cluster/images/etcd/Makefile
|
|
|
|
OS=1809
|
|
|
|
ALL_OS:= 1809 ltsc2022
|
|
|
|
BASE_IMAGE=mcr.microsoft.com/windows/nanoserver
|
2019-01-23 01:24:59 +00:00
|
|
|
|
2020-12-01 11:06:46 +00:00
|
|
|
.PHONY: build
|
|
|
|
build: windows_exporter.exe
|
|
|
|
windows_exporter.exe: **/*.go
|
2017-09-08 08:11:31 +00:00
|
|
|
promu build -v
|
2019-01-23 01:24:59 +00:00
|
|
|
|
|
|
|
test:
|
|
|
|
go test -v ./...
|
|
|
|
|
2021-01-25 00:53:24 +00:00
|
|
|
bench:
|
|
|
|
go test -v -bench='benchmark(cpu|logicaldisk|logon|memory|net|process|service|system|tcp|time)collector' ./...
|
|
|
|
|
2018-10-02 07:25:01 +00:00
|
|
|
lint:
|
2019-10-19 14:50:13 +00:00
|
|
|
golangci-lint -c .golangci.yaml run
|
2018-10-02 07:25:01 +00:00
|
|
|
|
2020-11-30 09:31:37 +00:00
|
|
|
.PHONY: e2e-test
|
2020-12-01 11:06:46 +00:00
|
|
|
e2e-test: windows_exporter.exe
|
2021-12-30 04:09:33 +00:00
|
|
|
pwsh -NonInteractive -ExecutionPolicy Bypass -File .\tools\end-to-end-test.ps1
|
2020-11-30 09:31:37 +00:00
|
|
|
|
2022-01-03 03:33:45 +00:00
|
|
|
.PHONY: promtool
|
|
|
|
promtool: windows_exporter.exe
|
|
|
|
pwsh -NonInteractive -ExecutionPolicy Bypass -File .\tools\promtool.ps1
|
|
|
|
|
2018-10-02 07:25:01 +00:00
|
|
|
fmt:
|
|
|
|
gofmt -l -w -s .
|
|
|
|
|
2019-01-23 01:24:59 +00:00
|
|
|
crossbuild:
|
|
|
|
# The prometheus/golang-builder image for promu crossbuild doesn't exist
|
|
|
|
# on Windows, so for now, we'll just build twice
|
|
|
|
GOARCH=amd64 promu build --prefix=output/amd64
|
|
|
|
GOARCH=386 promu build --prefix=output/386
|
2020-07-30 23:36:58 +00:00
|
|
|
|
|
|
|
build-image: crossbuild
|
|
|
|
$(DOCKER) build --build-arg=BASE=$(BASE_IMAGE):$(OS) -f Dockerfile -t $(DOCKER_REPO)/$(DOCKER_IMAGE_NAME):$(VERSION)-$(OS) .
|
|
|
|
|
|
|
|
sub-build-%:
|
|
|
|
$(MAKE) OS=$* build-image
|
|
|
|
|
|
|
|
build-all: $(addprefix sub-build-,$(ALL_OS))
|
|
|
|
|
|
|
|
push:
|
|
|
|
set -x; \
|
|
|
|
for osversion in ${ALL_OS}; do \
|
|
|
|
$(DOCKER) push $(DOCKER_REPO)/$(DOCKER_IMAGE_NAME):$(VERSION)-$${osversion}; \
|
|
|
|
$(DOCKER) manifest create --amend $(DOCKER_REPO)/$(DOCKER_IMAGE_NAME):$(VERSION) $(DOCKER_REPO)/$(DOCKER_IMAGE_NAME):$(VERSION)-$${osversion}; \
|
|
|
|
full_version=`$(DOCKER) manifest inspect $(BASE_IMAGE):$${osversion} | grep "os.version" | head -n 1 | awk -F\" '{print $$4}'` || true; \
|
|
|
|
$(DOCKER) manifest annotate --os windows --arch amd64 --os-version $${full_version} $(DOCKER_REPO)/$(DOCKER_IMAGE_NAME):$(VERSION) $(DOCKER_REPO)/$(DOCKER_IMAGE_NAME):$(VERSION)-$${osversion}; \
|
|
|
|
done
|
|
|
|
$(DOCKER) manifest push --purge $(DOCKER_REPO)/$(DOCKER_IMAGE_NAME):$(VERSION)
|
|
|
|
|
|
|
|
push-all: build-all push
|