This repository has been archived by the owner on Oct 27, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 16
/
Makefile
96 lines (77 loc) · 2.23 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
.DEFAULT_GOAL := validate
# Image URL to use all building/pushing image targets
APP_NAME ?= octopus
IMG ?= $(APP_NAME):latest
IMG-CI = $(DOCKER_PUSH_REPOSITORY)$(DOCKER_PUSH_DIRECTORY)/$(APP_NAME):$(DOCKER_TAG)
# Run tests
.PHONY: test
test: generate manifests
go test ./pkg/... ./cmd/... -coverprofile cover.out
# Run against the configured Kubernetes cluster in ~/.kube/config
.PHONY: run
run: generate fmt vet
go run ./cmd/manager/main.go
# Install CRDs and samples into a cluster
.PHONY: install
install: manifests
kubectl apply -f config/crds
kubectl apply -f config/samples
.PHONY: uninstall
uninstall:
kubectl delete pods -l testing.kyma-project.io/created-by-octopus=true
kubectl delete -f config/samples
# Deploy controller in the configured Kubernetes cluster in ~/.kube/config
.PHONY: deploy
deploy: manifests
kubectl apply -f config/crds
kustomize build config | kubectl apply -f -
# Generate manifests e.g. CRD, RBAC etc.
.PHONY: manifests
manifests: controller-gen
controller-gen crd rbac:roleName=manager-role webhook paths="./apis/..."
# Run go fmt against code
.PHONY: fmt
fmt:
go fmt ./pkg/... ./cmd/...
# Run go vet against code
.PHONY: vet
vet:
go vet ./pkg/... ./cmd/...
# Generate code
.PHONY: generate
generate: deepcopy-gen
go generate ./pkg/... ./cmd/...
# Build the docker image
.PHONY: docker-build
docker-build: generate validate
docker build . -t ${IMG}
docker tag ${IMG} ${IMG-CI}
@echo "updating kustomize image patch file for manager resource"
sed -i'' -e 's@image: .*@image: '"${IMG-CI}"'@' ./config/default/manager_image_patch.yaml
rm -rf vendor/
# Push the docker image
.PHONY: docker-push
docker-push:
docker push ${IMG-CI}
# Executes the whole validation
.PHONY: validate
validate: fmt vet test
go mod verify
# CI specified targets
.PHONY: ci-pr
ci-pr: docker-build docker-push
.PHONY: ci-master
ci-master: docker-build docker-push
.PHONY: ci-release
ci-release: docker-build docker-push
controller-gen:
ifeq (, $(shell which controller-gen))
go get sigs.k8s.io/controller-tools/cmd/[email protected]
CONTROLLER_GEN=$(GOBIN)/controller-gen
else
CONTROLLER_GEN=$(shell which controller-gen)
endif
deepcopy-gen:
ifeq (, $(shell which deepcopy-gen))
go get k8s.io/code-generator/cmd/[email protected]
endif