MCPcopy Create free account
hub / github.com/cloudbase/garm / handleCredentialsEvent

Method handleCredentialsEvent

workers/cache/cache.go:453–485  ·  view source on GitHub ↗
(event common.ChangePayload)

Source from the content-addressed store, hash-verified

451}
452
453func (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
487func (w *Worker) handleEndpointEvent(event common.ChangePayload) {
488 endpoint, ok := event.Payload.(params.ForgeEndpoint)

Callers 1

handleEventMethod · 0.95

Calls 6

SetGithubCredentialsFunction · 0.92
SetGiteaCredentialsFunction · 0.92
DeleteGithubCredentialsFunction · 0.92
DeleteGiteaCredentialsFunction · 0.92
ResetMethod · 0.65

Tested by

no test coverage detected