Skip to content
This repository was archived by the owner on May 13, 2025. It is now read-only.

Commit f7c1713

Browse files
author
Peyton Walters
committed
Change errors a bit
Signed-off-by: Peyton Walters <pwalters18@bloomberg.net>
1 parent 2e31f51 commit f7c1713

2 files changed

Lines changed: 6 additions & 8 deletions

File tree

cmd/plugin/vault-auth-spire.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ import (
2020
"context"
2121
"errors"
2222
"flag"
23+
"fmt"
24+
2325
"github.com/bloomberg/vault-auth-spire/internal/common"
2426
"github.com/hashicorp/vault/sdk/framework"
2527
"github.com/hashicorp/vault/sdk/logical"
@@ -144,7 +146,7 @@ func parseSettings() (*common.Settings, error) {
144146

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

150152
return settings, nil

internal/common/settings.go

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -54,10 +54,6 @@ type LogSettings struct {
5454
Compress bool
5555
}
5656

57-
func wrapError(err error) error {
58-
return errors.New("parse-settings: " + err.Error())
59-
}
60-
6157
// ReadSettings reads settings from JSON into config objects using Viper
6258
func ReadSettings(fromPath string) (*Settings, error) {
6359
settings := new(Settings)
@@ -68,17 +64,17 @@ func ReadSettings(fromPath string) (*Settings, error) {
6864
// Load the config from disk at sourcePath
6965
viper.SetConfigFile(fromPath)
7066
if err = viper.ReadInConfig(); err != nil {
71-
return nil, wrapError(err)
67+
return nil, err
7268
}
7369

7470
// Read logging settings
7571
if settings.Log, err = readLogSettings(); err != nil {
76-
return nil, wrapError(err)
72+
return nil, err
7773
}
7874

7975
// Read our source of trust settings
8076
if settings.SourceOfTrust, err = readSourceOfTrustSettings(); err != nil {
81-
return nil, wrapError(err)
77+
return nil, err
8278
}
8379

8480
return settings, nil

0 commit comments

Comments
 (0)