forked from netobserv/goflow2-kube-enricher
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
72 lines (58 loc) · 2.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
USER ?= netobserv
VERSION ?= latest
IMAGE ?= quay.io/${USER}/goflow2-kube:${VERSION}
GOLANGCI_LINT_VERSION = v1.42.1
COVERPROFILE = coverage.out
ifeq (,$(shell which podman 2>/dev/null))
OCI_BIN ?= docker
else
OCI_BIN ?= podman
endif
.PHONY: prereqs
prereqs:
@echo "### Test if prerequisites are met, and installing missing dependencies"
test -f $(go env GOPATH)/bin/golangci-lint || go install github.com/golangci/golangci-lint/cmd/golangci-lint@${GOLANGCI_LINT_VERSION}
test -f $(go env GOPATH)/bin/staticcheck || go install honnef.co/go/tools/cmd/staticcheck@latest
.PHONY: vendors
vendors:
@echo "### Checking vendors"
go mod tidy && go mod vendor
.PHONY: fmt
fmt:
go fmt ./...
.PHONY: lint
lint: prereqs
@echo "### Linting code"
# staticcheck does not work properly when invoked inside golangci-lint
staticcheck -f stylish ./...
golangci-lint run ./...
.PHONY: test
test:
@echo "### Testing"
go test ./... -coverprofile ${COVERPROFILE}
.PHONY: verify
verify: lint test
.PHONY: build
build:
@echo "### Building"
go build -ldflags "-X main.version=${VERSION}" -mod vendor -o goflow-kube cmd/goflow-kube.go
.PHONY: image
image:
@echo "### Building image with ${OCI_BIN}"
$(OCI_BIN) build --build-arg VERSION="$(VERSION)" -t $(IMAGE) .
.PHONY: push
push:
$(OCI_BIN) push $(IMAGE)
.PHONY: ovnk-deploy
ovnk-deploy:
sed -e 's~quay\.io/netobserv/goflow2-kube:main~$(IMAGE)~' ./examples/goflow-kube.yaml | kubectl apply -f - && \
GF_IP=`kubectl get svc goflow-kube -ojsonpath='{.spec.clusterIP}'` && echo "Goflow IP: $$GF_IP" && \
kubectl set env daemonset/ovnkube-node -c ovnkube-node -n ovn-kubernetes OVN_IPFIX_TARGETS="$$GF_IP:2055"
.PHONY: cno-deploy
cno-deploy:
sed -e 's~quay\.io/netobserv/goflow2-kube:main~$(IMAGE)~' ./examples/goflow-kube.yaml | oc apply -f - && \
GF_IP=`oc get svc goflow-kube -ojsonpath='{.spec.clusterIP}'` && "Goflow IP: $$GF_IP" && \
oc patch networks.operator.openshift.io cluster --type='json' -p "$(sed -e "s/GF_IP/$$GF_IP/" examples/net-cluster-patch.json)"
.PHONY: kill
kill:
kubectl delete pod -l app=goflow-kube