diff options
author | Bo-Yi Wu <appleboy.tw@gmail.com> | 2021-03-15 02:52:12 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-03-14 19:52:12 +0100 |
commit | 167b0f46ef946fad3ca13976c3b87598f505e2ea (patch) | |
tree | 8b6a4a47a2a0149899b3eb49b296677c2dba4d36 /models/ssh_key.go | |
parent | 164e35ead3c1b9b82d4a23644f6fe96652a747eb (diff) | |
download | gitea-167b0f46ef946fad3ca13976c3b87598f505e2ea.tar.gz gitea-167b0f46ef946fad3ca13976c3b87598f505e2ea.zip |
chore(models): rewrite code format. (#14754)
* chore: rewrite format.
* chore: update format
Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com>
* chore: update format
Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com>
* chore: Adjacent parameters with the same type should be grouped together
* chore: update format.
Diffstat (limited to 'models/ssh_key.go')
-rw-r--r-- | models/ssh_key.go | 24 |
1 files changed, 12 insertions, 12 deletions
diff --git a/models/ssh_key.go b/models/ssh_key.go index c4a6df89a1..9f9c33e848 100644 --- a/models/ssh_key.go +++ b/models/ssh_key.go @@ -377,7 +377,7 @@ func appendAuthorizedKeysToFile(keys ...*PublicKey) error { // This of course doesn't guarantee that this is the right directory for authorized_keys // but at least if it's supposed to be this directory and it doesn't exist and we're the // right user it will at least be created properly. - err := os.MkdirAll(setting.SSH.RootPath, 0700) + err := os.MkdirAll(setting.SSH.RootPath, 0o700) if err != nil { log.Error("Unable to MkdirAll(%s): %v", setting.SSH.RootPath, err) return err @@ -385,7 +385,7 @@ func appendAuthorizedKeysToFile(keys ...*PublicKey) error { } fPath := filepath.Join(setting.SSH.RootPath, "authorized_keys") - f, err := os.OpenFile(fPath, os.O_CREATE|os.O_WRONLY|os.O_APPEND, 0600) + f, err := os.OpenFile(fPath, os.O_CREATE|os.O_WRONLY|os.O_APPEND, 0o600) if err != nil { return err } @@ -399,9 +399,9 @@ func appendAuthorizedKeysToFile(keys ...*PublicKey) error { } // .ssh directory should have mode 700, and authorized_keys file should have mode 600. - if fi.Mode().Perm() > 0600 { + if fi.Mode().Perm() > 0o600 { log.Error("authorized_keys file has unusual permission flags: %s - setting to -rw-------", fi.Mode().Perm().String()) - if err = f.Chmod(0600); err != nil { + if err = f.Chmod(0o600); err != nil { return err } } @@ -465,7 +465,7 @@ func calcFingerprintNative(publicKeyContent string) (string, error) { } func calcFingerprint(publicKeyContent string) (string, error) { - //Call the method based on configuration + // Call the method based on configuration var ( fnName, fp string err error @@ -628,7 +628,7 @@ func ListPublicKeys(uid int64, listOptions ListOptions) ([]*PublicKey, error) { } // ListPublicLdapSSHKeys returns a list of synchronized public ldap ssh keys belongs to given user and login source. -func ListPublicLdapSSHKeys(uid int64, loginSourceID int64) ([]*PublicKey, error) { +func ListPublicLdapSSHKeys(uid, loginSourceID int64) ([]*PublicKey, error) { keys := make([]*PublicKey, 0, 5) return keys, x. Where("owner_id = ? AND login_source_id = ?", uid, loginSourceID). @@ -782,7 +782,7 @@ func RewriteAllPublicKeys() error { } func rewriteAllPublicKeys(e Engine) error { - //Don't rewrite key if internal server + // Don't rewrite key if internal server if setting.SSH.StartBuiltinServer || !setting.SSH.CreateAuthorizedKeysFile { return nil } @@ -795,7 +795,7 @@ func rewriteAllPublicKeys(e Engine) error { // This of course doesn't guarantee that this is the right directory for authorized_keys // but at least if it's supposed to be this directory and it doesn't exist and we're the // right user it will at least be created properly. - err := os.MkdirAll(setting.SSH.RootPath, 0700) + err := os.MkdirAll(setting.SSH.RootPath, 0o700) if err != nil { log.Error("Unable to MkdirAll(%s): %v", setting.SSH.RootPath, err) return err @@ -804,7 +804,7 @@ func rewriteAllPublicKeys(e Engine) error { fPath := filepath.Join(setting.SSH.RootPath, "authorized_keys") tmpPath := fPath + ".tmp" - t, err := os.OpenFile(tmpPath, os.O_RDWR|os.O_CREATE|os.O_TRUNC, 0600) + t, err := os.OpenFile(tmpPath, os.O_RDWR|os.O_CREATE|os.O_TRUNC, 0o600) if err != nil { return err } @@ -1147,7 +1147,7 @@ func listDeployKeys(e Engine, repoID int64, listOptions ListOptions) ([]*DeployK } // SearchDeployKeys returns a list of deploy keys matching the provided arguments. -func SearchDeployKeys(repoID int64, keyID int64, fingerprint string) ([]*DeployKey, error) { +func SearchDeployKeys(repoID, keyID int64, fingerprint string) ([]*DeployKey, error) { keys := make([]*DeployKey, 0, 5) cond := builder.NewCond() if repoID != 0 { @@ -1279,7 +1279,7 @@ func rewriteAllPrincipalKeys(e Engine) error { // This of course doesn't guarantee that this is the right directory for authorized_keys // but at least if it's supposed to be this directory and it doesn't exist and we're the // right user it will at least be created properly. - err := os.MkdirAll(setting.SSH.RootPath, 0700) + err := os.MkdirAll(setting.SSH.RootPath, 0o700) if err != nil { log.Error("Unable to MkdirAll(%s): %v", setting.SSH.RootPath, err) return err @@ -1288,7 +1288,7 @@ func rewriteAllPrincipalKeys(e Engine) error { fPath := filepath.Join(setting.SSH.RootPath, authorizedPrincipalsFile) tmpPath := fPath + ".tmp" - t, err := os.OpenFile(tmpPath, os.O_RDWR|os.O_CREATE|os.O_TRUNC, 0600) + t, err := os.OpenFile(tmpPath, os.O_RDWR|os.O_CREATE|os.O_TRUNC, 0o600) if err != nil { return err } |