-
Notifications
You must be signed in to change notification settings - Fork 1
/
Makefile
136 lines (107 loc) · 4.28 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
134
135
136
# runs the target list by default
.DEFAULT_GOAL = list
.PHONY: list
# Image URL to use all building/pushing image targets
OPERATOR_IMAGE = davideberdin/pinot-operator:v0.0.1
# Produce CRDs that work back to Kubernetes 1.11 (no version conversion)
CRD_OPTIONS = crd:crdVersions={v1},maxDescLen=0,trivialVersions=false
# Get the currently used golang install path (in GOPATH/bin, unless GOBIN is set)
ifeq (,$(shell go env GOBIN))
GOBIN=$(shell go env GOPATH)/bin
else
GOBIN=$(shell go env GOBIN)
endif
# Insert a comment starting with '##' after a target, and it will be printed by 'make' and 'make list'
list: ## list Makefile targets
@echo "The most used targets: \n"
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-20s\033[0m %s\n", $$1, $$2}'
all: manager
# Run tests
test: generate fmt vet manifests
go test ./... -coverprofile cover.out
unit-tests: install-tools generate fmt vet manifests ## Run unit tests
ginkgo -r --randomizeAllSpecs api/ internal/
# Build manager binary
manager: generate fmt vet
go build -o bin/manager main.go
# Run against the configured Kubernetes cluster in ~/.kube/config
run: generate fmt vet manifests
go run ./main.go
debug: generate fmt vet manifests
# Install CRDs into a cluster
install: manifests
kustomize build config/crd | kubectl apply -f -
# Uninstall CRDs from a cluster
uninstall: manifests
kustomize build config/crd | kubectl delete -f -
# Deploy controller in the configured Kubernetes cluster in ~/.kube/config
deploy: manifests
cd config/manager && kustomize edit set image controller=${OPERATOR_IMAGE}
kustomize build config/default | kubectl apply -f -
# Generate manifests e.g. CRD, RBAC etc.
manifests: download-deps
bin/controller-gen $(CRD_OPTIONS) rbac:roleName=operator-role paths="./pkg/apis/...;./controllers/..." output:crd:artifacts:config=config/crd/bases
# Run go fmt against code
fmt:
go fmt ./...
# Run go vet against code
vet:
go vet ./...
# Generate code
generate: download-deps api-reference
go generate ./pkg/...
bin/controller-gen object:headerFile="hack/boilerplate.go.txt" paths="./..."
# ./hack/update-codegen.sh
# Build the docker image
docker-build: test
docker build . -t ${OPERATOR_IMAGE}
# Push the docker image
docker-push:
docker push ${OPERATOR_IMAGE}
git-commit-sha:
ifeq ("", git diff --stat)
GIT_COMMIT=$(shell git rev-parse --short HEAD)
else
GIT_COMMIT=$(shell git rev-parse --short HEAD)-
endif
docker-build-dev: check-env-docker-repo git-commit-sha
docker build --build-arg=GIT_COMMIT=$(GIT_COMMIT) -t $(DOCKER_REGISTRY_SERVER)/$(OPERATOR_IMAGE):$(GIT_COMMIT) .
docker push $(DOCKER_REGISTRY_SERVER)/$(OPERATOR_IMAGE):$(GIT_COMMIT)
check-env-docker-repo: check-env-registry-server
ifndef OPERATOR_IMAGE
$(error OPERATOR_IMAGE is undefined: path to the Operator image within the registry specified in DOCKER_REGISTRY_SERVER (e.g. davideberdin/pinot-operator - without leading slash))
endif
check-env-docker-credentials: check-env-registry-server
ifndef DOCKER_REGISTRY_USERNAME
$(error DOCKER_REGISTRY_USERNAME is undefined: Username for accessing the docker registry)
endif
ifndef DOCKER_REGISTRY_PASSWORD
$(error DOCKER_REGISTRY_PASSWORD is undefined: Password for accessing the docker registry)
endif
ifndef DOCKER_REGISTRY_SECRET
$(error DOCKER_REGISTRY_SECRET is undefined: Name of Kubernetes secret in which to store the Docker registry username and password)
endif
check-env-registry-server:
ifndef DOCKER_REGISTRY_SERVER
$(error DOCKER_REGISTRY_SERVER is undefined: URL of docker registry containing the Operator image (e.g. registry.my-company.com))
endif
# Verify codegen
verify-codegen: download-deps
./hack/verify-codegen.sh
install-tools:
go mod download
grep _ tools/tools.go | awk -F '"' '{print $$2}' | xargs -t go install
# documentation
api-reference: install-tools ## Generate API reference documentation
crd-ref-docs \
--source-path ./pkg/apis/pinot/v1alpha1 \
--config ./docs/api/autogen/config.yaml \
--templates-dir ./docs/api/autogen/templates \
--output-path ./docs/index.asciidoc \
--max-depth 30
# Builds a single-file installation manifest to deploy the Operator
generate-installation-manifest:
mkdir -p releases
kustomize build config/installation/ > releases/pinot-cluster-operator.yaml
download-deps:
./scripts/download_deps.sh