entities

package
v0.0.51 Latest Latest
Warning

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

Go to latest
Published: May 27, 2024 License: Apache-2.0 Imports: 10 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 (
	// RepositoryEventEntityType is the entity type for repositories
	RepositoryEventEntityType = "repository"
	// VersionedArtifactEventEntityType is the entity type for versioned artifacts
	VersionedArtifactEventEntityType = "versioned_artifact"
	// PullRequestEventEntityType is the entity type for pull requests
	PullRequestEventEntityType = "pull_request"
)
View Source
const (
	// EntityTypeEventKey is the key for the entity type
	EntityTypeEventKey = "entity_type"
	// ProviderIDEventKey is the key for the provider ID
	ProviderIDEventKey = "provider_id"
	// ProjectIDEventKey is the key for the project ID
	ProjectIDEventKey = "project_id"
	// RepositoryIDEventKey is the key for the repository ID
	RepositoryIDEventKey = "repository_id"
	// ArtifactIDEventKey is the key for the artifact ID
	ArtifactIDEventKey = "artifact_id"
	// PullRequestIDEventKey is the key for the pull request ID
	PullRequestIDEventKey = "pull_request_id"
	// ExecutionIDKey is the key for the execution ID. This is set when acquiring a lock.
	ExecutionIDKey = "execution_id"
	// ActionEventKey is the key for the action event
	ActionEventKey = "action_event"
)

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
	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 - ProjectIDEventKey - project_id - RepositoryIDEventKey - repository_id - ArtifactIDEventKey - artifact_id (only for versioned artifacts)

Entity type is used to determine the type of the protobuf message and the entity type in the database. It may be one of the following:

- RepositoryEventEntityType - repository - VersionedArtifactEventEntityType - versioned_artifact

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) 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) GetEntityDBIDs

func (eiw *EntityInfoWrapper) GetEntityDBIDs() (repoID uuid.NullUUID, artifactID uuid.NullUUID, pullRequestID uuid.NullUUID)

GetEntityDBIDs returns the repository, artifact and pull request IDs from the ownership data

func (*EntityInfoWrapper) Publish

func (eiw *EntityInfoWrapper) Publish(evt events.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) WithActionEvent added in v0.0.43

func (eiw *EntityInfoWrapper) WithActionEvent(action string) *EntityInfoWrapper

WithActionEvent sets the webhook action

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) WithArtifactID

func (eiw *EntityInfoWrapper) WithArtifactID(id uuid.UUID) *EntityInfoWrapper

WithArtifactID sets the artifact ID

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) WithProjectID

func (eiw *EntityInfoWrapper) WithProjectID(id uuid.UUID) *EntityInfoWrapper

WithProjectID sets the project ID

func (*EntityInfoWrapper) WithProviderID added in v0.0.47

func (eiw *EntityInfoWrapper) WithProviderID(providerID uuid.UUID) *EntityInfoWrapper

WithProviderID sets the provider ID

func (*EntityInfoWrapper) WithPullRequest

func (eiw *EntityInfoWrapper) WithPullRequest(p *minderv1.PullRequest) *EntityInfoWrapper

WithPullRequest sets the entity to a repository

func (*EntityInfoWrapper) WithPullRequestID

func (eiw *EntityInfoWrapper) WithPullRequestID(id uuid.UUID) *EntityInfoWrapper

WithPullRequestID sets the pull request ID

func (*EntityInfoWrapper) WithRepository

func (eiw *EntityInfoWrapper) WithRepository(r *minderv1.Repository) *EntityInfoWrapper

WithRepository sets the entity to a repository

func (*EntityInfoWrapper) WithRepositoryID

func (eiw *EntityInfoWrapper) WithRepositoryID(id uuid.UUID) *EntityInfoWrapper

WithRepositoryID sets the repository ID

Jump to

Keyboard shortcuts

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