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 <paulo.gomes@weave.works>
This commit is contained in:
Paulo Gomes 2022-03-29 23:12:07 +01:00 committed by Hidde Beydals
parent c84179088c
commit da91e47036
2 changed files with 43 additions and 4 deletions

View File

@ -128,3 +128,31 @@ Deploy `source-controller` into the cluster that is configured in the local kube
```sh ```sh
make deploy make deploy
``` ```
### Debugging controller with VSCode
Create a `.vscode/launch.json` file:
```json
{
"version": "0.2.0",
"configurations": [
{
"name": "Launch Package",
"type": "go",
"request": "launch",
"mode": "auto",
"envFile": "${workspaceFolder}/build/.env",
"program": "${workspaceFolder}/main.go"
}
]
}
```
Create the environment file containing details on how to load
`libgit2` dependencies:
```bash
make env
```
Start debugging by either clicking `Run` > `Start Debugging` or using
the relevant shortcut.

View File

@ -241,19 +241,30 @@ endef
# Build fuzzers # Build fuzzers
fuzz-build: $(LIBGIT2) fuzz-build: $(LIBGIT2)
rm -rf $(shell pwd)/build/fuzz/ rm -rf $(BUILD_DIR)/fuzz/
mkdir -p $(shell pwd)/build/fuzz/out/ mkdir -p $(BUILD_DIR)/fuzz/out/
docker build . --tag local-fuzzing:latest -f tests/fuzz/Dockerfile.builder docker build . --tag local-fuzzing:latest -f tests/fuzz/Dockerfile.builder
docker run --rm \ docker run --rm \
-e FUZZING_LANGUAGE=go -e SANITIZER=address \ -e FUZZING_LANGUAGE=go -e SANITIZER=address \
-e CIFUZZ_DEBUG='True' -e OSS_FUZZ_PROJECT_NAME=fluxcd \ -e CIFUZZ_DEBUG='True' -e OSS_FUZZ_PROJECT_NAME=fluxcd \
-v "$(shell pwd)/build/fuzz/out":/out \ -v "$(BUILD_DIR)/fuzz/out":/out \
local-fuzzing:latest local-fuzzing:latest
fuzz-smoketest: fuzz-build fuzz-smoketest: fuzz-build
docker run --rm \ docker run --rm \
-v "$(shell pwd)/build/fuzz/out":/out \ -v "$(BUILD_DIR)/fuzz/out":/out \
-v "$(shell pwd)/tests/fuzz/oss_fuzz_run.sh":/runner.sh \ -v "$(shell pwd)/tests/fuzz/oss_fuzz_run.sh":/runner.sh \
local-fuzzing:latest \ local-fuzzing:latest \
bash -c "/runner.sh" bash -c "/runner.sh"
# Creates an env file that can be used to load all source-controller's dependencies
# this is handy when you want to run adhoc debug sessions on tests or start the
# controller in a new debug session.
env: $(LIBGIT2)
echo 'GO_ENABLED="1"' > $(BUILD_DIR)/.env
echo 'PKG_CONFIG_PATH="$(PKG_CONFIG_PATH)"' >> $(BUILD_DIR)/.env
echo 'LIBRARY_PATH="$(LIBRARY_PATH)"' >> $(BUILD_DIR)/.env
echo 'CGO_CFLAGS="$(CGO_CFLAGS)"' >> $(BUILD_DIR)/.env
echo 'CGO_LDFLAGS="$(CGO_LDFLAGS)"' >> $(BUILD_DIR)/.env
echo 'KUBEBUILDER_ASSETS=$(KUBEBUILDER_ASSETS)' >> $(BUILD_DIR)/.env