ruletypes

package
v0.0.72 Latest Latest
Warning

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

Go to latest
Published: Nov 5, 2024 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Overview

Package ruletypes contains logic relating to the management of rule types in minder

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrRuleNotFound is returned by the update method if the rule does not
	// already exist
	ErrRuleNotFound = errors.New("rule type not found")
	// ErrRuleAlreadyExists is returned by the create method if the rule
	// already exists
	ErrRuleAlreadyExists = errors.New("rule type already exists")
	// ErrRuleTypeInvalid is returned by both create and update if validation
	// fails
	ErrRuleTypeInvalid = errors.New("rule type validation failed")
)

Functions

func GetDBReleaseStatusFromPBReleasePhase

func GetDBReleaseStatusFromPBReleasePhase(in pb.RuleTypeReleasePhase) (*db.ReleaseStatus, error)

GetDBReleaseStatusFromPBReleasePhase converts a protobuf release phase to a database release status

func GetPBReleasePhaseFromDBReleaseStatus

func GetPBReleasePhaseFromDBReleaseStatus(s *db.ReleaseStatus) (pb.RuleTypeReleasePhase, error)

GetPBReleasePhaseFromDBReleaseStatus converts a database release status to a protobuf release phase

func RuleDefFromDB

func RuleDefFromDB(r *db.RuleType) (*pb.RuleType_Definition, error)

RuleDefFromDB converts a rule type definition from the database to a protobuf rule type definition

func RuleTypePBFromDB

func RuleTypePBFromDB(rt *db.RuleType) (*pb.RuleType, error)

RuleTypePBFromDB converts a rule type from the database to a protobuf rule type

Types

type RuleTypeService

type RuleTypeService interface {
	// CreateRuleType creates rule types in the database
	// the new rule type is validated
	// if the rule type already exists - this will return an error
	// returns the pb definition of the new rule type on success
	CreateRuleType(
		ctx context.Context,
		projectID uuid.UUID,
		subscriptionID uuid.UUID,
		ruleType *pb.RuleType,
		qtx db.Querier,
	) (*pb.RuleType, error)

	// UpdateRuleType updates rule types in the database
	// the new rule type is validated, and backwards compatibility verified
	// if the rule does not already exist - this will return an error
	// returns the pb definition of the updated rule type on success
	UpdateRuleType(
		ctx context.Context,
		projectID uuid.UUID,
		subscriptionID uuid.UUID,
		ruleType *pb.RuleType,
		qtx db.Querier,
	) (*pb.RuleType, error)

	// UpsertRuleType creates the rule type if it does not exist
	// or updates it if it already exists. This is used in the subscription
	// logic.
	UpsertRuleType(
		ctx context.Context,
		projectID uuid.UUID,
		subscriptionID uuid.UUID,
		ruleType *pb.RuleType,
		qtx db.Querier,
	) error
}

RuleTypeService encapsulates the creation and update of rule types TODO: in future, other operations such as delete should be moved here

func NewRuleTypeService

func NewRuleTypeService() RuleTypeService

NewRuleTypeService creates a new instance of RuleTypeService

Directories

Path Synopsis
Package mock_ruletypes is a generated GoMock package.
Package mock_ruletypes is a generated GoMock package.
fixtures
Package fixtures contains code for creating ProfileService fixtures and is used in various parts of the code.
Package fixtures contains code for creating ProfileService fixtures and is used in various parts of the code.

Jump to

Keyboard shortcuts

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