cfgmatcher

package
v0.0.0-...-45ee728 Latest Latest
Warning

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

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

Documentation

Overview

Package cfgmatcher efficiently matches a CL to 0+ ConfigGroupID for a single LUCI project.

Index

Constants

This section is empty.

Variables

View Source
var File_go_chromium_org_luci_cv_internal_gerrit_cfgmatcher_storage_proto protoreflect.FileDescriptor

Functions

This section is empty.

Types

type Group

type Group struct {

	// ConfigGroupID, as stored in ConfigGroup datastore entity.
	//
	// Used by gobmap.
	Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"`
	// Index of the ConfigGroup names interned in MatcherState.
	//
	// Used by MatcherState.
	Index int32 `protobuf:"varint,3,opt,name=index,proto3" json:"index,omitempty"`
	// If set, this ConfigGroup will be selected if no other ConfigGroup matches
	// refspec. At most 1 group will have this set (this is validated before
	// config is injected).
	Fallback bool `protobuf:"varint,2,opt,name=fallback,proto3" json:"fallback,omitempty"`
	// Regular expression that a CL's target ref must match. Required.
	//
	// It's constructed from `ref_regexp`s of CV config.
	Include string `protobuf:"bytes,13,opt,name=include,proto3" json:"include,omitempty"`
	// Regular expression that a CL's target ref must NOT match. Required.
	//
	// It's constructed from `ref_regexp_exclude`s of CV config.
	Exclude string `protobuf:"bytes,14,opt,name=exclude,proto3" json:"exclude,omitempty"`
	// contains filtered or unexported fields
}

Group represents one config group applied to just 1 Git repository.

For full documentation, see ConfigGroup of api/config/v2/config.proto.

func MakeGroup

MakeGroup returns a new Group based on the Gerrit Project section of a ConfigGroup.

func (*Group) Descriptor deprecated

func (*Group) Descriptor() ([]byte, []int)

Deprecated: Use Group.ProtoReflect.Descriptor instead.

func (*Group) GetExclude

func (x *Group) GetExclude() string

func (*Group) GetFallback

func (x *Group) GetFallback() bool

func (*Group) GetId

func (x *Group) GetId() string

func (*Group) GetInclude

func (x *Group) GetInclude() string

func (*Group) GetIndex

func (x *Group) GetIndex() int32

func (*Group) Match

func (g *Group) Match(ref string) bool

Match returns true iff ref matches given Group.

func (*Group) ProtoMessage

func (*Group) ProtoMessage()

func (*Group) ProtoReflect

func (x *Group) ProtoReflect() protoreflect.Message

func (*Group) Reset

func (x *Group) Reset()

func (*Group) String

func (x *Group) String() string

type Groups

type Groups struct {
	Groups []*Group `protobuf:"bytes,1,rep,name=groups,proto3" json:"groups,omitempty"`
	// contains filtered or unexported fields
}

Groups keeps config groups of a single LUCI project relevant to a specific Git repository (aka Gerrit project).

For now, this message is just a wrapper for a list of groups as they appear in LUCI Project's CV config file. In the future, this can optimized into treap-like structure based on known ref prefix if there are 100+ ref specs for the same repo.

func (*Groups) Descriptor deprecated

func (*Groups) Descriptor() ([]byte, []int)

Deprecated: Use Groups.ProtoReflect.Descriptor instead.

func (*Groups) GetGroups

func (x *Groups) GetGroups() []*Group

func (*Groups) Match

func (gs *Groups) Match(ref string) []*Group

Match returns matching groups, obeying fallback config.

If there are two groups that match, one fallback and one non-fallback, the non-fallback group is the one to use. The fallback group will be used if it's the only group that matches.

func (*Groups) ProtoMessage

func (*Groups) ProtoMessage()

func (*Groups) ProtoReflect

func (x *Groups) ProtoReflect() protoreflect.Message

func (*Groups) Reset

func (x *Groups) Reset()

func (*Groups) String

func (x *Groups) String() string

type Matcher

type Matcher struct {
	// contains filtered or unexported fields
}

Matcher effieciently find matching ConfigGroupID for Gerrit CLs.

func Deserialize

func Deserialize(buf []byte) (*Matcher, error)

func LoadMatcher

func LoadMatcher(ctx context.Context, luciProject, configHash string) (*Matcher, error)

LoadMatcher instantiates Matcher from config stored in Datastore.

func LoadMatcherFrom

func LoadMatcherFrom(ctx context.Context, meta prjcfg.Meta) (*Matcher, error)

LoadMatcherFrom instantiates Matcher from the given config.Meta.

func LoadMatcherFromConfigGroups

func LoadMatcherFromConfigGroups(ctx context.Context, configGroups []*prjcfg.ConfigGroup, meta *prjcfg.Meta) *Matcher

LoadMatcherFromConfigGroups instantiates Matcher.

There must be at least 1 config group, which is true for all valid CV configs.

meta, if not nil, must have been used to load the given ConfigGroups. It's an optimization to re-use memory since most callers typically have it.

func (*Matcher) ConfigHash

func (m *Matcher) ConfigHash() string

ConfigHash returns ConfigHash for which Matcher does matching.

func (*Matcher) Match

func (m *Matcher) Match(host, project, ref string) []prjcfg.ConfigGroupID

Match returns ConfigGroupIDs matched for a given triple.

func (*Matcher) Serialize

func (m *Matcher) Serialize() ([]byte, error)

type MatcherState

type MatcherState struct {
	ConfigHash string `protobuf:"bytes,1,opt,name=config_hash,json=configHash,proto3" json:"config_hash,omitempty"`
	// Interned config group names.
	//
	// Combine with config_hash to obtain config.ConfigGroupID.
	ConfigGroupNames []string `protobuf:"bytes,2,rep,name=config_group_names,json=configGroupNames,proto3" json:"config_group_names,omitempty"`
	// Maps Gerrit hosts to watched projects.
	Hosts map[string]*MatcherState_Projects `` /* 151-byte string literal not displayed */
	// contains filtered or unexported fields
}

MatcherState is serializable state of a matcher for a single LUCI project at specific config hash (version).

func (*MatcherState) Descriptor deprecated

func (*MatcherState) Descriptor() ([]byte, []int)

Deprecated: Use MatcherState.ProtoReflect.Descriptor instead.

func (*MatcherState) GetConfigGroupNames

func (x *MatcherState) GetConfigGroupNames() []string

func (*MatcherState) GetConfigHash

func (x *MatcherState) GetConfigHash() string

func (*MatcherState) GetHosts

func (x *MatcherState) GetHosts() map[string]*MatcherState_Projects

func (*MatcherState) ProtoMessage

func (*MatcherState) ProtoMessage()

func (*MatcherState) ProtoReflect

func (x *MatcherState) ProtoReflect() protoreflect.Message

func (*MatcherState) Reset

func (x *MatcherState) Reset()

func (*MatcherState) String

func (x *MatcherState) String() string

type MatcherState_Projects

type MatcherState_Projects struct {

	// Maps Gerrit project (aka Gerrit repo) to one or more config groups.
	Projects map[string]*Groups `` /* 157-byte string literal not displayed */
	// contains filtered or unexported fields
}

func (*MatcherState_Projects) Descriptor deprecated

func (*MatcherState_Projects) Descriptor() ([]byte, []int)

Deprecated: Use MatcherState_Projects.ProtoReflect.Descriptor instead.

func (*MatcherState_Projects) GetProjects

func (x *MatcherState_Projects) GetProjects() map[string]*Groups

func (*MatcherState_Projects) ProtoMessage

func (*MatcherState_Projects) ProtoMessage()

func (*MatcherState_Projects) ProtoReflect

func (x *MatcherState_Projects) ProtoReflect() protoreflect.Message

func (*MatcherState_Projects) Reset

func (x *MatcherState_Projects) Reset()

func (*MatcherState_Projects) String

func (x *MatcherState_Projects) String() string

Jump to

Keyboard shortcuts

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