forked from cert-manager/trust-manager
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
122 lines (93 loc) · 4.24 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
# Copyright 2022 The cert-manager Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
BINDIR ?= $(CURDIR)/bin
ARCH ?= $(shell go env GOARCH)
OS ?= $(shell go env GOOS)
HELM_VERSION ?= 3.6.3
KUBEBUILDER_TOOLS_VERISON ?= 1.21.2
IMAGE_PLATFORMS ?= linux/amd64,linux/arm64,linux/arm/v7,linux/ppc64le
RELEASE_VERSION ?= 0.2.0
.PHONY: help
help: ## display this help
@awk 'BEGIN {FS = ":.*##"; printf "\nUsage:\n make \033[36m<target>\033[0m\n\nTargets:\n"} /^[a-zA-Z0-9_-]+:.*?##/ { printf " \033[36m%-20s\033[0m %s\n", $$1, $$2 }' $(MAKEFILE_LIST)
.PHONY: all
all: depend generate test build image ## runs test, build and image
.PHONY: test
test: depend lint ## test trust
KUBEBUILDER_ASSETS=$(BINDIR)/kubebuilder/bin go test -v ./pkg/... ./cmd/...
.PHONY: lint
lint: vet
./hack/verify-boilerplate.sh
.PHONY: vet
vet:
go vet ./...
.PHONY: build
build: | $(BINDIR) ## build trust
CGO_ENABLED=0 go build -o $(BINDIR)/cert-manager-trust ./cmd/.
.PHONY: generate
generate: depend ## generate code
./hack/update-codegen.sh
.PHONY: verify
verify: depend test verify-helm-docs build ## tests and builds trust
# image will only build and store the image locally, targeted in OCI format.
# To actually push an image to the public repo, replace the `--output` flag and
# arguments to `--push`.
.PHONY: image
image: | $(BINDIR) ## build docker image targeting all supported platforms
docker buildx build --platform=$(IMAGE_PLATFORMS) -t quay.io/jetstack/cert-manager-trust:v$(RELEASE_VERSION) --output type=local,dest=$(BINDIR)/cert-manager-trust .
.PHONY: chart
chart: | $(BINDIR)/helm $(BINDIR)/chart
$(BINDIR)/helm package --app-version=$(RELEASE_VERSION) --version=$(RELEASE_VERSION) --destination "$(BINDIR)/chart" ./deploy/charts/trust
.PHONY: verify-helm-docs
verify-helm-docs: | $(BINDIR)/helm-docs
./hack/verify-helm-docs.sh $(BINDIR)/helm-docs
.PHONY: update-helm-docs
update-helm-docs: | $(BINDIR)/helm-docs
./hack/update-helm-docs.sh $(BINDIR)/helm-docs
.PHONY: clean
clean: ## clean up created files
rm -rf \
$(BINDIR) \
_artifacts
.PHONY: demo
demo: depend ## create cluster and deploy trust
REPO_ROOT=$(shell pwd) ./hack/ci/create-cluster.sh
.PHONY: smoke
smoke: demo ## create cluster, deploy trust and run smoke tests
REPO_ROOT=$(shell pwd) ./hack/ci/run-smoke-test.sh
.PHONY: depend
depend: $(BINDIR)/deepcopy-gen $(BINDIR)/controller-gen $(BINDIR)/ginkgo $(BINDIR)/kubectl $(BINDIR)/kind $(BINDIR)/helm $(BINDIR)/kubebuilder/bin/kube-apiserver
$(BINDIR)/deepcopy-gen: | $(BINDIR)
go build -o $@ k8s.io/code-generator/cmd/deepcopy-gen
$(BINDIR)/controller-gen: | $(BINDIR)
go build -o $@ sigs.k8s.io/controller-tools/cmd/controller-gen
$(BINDIR)/ginkgo: | $(BINDIR)
go build -o $(BINDIR)/ginkgo github.com/onsi/ginkgo/ginkgo
$(BINDIR)/kind: | $(BINDIR)
go build -o $(BINDIR)/kind sigs.k8s.io/kind
$(BINDIR)/helm: | $(BINDIR)
curl -o $(BINDIR)/helm.tar.gz -LO "https://get.helm.sh/helm-v$(HELM_VERSION)-$(OS)-$(ARCH).tar.gz"
tar -C $(BINDIR) -xzf $(BINDIR)/helm.tar.gz
cp $(BINDIR)/$(OS)-$(ARCH)/helm $@
rm -r $(BINDIR)/$(OS)-$(ARCH) $(BINDIR)/helm.tar.gz
$(BINDIR)/helm-docs: | $(BINDIR)
cd hack/tools && go build -o $@ github.com/norwoodj/helm-docs/cmd/helm-docs
$(BINDIR)/kubectl: | $(BINDIR)
curl -o $@ -LO "https://storage.googleapis.com/kubernetes-release/release/$(shell curl -s https://storage.googleapis.com/kubernetes-release/release/stable.txt)/bin/$(OS)/$(ARCH)/kubectl"
chmod +x $@
$(BINDIR)/kubebuilder/bin/kube-apiserver: | $(BINDIR)/kubebuilder
curl -sSLo $(BINDIR)/envtest-bins.tar.gz "https://storage.googleapis.com/kubebuilder-tools/kubebuilder-tools-$(KUBEBUILDER_TOOLS_VERISON)-$(OS)-$(ARCH).tar.gz"
tar -C $(BINDIR)/kubebuilder --strip-components=1 -zvxf $(BINDIR)/envtest-bins.tar.gz
$(BINDIR) $(BINDIR)/kubebuilder $(BINDIR)/chart:
@mkdir -p $@