(event common.ChangePayload)
| 451 | } |
| 452 | |
| 453 | func (w *Worker) handleCredentialsEvent(event common.ChangePayload) { |
| 454 | credentials, ok := event.Payload.(params.ForgeCredentials) |
| 455 | if !ok { |
| 456 | slog.DebugContext(w.ctx, "invalid payload type for credentials event", "payload", event.Payload) |
| 457 | return |
| 458 | } |
| 459 | switch event.Operation { |
| 460 | case common.CreateOperation, common.UpdateOperation: |
| 461 | switch credentials.ForgeType { |
| 462 | case params.GithubEndpointType: |
| 463 | cache.SetGithubCredentials(credentials) |
| 464 | case params.GiteaEndpointType: |
| 465 | cache.SetGiteaCredentials(credentials) |
| 466 | default: |
| 467 | slog.DebugContext(w.ctx, "invalid credentials type", "credentials_type", credentials.ForgeType) |
| 468 | return |
| 469 | } |
| 470 | entities := cache.GetEntitiesUsingCredentials(credentials) |
| 471 | for _, entity := range entities { |
| 472 | worker, ok := w.toolsWorkes[entity.ID] |
| 473 | if ok { |
| 474 | worker.Reset() |
| 475 | } |
| 476 | } |
| 477 | case common.DeleteOperation: |
| 478 | switch credentials.ForgeType { |
| 479 | case params.GithubEndpointType: |
| 480 | cache.DeleteGithubCredentials(credentials.ID) |
| 481 | case params.GiteaEndpointType: |
| 482 | cache.DeleteGiteaCredentials(credentials.ID) |
| 483 | } |
| 484 | } |
| 485 | } |
| 486 | |
| 487 | func (w *Worker) handleEndpointEvent(event common.ChangePayload) { |
| 488 | endpoint, ok := event.Payload.(params.ForgeEndpoint) |
no test coverage detected