From 68623cb4f6632544e9631bc6b386fceb96b3a3a2 Mon Sep 17 00:00:00 2001 From: Tom Thornton Date: Fri, 8 May 2026 16:59:18 +0100 Subject: [PATCH] fmt(lint): fixed lint issues --- models/migrations/v1_27/v332.go | 18 +++++++++--------- modules/auth/github_app.go | 8 +++++--- 2 files changed, 14 insertions(+), 12 deletions(-) diff --git a/models/migrations/v1_27/v332.go b/models/migrations/v1_27/v332.go index 6537e8c588..fd02429fcf 100644 --- a/models/migrations/v1_27/v332.go +++ b/models/migrations/v1_27/v332.go @@ -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)) diff --git a/modules/auth/github_app.go b/modules/auth/github_app.go index b56bddce1f..81aabd9083 100644 --- a/modules/auth/github_app.go +++ b/modules/auth/github_app.go @@ -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