chore: use fmt.Errorf(...) instead of errors.New(fmt.Sprintf(...)) (#542)

Signed-off-by: guoguangwu <guoguangwu@magic-shield.com>
This commit is contained in:
guangwu 2023-07-06 14:17:57 +08:00 committed by GitHub
parent 871a9771a0
commit 09058e2d78
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 3 additions and 4 deletions

View File

@ -2,7 +2,6 @@ package image
import (
"bytes"
"errors"
"fmt"
"path/filepath"
"regexp"
@ -149,7 +148,7 @@ func getRegistryCredential(registryAccount, registrySecret, dockerConfigPath, re
return
}
missingAuthConfigErr := errors.New(fmt.Sprintf("could not find an auth config for registry - %s", registry))
missingAuthConfigErr := fmt.Errorf("could not find an auth config for registry - %s", registry)
if dockerConfigPath != "" {
dAuthConfigs, err := docker.NewAuthConfigurationsFromFile(dockerConfigPath)
if err != nil {

View File

@ -827,7 +827,7 @@ func deserialiseHealtheckInstruction(data string) (string, *docker.HealthConfig,
} else if strings.Index(paramParts[3], `\`) == 0 {
// retries is printed as a C-escape
if len(paramParts[3]) != 2 {
err = errors.New(fmt.Sprintf("expected retries (%s) to be an escape sequence", paramParts[3]))
err = fmt.Errorf("expected retries (%s) to be an escape sequence", paramParts[3])
} else {
escapeCodes := map[byte]int64{
byte('a'): 7,
@ -840,7 +840,7 @@ func deserialiseHealtheckInstruction(data string) (string, *docker.HealthConfig,
}
var ok bool
if retries, ok = escapeCodes[(paramParts[3])[1]]; !ok {
err = errors.New(fmt.Sprintf("got an invalid escape sequence: %s", paramParts[3]))
err = fmt.Errorf("got an invalid escape sequence: %s", paramParts[3])
}
}
} else {