-
Notifications
You must be signed in to change notification settings - Fork 3
/
Makefile
111 lines (84 loc) · 3.02 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
version ?= test
IMAGE_REPO = quay.io/moolen/harbor-sync
IMG ?= ${IMAGE_REPO}:${version}
CRD_OPTIONS ?= "crd:trivialVersions=true"
GOPATH=$(shell go env GOPATH)
HUGO=bin/hugo
KUBECTL=bin/kubectl
MISSPELL=bin/misspell
CONTROLLER_GEN=bin/controller-gen
all: controller
# Run tests
test: generate fmt vet manifests misspell
go test -v ./pkg/... -coverprofile cover.out
e2e: generate manifests
go mod download
./test/e2e/run.sh
.PHONY: docs
docs: bin/hugo
cd docs_src; ../$(HUGO) --theme book --destination ../docs
docs-live: bin/hugo
cd docs_src; ../$(HUGO) server --minify --theme book
# Build harbor-sync-controller binary
controller: generate fmt vet
go build -o bin/harbor-sync-controller ./main.go
# Run against the configured Kubernetes cluster in ~/.kube/config
run: generate fmt vet manifests
mkdir -p bin/data
go run ./main.go controller
# Install CRDs into a cluster
install: bin/kubectl manifests
kustomize build config/crd | $(KUBECTL) apply -f -
# Deploy controller in the configured Kubernetes cluster in ~/.kube/config
deploy: bin/kubectl manifests
cd config/manager && kustomize edit set image controller=${IMG}
kustomize build config/default | $(KUBECTL) apply -f -
# Checks if generated files differ
check-gen-files: docs quick-install
git diff --exit-code
# Generate manifests e.g. CRD, RBAC etc.
manifests: bin/controller-gen
$(CONTROLLER_GEN) $(CRD_OPTIONS) rbac:roleName=harbor-sync paths="./..." output:crd:artifacts:config=config/crd/bases
quick-install: bin/kubectl
$(KUBECTL) kustomize config/default/ > install/kubernetes/quick-install.yaml
misspell: bin/misspell
$(MISSPELL) \
-locale US \
-error \
api/* pkg/* docs_src/content/* config/* hack/* README.md CONTRIBUTING.md
# Run go fmt against code
fmt:
go fmt ./...
# Run go vet against code
vet:
go vet ./...
# Generate code
generate: bin/controller-gen
$(CONTROLLER_GEN) object:headerFile=./hack/boilerplate.go.txt paths="./..."
# Build the docker image
docker-build:
docker build . -t ${IMG}
# Push the docker image
docker-push:
docker push ${IMG}
docker-push-latest:
docker tag ${IMG} ${IMAGE_REPO}:latest
docker push ${IMAGE_REPO}:latest
docker-release: docker-build docker-push docker-push-latest
release: quick-install controller docker-release
tar cvzf bin/harbor-sync-controller.tar.gz bin/harbor-sync-controller
bin/misspell:
curl -sL https://github.com/client9/misspell/releases/download/v0.3.4/misspell_0.3.4_linux_64bit.tar.gz | tar -xz -C /tmp/
mkdir bin; cp /tmp/misspell bin/misspell
bin/hugo:
curl -sL https://github.com/gohugoio/hugo/releases/download/v0.57.2/hugo_extended_0.57.2_Linux-64bit.tar.gz | tar -xz -C /tmp/
mkdir bin; cp /tmp/hugo bin/hugo
bin/kubectl:
curl -LO https://storage.googleapis.com/kubernetes-release/release/v1.21.2/bin/linux/amd64/kubectl
chmod +x ./kubectl
mkdir bin; mv kubectl bin/kubectl
# find or download controller-gen
# download controller-gen if necessary
bin/controller-gen:
go get sigs.k8s.io/controller-tools/cmd/[email protected]
mkdir bin; mv $(GOPATH)/bin/controller-gen bin/controller-gen