mirror of
https://github.com/woodpecker-ci/woodpecker.git
synced 2025-10-22 13:08:18 +00:00
Refactor pipeline parsing and forge refreshing (#2527)
- refactor pipeline parsing - do not parse the pipeline multiple times to perform filter checks, do this once and perform checks on the result directly - code deduplication - refactor forge token refreshing - move refreshing to a helper func to reduce code --------- Co-authored-by: Anbraten <anton@ju60.de>
This commit is contained in:
@@ -121,22 +121,10 @@ func CreatePipeline(ctx context.Context, store store.Store, f forge.Forge, cron
|
||||
return nil, nil, err
|
||||
}
|
||||
|
||||
// if the forge has a refresh token, the current access token
|
||||
// If the forge has a refresh token, the current access token
|
||||
// may be stale. Therefore, we should refresh prior to dispatching
|
||||
// the pipeline.
|
||||
if refresher, ok := f.(forge.Refresher); ok {
|
||||
refreshed, err := refresher.Refresh(ctx, creator)
|
||||
if err != nil {
|
||||
log.Error().Err(err).Msgf("failed to refresh oauth2 token for creator: %s", creator.Login)
|
||||
} else if refreshed {
|
||||
if err := store.UpdateUser(creator); err != nil {
|
||||
log.Error().Err(err).Msgf("error while updating creator: %s", creator.Login)
|
||||
// move forward
|
||||
} else {
|
||||
log.Debug().Msgf("token refreshed for creator: %s", creator.Login)
|
||||
}
|
||||
}
|
||||
}
|
||||
forge.Refresh(ctx, f, store, creator)
|
||||
|
||||
commit, err := f.BranchHead(ctx, creator, repo, cron.Branch)
|
||||
if err != nil {
|
||||
|
Reference in New Issue
Block a user