-
Notifications
You must be signed in to change notification settings - Fork 4
/
Makefile
83 lines (62 loc) · 3.36 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
VERSION?=1.0.1
GOOS=$(shell go env GOOS)
GOARCH=$(shell go env GOARCH)
.PHONY: all
all: config collector-bin collector-dist
.PHONY: config
config: artifacts/honeycomb-metrics-config.yaml
.PHONY: collector-bin
collector-bin: build/otelcol_hny_darwin_amd64 build/otelcol_hny_darwin_arm64 build/otelcol_hny_linux_amd64 build/otelcol_hny_linux_arm64 build/otelcol_hny_windows_amd64.exe
.PHONY: collector-dist
collector-dist: dist/otel-hny-collector_$(VERSION)_amd64.deb dist/otel-hny-collector_$(VERSION)_arm64.deb dist/otel-hny-collector_$(VERSION)_x86_64.rpm dist/otel-hny-collector_$(VERSION)_arm64.rpm
.PHONY: release
release:
$(MAKE) clean
$(MAKE) test
$(MAKE) artifacts/honeycomb-metrics-config.yaml
$(MAKE) collector-bin
$(MAKE) collector-dist
cp build/otelcol_hny_* dist
cp artifacts/honeycomb-metrics-config.yaml dist
(cd dist && shasum -a 256 * > checksums.txt)
.PHONY: test
test: integration_test
.PHONY: integration_test
integration_test: test/test.sh build/otelcol_hny_$(GOOS)_$(GOARCH) artifacts/honeycomb-metrics-config.yaml
./test/test.sh
# generate a configuration file for otel-collector that results in a favorable repackaging ratio
artifacts/honeycomb-metrics-config.yaml: config-generator.jq vendor-fixtures/hostmetrics-receiver-metadata.yaml
mkdir -p ./artifacts
yq -y -f ./config-generator.jq < ./vendor-fixtures/hostmetrics-receiver-metadata.yaml > ./artifacts/honeycomb-metrics-config.yaml
# copy hostmetrics metadata yaml file from the OpenTelemetry Collector repository, and prepend a note saying it's vendored
vendor-fixtures/hostmetrics-receiver-metadata.yaml:
REMOTE_PATH='https://raw.githubusercontent.com/open-telemetry/opentelemetry-collector-contrib/141da3a5c4a1bf1570372e2890af383dd833167b/receiver/hostmetricsreceiver/metadata.yaml'; \
curl $$REMOTE_PATH | sed "1s|^|# DO NOT EDIT! This file is vendored from $${REMOTE_PATH}"$$'\\\n\\\n|' > vendor-fixtures/hostmetrics-receiver-metadata.yaml
build/otelcol_hny_darwin_amd64:
GOOS=darwin GOARCH=amd64 $(MAKE) build-binary-internal
build/otelcol_hny_darwin_arm64:
GOOS=darwin GOARCH=arm64 $(MAKE) build-binary-internal
build/otelcol_hny_linux_amd64:
GOOS=linux GOARCH=amd64 $(MAKE) build-binary-internal
build/otelcol_hny_linux_arm64:
GOOS=linux GOARCH=arm64 $(MAKE) build-binary-internal
build/otelcol_hny_windows_amd64.exe:
GOOS=windows GOARCH=amd64 EXTENSION=.exe $(MAKE) build-binary-internal
.PHONY: build-binary-internal
build-binary-internal: builder-config.yaml
ocb --output-path=build --name=otelcol_hny_$(GOOS)_$(GOARCH)$(EXTENSION) --version=$(VERSION) --config=builder-config.yaml
dist/otel-hny-collector_%_amd64.deb: build/otelcol_hny_linux_amd64
PACKAGE=deb ARCH=amd64 VERSION=$* $(MAKE) build-package-internal
dist/otel-hny-collector_%_arm64.deb: build/otelcol_hny_linux_arm64
PACKAGE=deb ARCH=arm64 VERSION=$* $(MAKE) build-package-internal
dist/otel-hny-collector_%_x86_64.rpm: build/otelcol_hny_linux_amd64
PACKAGE=rpm ARCH=amd64 VERSION=$* $(MAKE) build-package-internal
dist/otel-hny-collector_%_arm64.rpm: build/otelcol_hny_linux_arm64
PACKAGE=rpm ARCH=arm64 VERSION=$* $(MAKE) build-package-internal
.PHONY: build-package-internal
build-package-internal:
docker build -t otelcol-fpm packaging/fpm
docker run --rm -v $(CURDIR):/repo -e VERSION=$(VERSION) -e ARCH=$(ARCH) -e PACKAGE=$(PACKAGE) otelcol-fpm
.PHONY: clean
clean:
rm -f build/* compact-config.yaml test/tmp-* dist/* artifacts/*