2024-05-12 10:25:06 +00:00
|
|
|
GOOS ?= windows
|
|
|
|
VERSION ?= $(shell cat VERSION)
|
|
|
|
DOCKER ?= docker
|
2024-05-11 21:06:22 +00:00
|
|
|
|
|
|
|
# DOCKER_REPO is the official image repository name at docker.io, quay.io.
|
2024-05-12 10:25:06 +00:00
|
|
|
DOCKER_REPO ?= prometheuscommunity
|
|
|
|
DOCKER_IMAGE_NAME ?= windows-exporter
|
2024-05-11 21:06:22 +00:00
|
|
|
|
|
|
|
# ALL_DOCKER_REPOS is the list of repositories to push the image to. ghcr.io requires that org name be the same as the image repo name.
|
2024-09-11 12:19:14 +00:00
|
|
|
ALL_DOCKER_REPOS ?= docker.io/$(DOCKER_REPO) ghcr.io/prometheus-community # quay.io/$(DOCKER_REPO)
|
2020-07-30 23:36:58 +00:00
|
|
|
|
2024-05-12 10:25:06 +00:00
|
|
|
# Image Variables for host process Container
|
2020-07-30 23:36:58 +00:00
|
|
|
# Windows image build is heavily influenced by https://github.com/kubernetes/kubernetes/blob/master/cluster/images/etcd/Makefile
|
2024-05-12 10:25:06 +00:00
|
|
|
OS ?= ltsc2019
|
|
|
|
ALL_OS ?= ltsc2019 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
|
2024-05-03 05:30:31 +00:00
|
|
|
build: generate windows_exporter.exe
|
|
|
|
|
2023-11-04 19:51:35 +00:00
|
|
|
windows_exporter.exe: pkg/**/*.go
|
2017-09-08 08:11:31 +00:00
|
|
|
promu build -v
|
2019-01-23 01:24:59 +00:00
|
|
|
|
2024-05-03 05:30:31 +00:00
|
|
|
.PHONY: generate
|
|
|
|
generate:
|
|
|
|
go generate ./...
|
|
|
|
|
2019-01-23 01:24:59 +00:00
|
|
|
test:
|
|
|
|
go test -v ./...
|
|
|
|
|
2021-01-25 00:53:24 +00:00
|
|
|
bench:
|
2024-05-17 16:47:32 +00:00
|
|
|
go test -v -bench='benchmarkcollector' ./pkg/collector/{cpu,logical_disk,physical_disk,logon,memory,net,printer,process,service,system,tcp,time}
|
2021-01-25 00:53:24 +00:00
|
|
|
|
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 .
|
|
|
|
|
2024-05-03 05:30:31 +00:00
|
|
|
crossbuild: generate
|
2019-01-23 01:24:59 +00:00
|
|
|
# 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
|
2022-09-03 00:21:38 +00:00
|
|
|
GOARCH=arm64 promu build --prefix=output/arm64
|
2020-07-30 23:36:58 +00:00
|
|
|
|
2024-05-11 22:24:52 +00:00
|
|
|
.PHONY: package
|
|
|
|
package: crossbuild
|
|
|
|
powershell -NonInteractive -ExecutionPolicy Bypass -File .\installer\build.ps1 -PathToExecutable .\output\amd64\windows_exporter.exe -Version $(shell git describe --tags --abbrev=0)
|
|
|
|
|
2020-07-30 23:36:58 +00:00
|
|
|
build-image: crossbuild
|
2024-09-11 12:19:14 +00:00
|
|
|
$(DOCKER) build --build-arg=BASE=$(BASE_IMAGE):$(OS) -f Dockerfile -t local/$(DOCKER_IMAGE_NAME):$(VERSION)-$(OS) .
|
2020-07-30 23:36:58 +00:00
|
|
|
|
2024-07-22 13:21:05 +00:00
|
|
|
build-hostprocess:
|
2024-09-11 12:19:14 +00:00
|
|
|
$(DOCKER) buildx build --build-arg=BASE=mcr.microsoft.com/oss/kubernetes/windows-host-process-containers-base-image:v1.0.0 -f Dockerfile -t local/$(DOCKER_IMAGE_NAME):$(VERSION)-hostprocess .
|
2024-07-22 13:21:05 +00:00
|
|
|
|
2020-07-30 23:36:58 +00:00
|
|
|
sub-build-%:
|
|
|
|
$(MAKE) OS=$* build-image
|
|
|
|
|
2024-07-22 13:21:05 +00:00
|
|
|
build-all: $(addprefix sub-build-,$(ALL_OS)) build-hostprocess
|
2020-07-30 23:36:58 +00:00
|
|
|
|
|
|
|
push:
|
|
|
|
set -x; \
|
2024-05-17 17:38:51 +00:00
|
|
|
for docker_repo in ${DOCKER_REPO}; do \
|
|
|
|
for osversion in ${ALL_OS}; do \
|
2024-09-11 12:19:14 +00:00
|
|
|
$(DOCKER) tag local/$(DOCKER_IMAGE_NAME):$(VERSION)-$${osversion} $${docker_repo}/$(DOCKER_IMAGE_NAME):$(VERSION)-$${osversion}; \
|
|
|
|
$(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}; \
|
2024-05-17 17:38:51 +00:00
|
|
|
full_version=`$(DOCKER) manifest inspect $(BASE_IMAGE):$${osversion} | grep "os.version" | head -n 1 | awk -F\" '{print $$4}'` || true; \
|
2024-09-11 12:19:14 +00:00
|
|
|
$(DOCKER) manifest annotate --os windows --arch amd64 --os-version $${full_version} $${docker_repo}/$(DOCKER_IMAGE_NAME):$(VERSION) $${docker_repo}/$(DOCKER_IMAGE_NAME):$(VERSION)-$${osversion}; \
|
2024-05-17 17:38:51 +00:00
|
|
|
done; \
|
2024-09-11 12:19:14 +00:00
|
|
|
$(DOCKER) manifest push --purge $${docker_repo}/$(DOCKER_IMAGE_NAME):$(VERSION); \
|
2020-07-30 23:36:58 +00:00
|
|
|
done
|
2024-05-11 21:06:22 +00:00
|
|
|
|
2024-07-22 13:21:05 +00:00
|
|
|
# We can't load the image into the local docker store, so we have to build and push it in one go
|
|
|
|
push-hostprocess:
|
|
|
|
set -x; \
|
|
|
|
for docker_repo in ${DOCKER_REPO}; do \
|
2024-09-11 12:19:14 +00:00
|
|
|
$(DOCKER) buildx build --push --build-arg=BASE=mcr.microsoft.com/oss/kubernetes/windows-host-process-containers-base-image:v1.0.0 -f Dockerfile -t $${docker_repo}/$(DOCKER_IMAGE_NAME):$(VERSION)-hostprocess .; \
|
2024-07-22 13:21:05 +00:00
|
|
|
done
|
|
|
|
|
2024-05-12 10:25:06 +00:00
|
|
|
.PHONY: push-all
|
2024-05-17 17:38:51 +00:00
|
|
|
push-all: build-all
|
2024-07-29 07:28:44 +00:00
|
|
|
$(MAKE) DOCKER_REPO="$(ALL_DOCKER_REPOS)" push # push-hostprocess - disabled until it works on Windows
|
2020-07-30 23:36:58 +00:00
|
|
|
|
2024-05-11 21:06:22 +00:00
|
|
|
# Mandatory target for container description sync action
|
|
|
|
.PHONY: docker-repo-name
|
|
|
|
docker-repo-name:
|
2024-07-24 14:01:22 +00:00
|
|
|
@echo "$(DOCKER_REPO)/$(DOCKER_IMAGE_NAME)"
|