profiles

package
v0.0.50 Latest Latest
Warning

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

Go to latest
Published: May 20, 2024 License: Apache-2.0 Imports: 24 Imported by: 0

Documentation

Overview

Package profiles contains business logic relating to the Profile entity in Minder

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ComputeRuleName

func ComputeRuleName(rule *minderv1.Profile_Rule) string

ComputeRuleName returns the rule instance's name, or generates a default one

func PopulateRuleNames

func PopulateRuleNames(profile *minderv1.Profile)

PopulateRuleNames fills in the rule name for all rule instances in a profile

Types

type EntityAndRuleTuple

type EntityAndRuleTuple struct {
	Entity minderv1.Entity
	RuleID uuid.UUID
}

EntityAndRuleTuple is a tuple that allows us track rule instantiations and the entity they're associated with

type ProfileService added in v0.0.36

type ProfileService interface {
	// CreateProfile creates the profile in the specified project
	// returns the updated profile structure on successful update
	// subscriptionID should be set to nil when not calling
	CreateProfile(
		ctx context.Context,
		projectID uuid.UUID,
		subscriptionID uuid.UUID,
		profile *minderv1.Profile,
		qtx db.Querier,
	) (*minderv1.Profile, error)

	// UpdateProfile updates the profile in the specified project
	// returns the updated profile structure on successful update
	UpdateProfile(
		ctx context.Context,
		projectID uuid.UUID,
		subscriptionID uuid.UUID,
		profile *minderv1.Profile,
		qtx db.Querier,
	) (*minderv1.Profile, error)

	// PatchProfile updates the profile in the specified project
	// by applying the changes in the provided profile structure
	// as specified by the updateMask
	PatchProfile(
		ctx context.Context,
		projectID uuid.UUID,
		profileID uuid.UUID,
		profile *minderv1.Profile,
		updateMask *fieldmaskpb.FieldMask,
		qtx db.Querier,
	) (*minderv1.Profile, error)
}

ProfileService encapsulates methods for creating and updating profiles TODO: other methods such as deletion and patch should be moved here

func NewProfileService added in v0.0.36

func NewProfileService(publisher events.Publisher) ProfileService

NewProfileService creates an instance of ProfileService

type RuleMapping

RuleMapping is a mapping of rule instance info (name + type) to entity info (rule ID + entity type)

type RuleTypeAndNamePair

type RuleTypeAndNamePair struct {
	RuleType string
	RuleName string
}

RuleTypeAndNamePair is a tuple of a rule instance's name and rule type name

type Validator

type Validator struct{}

Validator encapsulates the logic for validating profiles

func (*Validator) ValidateAndExtractRules

func (v *Validator) ValidateAndExtractRules(
	ctx context.Context,
	qtx db.Querier,
	projectID uuid.UUID,
	profile *minderv1.Profile,
) (RuleMapping, error)

ValidateAndExtractRules validates a profile to ensure it is well-formed it also returns information about the rules in the profile

Directories

Path Synopsis
Package mock_profiles is a generated GoMock package.
Package mock_profiles 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