Documentation
¶
Overview ¶
Package auditpg stores write and administrator audit records in PostgreSQL. Every other adapter records audit rows through it, inside its own business transaction; it is the one adapter that other adapters call directly.
Index ¶
- func RecordAdminMutation(ctx context.Context, q *sqlc.Queries, ...) error
- func RecordDeploymentMutation(ctx context.Context, q *sqlc.Queries, action, resourceType, resourceID string) error
- func RecordWriteAudit(ctx context.Context, q *sqlc.Queries, ...) error
- type Store
- func (s *Store) DeleteExpiredWriteOperations(ctx context.Context, olderThan time.Time, limit int) (int64, error)
- func (s *Store) GetResourceOwners(ctx context.Context, tenantID, resourceType string, resourceIDs []string) ([]writeaudit.ResourceOwner, error)
- func (s *Store) ListAdminAudit(ctx context.Context, filter adminaudit.Filter) (adminaudit.Page, error)
- func (s *Store) ListWriteOperations(ctx context.Context, tenantID string, filter writeaudit.Filter) (writeaudit.Page, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func RecordAdminMutation ¶
func RecordAdminMutation(ctx context.Context, q *sqlc.Queries, tenant, action, resourceType, resourceID string) error
RecordAdminMutation records an administrator mutation in tenant, the Project that the administrator provenance names. Missing or malformed provenance fails with adminaudit.ErrInvalidSource.
func RecordDeploymentMutation ¶
func RecordDeploymentMutation(ctx context.Context, q *sqlc.Queries, action, resourceType, resourceID string) error
RecordDeploymentMutation records a deployment-wide administrator mutation, which has no Project or tenant. Missing or malformed provenance fails with adminaudit.ErrInvalidSource.
func RecordWriteAudit ¶
func RecordWriteAudit(ctx context.Context, q *sqlc.Queries, tenant, action, resourceType, resourceID, parentID string, created ...writeaudit.Resource) error
RecordWriteAudit records a public write in tenant and the resources the write genuinely created. Administrator provenance takes precedence. A write without provenance, such as internal lifecycle work, stays unattributed; malformed provenance fails closed with writeaudit.ErrInvalidSource. A request that already recorded its operation records nothing more.
Types ¶
type Store ¶
type Store struct {
// contains filtered or unexported fields
}
Store reads the audit records and applies write audit retention.
func (*Store) DeleteExpiredWriteOperations ¶
func (s *Store) DeleteExpiredWriteOperations(ctx context.Context, olderThan time.Time, limit int) (int64, error)
DeleteExpiredWriteOperations deletes at most limit operations older than olderThan in one transaction. It never removes an operation referenced by a genuine creation anchor, even after the resource is deleted.
func (*Store) GetResourceOwners ¶
func (s *Store) GetResourceOwners(ctx context.Context, tenantID, resourceType string, resourceIDs []string) ([]writeaudit.ResourceOwner, error)
GetResourceOwners returns each resource's recorded creator in request order. A resource created through a removed administrator copy reports that audit entry instead of a key.
func (*Store) ListAdminAudit ¶
func (s *Store) ListAdminAudit(ctx context.Context, filter adminaudit.Filter) (adminaudit.Page, error)
ListAdminAudit pages committed administrator mutations across the deployment, newest first, with the ID as the tie breaker.
func (*Store) ListWriteOperations ¶
func (s *Store) ListWriteOperations(ctx context.Context, tenantID string, filter writeaudit.Filter) (writeaudit.Page, error)
ListWriteOperations pages a tenant's committed writes, newest first, with the ID as the tie breaker.