MCPcopy Index your code
hub / github.com/coder/coder / either

Function either

coderd/audit/request.go:629–642  ·  view source on GitHub ↗
(old, newVal T, fn func(T) R, auditAction database.AuditAction)

Source from the content-addressed store, hash-verified

627}
628
629func either[T Auditable, R any](old, newVal T, fn func(T) R, auditAction database.AuditAction) R {
630 switch {
631 case ResourceID(newVal) != uuid.Nil:
632 return fn(newVal)
633 case ResourceID(old) != uuid.Nil:
634 return fn(old)
635 case auditAction == database.AuditActionLogin || auditAction == database.AuditActionLogout:
636 // If the request action is a login or logout, we always want to audit it even if
637 // there is no diff. See the comment in audit.InitRequest for more detail.
638 return fn(old)
639 default:
640 panic("both old and new are nil")
641 }
642}

Callers 2

InitRequestFunction · 0.85
BackgroundAuditFunction · 0.85

Calls 1

ResourceIDFunction · 0.85

Tested by

no test coverage detected