Documentation
¶
Index ¶
Constants ¶
const ActorSystemIdentifier = "system@chainloop.dev"
GetActorIdentifier returns the actor identifier for audit log descriptions. It prioritizes ActorName, then ActorEmail, and finally falls back to system@chainloop.dev.
const AuditEventType = "AUDIT_EVENT"
Variables ¶
This section is empty.
Functions ¶
func GetActorIdentifier ¶ added in v1.41.0
func GetActorIdentifier() string
Types ¶
type ActorType ¶
type ActorType string
ActorType is the type for the actor of a log entry, meaning the user or service that performed the action.
type AuditEventPayload ¶
type AuditLogPublisher ¶
type AuditLogPublisher struct {
// contains filtered or unexported fields
}
func NewAuditLogPublisher ¶
func NewAuditLogPublisher(ctx context.Context, rc *natsconn.ReloadableConnection, logger log.Logger) (*AuditLogPublisher, error)
NewAuditLogPublisher creates a publisher that owns the JetStream stream: it creates or updates it on boot and after every NATS reconnection.
func NewPublishOnlyAuditLogPublisher ¶ added in v1.100.4
func NewPublishOnlyAuditLogPublisher(rc *natsconn.ReloadableConnection, logger log.Logger) (*AuditLogPublisher, error)
NewPublishOnlyAuditLogPublisher creates a publisher that never creates or updates the JetStream stream. Meant for components (e.g. the Artifact CAS) that publish to the stream owned and configured by the control plane, so they can't accidentally override its configuration (e.g. downgrade the replica count).
func (*AuditLogPublisher) Publish ¶
func (p *AuditLogPublisher) Publish(data *EventPayload) error
type DescriptionVariables ¶
type EventPayload ¶
type EventPayload struct {
EventType string // AUDIT_EVENT
Timestamp time.Time
Data *AuditEventPayload
}
func GenerateAuditEvent ¶
func GenerateAuditEvent(entry LogEntry, opts ...GeneratorOption) (*EventPayload, error)
func (*EventPayload) ToJSON ¶
func (e *EventPayload) ToJSON() ([]byte, error)
type GeneratorOption ¶
type GeneratorOption func(*GeneratorOptions) error
func WithActor ¶
func WithActor(actorType ActorType, actorID uuid.UUID, email, name string) GeneratorOption
func WithOrgID ¶
func WithOrgID(orgID uuid.UUID) GeneratorOption
type GeneratorOptions ¶
type LogEntry ¶
type LogEntry interface {
// ActionType returns the type of the action performed.
ActionType() string
// ActionInfo returns the information about the action performed.
ActionInfo() (json.RawMessage, error)
// TargetType returns the type of the target of the action.
TargetType() TargetType
// TargetID returns the ID of the target of the action.
TargetID() *uuid.UUID
// Description returns a templatable string, see the DescriptionVariables struct.
Description() string
RequiresActor() bool
}
LogEntry is the interface for all log entries. All events should implement this interface to be able to be logged.
type TargetType ¶
type TargetType string
TargetType is the type for the target of a log entry, aka the resource acted upon.