0
0
mirror of https://github.com/go-gitea/gitea.git synced 2026-05-14 19:38:04 +02:00

fmt(lint): fixed lint issues

This commit is contained in:
Tom Thornton 2026-05-08 16:59:18 +01:00
parent 86425f5330
commit 68623cb4f6
2 changed files with 14 additions and 12 deletions

View File

@ -13,15 +13,15 @@ import (
func AddGithubAppCredentialTable(ctx context.Context, x *xorm.Engine) error {
type GithubAppCredential struct {
ID int64 `xorm:"pk autoincr"`
OwnerID int64 `xorm:"INDEX NOT NULL"`
Name string `xorm:"NOT NULL"`
AppID int64 `xorm:"NOT NULL"`
InstallationID int64 `xorm:"NOT NULL"`
PrivateKeyEncrypted string `xorm:"TEXT NOT NULL"`
BaseURL string `xorm:"VARCHAR(255) NOT NULL DEFAULT 'https://api.github.com'"`
CreatedUnix timeutil.TimeStamp `xorm:"created"`
UpdatedUnix timeutil.TimeStamp `xorm:"updated"`
ID int64 `xorm:"pk autoincr"`
OwnerID int64 `xorm:"INDEX NOT NULL"`
Name string `xorm:"NOT NULL"`
AppID int64 `xorm:"NOT NULL"`
InstallationID int64 `xorm:"NOT NULL"`
PrivateKeyEncrypted string `xorm:"TEXT NOT NULL"`
BaseURL string `xorm:"VARCHAR(255) NOT NULL DEFAULT 'https://api.github.com'"`
CreatedUnix timeutil.TimeStamp `xorm:"created"`
UpdatedUnix timeutil.TimeStamp `xorm:"updated"`
}
return x.Sync(new(GithubAppCredential))

View File

@ -8,8 +8,10 @@ import (
"crypto/rsa"
"crypto/x509"
"encoding/pem"
"errors"
"fmt"
"net/http"
"strconv"
"strings"
"sync"
"time"
@ -51,7 +53,7 @@ func GenerateGitHubAppJWT(appID int64, privateKeyPEM string) (string, error) {
// Parse the private key
block, _ := pem.Decode([]byte(privateKeyPEM))
if block == nil {
return "", fmt.Errorf("failed to parse PEM block containing the private key")
return "", errors.New("failed to parse PEM block containing the private key")
}
privateKey, err := x509.ParsePKCS1PrivateKey(block.Bytes)
@ -64,7 +66,7 @@ func GenerateGitHubAppJWT(appID int64, privateKeyPEM string) (string, error) {
var ok bool
privateKey, ok = key.(*rsa.PrivateKey)
if !ok {
return "", fmt.Errorf("private key is not RSA")
return "", errors.New("private key is not RSA")
}
}
@ -73,7 +75,7 @@ func GenerateGitHubAppJWT(appID int64, privateKeyPEM string) (string, error) {
claims := jwt.RegisteredClaims{
IssuedAt: jwt.NewNumericDate(now),
ExpiresAt: jwt.NewNumericDate(now.Add(10 * time.Minute)), // GitHub requires max 10 minutes
Issuer: fmt.Sprintf("%d", appID),
Issuer: strconv.FormatInt(appID, 10),
}
// Create token