From 167c95bb0347fe019f65466df94fac99cd612c9b Mon Sep 17 00:00:00 2001 From: davidvader Date: Tue, 4 Jun 2024 10:28:05 -0500 Subject: [PATCH 1/2] enhance: use repo owner token in schedule processing --- cmd/vela-server/schedule.go | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/cmd/vela-server/schedule.go b/cmd/vela-server/schedule.go index e7e0df759..3709df9a8 100644 --- a/cmd/vela-server/schedule.go +++ b/cmd/vela-server/schedule.go @@ -180,16 +180,10 @@ func processSchedule(ctx context.Context, s *api.Schedule, settings *settings.Pl b.SetRepo(r) b.SetSender(s.GetUpdatedBy()) - // send API call to capture the user for the schedule trigger - u, err := database.GetUserForName(ctx, s.GetUpdatedBy()) - if err != nil { - return fmt.Errorf("unable to get user for name %s: %w", s.GetUpdatedBy(), err) - } - // fetch scm user id - senderID, err := scm.GetUserID(ctx, u.GetName(), u.GetToken()) + senderID, err := scm.GetUserID(ctx, s.GetUpdatedBy(), r.GetOwner().GetToken()) if err != nil { - return fmt.Errorf("unable to get SCM user id for %s: %w", u.GetName(), err) + return fmt.Errorf("unable to get SCM user id for %s: %w", s.GetUpdatedBy(), err) } b.SetSenderSCMID(senderID) From 37d5dfccb01b97cd03a502081ca25956bf7998e0 Mon Sep 17 00:00:00 2001 From: davidvader Date: Tue, 4 Jun 2024 10:33:04 -0500 Subject: [PATCH 2/2] enhance: use repo owner token in restart build --- api/build/restart.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/api/build/restart.go b/api/build/restart.go index a02d368b4..f8798fbb6 100644 --- a/api/build/restart.go +++ b/api/build/restart.go @@ -117,7 +117,7 @@ func RestartBuild(c *gin.Context) { b.SetSender(cl.Subject) // fetch scm user id - senderID, err := scm.GetUserID(ctx, u.GetName(), u.GetToken()) + senderID, err := scm.GetUserID(ctx, u.GetName(), r.GetOwner().GetToken()) if err != nil { retErr := fmt.Errorf("unable to get SCM user id for %s: %w", u.GetName(), err)