Skip to content

Commit

Permalink
Change errors a bit
Browse files Browse the repository at this point in the history
Signed-off-by: Peyton Walters <[email protected]>
  • Loading branch information
Peyton Walters committed Jan 9, 2020
1 parent 2e31f51 commit f7c1713
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 8 deletions.
4 changes: 3 additions & 1 deletion cmd/plugin/vault-auth-spire.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ import (
"context"
"errors"
"flag"
"fmt"

"github.com/bloomberg/vault-auth-spire/internal/common"
"github.com/hashicorp/vault/sdk/framework"
"github.com/hashicorp/vault/sdk/logical"
Expand Down Expand Up @@ -144,7 +146,7 @@ func parseSettings() (*common.Settings, error) {

settings, err := common.ReadSettings(settingsFilePath)
if err != nil {
return nil, errors.New("vault-auth-spire: Failed to read settings from '" + settingsFilePath + "' - " + err.Error())
return nil, fmt.Errorf("vault-auth-spire: Failed to read settings from %s: %v", settingsFilePath, err)
}

return settings, nil
Expand Down
10 changes: 3 additions & 7 deletions internal/common/settings.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,6 @@ type LogSettings struct {
Compress bool
}

func wrapError(err error) error {
return errors.New("parse-settings: " + err.Error())
}

// ReadSettings reads settings from JSON into config objects using Viper
func ReadSettings(fromPath string) (*Settings, error) {
settings := new(Settings)
Expand All @@ -68,17 +64,17 @@ func ReadSettings(fromPath string) (*Settings, error) {
// Load the config from disk at sourcePath
viper.SetConfigFile(fromPath)
if err = viper.ReadInConfig(); err != nil {
return nil, wrapError(err)
return nil, err
}

// Read logging settings
if settings.Log, err = readLogSettings(); err != nil {
return nil, wrapError(err)
return nil, err
}

// Read our source of trust settings
if settings.SourceOfTrust, err = readSourceOfTrustSettings(); err != nil {
return nil, wrapError(err)
return nil, err
}

return settings, nil
Expand Down

0 comments on commit f7c1713

Please sign in to comment.