This repository has been archived by the owner on Sep 10, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Makefile
170 lines (133 loc) · 4.88 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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
include ./Makefile.Common
BUILD_OTELCOL=builder
OTELCOL=./cmd/otelcol-contrib
# Images management
REGISTRY_SERVER_ADDRESS?=ghcr.io
REGISTRY?=ghcr.io
REGISTRY_USER_NAME?=
REGISTRY_PASSWORD?=
TAG ?= latest
# Build parameters
GOOS ?= $(shell go env GOOS)
GOARCH ?= $(shell go env GOARCH)
BUILD_ARCH ?= linux/$(GOARCH)
FIND_MOD_ARGS=-type f -name "go.mod"
TO_MOD_DIR=dirname {} \; | sort | grep -E '^./'
# NONROOT_MODS includes ./* dirs (excludes . dir)
NONROOT_MODS := $(shell find . $(FIND_MOD_ARGS) -exec $(TO_MOD_DIR) )
RECEIVER_MODS_0 := $(shell find ./receiver/[a-k]* $(FIND_MOD_ARGS) -exec $(TO_MOD_DIR) )
RECEIVER_MODS_1 := $(shell find ./receiver/[l-z]* $(FIND_MOD_ARGS) -exec $(TO_MOD_DIR) )
RECEIVER_MODS := $(RECEIVER_MODS_0) $(RECEIVER_MODS_1)
PROCESSOR_MODS := $(shell find ./processor/* $(FIND_MOD_ARGS) -exec $(TO_MOD_DIR) )
EXPORTER_MODS := $(shell find ./exporter/* $(FIND_MOD_ARGS) -exec $(TO_MOD_DIR) )
EXTENSION_MODS := $(shell find ./extension/* $(FIND_MOD_ARGS) -exec $(TO_MOD_DIR) )
INTERNAL_MODS := $(shell find ./internal/* $(FIND_MOD_ARGS) -exec $(TO_MOD_DIR) )
OTHER_MODS := $(shell find . $(EX_COMPONENTS) $(EX_INTERNAL) $(FIND_MOD_ARGS) -exec $(TO_MOD_DIR) ) $(PWD)
ALL_MODS := $(RECEIVER_MODS) $(PROCESSOR_MODS) $(EXPORTER_MODS) $(EXTENSION_MODS) $(INTERNAL_MODS) $(OTHER_MODS)
.DEFAULT_GOAL := all
GROUP ?= all
FOR_GROUP_TARGET=for-$(GROUP)-target
all-modules:
@echo $(ALL_MODULES) | tr ' ' '\n' | sort
TOOLS_MOD_DIR := ./internal/tools
.PHONY: install-builder-tools
install-builder-tools:
GO111MODULE=on go install go.opentelemetry.io/collector/cmd/builder@latest
# Build the Collector executable.
.PHONY: build-openinsight
build-openinsight:
$(BUILD_OTELCOL) --output-path=cmd/ --config=builder/otelcol-builder.yaml
.PHONY: openinsight-darwin
openinsight-darwin:
GO111MODULE=on CGO_ENABLED=0 GOOS=darwin GOARCH=${GOARCH} make build-openinsight
.PHONY: openinsight-linux
openinsight-linux:
GO111MODULE=on CGO_ENABLED=0 GOOS=linux GOARCH=${GOARCH} make build-openinsight
.PHONY: run-openinsight
run-openinsight:
$(OTELCOL) --config configs/otelcol-contrib.yaml
.PHONY: build-openinsight-docker
build-openinsight-docker-multiarch: build-operator-crosscompile
docker buildx build \
--builder openinsight-multi-platform-builder \
--platform linux/amd64,linux/arm64 \
--tag $(REGISTRY)/openinsight:$(TAG) \
--tag $(REGISTRY)/openinsight:latest \
-f ./Dockerfile \
--push \
.
.PHONY: build-openinsight-docker
build-openinsight-docker: openinsight-linux
docker build --tag $(REGISTRY)/openinsight-proj/openinsight:$(TAG) \
--tag $(REGISTRY)/openinsight-proj/openinsight:dev \
-f ./Dockerfile.single \
.
.PHONY: run-otelcol-docker
run-openinsight-demo: build-openinsight-docker
docker-compose -f examples/demo/docker-compose.yaml up
.PHONY: gotidy
gotidy:
$(MAKE) $(FOR_GROUP_TARGET) TARGET="tidy"
.PHONY: gomoddownload
gomoddownload:
$(MAKE) $(FOR_GROUP_TARGET) TARGET="moddownload"
.PHONY: gotest
gotest:
$(MAKE) $(FOR_GROUP_TARGET) TARGET="test"
.PHONY: gofmt
gofmt:
$(MAKE) $(FOR_GROUP_TARGET) TARGET="fmt"
.PHONY: golint
golint:
$(MAKE) $(FOR_GROUP_TARGET) TARGET="lint"
# Define a delegation target for each module
.PHONY: $(ALL_MODS)
$(ALL_MODS):
@echo "Running target '$(TARGET)' in module '$@' as part of group '$(GROUP)'"
$(MAKE) -C $@ $(TARGET)
# Trigger each module's delegation target
.PHONY: for-all-target
for-all-target: $(ALL_MODS)
.PHONY: for-receiver-target
for-receiver-target: $(RECEIVER_MODS)
.PHONY: for-receiver-0-target
for-receiver-0-target: $(RECEIVER_MODS_0)
.PHONY: for-receiver-1-target
for-receiver-1-target: $(RECEIVER_MODS_1)
.PHONY: for-processor-target
for-processor-target: $(PROCESSOR_MODS)
.PHONY: for-exporter-target
for-exporter-target: $(EXPORTER_MODS)
.PHONY: for-extension-target
for-extension-target: $(EXTENSION_MODS)
.PHONY: for-internal-target
for-internal-target: $(INTERNAL_MODS)
.PHONY: for-other-target
for-other-target: $(OTHER_MODS)
.PHONY: add-tag
add-tag:
@[ "${TAG}" ] || ( echo ">> env var TAG is not set"; exit 1 )
@echo "Adding tag ${TAG}"
@git tag -a ${TAG} -s -m "Version ${TAG}"
@set -e; for dir in $(NONROOT_MODS); do \
(echo Adding tag "$${dir:2}/$${TAG}" && \
git tag -a "$${dir:2}/$${TAG}" -s -m "Version ${dir:2}/${TAG}" ); \
done
.PHONY: push-tag
push-tag:
@[ "${TAG}" ] || ( echo ">> env var TAG is not set"; exit 1 )
@echo "Pushing tag ${TAG}"
@git push git@github.com:openinsight-proj/OpenInsight.git ${TAG}
@set -e; for dir in $(NONROOT_MODS); do \
(echo Pushing tag "$${dir:2}/$${TAG}" && \
git push git@github.com:openinsight-proj/OpenInsight.git "$${dir:2}/$${TAG}"); \
done
.PHONY: delete-tag
delete-tag:
@[ "${TAG}" ] || ( echo ">> env var TAG is not set"; exit 1 )
@echo "Deleting tag ${TAG}"
@git tag -d ${TAG}
@set -e; for dir in $(NONROOT_MODS); do \
(echo Deleting tag "$${dir:2}/$${TAG}" && \
git tag -d "$${dir:2}/$${TAG}" ); \
done