Documentation ¶
Overview ¶
Package cfgmatcher efficiently matches a CL to 0+ ConfigGroupID for a single LUCI project.
Index ¶
- Variables
- type Group
- func (*Group) Descriptor() ([]byte, []int)deprecated
- func (x *Group) GetExclude() string
- func (x *Group) GetFallback() bool
- func (x *Group) GetId() string
- func (x *Group) GetInclude() string
- func (x *Group) GetIndex() int32
- func (g *Group) Match(ref string) bool
- func (*Group) ProtoMessage()
- func (x *Group) ProtoReflect() protoreflect.Message
- func (x *Group) Reset()
- func (x *Group) String() string
- type Groups
- type Matcher
- func Deserialize(buf []byte) (*Matcher, error)
- func LoadMatcher(ctx context.Context, luciProject, configHash string) (*Matcher, error)
- func LoadMatcherFrom(ctx context.Context, meta prjcfg.Meta) (*Matcher, error)
- func LoadMatcherFromConfigGroups(ctx context.Context, configGroups []*prjcfg.ConfigGroup, meta *prjcfg.Meta) *Matcher
- type MatcherState
- func (*MatcherState) Descriptor() ([]byte, []int)deprecated
- func (x *MatcherState) GetConfigGroupNames() []string
- func (x *MatcherState) GetConfigHash() string
- func (x *MatcherState) GetHosts() map[string]*MatcherState_Projects
- func (*MatcherState) ProtoMessage()
- func (x *MatcherState) ProtoReflect() protoreflect.Message
- func (x *MatcherState) Reset()
- func (x *MatcherState) String() string
- type MatcherState_Projects
- func (*MatcherState_Projects) Descriptor() ([]byte, []int)deprecated
- func (x *MatcherState_Projects) GetProjects() map[string]*Groups
- func (*MatcherState_Projects) ProtoMessage()
- func (x *MatcherState_Projects) ProtoReflect() protoreflect.Message
- func (x *MatcherState_Projects) Reset()
- func (x *MatcherState_Projects) String() string
Constants ¶
This section is empty.
Variables ¶
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 ¶
func MakeGroup(g *prjcfg.ConfigGroup, p *cfgpb.ConfigGroup_Gerrit_Project) *Group
MakeGroup returns a new Group based on the Gerrit Project section of a ConfigGroup.
func (*Group) Descriptor
deprecated
func (*Group) GetExclude ¶
func (*Group) GetFallback ¶
func (*Group) GetInclude ¶
func (*Group) ProtoMessage ¶
func (*Group) ProtoMessage()
func (*Group) ProtoReflect ¶
func (x *Group) ProtoReflect() protoreflect.Message
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) Match ¶
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
type Matcher ¶
type Matcher struct {
// contains filtered or unexported fields
}
Matcher effieciently find matching ConfigGroupID for Gerrit CLs.
func Deserialize ¶
func LoadMatcher ¶
LoadMatcher instantiates Matcher from config stored in Datastore.
func LoadMatcherFrom ¶
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 ¶
ConfigHash returns ConfigHash for which Matcher does matching.
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