Skip to content

Commit

Permalink
address PR comments
Browse files Browse the repository at this point in the history
  • Loading branch information
edwardmack committed Feb 10, 2023
1 parent c7e7b06 commit 4a4ccec
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 7 deletions.
7 changes: 3 additions & 4 deletions cmd/gossamer/toml_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,7 @@ import (
func loadConfigFromResource(cfg *ctoml.Config, resourcePath string) error {
file, err := internal.DefaultConfigTomlFiles.Open(resourcePath)
if err != nil {
logger.Errorf("opening toml configuration file: %w", err)
return err
return fmt.Errorf("opening toml configuration file: %w", err)
}
return loadConfig(cfg, file)
}
Expand All @@ -40,7 +39,7 @@ func loadConfigFromFile(cfg *ctoml.Config, fp string) error {
}

// loadConfig loads the values from the toml configuration file into the provided configuration
func loadConfig(cfg *ctoml.Config, file fs.File) error {
func loadConfig(cfg *ctoml.Config, file fs.File) (err error) {
var tomlSettings = toml.Config{
NormFieldName: func(rt reflect.Type, key string) string {
return key
Expand All @@ -57,7 +56,7 @@ func loadConfig(cfg *ctoml.Config, file fs.File) error {
},
}

if err := tomlSettings.NewDecoder(file).Decode(cfg); err != nil {
if err = tomlSettings.NewDecoder(file).Decode(cfg); err != nil {
logger.Errorf("failed to decode configuration: %s", err)
return err
}
Expand Down
5 changes: 2 additions & 3 deletions lib/utils/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -192,14 +192,13 @@ var (
)

// GetProjectRootPath finds the root of the project where directory `cmd`
// and subdirectories `gossamer, testcases` are
// and returns it as an absolute path.
// and subdirectory `gossamer` is and returns it as an absolute path.
func GetProjectRootPath() (rootPath string, err error) {
_, fullpath, _, _ := runtime.Caller(0)
rootPath = path.Dir(fullpath)

const directoryToFind = "cmd"
const subPathsToFind = "gossamer,testcases"
const subPathsToFind = "gossamer"

subPaths := strings.Split(subPathsToFind, ",")

Expand Down

0 comments on commit 4a4ccec

Please sign in to comment.