-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
67 lines (57 loc) · 2.19 KB
/
Copy pathMakefile
File metadata and controls
67 lines (57 loc) · 2.19 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
GO ?= go
GO_BUILD_FLAGS ?=
GO_LINT_FLAGS := --modules-download-mode=vendor --verbose
DOCKER_BUILD_FLAGS ?=
IMAGE_TAG ?= latest
.PHONY: all
all: test
include Makefile.OpenSearch
corgi: $(shell find . -iname "*.go") # Build the main binary
CGO_ENABLED=0 $(GO) build $(GO_BUILD_FLAGS) \
-mod=vendor \
-o $@ .
.PHONY: build # Build the main binary
build: corgi
.PHONY: test
test: build # Build and run the tests
$(GO) test -mod=vendor ./...
.PHONY: lint
lint:
golangci-lint run $(GO_LINT_FLAGS)
.PHONY: lint-fix
lint-fix:
golangci-lint run $(GO_LINT_FLAGS) --fix
.PHONY: clean
clean: # Clean the local generated artifacts
rm -fr -- corgi
.PHONY: kube-test
kube-test: opensearch-values.yaml # Set up a kube environment with opensearch
kubectl create namespace corgi-test \
--dry-run=client -o yaml \
| kubectl apply -f -
helm repo add opensearch https://opensearch-project.github.io/helm-charts/
helm repo update
helm upgrade opensearch opensearch/opensearch \
--install \
--namespace corgi-test \
--values opensearch-values.yaml
helm upgrade opensearch-dashboards opensearch/opensearch-dashboards \
--install \
--namespace corgi-test
>&2 echo
>&2 echo "You can use 'make kube-port-forward' to expose opensearch ports locally"
.PHONY: kube-port-forward
kube-port-forward: opensearch-ready # Port-forward access to opensearch into the host
-@pkill -f 'port-forward opensearch.*corgi-test'
$(eval KOS_SERV=$(shell kubectl get pods --namespace corgi-test -l "app.kubernetes.io/name=opensearch" -o jsonpath="{.items[0].metadata.name}"))
$(eval KOS_SERV_PORT=$(shell kubectl get pod --namespace corgi-test $(KOS_SERV) -o jsonpath="{.spec.containers[0].ports[0].containerPort}"))
kubectl port-forward $(KOS_SERV) 9200:$(KOS_SERV_PORT) \
--namespace=corgi-test \
--address 127.0.0.1 \
&
$(eval KOS_DASH=$(shell kubectl get pods --namespace corgi-test -l "app.kubernetes.io/name=opensearch-dashboards" -o jsonpath="{.items[0].metadata.name}"))
$(eval KOS_DASH_PORT=$(shell kubectl get pod --namespace corgi-test $(KOS_DASH) -o jsonpath="{.spec.containers[0].ports[0].containerPort}"))
kubectl port-forward $(KOS_DASH) 5601:$(KOS_DASH_PORT) \
--namespace=corgi-test \
--address 127.0.0.1 \
&