Add Login Manage Functions (#182)

rename Active to Default

manage Default login via CI

use open to edit login config ... for now

Co-authored-by: 6543 <6543@obermui.de>
Reviewed-on: https://gitea.com/gitea/tea/pulls/182
Reviewed-by: Lunny Xiao <xiaolunwen@gmail.com>
Reviewed-by: Norwin <noerw@noreply.gitea.io>
This commit is contained in:
6543
2020-09-23 14:23:27 +00:00
parent 3652f1dcb2
commit eacf1be066
3 changed files with 61 additions and 5 deletions

View File

@@ -30,7 +30,7 @@ type Login struct {
Name string `yaml:"name"`
URL string `yaml:"url"`
Token string `yaml:"token"`
Active bool `yaml:"active"`
Default bool `yaml:"default"`
SSHHost string `yaml:"ssh_host"`
// optional path to the private key
SSHKey string `yaml:"ssh_key"`
@@ -119,12 +119,12 @@ func getOwnerAndRepo(repoPath, user string) (string, string) {
return user, repoPath
}
func getActiveLogin() (*Login, error) {
func getDefaultLogin() (*Login, error) {
if len(config.Logins) == 0 {
return nil, errors.New("No available login")
}
for _, l := range config.Logins {
if l.Active {
if l.Default {
return &l, nil
}
}