Skip to content

Commit da91e47

Browse files
Paulo Gomeshiddeco
authored andcommitted
Improve documentation on Debugging source controller
Expands on the current documentation to help contributors debug the controller regardless of all its existing dependencies. Signed-off-by: Paulo Gomes <[email protected]>
1 parent c841790 commit da91e47

File tree

2 files changed

+43
-4
lines changed

2 files changed

+43
-4
lines changed

DEVELOPMENT.md

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,3 +128,31 @@ Deploy `source-controller` into the cluster that is configured in the local kube
128128
```sh
129129
make deploy
130130
```
131+
132+
### Debugging controller with VSCode
133+
134+
Create a `.vscode/launch.json` file:
135+
```json
136+
{
137+
"version": "0.2.0",
138+
"configurations": [
139+
{
140+
"name": "Launch Package",
141+
"type": "go",
142+
"request": "launch",
143+
"mode": "auto",
144+
"envFile": "${workspaceFolder}/build/.env",
145+
"program": "${workspaceFolder}/main.go"
146+
}
147+
]
148+
}
149+
```
150+
151+
Create the environment file containing details on how to load
152+
`libgit2` dependencies:
153+
```bash
154+
make env
155+
```
156+
157+
Start debugging by either clicking `Run` > `Start Debugging` or using
158+
the relevant shortcut.

Makefile

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -241,19 +241,30 @@ endef
241241

242242
# Build fuzzers
243243
fuzz-build: $(LIBGIT2)
244-
rm -rf $(shell pwd)/build/fuzz/
245-
mkdir -p $(shell pwd)/build/fuzz/out/
244+
rm -rf $(BUILD_DIR)/fuzz/
245+
mkdir -p $(BUILD_DIR)/fuzz/out/
246246

247247
docker build . --tag local-fuzzing:latest -f tests/fuzz/Dockerfile.builder
248248
docker run --rm \
249249
-e FUZZING_LANGUAGE=go -e SANITIZER=address \
250250
-e CIFUZZ_DEBUG='True' -e OSS_FUZZ_PROJECT_NAME=fluxcd \
251-
-v "$(shell pwd)/build/fuzz/out":/out \
251+
-v "$(BUILD_DIR)/fuzz/out":/out \
252252
local-fuzzing:latest
253253

254254
fuzz-smoketest: fuzz-build
255255
docker run --rm \
256-
-v "$(shell pwd)/build/fuzz/out":/out \
256+
-v "$(BUILD_DIR)/fuzz/out":/out \
257257
-v "$(shell pwd)/tests/fuzz/oss_fuzz_run.sh":/runner.sh \
258258
local-fuzzing:latest \
259259
bash -c "/runner.sh"
260+
261+
# Creates an env file that can be used to load all source-controller's dependencies
262+
# this is handy when you want to run adhoc debug sessions on tests or start the
263+
# controller in a new debug session.
264+
env: $(LIBGIT2)
265+
echo 'GO_ENABLED="1"' > $(BUILD_DIR)/.env
266+
echo 'PKG_CONFIG_PATH="$(PKG_CONFIG_PATH)"' >> $(BUILD_DIR)/.env
267+
echo 'LIBRARY_PATH="$(LIBRARY_PATH)"' >> $(BUILD_DIR)/.env
268+
echo 'CGO_CFLAGS="$(CGO_CFLAGS)"' >> $(BUILD_DIR)/.env
269+
echo 'CGO_LDFLAGS="$(CGO_LDFLAGS)"' >> $(BUILD_DIR)/.env
270+
echo 'KUBEBUILDER_ASSETS=$(KUBEBUILDER_ASSETS)' >> $(BUILD_DIR)/.env

0 commit comments

Comments
 (0)