Repository navigation
Expand file tree
/
Copy pathMakefile
More file actions
151 lines (118 loc) · 6.09 KB
/
Copy pathMakefile
File metadata and controls
151 lines (118 loc) · 6.09 KB
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
# include the bingo binary variables. This enables the bingo versions to be
# referenced here as make variables. For example: $(GOLANGCI_LINT)
include .bingo/Variables.mk
# set the default target here, because the include above will automatically set
# it to the first defined target
.DEFAULT_GOAL := default
default: all
VERSION ?= v0.0.1
CRD_DIR := $(shell pwd)/deploy/crds
TEST_CRD_DIR := $(CURDIR)/test/integration/crds
BIN_DIR := $(CURDIR)/bin
CONTAINER_ENGINE ?= $(shell which podman 2>/dev/null || which docker 2>/dev/null)
# REGISTRY_BASE
# defines the container registry and organization for the bundle and operator container images.
REGISTRY_BASE_OPENSHIFT = quay.io/rhobs
REGISTRY_BASE ?= $(REGISTRY_BASE_OPENSHIFT)
# Image URL to use all building/pushing image targets
IMG ?= $(REGISTRY_BASE)/multicluster-observability-addon:$(VERSION)
PLATFORM ?= linux/amd64
.PHONY: deps
deps: go.mod go.sum
go mod tidy
go mod download
go mod verify
$(CRD_DIR)/observability.openshift.io_clusterlogforwarders.yaml:
@mkdir -p $(CRD_DIR)
@curl https://raw.githubusercontent.com/openshift/cluster-logging-operator/release-6.0/bundle/manifests/observability.openshift.io_clusterlogforwarders.yaml > $(CRD_DIR)/observability.openshift.io_clusterlogforwarders.yaml
$(CRD_DIR)/opentelemetry.io_opentelemetrycollectors.yaml:
@mkdir -p $(CRD_DIR)
@curl https://raw.githubusercontent.com/open-telemetry/opentelemetry-operator/v0.100.1/bundle/manifests/opentelemetry.io_opentelemetrycollectors.yaml > $(CRD_DIR)/opentelemetry.io_opentelemetrycollectors.yaml
$(CRD_DIR)/opentelemetry.io_instrumentations.yaml:
@mkdir -p $(CRD_DIR)
@curl https://raw.githubusercontent.com/open-telemetry/opentelemetry-operator/v0.100.1/bundle/manifests/opentelemetry.io_instrumentations.yaml > $(CRD_DIR)/opentelemetry.io_instrumentations.yaml
$(CRD_DIR)/monitoring.coreos.com_prometheusagents.yaml:
@mkdir -p $(CRD_DIR)
@curl https://raw.githubusercontent.com/rhobs/obo-prometheus-operator/refs/tags/v0.83.0-rhobs1/example/prometheus-operator-crd/monitoring.rhobs_prometheusagents.yaml > $(CRD_DIR)/monitoring.coreos.com_prometheusagents.yaml
$(CRD_DIR)/monitoring.coreos.com_scrapeconfigs.yaml:
@mkdir -p $(CRD_DIR)
@curl https://raw.githubusercontent.com/rhobs/obo-prometheus-operator/refs/tags/v0.83.0-rhobs1/example/prometheus-operator-crd/monitoring.rhobs_scrapeconfigs.yaml > $(CRD_DIR)/monitoring.coreos.com_scrapeconfigs.yaml
$(CRD_DIR)/monitoring.rhobs_prometheusrules.yaml:
@mkdir -p $(CRD_DIR)
@curl https://raw.githubusercontent.com/rhobs/obo-prometheus-operator/refs/tags/v0.83.0-rhobs1/example/prometheus-operator-crd/monitoring.rhobs_prometheusrules.yaml > $(CRD_DIR)/monitoring.rhobs_prometheusrules.yaml
$(CRD_DIR)/core.observatorium.io_observatoria.yaml:
@mkdir -p $(CRD_DIR)
@curl https://raw.githubusercontent.com/stolostron/observatorium-operator/blob/main/manifests/crds/core.observatorium.io_observatoria.yaml > $(CRD_DIR)/core.observatorium.io_observatoria.yaml
# CRDs synchronized from deploy/crds into test/integration/crds for envtest
SHARED_INTEGRATION_CRDS := \
observability.openshift.io_clusterlogforwarders.yaml \
opentelemetry.io_opentelemetrycollectors.yaml \
opentelemetry.io_instrumentations.yaml \
monitoring.rhobs_prometheusagents.yaml \
monitoring.rhobs_scrapeconfigs.yaml \
monitoring.rhobs_prometheusrules.yaml
.PHONY: sync-integration-crds
sync-integration-crds: ## Sync shared operand CRDs from deploy/crds to test/integration/crds
@mkdir -p $(TEST_CRD_DIR)
@for crd in $(SHARED_INTEGRATION_CRDS); do \
cp $(CRD_DIR)/$$crd $(TEST_CRD_DIR)/$$crd; \
done
.PHONY: download-crds
download-crds: $(CRD_DIR)/observability.openshift.io_clusterlogforwarders.yaml $(CRD_DIR)/opentelemetry.io_opentelemetrycollectors.yaml $(CRD_DIR)/opentelemetry.io_instrumentations.yaml $(CRD_DIR)/monitoring.coreos.com_prometheusagents.yaml $(CRD_DIR)/monitoring.coreos.com_scrapeconfigs.yaml $(CRD_DIR)/monitoring.rhobs_prometheusrules.yaml $(CRD_DIR)/core.observatorium.io_observatoria.yaml
@$(MAKE) sync-integration-crds
.PHONY: verify-dockerfile-labels
verify-dockerfile-labels: ## Verify Dockerfile.Konflux RHEL version consistency
@./hack/verify-dockerfile-labels.sh
.PHONY: lint
lint: $(GOLANGCI_LINT) verify-dockerfile-labels ## Run golangci-lint and dockerfile verification
$(GOLANGCI_LINT) config verify
$(GOLANGCI_LINT) run --timeout=5m ./...
.PHONY: lint-fix
lint-fix: $(GOLANGCI_LINT) ## Attempt to automatically fix lint issues in source code.
$(GOLANGCI_LINT) run --fix --timeout=5m ./...
.PHONY: fmt
fmt: lint-fix
.PHONY: test
test:
go test ./internal/...
.PHONY: bench
bench: ## Run Go performance benchmarks with memory allocation profiling
go test -run=^# -bench=. -benchmem ./internal/...
ENVTEST_K8S_VERSION ?= 1.35.0
SETUP_ENVTEST ?= $(BIN_DIR)/setup-envtest
$(SETUP_ENVTEST): prepare-bin
@if [ ! -f $(SETUP_ENVTEST) ]; then \
echo "Installing setup-envtest to $(BIN_DIR)..."; \
GOBIN=$(BIN_DIR) go install sigs.k8s.io/controller-runtime/tools/setup-envtest@release-0.23; \
fi
.PHONY: envtest-bins
envtest-bins: $(SETUP_ENVTEST) ## Download envtest kubernetes binaries
@$(SETUP_ENVTEST) use $(ENVTEST_K8S_VERSION) --bin-dir $(BIN_DIR) > /dev/null
.PHONY: test-integration
test-integration: envtest-bins ## Run controller integration tests using envtest
KUBEBUILDER_ASSETS="$$($(SETUP_ENVTEST) use $(ENVTEST_K8S_VERSION) --bin-dir $(BIN_DIR) -p path)" \
go test -v ./test/integration/...
.PHONY: prepare-bin
prepare-bin:
@mkdir -p $(BIN_DIR)
.PHONY: addon
addon: deps fmt ## Build addon binary
go build -o bin/multicluster-observability-addon main.go
.PHONY: oci-build
oci-build: ## Build the image
$(CONTAINER_ENGINE) build --platform $(PLATFORM) -t ${IMG} .
.PHONY: oci-push
oci-push: ## Push the image
$(CONTAINER_ENGINE) push ${IMG}
.PHONY: oci
oci: oci-build oci-push
.PHONY: install-crds
install-crds: download-crds
kubectl apply --server-side -f $(CRD_DIR)
.PHONY: addon-deploy
addon-deploy: download-crds
cd deploy && $(KUSTOMIZE) edit set image controller=${IMG}
$(KUSTOMIZE) build ./deploy | kubectl apply --server-side -f -
.PHONY: addon-undeploy
addon-undeploy: download-crds
$(KUSTOMIZE) build ./deploy | kubectl delete -f -