serviceregistration: deprecate errwrap.Wrapf() (#11443)

This commit is contained in:
Lars Lehtonen 2021-04-26 05:33:50 -07:00 committed by GitHub
parent bcecb885ff
commit b6f75f49e0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 7 additions and 8 deletions

View File

@ -15,7 +15,6 @@ import (
"time"
"github.com/hashicorp/consul/api"
"github.com/hashicorp/errwrap"
log "github.com/hashicorp/go-hclog"
"github.com/hashicorp/vault/sdk/helper/consts"
"github.com/hashicorp/vault/sdk/helper/parseutil"
@ -86,7 +85,7 @@ func NewServiceRegistration(conf map[string]string, logger log.Logger, state sr.
if ok && disableReg != "" {
b, err := parseutil.ParseBool(disableReg)
if err != nil {
return nil, errwrap.Wrapf("failed parsing disable_registration parameter: {{err}}", err)
return nil, fmt.Errorf("failed parsing disable_registration parameter: %w", err)
}
disableRegistration = b
}
@ -195,7 +194,7 @@ func NewServiceRegistration(conf map[string]string, logger log.Logger, state sr.
consulConf.HttpClient = &http.Client{Transport: consulConf.Transport}
client, err := api.NewClient(consulConf)
if err != nil {
return nil, errwrap.Wrapf("client setup failed: {{err}}", err)
return nil, fmt.Errorf("client setup failed: %w", err)
}
// Setup the backend
@ -496,11 +495,11 @@ func (c *serviceRegistration) reconcileConsul(registeredServiceID string) (servi
}
if err := agent.ServiceRegister(service); err != nil {
return "", errwrap.Wrapf(`service registration failed: {{err}}`, err)
return "", fmt.Errorf(`service registration failed: %w`, err)
}
if err := agent.CheckRegister(sealedCheck); err != nil {
return serviceID, errwrap.Wrapf(`service check registration failed: {{err}}`, err)
return serviceID, fmt.Errorf(`service check registration failed: %w`, err)
}
return serviceID, nil
@ -544,7 +543,7 @@ func (c *serviceRegistration) setRedirectAddr(addr string) (err error) {
url, err := url.Parse(addr)
if err != nil {
return errwrap.Wrapf(fmt.Sprintf("failed to parse redirect URL %q: {{err}}", addr), err)
return fmt.Errorf("failed to parse redirect URL %q: %w", addr, err)
}
var portStr string
@ -558,12 +557,12 @@ func (c *serviceRegistration) setRedirectAddr(addr string) (err error) {
portStr = "-1"
c.redirectHost = url.Path
} else {
return errwrap.Wrapf(fmt.Sprintf(`failed to find a host:port in redirect address "%v": {{err}}`, url.Host), err)
return fmt.Errorf("failed to find a host:port in redirect address %q: %w", url.Host, err)
}
}
c.redirectPort, err = strconv.ParseInt(portStr, 10, 0)
if err != nil || c.redirectPort < -1 || c.redirectPort > 65535 {
return errwrap.Wrapf(fmt.Sprintf(`failed to parse valid port "%v": {{err}}`, portStr), err)
return fmt.Errorf("failed to parse valid port %q: %w", portStr, err)
}
return nil