forked from banzaicloud/istio-operator
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
165 lines (127 loc) · 5.15 KB
/
Copy pathMakefile
File metadata and controls
165 lines (127 loc) · 5.15 KB
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
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
# Using -u (unset variable) results in an error on CircleCI (/etc/bash.bashrc uses unset "PS1")
SHELL := /bin/bash -eo pipefail
# Image URL to use all building/pushing image targets
TAG ?= $(shell git describe --tags --abbrev=0 --match '[0-9].*[0-9].*[0-9]' 2>/dev/null )
IMAGE_REPOSITORY ?= banzaicloud/istio-operator
IMG ?= ${IMAGE_REPOSITORY}:$(TAG)
# Produce CRDs that work back to Kubernetes 1.11 (no version conversion)
CRD_OPTIONS = "crd:trivialVersions=true,maxDescLen=0,preserveUnknownFields=false,allowDangerousTypes=true"
include test/e2e/e2e-test.mk
TEST_RACE_DETECTOR ?= 0
RELEASE_TYPE ?= p
RELEASE_MSG ?= "operator release"
REL_TAG = $(shell ./scripts/increment_version.sh -${RELEASE_TYPE} ${TAG})
GOLANGCI_VERSION = 1.31.0
LICENSEI_VERSION = 0.1.0
KUBEBUILDER_VERSION = 2.3.1
KUSTOMIZE_VERSION = 2.0.3
ISTIO_VERSION = 1.9.5
KUSTOMIZE_BASE = config/overlays/specific-manager-version
ifeq (${TEST_RACE_DETECTOR}, 1)
TEST_GOARGS += -race
TEST_CGO_ENABLED = 1
endif
TEST_CGO_ENABLED ?= 0
all: test manager
.PHONY: check
check: test lint shellcheck-makefile shellcheck check-diff ## 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
.PHONY: test
test: install-kubebuilder generate fmt vet manifests
env CGO_ENABLED=${TEST_CGO_ENABLED} \
KUBEBUILDER_ASSETS="$${PWD}/bin/kubebuilder/bin" \
go test ${TEST_GOARGS} ./pkg/... ./cmd/... -coverprofile cover.out
# Build manager binary
manager: generate fmt vet build
# Build manager binary
build:
go build -o bin/manager -ldflags="-X github.com/banzaicloud/istio-operator/pkg/apis/istio/v1beta1.SupportedIstioVersion=${ISTIO_VERSION} -X github.com/banzaicloud/istio-operator/pkg/apis/istio/v1beta1.Version=${TAG}" 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:
scripts/install_kustomize.sh ${KUSTOMIZE_VERSION}
# Install kubebuilder
install-kubebuilder:
scripts/install_kubebuilder.sh ${KUBEBUILDER_VERSION}
.PHONY: vendor
vendor:
go mod vendor
# Install CRDs into a cluster
install: manifests
kubectl apply -f config/base/crds
# Deploy controller in the configured Kubernetes cluster in ~/.kube/config
deploy: install-kustomize
bin/kustomize build config | kubectl apply -f -
./scripts/image_patch.sh "${KUSTOMIZE_BASE}/manager_image_patch.yaml" ${IMG}
bin/kustomize build $(KUSTOMIZE_BASE) | kubectl apply -f -
# Generate manifests e.g. CRD, RBAC etc.
manifests: download-deps
bin/controller-gen $(CRD_OPTIONS) rbac:roleName=manager-role webhook paths="./..." output:rbac:artifacts:config=config/base/rbac output:crd:artifacts:config=config/base/crds
rm deploy/charts/istio-operator/crds/* && cp config/base/crds/* deploy/charts/istio-operator/crds/
scripts/label-crds.sh $(ISTIO_VERSION)
# Run go fmt against code
fmt:
go fmt ./...
# Run go vet against code
vet:
go vet ./...
download-deps:
./scripts/download-deps.sh
# Generate code
generate: download-deps
go generate ./pkg/... ./cmd/...
bin/controller-gen object:headerFile="hack/boilerplate.go.txt" paths="./..."
./hack/update-codegen.sh
go run static/generate.go
# Verify codegen
verify-codegen: download-deps
./hack/verify-codegen.sh
# Build the docker image
docker-build: vendor
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 -r ans && [ "$${ans:-N}" = y ]
.PHONY: check-diff
check-diff:
@git --no-pager diff --name-only --exit-code -- 'static/*' || (echo "Please commit any changes to the generated code" && false)
release: check_release
git tag -a ${REL_TAG} -m ${RELEASE_MSG}
git push origin ${REL_TAG}
.PHONY: shellcheck-makefile
shellcheck-makefile: bin/shellcheck ## Check each makefile recipe using shellcheck
@grep -h -E '^[a-zA-Z_-]+:' $(MAKEFILE_LIST) | cut -d: -f1 | while IFS= read -r target; do \
echo "Checking make target: $$target"; \
make -s "$$target" SHELL=scripts/shellcheck-makefile.sh || exit 1; \
done
.PHONY: shellcheck
shellcheck: bin/shellcheck ## Check shell scripts
bin/shellcheck scripts/*.sh hack/*.sh docs/federation/gateway/cluster-add/*.sh docs/federation/flat/*.sh
bin/shellcheck:
scripts/install_shellcheck.sh