Revert wrong change

This commit is contained in:
Lunny Xiao 2024-12-17 23:49:42 -08:00
parent d31fe7c60f
commit 999338848d
No known key found for this signature in database
GPG Key ID: C3B7C91B632F738A
3 changed files with 6 additions and 10 deletions

View File

@ -83,9 +83,9 @@ func runSetActionsRunnerToken(c *cli.Context) error {
setting.MustInstalled() setting.MustInstalled()
scope := c.String("scope") scope := c.String("scope")
putToken := c.String("token") token := c.String("token")
respText, extra := private.SetActionsRunnerToken(ctx, scope, putToken) respText, extra := private.SetActionsRunnerToken(ctx, scope, token)
if extra.HasError() { if extra.HasError() {
return handleCliResponseExtra(extra) return handleCliResponseExtra(extra)
} }

View File

@ -10,8 +10,7 @@ import (
) )
type GenerateTokenRequest struct { type GenerateTokenRequest struct {
Scope string Scope string
PutToken string
} }
// GenerateActionsRunnerToken calls the internal GenerateActionsRunnerToken function // GenerateActionsRunnerToken calls the internal GenerateActionsRunnerToken function

View File

@ -41,12 +41,9 @@ func GenerateActionsRunnerToken(ctx *context.PrivateContext) {
}) })
} }
var token *actions_model.ActionRunnerToken token, err := actions_model.GetLatestRunnerToken(ctx, owner, repo)
if genRequest.PutToken == "" { if errors.Is(err, util.ErrNotExist) || (token != nil && !token.IsActive) {
token, err = actions_model.GetLatestRunnerToken(ctx, owner, repo) token, err = actions_model.NewRunnerToken(ctx, owner, repo, "")
}
if genRequest.PutToken != "" || errors.Is(err, util.ErrNotExist) || (token != nil && !token.IsActive) {
token, err = actions_model.NewRunnerToken(ctx, owner, repo, genRequest.PutToken)
if err != nil { if err != nil {
errMsg := fmt.Sprintf("error while creating runner token: %v", err) errMsg := fmt.Sprintf("error while creating runner token: %v", err)
log.Error("NewRunnerToken failed: %v", errMsg) log.Error("NewRunnerToken failed: %v", errMsg)