-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathkubebuilder.mk
More file actions
65 lines (58 loc) · 2.56 KB
/
Copy pathkubebuilder.mk
File metadata and controls
65 lines (58 loc) · 2.56 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
# Copyright 2026 Dimitri Koshkin. All rights reserved.
# SPDX-License-Identifier: Apache-2.0
IMG ?= controller:latest
.PHONY: controller-gen
controller-gen: ; $(info $(M) using controller-gen from PATH)
command -v controller-gen >/dev/null
.PHONY: kustomize
kustomize: ; $(info $(M) using kustomize from PATH)
command -v kustomize >/dev/null
.PHONY: manifests
manifests: controller-gen mod-tidy ## Generate WebhookConfiguration, ClusterRole and CustomResourceDefinition objects.
manifests: ; $(info $(M) generating CRDs and RBAC manifests)
controller-gen paths="./..." \
rbac:headerFile="hack/license/yaml.txt",roleName=manager-role
controller-gen paths="./..." \
crd:headerFile="hack/license/yaml.txt" \
output:crd:artifacts:config=config/crd/bases
controller-gen paths="./..." \
webhook:headerFile="hack/license/yaml.txt"
.PHONY: generate
generate: controller-gen mod-tidy ## Generate code containing DeepCopy, DeepCopyInto, and DeepCopyObject method implementations.
generate: ; $(info $(M) generating deepcopy code)
controller-gen object:headerFile="hack/license/go.txt" paths="./..."
.PHONY: build-installer
build-installer: manifests generate kustomize ## Generate a consolidated YAML with CRDs and deployment.
build-installer: ; $(info $(M) building installer manifest)
mkdir -p dist
cd config/manager && kustomize edit set image controller=${IMG}
kustomize build config/default > dist/install.yaml
.PHONY: kubebuilder.sync-chart
kubebuilder.sync-chart: ## Regenerate kubebuilder helm chart and sync to charts/golang-repository-template
kubebuilder.sync-chart: ; $(info $(M) syncing kubebuilder helm chart)
rm -rf dist/chart/templates
kubebuilder edit --plugins=helm/v2-alpha
# This workflow is added by the plugin, just remove it.
rm -rf .github/workflows/test-chart.yml
for file in $$(find dist/chart/templates -type f \( -name '*.yaml' -o -name '*.yml' \)); do \
{ \
cat hack/license/yaml.txt; \
echo; \
cat "$$file"; \
} > "$$file.tmp"; \
mv "$$file.tmp" "$$file"; \
done
rm -rf charts/golang-repository-template/templates
cp -R dist/chart/templates charts/golang-repository-template/templates
# Format the values.yaml file.
cp dist/chart/values.yaml dist/chart/values.yaml.formatted
yamlfmt dist/chart/values.yaml.formatted
# Remove the last line to avoid double newline when copying.
sed -i '$$d' dist/chart/values.yaml.formatted
{ \
cat hack/license/yaml.txt; \
echo; \
cat dist/chart/values.yaml.formatted; \
} > charts/golang-repository-template/values.yaml
rm -f dist/chart/values.yaml.formatted
$(MAKE) chart-docs schema-chart