-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
114 lines (93 loc) · 3.47 KB
/
Copy pathMakefile
File metadata and controls
114 lines (93 loc) · 3.47 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
# forail-operator — build & deploy targets.
#
# All commands assume Go 1.23+ and kubectl on PATH (or running inside the
# k8s-m1 vagrant VM where they're installed).
IMAGE ?= ghcr.io/forail-platform/forail-operator:2026.06.0
.PHONY: tidy
tidy:
go mod tidy
.PHONY: generate
generate:
# Regenerates zz_generated.deepcopy.go for the API types.
# Requires `controller-gen` (install: go install sigs.k8s.io/controller-tools/cmd/controller-gen@v0.16.5).
controller-gen object paths="./api/..."
.PHONY: manifests
manifests:
# Re-generate the CRD YAML from kubebuilder markers in api/v1alpha1.
controller-gen rbac:roleName=manager-role crd webhook paths="./..." output:crd:artifacts:config=config/crd/bases
.PHONY: build
build:
CGO_ENABLED=0 go build -ldflags="-s -w" -o bin/manager ./cmd
.PHONY: test
test: envtest-assets
KUBEBUILDER_ASSETS="$(shell setup-envtest use 1.30 -p path)" go test ./... -v -count=1 -timeout=120s
# Install setup-envtest tool and download envtest binaries (apiserver,
# etcd, kubectl) for the targeted Kubernetes version. Stored under
# ~/.local/share/kubebuilder-envtest by default.
.PHONY: envtest-assets
envtest-assets:
@command -v setup-envtest >/dev/null || go install sigs.k8s.io/controller-runtime/tools/setup-envtest@latest
setup-envtest use 1.30 -p path >/dev/null
.PHONY: vet
vet:
go vet ./...
.PHONY: docker-build
docker-build:
docker build -t $(IMAGE) .
.PHONY: install-crd
install-crd:
kubectl apply -f config/crd/bases/
.PHONY: deploy
deploy: install-crd
kubectl apply -f config/rbac/rbac.yaml
kubectl apply -f config/manager/manager.yaml
.PHONY: undeploy
undeploy:
-kubectl delete -f config/manager/manager.yaml
-kubectl delete -f config/rbac/rbac.yaml
-kubectl delete -f config/crd/bases/
.PHONY: run
run:
# Run the operator out-of-cluster against the kubeconfig in $KUBECONFIG.
go run ./cmd \
--forail-url=$$FORAIL_URL \
--forail-user=$$FORAIL_USER \
--forail-password=$$FORAIL_PASSWORD \
--forail-insecure-skip-verify
# --- OLM bundle + catalog ---
#
# Bundle wraps the operator manifests (CSV + CRDs) into an OCI image that
# an OLM CatalogSource can serve. Catalog is a file-based catalog (FBC)
# image listing one or more bundle versions.
VERSION ?= 1.0.0
BUNDLE_IMG ?= ghcr.io/forail-platform/forail-operator-bundle:v$(VERSION)
CATALOG_IMG ?= ghcr.io/forail-platform/forail-operator-catalog:v$(VERSION)
.PHONY: bundle
bundle: manifests
# Refresh bundle/manifests with the latest CRDs and the CSV base.
rm -rf bundle/manifests
mkdir -p bundle/manifests
cp config/crd/bases/*.yaml bundle/manifests/
cp config/manifests/bases/forail-operator.clusterserviceversion.yaml bundle/manifests/
.PHONY: bundle-build
bundle-build:
docker build -f bundle.Dockerfile -t $(BUNDLE_IMG) .
.PHONY: bundle-push
bundle-push:
docker push $(BUNDLE_IMG)
# Validate bundle layout (requires operator-sdk).
.PHONY: bundle-validate
bundle-validate:
@command -v operator-sdk >/dev/null || { echo "operator-sdk required"; exit 1; }
operator-sdk bundle validate ./bundle --select-optional name=operatorhub
# Build a file-based catalog image referencing the bundle. For a
# multi-version catalog, re-run with --bundles "$(BUNDLE_IMG_v1.0.0),$(BUNDLE_IMG_v1.1.0)".
.PHONY: catalog-build
catalog-build:
@command -v opm >/dev/null || { echo "opm required (https://github.com/operator-framework/operator-registry)"; exit 1; }
opm index add --container-tool docker \
--bundles $(BUNDLE_IMG) \
--tag $(CATALOG_IMG)
.PHONY: catalog-push
catalog-push:
docker push $(CATALOG_IMG)