summaryrefslogtreecommitdiffstats
path: root/cmd
diff options
context:
space:
mode:
Diffstat (limited to 'cmd')
-rw-r--r--cmd/admin.go10
-rw-r--r--cmd/admin_auth_ldap_test.go17
-rw-r--r--cmd/cert.go2
-rw-r--r--cmd/doctor.go1
-rw-r--r--cmd/dump.go2
-rw-r--r--cmd/dump_repo.go2
-rw-r--r--cmd/embedded.go13
-rw-r--r--cmd/manager.go3
-rw-r--r--cmd/serv.go2
-rw-r--r--cmd/web.go3
-rw-r--r--cmd/web_letsencrypt.go3
11 files changed, 26 insertions, 32 deletions
diff --git a/cmd/admin.go b/cmd/admin.go
index 3042df8bb7..66c7959ab3 100644
--- a/cmd/admin.go
+++ b/cmd/admin.go
@@ -525,7 +525,7 @@ func runCreateUser(c *cli.Context) error {
}
// always default to true
- var changePassword = true
+ changePassword := true
// If this is the first user being created.
// Take it as the admin and don't force a password update.
@@ -577,7 +577,6 @@ func runListUsers(c *cli.Context) error {
}
users, err := user_model.GetAllUsers()
-
if err != nil {
return err
}
@@ -601,7 +600,6 @@ func runListUsers(c *cli.Context) error {
w.Flush()
return nil
-
}
func runDeleteUser(c *cli.Context) error {
@@ -826,7 +824,6 @@ func runUpdateOauth(c *cli.Context) error {
if c.IsSet("required-claim-name") {
oAuth2Config.RequiredClaimName = c.String("required-claim-name")
-
}
if c.IsSet("required-claim-value") {
oAuth2Config.RequiredClaimValue = c.String("required-claim-value")
@@ -843,7 +840,7 @@ func runUpdateOauth(c *cli.Context) error {
}
// update custom URL mapping
- var customURLMapping = &oauth2.CustomURLMapping{}
+ customURLMapping := &oauth2.CustomURLMapping{}
if oAuth2Config.CustomURLMapping != nil {
customURLMapping.TokenURL = oAuth2Config.CustomURLMapping.TokenURL
@@ -926,7 +923,7 @@ func runAddSMTP(c *cli.Context) error {
if !c.IsSet("port") {
return errors.New("port must be set")
}
- var active = true
+ active := true
if c.IsSet("active") {
active = c.BoolT("active")
}
@@ -994,7 +991,6 @@ func runListAuth(c *cli.Context) error {
}
authSources, err := auth.Sources()
-
if err != nil {
return err
}
diff --git a/cmd/admin_auth_ldap_test.go b/cmd/admin_auth_ldap_test.go
index e1cd1c3244..f050b536fd 100644
--- a/cmd/admin_auth_ldap_test.go
+++ b/cmd/admin_auth_ldap_test.go
@@ -17,12 +17,12 @@ import (
func TestAddLdapBindDn(t *testing.T) {
// Mock cli functions to do not exit on error
- var osExiter = cli.OsExiter
+ osExiter := cli.OsExiter
defer func() { cli.OsExiter = osExiter }()
cli.OsExiter = func(code int) {}
// Test cases
- var cases = []struct {
+ cases := []struct {
args []string
source *auth.Source
errMsg string
@@ -243,12 +243,12 @@ func TestAddLdapBindDn(t *testing.T) {
func TestAddLdapSimpleAuth(t *testing.T) {
// Mock cli functions to do not exit on error
- var osExiter = cli.OsExiter
+ osExiter := cli.OsExiter
defer func() { cli.OsExiter = osExiter }()
cli.OsExiter = func(code int) {}
// Test cases
- var cases = []struct {
+ cases := []struct {
args []string
authSource *auth.Source
errMsg string
@@ -474,12 +474,12 @@ func TestAddLdapSimpleAuth(t *testing.T) {
func TestUpdateLdapBindDn(t *testing.T) {
// Mock cli functions to do not exit on error
- var osExiter = cli.OsExiter
+ osExiter := cli.OsExiter
defer func() { cli.OsExiter = osExiter }()
cli.OsExiter = func(code int) {}
// Test cases
- var cases = []struct {
+ cases := []struct {
args []string
id int64
existingAuthSource *auth.Source
@@ -907,12 +907,12 @@ func TestUpdateLdapBindDn(t *testing.T) {
func TestUpdateLdapSimpleAuth(t *testing.T) {
// Mock cli functions to do not exit on error
- var osExiter = cli.OsExiter
+ osExiter := cli.OsExiter
defer func() { cli.OsExiter = osExiter }()
cli.OsExiter = func(code int) {}
// Test cases
- var cases = []struct {
+ cases := []struct {
args []string
id int64
existingAuthSource *auth.Source
@@ -1161,7 +1161,6 @@ func TestUpdateLdapSimpleAuth(t *testing.T) {
authSource: &auth.Source{
Type: auth.DLDAP,
Cfg: &ldap.Source{
-
AttributeMail: "mail",
},
},
diff --git a/cmd/cert.go b/cmd/cert.go
index b62319f808..162c4171bf 100644
--- a/cmd/cert.go
+++ b/cmd/cert.go
@@ -180,7 +180,7 @@ func runCert(c *cli.Context) error {
}
log.Println("Written cert.pem")
- keyOut, err := os.OpenFile("key.pem", os.O_WRONLY|os.O_CREATE|os.O_TRUNC, 0600)
+ keyOut, err := os.OpenFile("key.pem", os.O_WRONLY|os.O_CREATE|os.O_TRUNC, 0o600)
if err != nil {
log.Fatalf("Failed to open key.pem for writing: %v", err)
}
diff --git a/cmd/doctor.go b/cmd/doctor.go
index 35cc305f4c..10f62f32c1 100644
--- a/cmd/doctor.go
+++ b/cmd/doctor.go
@@ -121,7 +121,6 @@ func runRecreateTable(ctx *cli.Context) error {
}
return recreateTables(x)
})
-
}
func runDoctor(ctx *cli.Context) error {
diff --git a/cmd/dump.go b/cmd/dump.go
index d6a5230060..4180425598 100644
--- a/cmd/dump.go
+++ b/cmd/dump.go
@@ -370,7 +370,7 @@ func runDump(ctx *cli.Context) error {
fatal("Failed to save %s: %v", fileName, err)
}
- if err := os.Chmod(fileName, 0600); err != nil {
+ if err := os.Chmod(fileName, 0o600); err != nil {
log.Info("Can't change file access permissions mask to 0600: %v", err)
}
}
diff --git a/cmd/dump_repo.go b/cmd/dump_repo.go
index 1a9344dbe1..e980af3011 100644
--- a/cmd/dump_repo.go
+++ b/cmd/dump_repo.go
@@ -107,7 +107,7 @@ func runDumpRepository(ctx *cli.Context) error {
}
serviceType = convert.ToGitServiceType(serviceStr)
- var opts = base.MigrateOptions{
+ opts := base.MigrateOptions{
GitServiceType: serviceType,
CloneAddr: cloneAddr,
AuthUsername: ctx.String("auth_username"),
diff --git a/cmd/embedded.go b/cmd/embedded.go
index c608667bf8..2930e5d307 100644
--- a/cmd/embedded.go
+++ b/cmd/embedded.go
@@ -109,7 +109,6 @@ type asset struct {
}
func initEmbeddedExtractor(c *cli.Context) error {
-
// Silence the console logger
log.DelNamedLogger("console")
log.DelNamedLogger(log.DEFAULT)
@@ -260,7 +259,7 @@ func extractAsset(d string, a asset, overwrite, rename bool) error {
return fmt.Errorf("%s: %v", dir, err)
}
- perms := os.ModePerm & 0666
+ perms := os.ModePerm & 0o666
fi, err := os.Lstat(dest)
if err != nil {
@@ -296,7 +295,7 @@ func extractAsset(d string, a asset, overwrite, rename bool) error {
}
func buildAssetList(sec *section, globs []glob.Glob, c *cli.Context) []asset {
- var results = make([]asset, 0, 64)
+ results := make([]asset, 0, 64)
for _, name := range sec.Names() {
if isdir, err := sec.IsDir(name); !isdir && err == nil {
if sec.Path == "public" &&
@@ -307,9 +306,11 @@ func buildAssetList(sec *section, globs []glob.Glob, c *cli.Context) []asset {
matchName := sec.Path + "/" + name
for _, g := range globs {
if g.Match(matchName) {
- results = append(results, asset{Section: sec,
- Name: name,
- Path: sec.Path + "/" + name})
+ results = append(results, asset{
+ Section: sec,
+ Name: name,
+ Path: sec.Path + "/" + name,
+ })
break
}
}
diff --git a/cmd/manager.go b/cmd/manager.go
index 99d283b441..50b66cc7f2 100644
--- a/cmd/manager.go
+++ b/cmd/manager.go
@@ -58,7 +58,8 @@ var (
Name: "timeout",
Value: 60 * time.Second,
Usage: "Timeout for the flushing process",
- }, cli.BoolFlag{
+ },
+ cli.BoolFlag{
Name: "non-blocking",
Usage: "Set to true to not wait for flush to complete before returning",
},
diff --git a/cmd/serv.go b/cmd/serv.go
index ab60358b53..e42213cb98 100644
--- a/cmd/serv.go
+++ b/cmd/serv.go
@@ -247,7 +247,7 @@ func runServ(c *cli.Context) error {
os.Setenv(models.EnvKeyID, fmt.Sprintf("%d", results.KeyID))
os.Setenv(models.EnvAppURL, setting.AppURL)
- //LFS token authentication
+ // LFS token authentication
if verb == lfsAuthenticateVerb {
url := fmt.Sprintf("%s%s/%s.git/info/lfs", setting.AppURL, url.PathEscape(results.OwnerName), url.PathEscape(results.RepoName))
diff --git a/cmd/web.go b/cmd/web.go
index ec92ef242a..9a8d9dfa73 100644
--- a/cmd/web.go
+++ b/cmd/web.go
@@ -71,8 +71,7 @@ func runHTTPRedirector() {
http.Redirect(w, r, target, http.StatusTemporaryRedirect)
})
- var err = runHTTP("tcp", source, "HTTP Redirector", handler)
-
+ err := runHTTP("tcp", source, "HTTP Redirector", handler)
if err != nil {
log.Fatal("Failed to start port redirection: %v", err)
}
diff --git a/cmd/web_letsencrypt.go b/cmd/web_letsencrypt.go
index 866b88f7c9..517d71f017 100644
--- a/cmd/web_letsencrypt.go
+++ b/cmd/web_letsencrypt.go
@@ -17,7 +17,6 @@ import (
)
func runLetsEncrypt(listenAddr, domain, directory, email string, m http.Handler) error {
-
// If HTTP Challenge enabled, needs to be serving on port 80. For TLSALPN needs 443.
// Due to docker port mapping this can't be checked programmatically
// TODO: these are placeholders until we add options for each in settings with appropriate warning
@@ -77,7 +76,7 @@ func runLetsEncrypt(listenAddr, domain, directory, email string, m http.Handler)
go func() {
log.Info("Running Let's Encrypt handler on %s", setting.HTTPAddr+":"+setting.PortToRedirect)
// all traffic coming into HTTP will be redirect to HTTPS automatically (LE HTTP-01 validation happens here)
- var err = runHTTP("tcp", setting.HTTPAddr+":"+setting.PortToRedirect, "Let's Encrypt HTTP Challenge", myACME.HTTPChallengeHandler(http.HandlerFunc(runLetsEncryptFallbackHandler)))
+ err := runHTTP("tcp", setting.HTTPAddr+":"+setting.PortToRedirect, "Let's Encrypt HTTP Challenge", myACME.HTTPChallengeHandler(http.HandlerFunc(runLetsEncryptFallbackHandler)))
if err != nil {
log.Fatal("Failed to start the Let's Encrypt handler on port %s: %v", setting.PortToRedirect, err)
}