Skip to content
This repository has been archived by the owner on Apr 22, 2024. It is now read-only.

Commit

Permalink
Properly validate configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
nacx committed Feb 9, 2024
1 parent 6844fc0 commit 91ba58c
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 2 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ config/lint: ## Lint the Config Proto generated code
test: ## Run all the tests
@go test $(TEST_OPTS) $(TEST_PKGS)

COVERAGE_OPTS ?=
COVERAGE_OPTS ?=
.PHONY: coverage
coverage: ## Creates coverage report for all projects
@echo "Running test coverage"
Expand Down
9 changes: 8 additions & 1 deletion internal/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,5 +57,12 @@ func (l *LocalConfigFile) Validate() error {
return err
}

return protojson.Unmarshal(content, &l.Config)
if err = protojson.Unmarshal(content, &l.Config); err != nil {
return err
}

// Set reasonable defaults for non-supported values
l.Config.Threads = 1

return l.Config.Validate()
}
2 changes: 2 additions & 0 deletions internal/testdata/mock.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
{
"listen_address": "0.0.0.0",
"listen_port": 8080,
"log_level": "debug",
"chains": [
{
Expand Down

0 comments on commit 91ba58c

Please sign in to comment.