forked from banzaicloud/istio-operator
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
132 lines (103 loc) · 3.74 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
# Image URL to use all building/pushing image targets
TAG ?= $(shell git describe --tags --abbrev=0 2>/dev/null )
IMG ?= banzaicloud/istio-operator:$(TAG)
RELEASE_TYPE ?= p
RELEASE_MSG ?= "operator release"
REL_TAG = $(shell ./scripts/increment_version.sh -${RELEASE_TYPE} ${TAG})
DEP_VERSION = 0.5.1
GOLANGCI_VERSION = 1.15.0
LICENSEI_VERSION = 0.1.0
KUSTOMIZE_BASE = config/custom
all: test manager
.PHONY: check
check: test lint ## Run tests and linters
bin/golangci-lint: bin/golangci-lint-${GOLANGCI_VERSION}
@ln -sf golangci-lint-${GOLANGCI_VERSION} bin/golangci-lint
bin/golangci-lint-${GOLANGCI_VERSION}:
@mkdir -p bin
curl -sfL https://install.goreleaser.com/github.com/golangci/golangci-lint.sh | bash -s -- -b ./bin v${GOLANGCI_VERSION}
@mv bin/golangci-lint $@
.PHONY: lint
lint: bin/golangci-lint ## Run linter
@bin/golangci-lint run -v
bin/licensei: bin/licensei-${LICENSEI_VERSION}
@ln -sf licensei-${LICENSEI_VERSION} bin/licensei
bin/licensei-${LICENSEI_VERSION}:
@mkdir -p bin
curl -sfL https://raw.githubusercontent.com/goph/licensei/master/install.sh | bash -s v${LICENSEI_VERSION}
@mv bin/licensei $@
.PHONY: license-check
license-check: bin/licensei ## Run license check
bin/licensei check
./scripts/check-header.sh
.PHONY: license-cache
license-cache: bin/licensei ## Generate license cache
bin/licensei cache
# Run tests
test: install-kubebuilder generate fmt vet manifests
KUBEBUILDER_ASSETS="$${PWD}/bin/kubebuilder/bin" go test ./pkg/... ./cmd/... -coverprofile cover.out
# Build manager binary
manager: generate fmt vet
go build -o bin/manager github.com/banzaicloud/istio-operator/cmd/manager
# Run against the configured Kubernetes cluster in ~/.kube/config
run: generate fmt vet
go run ./cmd/manager/main.go
# Install kustomize
install-kustomize:
@ if ! which bin/kustomize &>/dev/null; then\
scripts/install_kustomize.sh;\
fi
# Install kubebuilder
install-kubebuilder:
@ if ! which bin/kubebuilder/bin/kubebuilder &>/dev/null; then\
scripts/install_kubebuilder.sh;\
fi
bin/dep: bin/dep-${DEP_VERSION}
@ln -sf dep-${DEP_VERSION} bin/dep
bin/dep-${DEP_VERSION}:
@mkdir -p bin
curl https://raw.githubusercontent.com/golang/dep/master/install.sh | INSTALL_DIRECTORY=bin DEP_RELEASE_TAG=v${DEP_VERSION} sh
@mv bin/dep $@
.PHONY: vendor
vendor: bin/dep ## Install dependencies
bin/dep ensure -v -vendor-only
# Install CRDs into a cluster
install: manifests
kubectl apply -f config/crds
# Deploy controller in the configured Kubernetes cluster in ~/.kube/config
deploy: install-kustomize
kubectl apply -f config/crds
kubectl apply -f config/manager/namespace.yaml
./scripts/image_patch.sh ./config/custom/manager_image_patch.yaml ${IMG}
bin/kustomize build $(KUSTOMIZE_BASE) | kubectl apply -f -
# Generate manifests e.g. CRD, RBAC etc.
manifests:
go run vendor/sigs.k8s.io/controller-tools/cmd/controller-gen/main.go rbac --output-dir config/base/rbac
go run vendor/sigs.k8s.io/controller-tools/cmd/controller-gen/main.go crd --output-dir config/base/crds
# Run go fmt against code
fmt:
go fmt ./pkg/... ./cmd/...
# Run go vet against code
vet:
go vet ./pkg/... ./cmd/...
# Generate code
generate:
ifndef GOPATH
$(error GOPATH not defined, please define GOPATH. Run "go help gopath" to learn more about GOPATH)
endif
go generate ./pkg/... ./cmd/...
./hack/update-codegen.sh
# Verify codegen
verify-codegen:
./hack/verify-codegen.sh
# Build the docker image
docker-build:
docker build -f Dockerfile.dev . -t ${IMG}
# Push the docker image
docker-push:
docker push ${IMG}
check_release:
@echo "A new tag (${REL_TAG}) will be pushed to Github, and a new Docker image will be released. Are you sure? [y/N] " && read ans && [ $${ans:-N} == y ]
release: check_release
git tag -a ${REL_TAG} -m ${RELEASE_MSG}
git push origin ${REL_TAG}