Skip to content

Commit

Permalink
relaxing strict override restriction, and improving log line details
Browse files Browse the repository at this point in the history
  • Loading branch information
patrickhuie19 committed Aug 16, 2024
1 parent 8539f88 commit f90b635
Showing 1 changed file with 5 additions and 11 deletions.
16 changes: 5 additions & 11 deletions core/chains/evm/config/toml/defaults.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package toml
import (
"bytes"
"embed"
"fmt"
"io"
"log"
"os"
Expand Down Expand Up @@ -85,7 +84,7 @@ func init() {
// Read directory contents
entries, err := os.ReadDir(dir)
if err != nil {
fmt.Println("Error reading directory:", err)
log.Printf("error reading custom defaults override directory: %v", err)
return
}

Expand All @@ -98,14 +97,14 @@ func init() {
path := dir + "/" + entry.Name()
file, err := os.Open(path)
if err != nil {
fmt.Println("Error opening file:", err)
log.Printf("error opening file (name: %v) in custom defaults override directory: %w", entry.Name(), err)

Check failure on line 100 in core/chains/evm/config/toml/defaults.go

View workflow job for this annotation

GitHub Actions / lint

printf: log.Printf does not support error-wrapping directive %w (govet)

Check failure on line 100 in core/chains/evm/config/toml/defaults.go

View workflow job for this annotation

GitHub Actions / Core Tests (go_core_race_tests)

log.Printf does not support error-wrapping directive %w

Check failure on line 100 in core/chains/evm/config/toml/defaults.go

View workflow job for this annotation

GitHub Actions / Core Tests (go_core_tests)

log.Printf does not support error-wrapping directive %w
continue
}

// Read file contents
b, err := io.ReadAll(file)
if err != nil {
fmt.Println("Error reading file:", err)
log.Printf("error reading file (name: %v) contents in custom defaults override directory: %w", entry.Name(), err)

Check failure on line 107 in core/chains/evm/config/toml/defaults.go

View workflow job for this annotation

GitHub Actions / lint

printf: log.Printf does not support error-wrapping directive %w (govet)

Check failure on line 107 in core/chains/evm/config/toml/defaults.go

View workflow job for this annotation

GitHub Actions / Core Tests (go_core_race_tests)

log.Printf does not support error-wrapping directive %w

Check failure on line 107 in core/chains/evm/config/toml/defaults.go

View workflow job for this annotation

GitHub Actions / Core Tests (go_core_tests)

log.Printf does not support error-wrapping directive %w
file.Close()
continue
}
Expand All @@ -117,19 +116,14 @@ func init() {
}{}

if err := cconfig.DecodeTOML(bytes.NewReader(b), &config); err != nil {
log.Fatalf("failed to decode %q: %v", path, err)
log.Fatalf("failed to decode %q in custom defaults override directory: %v", path, err)
}

if config.ChainID == nil {
log.Fatalf("missing ChainID: %s", path)
log.Fatalf("missing ChainID in: %s in custom defaults override directory. exiting", path)
}

id := config.ChainID.String()
// these custom defaults are only meant to be overrides on existing chains;
// if the chain does not exist already in defaults error out
if _, ok := defaults[id]; !ok {
log.Fatalf("%q does not contain ChainID: %s", path, id)
}
customDefaults[id] = config.Chain
}
}
Expand Down

0 comments on commit f90b635

Please sign in to comment.