forked from redhat-cne/cloud-event-proxy
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
133 lines (102 loc) · 3.93 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
.PHONY: build, test
#for examples
# Current version
VERSION ?=latest
# Default image tag
IMG ?= quay.io/openshift/origin-cloud-event-proxy:$(VERSION)
CONSUMER_IMG ?= quay.io/redhat-cne/cloud-event-consumer:$(VERSION)
# Export GO111MODULE=on to enable project to be built from within GOPATH/src
export GO111MODULE=on
export CGO_ENABLED=1
export GOFLAGS=-mod=vendor
export COMMON_GO_ARGS=-race
export GOOS=linux
ifeq (,$(shell go env GOBIN))
GOBIN=$(shell go env GOPATH)/bin
else
GOBIN=$(shell go env GOBIN)
endif
kustomize:
ifeq (, $(shell which kustomize))
@{ \
set -e ;\
KUSTOMIZE_GEN_TMP_DIR=$$(mktemp -d) ;\
cd $$KUSTOMIZE_GEN_TMP_DIR ;\
go mod init tmp ;\
go get sigs.k8s.io/kustomize/kustomize/[email protected] ;\
rm -rf $$KUSTOMIZE_GEN_TMP_DIR ;\
}
KUSTOMIZE=$(GOBIN)/kustomize
else
KUSTOMIZE=$(shell which kustomize)
endif
deps-update:
go get github.com/redhat-cne/sdk-go@$(branch) && \
go get github.com/redhat-cne/rest-api@$(branch) && \
go mod tidy && \
go mod vendor
build:build-plugins test
go fmt ./...
make lint
go build -o ./build/cloud-event-proxy cmd/main.go
build-only:
go build -o ./build/cloud-event-proxy cmd/main.go
build-examples:
go build -o ./build/cloud-event-consumer ./examples/consumer/main.go
lint:
golangci-lint run
build-plugins:
go build -a -o plugins/amqp_plugin.so -buildmode=plugin plugins/amqp/amqp_plugin.go
go build -a -o plugins/ptp_operator_plugin.so -buildmode=plugin plugins/ptp_operator/ptp_operator_plugin.go
go build -a -o plugins/http_plugin.so -buildmode=plugin plugins/http/http_plugin.go
go build -a -o plugins/mock_plugin.so -buildmode=plugin plugins/mock/mock_plugin.go
build-amqp-plugin:
go build -a -o plugins/amqp_plugin.so -buildmode=plugin plugins/amqp/amqp_plugin.go
build-ptp-operator-plugin:
go build -a -o plugins/ptp_operator_plugin.so -buildmode=plugin plugins/ptp_operator/ptp_operator_plugin.go
build-http-plugin:
go build -a -o plugins/http_plugin.so -buildmode=plugin plugins/http/http_plugin.go
build-mock-plugin:
go build -a -o plugins/mock_plugin.so -buildmode=plugin plugins/mock/mock_plugin.go
run:
go run cmd/main.go
run-consumer:
go run examples/consumer/main.go
test:
go test ./... --tags=unittests -coverprofile=cover.out
functests:
SUITE=./test/cne hack/run-functests.sh
# Deploy all in the configured Kubernetes cluster in ~/.kube/config
deploy-consumer:kustomize
cd ./examples/manifests && $(KUSTOMIZE) edit set image cloud-event-sidecar=${IMG} && $(KUSTOMIZE) edit set image cloud-event-consumer=${CONSUMER_IMG}
$(KUSTOMIZE) build ./examples/manifests | kubectl apply -f -
# Deploy all in the configured Kubernetes cluster in ~/.kube/config
undeploy-consumer:kustomize
cd ./examples/manifests && $(KUSTOMIZE) edit set image cloud-event-sidecar=${IMG} && $(KUSTOMIZE) edit set image cloud-event-consumer=${CONSUMER_IMG}
$(KUSTOMIZE) build ./examples/manifests | kubectl delete -f -
# For GitHub Actions CI
gha:
go build -a -o plugins/amqp_plugin.so -buildmode=plugin plugins/amqp/amqp_plugin.go
go build -a -o plugins/ptp_operator_plugin.so -buildmode=plugin plugins/ptp_operator/ptp_operator_plugin.go
go build -a -o plugins/mock_plugin.so -buildmode=plugin plugins/mock/mock_plugin.go
go build -a -o plugins/http_plugin.so -buildmode=plugin plugins/http/http_plugin.go
go test ./... --tags=unittests -coverprofile=cover.out
docker-build: #test ## Build docker image with the manager.
docker build --no-cache -t ${IMG} .
docker-push: ## Push docker image with the manager.
docker push ${IMG}
docker-build-consumer: #test ## Build docker image with the manager.
docker build -f ./examples/consumer.Dockerfile -t ${CONSUMER_IMG} .
docker-push-consumer: ## Push docker image with the manager.
docker push ${CONSUMER_IMG}
fmt: ## Go fmt your code
hack/gofmt.sh
fmt-code: ## Run go fmt against code.
go fmt ./...
vet: ## Run go vet against code.
go vet ./...
generate-api:
hack/verify-codegen.sh
rm -rf github.com
install-tools:
hack/install-kubebuilder-tools.sh