summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDave Henderson <dhenderson@gmail.com>2022-02-01 12:36:24 -0500
committerDave Henderson <dhenderson@gmail.com>2022-02-01 12:36:24 -0500
commitd76cb3b452891fc1bdda75e1db2be6753ffcc427 (patch)
tree2c0e40104ff329055d3f6a72e178e338f5c56871
parenta2265a15117611e1fcc6a7ed3cf5f3d625f2f4a7 (diff)
Fix lint failures around error strings
Signed-off-by: Dave Henderson <dhenderson@gmail.com>
-rw-r--r--aws/ec2info.go8
-rw-r--r--gcp/meta.go7
-rw-r--r--random/random.go11
3 files changed, 12 insertions, 14 deletions
diff --git a/aws/ec2info.go b/aws/ec2info.go
index 366fc7ff..9419f8db 100644
--- a/aws/ec2info.go
+++ b/aws/ec2info.go
@@ -1,6 +1,7 @@
package aws
import (
+ "fmt"
"net/http"
"os"
"strconv"
@@ -12,7 +13,6 @@ import (
"github.com/aws/aws-sdk-go/aws/session"
"github.com/aws/aws-sdk-go/service/ec2"
"github.com/hairyhenderson/gomplate/v3/env"
- "github.com/pkg/errors"
)
var describerClient InstanceDescriber
@@ -52,7 +52,7 @@ func GetClientOptions() ClientOptions {
t, err := strconv.Atoi(timeout)
if err != nil {
- panic(errors.Wrapf(err, "Invalid AWS_TIMEOUT value '%s' - must be an integer\n", timeout))
+ panic(fmt.Errorf("invalid AWS_TIMEOUT value '%s' - must be an integer: %w", timeout, err))
}
co.Timeout = time.Duration(t) * time.Millisecond
@@ -83,7 +83,7 @@ func SDKSession(region ...string) *session.Session {
var err error
metaRegion, err = getRegion()
if err != nil {
- panic(errors.Wrap(err, "failed to determine EC2 region"))
+ panic(fmt.Errorf("failed to determine EC2 region: %w", err))
}
}
if metaRegion != "" && metaRegion != unknown {
@@ -119,7 +119,7 @@ func getRegion(m ...*Ec2Meta) (string, error) {
var err error
region, err = metaClient.Region()
if err != nil {
- return "", errors.Wrap(err, "failed to determine EC2 region")
+ return "", fmt.Errorf("failed to determine EC2 region: %w", err)
}
}
return region, nil
diff --git a/gcp/meta.go b/gcp/meta.go
index 894e9445..bf80821b 100644
--- a/gcp/meta.go
+++ b/gcp/meta.go
@@ -1,6 +1,7 @@
package gcp
import (
+ "fmt"
"io/ioutil"
"net/http"
"strconv"
@@ -8,8 +9,6 @@ import (
"sync"
"time"
- "github.com/pkg/errors"
-
"github.com/hairyhenderson/gomplate/v3/env"
)
@@ -39,7 +38,7 @@ func GetClientOptions() ClientOptions {
t, err := strconv.Atoi(timeout)
if err != nil {
- panic(errors.Wrapf(err, "Invalid GCP_TIMEOUT value '%s' - must be an integer\n", timeout))
+ panic(fmt.Errorf("invalid GCP_TIMEOUT value '%s' - must be an integer: %w", timeout, err))
}
co.Timeout = time.Duration(t) * time.Millisecond
@@ -113,7 +112,7 @@ func (c *MetaClient) retrieveMetadata(url string, def ...string) (string, error)
body, err := ioutil.ReadAll(resp.Body)
if err != nil {
- return "", errors.Wrapf(err, "Failed to read response body from %s", url)
+ return "", fmt.Errorf("failed to read response body from %s: %w", url, err)
}
value := strings.TrimSpace(string(body))
c.cache[url] = value
diff --git a/random/random.go b/random/random.go
index e7b9d6df..eb993f57 100644
--- a/random/random.go
+++ b/random/random.go
@@ -2,13 +2,12 @@
package random
import (
+ "fmt"
"math"
"math/rand"
"regexp"
"time"
"unicode"
-
- "github.com/pkg/errors"
)
func init() {
@@ -39,7 +38,7 @@ func StringRE(count int, match string) (r string, err error) {
func StringBounds(count int, lower, upper rune) (r string, err error) {
chars := filterRange(lower, upper)
if len(chars) == 0 {
- return "", errors.Errorf("No printable codepoints found between U%#q and U%#q.", lower, upper)
+ return "", fmt.Errorf("no printable codepoints found between U%#q and U%#q", lower, upper)
}
return rndString(count, chars)
}
@@ -82,7 +81,7 @@ func matchChars(match string) ([]rune, error) {
// Item -
func Item(items []interface{}) (interface{}, error) {
if len(items) == 0 {
- return nil, errors.Errorf("expected a non-empty array or slice")
+ return nil, fmt.Errorf("expected a non-empty array or slice")
}
if len(items) == 1 {
return items[0], nil
@@ -96,13 +95,13 @@ func Item(items []interface{}) (interface{}, error) {
// Number -
func Number(min, max int64) (int64, error) {
if min > max {
- return 0, errors.Errorf("min must not be greater than max (was %d, %d)", min, max)
+ return 0, fmt.Errorf("min must not be greater than max (was %d, %d)", min, max)
}
if min == math.MinInt64 {
min++
}
if max-min >= (math.MaxInt64 >> 1) {
- return 0, errors.Errorf("spread between min and max too high - must not be greater than 63-bit maximum (%d - %d = %d)", max, min, max-min)
+ return 0, fmt.Errorf("spread between min and max too high - must not be greater than 63-bit maximum (%d - %d = %d)", max, min, max-min)
}
//nolint:gosec