-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTaskfile.yml
More file actions
203 lines (178 loc) · 5.84 KB
/
Taskfile.yml
File metadata and controls
203 lines (178 loc) · 5.84 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
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
version: '3'
vars:
IMG:
sh: echo "${IMG:-controller:latest}"
CRD_OPTIONS: "crd:trivialVersions=true,preserveUnknownFields=false"
ENVTEST_K8S_VERSION: "1.28.0"
CONTROLLER_TOOLS_VERSION: "v0.14.0"
LOCALBIN:
sh: echo "$(pwd)/bin"
GOBIN:
sh: |
if [ -z "$(go env GOBIN)" ]; then
echo "$(go env GOPATH)/bin"
else
go env GOBIN
fi
tasks:
default:
desc: Build manager binary
deps: [generate, fmt, vet]
cmds:
- go build -o bin/manager main.go
help:
desc: Display this help
cmds:
- task --list
# Development tasks
manifests:
desc: Generate ClusterRole and CustomResourceDefinition objects
deps: [controller-gen]
cmds:
- '{{.LOCALBIN}}/controller-gen rbac:roleName=manager-role crd webhook paths=./api/... output:crd:artifacts:config=config/crd/bases'
generate:
desc: Generate code containing DeepCopy, DeepCopyInto, and DeepCopyObject method implementations
deps: [controller-gen]
cmds:
- '{{.LOCALBIN}}/controller-gen object:headerFile="hack/boilerplate.go.txt" paths=./api/...'
fmt:
desc: Run go fmt against code
cmds:
- go fmt ./...
vet:
desc: Run go vet against code
cmds:
- go vet ./...
test:
desc: Run all tests with coverage (requires envtest)
deps: [manifests, generate, fmt, vet, envtest]
cmds:
- |
KUBEBUILDER_ASSETS="$$({{.LOCALBIN}}/setup-envtest use {{.ENVTEST_K8S_VERSION}} -p path)" \
GOTOOLCHAIN=go1.25.0 go test ./internal/... ./test/... -coverprofile cover.out || true
test-unit:
desc: Run unit tests without envtest with statistics
cmds:
- GOTOOLCHAIN=go1.25.0 ./scripts/run-tests-with-stats.sh ./...
test-unit-simple:
desc: Run unit tests without envtest (simple output)
cmds:
- GOTOOLCHAIN=go1.25.0 go test ./... -v
test-all:
desc: Run all unit tests (alias for test-unit)
cmds:
- task: test-unit
test-integration:
desc: Run integration tests with statistics (Docker required for Kafka/ClickHouse)
cmds:
- GOTOOLCHAIN=go1.25.0 GO_TEST_TAGS=integration ./scripts/run-tests-with-stats.sh ./test/integration/...
test-integration-simple:
desc: Run integration tests (simple output, Docker required for Kafka/ClickHouse)
cmds:
- GOTOOLCHAIN=go1.25.0 go test -tags=integration ./test/integration/... -v
# Build tasks
build:
desc: Build manager binary
deps: [generate, fmt, vet]
cmds:
- go build -o bin/manager main.go
run:
desc: Run a controller from your host
deps: [manifests, generate, fmt, vet]
cmds:
- go run ./main.go
sync-crd-to-helm:
desc: Sync generated CRD into Helm chart template (wraps CRD with Helm conditionals)
deps: [manifests]
vars:
CRD_SOURCE: config/crd/bases/dataflow.dataflow.io_dataflows.yaml
HELM_TARGET: ../helm-charts/charts/dataflow-operator/templates/crd.yaml
cmds:
- |
HEADER='{{- if .Values.crds.install }}'
FOOTER='{{- end }}'
LABELS_BLOCK=' labels:
{{- include "dataflow-operator.labels" . | nindent 4 }}'
KEEP_BLOCK=' {{- if .Values.crds.keep }}
"helm.sh/resource-policy": keep
{{- end }}'
{
echo "$HEADER"
awk '
/^---$/ { next }
/^metadata:$/ {
print
getline
# annotations block
if ($0 ~ /^ annotations:/) {
print
# print existing annotations
while (getline > 0 && $0 ~ /^ [^ ]/) {
print
}
# insert keep annotation block
printf "%s\n", "'"$KEEP_BLOCK"'"
# insert labels block
printf "%s\n", "'"$LABELS_BLOCK"'"
print
}
next
}
{ print }
' "{{.CRD_SOURCE}}"
echo "$FOOTER"
} > "{{.HELM_TARGET}}"
echo "Synced CRD to {{.HELM_TARGET}}"
# Deployment tasks
install:
desc: Install CRDs into the K8s cluster specified in ~/.kube/config
deps: [manifests]
cmds:
- kubectl apply -f config/crd/bases
uninstall:
desc: Uninstall CRDs from the K8s cluster specified in ~/.kube/config
deps: [manifests]
cmds:
- |
ignore_not_found="${IGNORE_NOT_FOUND:-false}"
kubectl delete --ignore-not-found=$ignore_not_found -f config/crd/bases
deploy:
desc: Deploy controller to the K8s cluster specified in ~/.kube/config
deps: [manifests]
cmds:
- |
cd config/manager && kustomize edit set image controller={{.IMG}}
kustomize build config/default | kubectl apply -f -
undeploy:
desc: Undeploy controller from the K8s cluster specified in ~/.kube/config
cmds:
- |
ignore_not_found="${IGNORE_NOT_FOUND:-false}"
kustomize build config/default | kubectl delete --ignore-not-found=$ignore_not_found -f -
# Build Dependencies
controller-gen:
desc: Download controller-gen locally if necessary
cmds:
- |
if [ ! -f {{.LOCALBIN}}/controller-gen ]; then
GOBIN={{.LOCALBIN}} go install sigs.k8s.io/controller-tools/cmd/controller-gen@{{.CONTROLLER_TOOLS_VERSION}}
fi
preconditions:
- test -d {{.LOCALBIN}} || mkdir -p {{.LOCALBIN}}
envtest:
desc: Download envtest-setup locally if necessary
cmds:
- |
if [ ! -f {{.LOCALBIN}}/setup-envtest ]; then
GOBIN={{.LOCALBIN}} go install sigs.k8s.io/controller-runtime/tools/setup-envtest@latest
fi
preconditions:
- test -d {{.LOCALBIN}} || mkdir -p {{.LOCALBIN}}
test-helm-crd:
desc: Run Helm CRD template tests (requires helm CLI)
cmds:
- bash ../helm-charts/charts/dataflow-operator/tests/crd_test.sh
tidy:
desc: Run go mod tidy
cmds:
- go mod tidy