forked from networkmachinery/networkmachinery-operators
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
96 lines (75 loc) · 2.97 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
BIN_NAME=networkmachinery-hyper
VERSION := $(shell grep "const Version " version/version.go | sed -E 's/.*"(.+)"$$/\1/')
GIT_COMMIT=$(shell git rev-parse HEAD)
GIT_DIRTY=$(shell test -n "`git status --porcelain`" && echo "+CHANGES" || true)
BUILD_DATE=$(shell date '+%Y-%m-%d-%H:%M:%S')
IMAGE_NAME := "zanetworker/networkmachinery-hyper"
.PHONY: default
default: test
.PHONY: generate
generate:
./hack/update-codegen.sh
.PHONY: build
build:
@echo "building ${BIN_NAME} ${VERSION}"
@echo "GOPATH=${GOPATH}"
go build -ldflags "-X github.com/networkmachinery/networkmachinery-operators/version.GitCommit=${GIT_COMMIT}${GIT_DIRTY} -X github.com/networkmachinery/networkmachinery-operators/version.BuildDate=${BUILD_DATE}" -o bin/${BIN_NAME} cmd/networkmachinery-hyper/main.go
.PHONY: install
install:
@go install cmd/networkmachinery-hyper/main.go
.PHONY: vendor
vendor:
GO111MODULE=on go mod vendor
.PHONY: build-alpine
build-alpine:
@echo "building ${BIN_NAME} ${VERSION}"
@echo "GOPATH=${GOPATH}"
go build -ldflags '-w -linkmode external -extldflags "-static" -X github.com/networkmachinery/networkmachinery-operators/version.GitCommit=${GIT_COMMIT}${GIT_DIRTY} -X github.com/networkmachinery/networkmachinery-operators/version.BuildDate=${BUILD_DATE}' -o bin/${BIN_NAME} cmd/networkmachinery-hyper/main.go
.PHONY: package
package:
@echo "building image ${BIN_NAME} ${VERSION} $(GIT_COMMIT)"
docker build --build-arg VERSION=${VERSION} --build-arg GIT_COMMIT=$(GIT_COMMIT) -t $(IMAGE_NAME):local .
.PHONY: tag
tag:
@echo "Tagging: latest ${VERSION} $(GIT_COMMIT)"
docker tag $(IMAGE_NAME):local $(IMAGE_NAME):$(GIT_COMMIT)
docker tag $(IMAGE_NAME):local $(IMAGE_NAME):${VERSION}
docker tag $(IMAGE_NAME):local $(IMAGE_NAME):latest
.PHONY: push
push: tag
@echo "Pushing docker image to registry: latest ${VERSION} $(GIT_COMMIT)"
docker push $(IMAGE_NAME):$(GIT_COMMIT)
docker push $(IMAGE_NAME):${VERSION}
docker push $(IMAGE_NAME):latest
.PHONY: ship
ship: package tag push
.PHONY: clean
clean:
@test ! -e bin/${BIN_NAME} || rm bin/${BIN_NAME}
.PHONY: requirements
requirements:
@GO111MODULE=on go get github.com/golangci/golangci-lint/cmd/[email protected]
.PHONY: lint
lint:
@go run github.com/golangci/golangci-lint/cmd/golangci-lint run
.PHONY: test
test:
go test ./...
.PHONY: webhook
webhook:
@./hack/kubectl-hook.sh
.PHONY: install-crds
install-crds:
@./hack/install-crds.sh
.PHONY: start-network-monitor
start-network-monitor:
@go run cmd/networkmachinery-hyper/main.go networkmonitor-controller
.PHONY: start-network-control-controller
start-network-control-controller:
@go run cmd/networkmachinery-hyper/main.go network-control-controller
.PHONY: start-network-connectivity-test-controller
start-network-connectivity-test-controller:
@go run cmd/networkmachinery-hyper/main.go networkconnectivity-test-controller
.PHONY: start-network-trafficshaper-controller
start-network-trafficshaper-controller:
@go run cmd/networkmachinery-hyper/main.go network-trafficshaper-controller