forked from signalfx/splunk-otel-collector-chart
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
138 lines (115 loc) · 5.04 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
##@ General
# The general settings and variables for the project
SHELL := /bin/bash
# TODO: Move CHART_FILE_PATH and VALUES_FILE_PATH here, currently set in multiple places
# The version of the splunk-otel-collector chart
VERSION := $(shell grep "^version:" helm-charts/splunk-otel-collector/Chart.yaml | awk '{print $$2}')
## Location for GO resources
ifeq (,$(shell go env GOBIN))
GOBIN=$(shell go env GOPATH)/bin
else
GOBIN=$(shell go env GOBIN)
endif
## Location to install dependencies to
LOCALBIN ?= $(shell pwd)/bin
$(LOCALBIN):
mkdir -p $(LOCALBIN)
CHLOGGEN ?= $(LOCALBIN)/chloggen
CERTMANAGER_VERSION ?= $(shell yq eval ".dependencies[] | select(.name == \"cert-manager\") | .version" helm-charts/splunk-otel-collector/Chart.yaml)
# The help target as provided
.PHONY: help
help: ## Display Makefile help information for all actions
@awk 'BEGIN {FS = ":.*##"; \
printf "\nUsage:\n make \033[36m<target>\033[0m\n"} \
/^[a-zA-Z_0-9-]+:.*?##/ { printf " \033[36m%-15s\033[0m %s\n", $$1, $$2 } \
/^##@/ { printf "\n\033[1m%s\033[0m\n", substr($$0, 5) }' \
$(MAKEFILE_LIST)
##@ Initialization
# Tasks for setting up the project environment
.PHONY: install-tools
install-tools: ## Install tools (macOS/Linux)
LOCALBIN=$(LOCALBIN) GOBIN=$(LOCALBIN) ci_scripts/install-tools.sh || exit 1
##@ Build
# Tasks related to building the Helm chart
.PHONY: repo-update
repo-update: ## Update Helm repositories to latest
@{ \
if ! (helm repo list | grep -q open-telemetry) ; then \
helm repo add open-telemetry https://open-telemetry.github.io/opentelemetry-helm-charts || exit 1; \
fi ;\
if ! (helm repo list | grep -q jetstack) ; then \
helm repo add jetstack https://charts.jetstack.io || exit 1; \
fi ;\
helm repo update open-telemetry jetstack || exit 1; \
}
.PHONY: dep-build
dep-build: ## Build the Helm chart with latest dependencies from the current Helm repositories
@{ \
DEP_OK=true ;\
DIR=helm-charts/splunk-otel-collector ;\
if ! helm dependencies list $$DIR | grep open-telemetry | grep -q ok ; then DEP_OK=false ; fi ;\
if ! helm dependencies list $$DIR | grep jetstack | grep -q ok ; then DEP_OK=false ; fi ;\
if [ "$$DEP_OK" = "false" ] ; then helm dependencies build $$DIR || exit 1; fi ;\
}
.PHONY: render
render: repo-update dep-build ## Render the Helm chart with the examples as input
examples/render-examples.sh || exit 1
##@ Test
# Tasks related to testing the Helm chart
.PHONY: lint
lint: ## Lint the Helm chart with ct
@echo "Linting Helm chart..."
ct lint --config=ct.yaml || exit 1
.PHONY: pre-commit
pre-commit: render ## Test the Helm chart with pre-commit
@echo "Checking the Helm chart with pre-commit..."
pre-commit run --all-files || exit 1
##@ Changelog
# Tasks related to changelog management
.PHONY: chlog-available
chlog-available: ## Validate the chloggen tool is available
@if [ -z "$(CHLOGGEN)" ]; then \
echo "Error: chloggen is not available. Please run 'make install-tools' to install it."; \
exit 1; \
fi
# Example Usage:
# make chlog-new CHANGE_TYPE=enhancement COMPONENT=agent NOTE="Add X" ISSUES='[42]'
# make chlog-new [CHANGE_TYPE=enhancement] [COMPONENT=agent] [NOTE="Add X"] [ISSUES='[42]'] [FILENAME=add-x] [SUBTEXT="Add Y"]
.PHONY: chlog-new
chlog-new: chlog-available ## Creates or updates a YAML file under .chloggen
ci_scripts/chloggen-new.sh || exit 1
.PHONY: chlog-validate
chlog-validate: chlog-available ## Validates changelog requirements for pull requests
$(CHLOGGEN) validate || exit 1
ci_scripts/chloggen-pr-validate.sh || exit 1
.PHONY: chlog-preview
chlog-preview: chlog-validate ## Provide a preview of the generated CHANGELOG.md file for a release
$(CHLOGGEN) update --dry || exit 1
# Example Usage: make chlog-update
.PHONY: chlog-update
chlog-update: chlog-validate ## Creates an update to CHANGELOG.md for a release entry from content in .chloggen
$(CHLOGGEN) update --version "[$(VERSION)] - $$(date +'%Y-%m-%d')" || exit 1; \
ci_scripts/chloggen-update.sh || exit 1
##@ Cert Manager
# Tasks related to deploying and managing Cert Manager
.PHONY: cert-manager
cert-manager: cmctl ## Installs cert-manager in the current Kubernetes cluster and verifies API access with cmctl
# Consider using cmctl to install the cert-manager once install command is not experimental
kubectl apply --validate=false -f https://github.com/jetstack/cert-manager/releases/download/${CERTMANAGER_VERSION}/cert-manager.yaml
$(CMCTL) check api --wait=5m
PROJECT_DIR := $(shell dirname $(abspath $(lastword $(MAKEFILE_LIST))))
CMCTL = $(shell pwd)/bin/cmctl
.PHONY: cmctl
cmctl: ## Downloads and installs cmctl, the CLI for cert-manager, to your local system
@{ \
set -e ;\
if (`pwd`/bin/cmctl version | grep ${CERTMANAGER_VERSION}) > /dev/null 2>&1 ; then \
exit 0; \
fi ;\
TMP_DIR=$$(mktemp -d) ;\
curl -L -o $$TMP_DIR/cmctl.tar.gz https://github.com/jetstack/cert-manager/releases/download/$(CERTMANAGER_VERSION)/cmctl-`go env GOOS`-`go env GOARCH`.tar.gz ;\
tar xzf $$TMP_DIR/cmctl.tar.gz -C $$TMP_DIR ;\
[ -d bin ] || mkdir bin ;\
mv $$TMP_DIR/cmctl $(CMCTL) ;\
rm -rf $$TMP_DIR ;\
}