entities

package
v0.0.79 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 10, 2024 License: Apache-2.0 Imports: 13 Imported by: 0

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

View Source
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

func EntityTypeFromDB(entity db.Entities) minderv1.Entity

EntityTypeFromDB returns the entity type from the database entity

func EntityTypeToDB

func EntityTypeToDB(entity minderv1.Entity) db.Entities

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

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL