Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-pages.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Quirk <tquirk@gitlab.com>2020-11-27 02:16:06 +0300
committerTom Quirk <tquirk@gitlab.com>2020-11-27 02:39:54 +0300
commitbaf188cf6042bf17ee201067bd3adc077246f414 (patch)
treef8400818f4a2484135109959e6a3e8f12d13426f
parent84abda0e2cc2d47078d20abc1dad338402060b90 (diff)
De-capitalise all fm.Errorf messagesstandardize-error-msg-formatting
Conform to the official CodeReviewComments guide, which says: Error strings should not be capitalized (unless beginning with proper nouns or acronyms) or end with punctuation, since they are usually printed following other context. That is, use fmt.Errorf("something bad") not fmt.Errorf("Something bad") Source: https://github.com/golang/go/wiki/CodeReviewComments#error-strings
-rw-r--r--internal/jail/jail.go22
-rw-r--r--internal/jail/mount_linux.go4
-rw-r--r--internal/jail/mount_not_supported.go4
-rw-r--r--internal/source/gitlab/client/client_test.go2
-rw-r--r--internal/tlsconfig/tlsconfig.go6
-rw-r--r--internal/tlsconfig/tlsconfig_test.go8
-rw-r--r--main.go2
7 files changed, 24 insertions, 24 deletions
diff --git a/internal/jail/jail.go b/internal/jail/jail.go
index ec64805b..13b39374 100644
--- a/internal/jail/jail.go
+++ b/internal/jail/jail.go
@@ -80,14 +80,14 @@ func (j *Jail) Build() error {
for _, dir := range j.directories {
if err := os.Mkdir(dir.path, dir.mode); err != nil {
j.removeAll()
- return fmt.Errorf("Can't create directory %q. %s", dir.path, err)
+ return fmt.Errorf("can't create directory %q. %s", dir.path, err)
}
}
for dest, src := range j.files {
if err := handleFile(dest, src); err != nil {
j.removeAll()
- return fmt.Errorf("Can't copy %q -> %q. %s", src.path, dest, err)
+ return fmt.Errorf("can't copy %q -> %q. %s", src.path, dest, err)
}
}
@@ -106,12 +106,12 @@ func (j *Jail) removeAll() error {
// to traverse files and directories
if j.deleteRoot {
if err := os.RemoveAll(j.Path()); err != nil {
- return fmt.Errorf("Can't delete jail %q. %s", j.Path(), err)
+ return fmt.Errorf("can't delete jail %q. %s", j.Path(), err)
}
} else {
for path := range j.files {
if err := os.Remove(path); err != nil {
- return fmt.Errorf("Can't delete file in jail %q: %s", path, err)
+ return fmt.Errorf("can't delete file in jail %q: %s", path, err)
}
}
@@ -119,7 +119,7 @@ func (j *Jail) removeAll() error {
for i := len(j.directories) - 1; i >= 0; i-- {
dest := j.directories[i]
if err := os.Remove(dest.path); err != nil {
- return fmt.Errorf("Can't delete directory in jail %q: %s", dest.path, err)
+ return fmt.Errorf("can't delete directory in jail %q: %s", dest.path, err)
}
}
}
@@ -134,7 +134,7 @@ func (j *Jail) Dispose() error {
}
if err := j.removeAll(); err != nil {
- return fmt.Errorf("Can't delete jail %q. %s", j.Path(), err)
+ return fmt.Errorf("can't delete jail %q. %s", j.Path(), err)
}
return nil
@@ -150,17 +150,17 @@ func (j *Jail) MkDir(path string, perm os.FileMode) {
func (j *Jail) CharDev(path string) error {
fi, err := os.Stat(path)
if err != nil {
- return fmt.Errorf("Can't stat %q: %s", path, err)
+ return fmt.Errorf("can't stat %q: %s", path, err)
}
if (fi.Mode() & os.ModeCharDevice) == 0 {
- return fmt.Errorf("Can't mknod %q: not a character device", path)
+ return fmt.Errorf("can't mknod %q: not a character device", path)
}
// Read the device number from the underlying unix implementation of stat()
sys, ok := fi.Sys().(*syscall.Stat_t)
if !ok {
- return fmt.Errorf("Couldn't determine rdev for %q", path)
+ return fmt.Errorf("couldn't determine rdev for %q", path)
}
jailedDest := j.ExternalPath(path)
@@ -177,11 +177,11 @@ func (j *Jail) CharDev(path string) error {
func (j *Jail) CopyTo(dest, src string) error {
fi, err := os.Stat(src)
if err != nil {
- return fmt.Errorf("Can't stat %q. %s", src, err)
+ return fmt.Errorf("can't stat %q. %s", src, err)
}
if fi.IsDir() {
- return fmt.Errorf("Can't copy directories. %s", src)
+ return fmt.Errorf("can't copy directories. %s", src)
}
jailedDest := j.ExternalPath(dest)
diff --git a/internal/jail/mount_linux.go b/internal/jail/mount_linux.go
index 7b3eb56e..54093c40 100644
--- a/internal/jail/mount_linux.go
+++ b/internal/jail/mount_linux.go
@@ -33,7 +33,7 @@ func (j *Jail) mount() error {
for dest, src := range j.bindMounts {
var opts uintptr = unix.MS_BIND | unix.MS_REC
if err := unix.Mount(src, dest, "none", opts, ""); err != nil {
- return fmt.Errorf("Failed to bind mount %s on %s. %s", src, dest, err)
+ return fmt.Errorf("failed to bind mount %s on %s. %s", src, dest, err)
}
}
@@ -46,7 +46,7 @@ func (j *Jail) unmount() error {
// A second invocation on unmount with MNT_DETACH flag will return EINVAL
// there's no need to abort with an error if bind mountpoint is already unmounted
if err != unix.EINVAL {
- return fmt.Errorf("Failed to unmount %s. %s", dest, err)
+ return fmt.Errorf("failed to unmount %s. %s", dest, err)
}
}
}
diff --git a/internal/jail/mount_not_supported.go b/internal/jail/mount_not_supported.go
index 0ab0f5f0..b4d3e348 100644
--- a/internal/jail/mount_not_supported.go
+++ b/internal/jail/mount_not_supported.go
@@ -8,12 +8,12 @@ import (
)
func (j *Jail) Unshare() error {
- return fmt.Errorf("Unshare not supported on %s", runtime.GOOS)
+ return fmt.Errorf("unshare not supported on %s", runtime.GOOS)
}
func (j *Jail) notSupported() error {
if len(j.bindMounts) > 0 {
- return fmt.Errorf("Bind mount not supported on %s", runtime.GOOS)
+ return fmt.Errorf("bind mount not supported on %s", runtime.GOOS)
}
return nil
diff --git a/internal/source/gitlab/client/client_test.go b/internal/source/gitlab/client/client_test.go
index c888a059..6d4ce814 100644
--- a/internal/source/gitlab/client/client_test.go
+++ b/internal/source/gitlab/client/client_test.go
@@ -319,7 +319,7 @@ func validateToken(t *testing.T, tokenString string) {
t.Helper()
token, err := jwt.Parse(tokenString, func(token *jwt.Token) (interface{}, error) {
if _, ok := token.Method.(*jwt.SigningMethodHMAC); !ok {
- return nil, fmt.Errorf("Unexpected signing method: %v", token.Header["alg"])
+ return nil, fmt.Errorf("unexpected signing method: %v", token.Header["alg"])
}
return secretKey(t), nil
diff --git a/internal/tlsconfig/tlsconfig.go b/internal/tlsconfig/tlsconfig.go
index 5d26ed52..9babf374 100644
--- a/internal/tlsconfig/tlsconfig.go
+++ b/internal/tlsconfig/tlsconfig.go
@@ -73,13 +73,13 @@ func ValidateTLSVersions(min, max string) error {
tlsMax, tlsMaxOk := AllTLSVersions[max]
if !tlsMinOk {
- return fmt.Errorf("Invalid minimum TLS version: %s", min)
+ return fmt.Errorf("invalid minimum TLS version: %s", min)
}
if !tlsMaxOk {
- return fmt.Errorf("Invalid maximum TLS version: %s", max)
+ return fmt.Errorf("invalid maximum TLS version: %s", max)
}
if tlsMin > tlsMax && tlsMax > 0 {
- return fmt.Errorf("Invalid maximum TLS version: %s; Should be at least %s", max, min)
+ return fmt.Errorf("invalid maximum TLS version: %s; should be at least %s", max, min)
}
return nil
diff --git a/internal/tlsconfig/tlsconfig_test.go b/internal/tlsconfig/tlsconfig_test.go
index e37ab51b..00a08066 100644
--- a/internal/tlsconfig/tlsconfig_test.go
+++ b/internal/tlsconfig/tlsconfig_test.go
@@ -35,9 +35,9 @@ func TestValidateTLSVersions(t *testing.T) {
tlsMax string
err string
}{
- "invalid minimum TLS version": {tlsMin: "tls123", tlsMax: "", err: "Invalid minimum TLS version: tls123"},
- "invalid maximum TLS version": {tlsMin: "", tlsMax: "tls123", err: "Invalid maximum TLS version: tls123"},
- "TLS versions conflict": {tlsMin: "tls1.2", tlsMax: "tls1.1", err: "Invalid maximum TLS version: tls1.1; Should be at least tls1.2"},
+ "invalid minimum TLS version": {tlsMin: "tls123", tlsMax: "", err: "invalid minimum TLS version: tls123"},
+ "invalid maximum TLS version": {tlsMin: "", tlsMax: "tls123", err: "invalid maximum TLS version: tls123"},
+ "TLS versions conflict": {tlsMin: "tls1.2", tlsMax: "tls1.1", err: "invalid maximum TLS version: tls1.1; should be at least tls1.2"},
}
for name, tc := range tests {
@@ -53,7 +53,7 @@ func TestInvalidKeyPair(t *testing.T) {
require.EqualError(t, err, "tls: failed to find any PEM data in certificate input")
}
-func TestInsecureCihers(t *testing.T) {
+func TestInsecureCiphers(t *testing.T) {
tlsConfig, err := Create(cert, key, getCertificate, true, tls.VersionTLS11, tls.VersionTLS12)
require.NoError(t, err)
require.False(t, tlsConfig.PreferServerCipherSuites)
diff --git a/main.go b/main.go
index 7defd281..95805b25 100644
--- a/main.go
+++ b/main.go
@@ -155,7 +155,7 @@ func setGitLabAPISecretKey(secretFile string, config *appConfig) {
}
if secretLength != 32 {
- log.WithError(fmt.Errorf("Expected 32 bytes GitLab API secret but got %d bytes", secretLength)).Fatal("Failed to decode GitLab API secret")
+ log.WithError(fmt.Errorf("expected 32 bytes GitLab API secret but got %d bytes", secretLength)).Fatal("Failed to decode GitLab API secret")
}
config.GitLabAPISecretKey = decoded