Documentation ¶
Overview ¶
Package entities contains internal helper functions to deal with, validate and print the Entity protobuf enum. Mostly to interact with the database.
Index ¶
- Constants
- func EntityTypeFromDB(entity db.Entities) minderv1.Entity
- func EntityTypeToDB(entity minderv1.Entity) db.Entities
- func KnownTypesCSV() string
- type EntityInfoWrapper
- func (eiw *EntityInfoWrapper) AsArtifact() *EntityInfoWrapper
- func (eiw *EntityInfoWrapper) AsEntityInstance(entityType minderv1.Entity)
- func (eiw *EntityInfoWrapper) AsPullRequest()
- func (eiw *EntityInfoWrapper) AsRepository() *EntityInfoWrapper
- func (eiw *EntityInfoWrapper) BuildMessage() (*message.Message, error)
- func (eiw *EntityInfoWrapper) GetID() (uuid.UUID, error)
- func (eiw *EntityInfoWrapper) Publish(evt interfaces.Publisher) error
- func (eiw *EntityInfoWrapper) ToMessage(msg *message.Message) error
- func (eiw *EntityInfoWrapper) WithArtifact(va *minderv1.Artifact) *EntityInfoWrapper
- func (eiw *EntityInfoWrapper) WithEntityInstance(etyp minderv1.Entity, ei *minderv1.EntityInstance) *EntityInfoWrapper
- func (eiw *EntityInfoWrapper) WithExecutionID(id uuid.UUID) *EntityInfoWrapper
- func (eiw *EntityInfoWrapper) WithExecutionIDFromMessage(msg *message.Message) error
- func (eiw *EntityInfoWrapper) WithID(id uuid.UUID) *EntityInfoWrapper
- func (eiw *EntityInfoWrapper) WithProjectID(id uuid.UUID) *EntityInfoWrapper
- func (eiw *EntityInfoWrapper) WithProtoMessage(entType minderv1.Entity, msg protoreflect.ProtoMessage) *EntityInfoWrapper
- func (eiw *EntityInfoWrapper) WithProviderID(providerID uuid.UUID) *EntityInfoWrapper
- func (eiw *EntityInfoWrapper) WithPullRequest(p *pbinternal.PullRequest) *EntityInfoWrapper
- func (eiw *EntityInfoWrapper) WithRepository(r *minderv1.Repository) *EntityInfoWrapper
Constants ¶
const ( // EntityTypeEventKey is the key for the entity type EntityTypeEventKey = "entity_type" // EntityIDEventKey is the key for the entity ID // Note that we'll be migrating to this key // and deprecating the other entity ID keys EntityIDEventKey = "entity_id" // ProviderIDEventKey is the key for the provider ID ProviderIDEventKey = "provider_id" // ProjectIDEventKey is the key for the project ID ProjectIDEventKey = "project_id" // ExecutionIDKey is the key for the execution ID. This is set when acquiring a lock. ExecutionIDKey = "execution_id" )
Variables ¶
This section is empty.
Functions ¶
func EntityTypeFromDB ¶
EntityTypeFromDB returns the entity type from the database entity
func EntityTypeToDB ¶
EntityTypeToDB returns the database entity from the protobuf entity type
func KnownTypesCSV ¶
func KnownTypesCSV() string
KnownTypesCSV returns a comma separated list of known entity types. Useful for UI
Types ¶
type EntityInfoWrapper ¶
type EntityInfoWrapper struct { ProviderID uuid.UUID ProjectID uuid.UUID EntityID uuid.UUID Entity protoreflect.ProtoMessage Type minderv1.Entity OwnershipData map[string]string ExecutionID *uuid.UUID ActionEvent string }
EntityInfoWrapper is a helper struct to gather information about entities from events. It's able to build message.Message structures from the information it gathers.
It's also able to read the message.Message that contains a payload with a protobuf message that's specific to the entity type.
It also assumes the following metadata keys are present:
- EntityTypeEventKey - entity_type - EntityIDEventKey - entity_id
func NewEntityInfoWrapper ¶
func NewEntityInfoWrapper() *EntityInfoWrapper
NewEntityInfoWrapper creates a new EntityInfoWrapper
func ParseEntityEvent ¶
func ParseEntityEvent(msg *message.Message) (*EntityInfoWrapper, error)
ParseEntityEvent parses a message.Message and returns an EntityInfoWrapper
func (*EntityInfoWrapper) AsArtifact ¶
func (eiw *EntityInfoWrapper) AsArtifact() *EntityInfoWrapper
AsArtifact sets the entity type to a versioned artifact
func (*EntityInfoWrapper) AsEntityInstance ¶
func (eiw *EntityInfoWrapper) AsEntityInstance(entityType minderv1.Entity)
AsEntityInstance sets the entity type to an entity instance
func (*EntityInfoWrapper) AsPullRequest ¶
func (eiw *EntityInfoWrapper) AsPullRequest()
AsPullRequest sets the entity type to a pull request
func (*EntityInfoWrapper) AsRepository ¶
func (eiw *EntityInfoWrapper) AsRepository() *EntityInfoWrapper
AsRepository sets the entity type to a repository
func (*EntityInfoWrapper) BuildMessage ¶
func (eiw *EntityInfoWrapper) BuildMessage() (*message.Message, error)
BuildMessage builds a message.Message from the information
func (*EntityInfoWrapper) GetID ¶
func (eiw *EntityInfoWrapper) GetID() (uuid.UUID, error)
GetID returns the entity ID.
func (*EntityInfoWrapper) Publish ¶
func (eiw *EntityInfoWrapper) Publish(evt interfaces.Publisher) error
Publish builds a message.Message and publishes it to the event bus
func (*EntityInfoWrapper) ToMessage ¶
func (eiw *EntityInfoWrapper) ToMessage(msg *message.Message) error
ToMessage sets the information to a message.Message
func (*EntityInfoWrapper) WithArtifact ¶
func (eiw *EntityInfoWrapper) WithArtifact(va *minderv1.Artifact) *EntityInfoWrapper
WithArtifact sets the entity to a versioned artifact sets the entity to a versioned artifact
func (*EntityInfoWrapper) WithEntityInstance ¶
func (eiw *EntityInfoWrapper) WithEntityInstance(etyp minderv1.Entity, ei *minderv1.EntityInstance) *EntityInfoWrapper
WithEntityInstance sets the entity to an entity instance
func (*EntityInfoWrapper) WithExecutionID ¶
func (eiw *EntityInfoWrapper) WithExecutionID(id uuid.UUID) *EntityInfoWrapper
WithExecutionID sets the execution ID
func (*EntityInfoWrapper) WithExecutionIDFromMessage ¶
func (eiw *EntityInfoWrapper) WithExecutionIDFromMessage(msg *message.Message) error
WithExecutionIDFromMessage sets the execution ID from the message
func (*EntityInfoWrapper) WithID ¶
func (eiw *EntityInfoWrapper) WithID(id uuid.UUID) *EntityInfoWrapper
WithID sets the ID for an entity type
func (*EntityInfoWrapper) WithProjectID ¶
func (eiw *EntityInfoWrapper) WithProjectID(id uuid.UUID) *EntityInfoWrapper
WithProjectID sets the project ID
func (*EntityInfoWrapper) WithProtoMessage ¶
func (eiw *EntityInfoWrapper) WithProtoMessage(entType minderv1.Entity, msg protoreflect.ProtoMessage) *EntityInfoWrapper
WithProtoMessage sets the entity to a protobuf message and sets the entity type
func (*EntityInfoWrapper) WithProviderID ¶
func (eiw *EntityInfoWrapper) WithProviderID(providerID uuid.UUID) *EntityInfoWrapper
WithProviderID sets the provider ID
func (*EntityInfoWrapper) WithPullRequest ¶
func (eiw *EntityInfoWrapper) WithPullRequest(p *pbinternal.PullRequest) *EntityInfoWrapper
WithPullRequest sets the entity to a repository
func (*EntityInfoWrapper) WithRepository ¶
func (eiw *EntityInfoWrapper) WithRepository(r *minderv1.Repository) *EntityInfoWrapper
WithRepository sets the entity to a repository