Fix invalid config JSON and enforce canonical config format

config/disk-log-message-filelog.json contained trailing commas and no
trailing newline, so it could not be parsed by encoding/json and NPD
would fail to start when configured with it.

- Fix the invalid JSON
- Add TestShippedConfigs, which verifies that every shipped JSON config
  under config/ (top level and one directory down) parses (catching
  trailing commas, UTF-8 BOMs and other syntax errors) and is in the
  canonical format (2-space indent, trailing newline), showing a diff on
  failure
- Add `make fmt-configs` to rewrite nonconforming files in place
  (UPDATE_EXPECTED=y)
- Normalize the existing config files to the canonical format
  (whitespace-only changes)
This commit is contained in:
Ciprian Hacman
2026-07-22 07:58:20 +03:00
parent fe3ab8c84e
commit 87dfadb120
18 changed files with 791 additions and 565 deletions
+4 -1
View File
@@ -15,7 +15,7 @@
# Build the node-problem-detector image.
.PHONY: all \
lint vet fmt version test e2e-test \
lint vet fmt fmt-configs version test e2e-test \
build-binaries build-container build-tar build \
docker-builder build-in-docker \
push-container push-tar push release clean depup \
@@ -144,6 +144,9 @@ fmt: $(GOLANGCI_LINT)
find . -type f -name "*.go" | grep -v "./vendor/*" | xargs gofmt -s -w -l
$(GOLANGCI_LINT) run --config .golangci.yml --fix ./...
fmt-configs:
UPDATE_EXPECTED=y go test -run TestShippedConfigs ./pkg/systemlogmonitor
version:
@echo $(VERSION)