config

package
v0.0.0-...-f2f7d99 Latest Latest
Warning

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

Go to latest
Published: Feb 25, 2025 License: BSD-3-Clause Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var File_go_chromium_org_infra_appengine_rubber_stamper_config_config_proto protoreflect.FileDescriptor

Functions

func SetTestConfig

func SetTestConfig(ctx context.Context, cfg *Config) error

SetTestConfig set test configs in the cachedCfg.

func Update

func Update(c context.Context) error

Update fetches the config and puts it into the datastore.

Types

type BenignFilePattern

type BenignFilePattern struct {

	// Paths contains the information that which files are allowed and which are
	// not. The paths is parsed as lines in a .gitignore document, and therefore
	// should follows rules listed in https://git-scm.com/docs/gitignore.
	Paths []string `protobuf:"bytes,2,rep,name=paths,proto3" json:"paths,omitempty"`
	// contains filtered or unexported fields
}

BenignFilePattern describes pattern of changes to benign files.

func (*BenignFilePattern) Descriptor deprecated

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

Deprecated: Use BenignFilePattern.ProtoReflect.Descriptor instead.

func (*BenignFilePattern) GetPaths

func (x *BenignFilePattern) GetPaths() []string

func (*BenignFilePattern) ProtoMessage

func (*BenignFilePattern) ProtoMessage()

func (*BenignFilePattern) ProtoReflect

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

func (*BenignFilePattern) Reset

func (x *BenignFilePattern) Reset()

func (*BenignFilePattern) String

func (x *BenignFilePattern) String() string

type CleanCherryPickPattern

type CleanCherryPickPattern struct {

	// The length of time in <int><unit> form. Has the same format as the
	// `time_window` in CleanRevertPattern.
	TimeWindow string `protobuf:"bytes,1,opt,name=time_window,json=timeWindow,proto3" json:"time_window,omitempty"`
	// Paths that must have a human reviewer.
	ExcludedPaths       []string                                    `protobuf:"bytes,2,rep,name=excluded_paths,json=excludedPaths,proto3" json:"excluded_paths,omitempty"`
	FileCheckBypassRule *CleanCherryPickPattern_FileCheckBypassRule `protobuf:"bytes,3,opt,name=file_check_bypass_rule,json=fileCheckBypassRule,proto3" json:"file_check_bypass_rule,omitempty"`
	// contains filtered or unexported fields
}

func (*CleanCherryPickPattern) Descriptor deprecated

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

Deprecated: Use CleanCherryPickPattern.ProtoReflect.Descriptor instead.

func (*CleanCherryPickPattern) GetExcludedPaths

func (x *CleanCherryPickPattern) GetExcludedPaths() []string

func (*CleanCherryPickPattern) GetFileCheckBypassRule

func (*CleanCherryPickPattern) GetTimeWindow

func (x *CleanCherryPickPattern) GetTimeWindow() string

func (*CleanCherryPickPattern) ProtoMessage

func (*CleanCherryPickPattern) ProtoMessage()

func (*CleanCherryPickPattern) ProtoReflect

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

func (*CleanCherryPickPattern) Reset

func (x *CleanCherryPickPattern) Reset()

func (*CleanCherryPickPattern) String

func (x *CleanCherryPickPattern) String() string

type CleanCherryPickPattern_FileCheckBypassRule

type CleanCherryPickPattern_FileCheckBypassRule struct {

	// The allowed paths of files that change between the initial revision and
	// the current revision.
	IncludedPaths []string `protobuf:"bytes,1,rep,name=included_paths,json=includedPaths,proto3" json:"included_paths,omitempty"`
	// Hashtag of the CL.
	Hashtag string `protobuf:"bytes,2,opt,name=hashtag,proto3" json:"hashtag,omitempty"`
	// Allowed CL owners. The CL owner needs to be one of them.
	AllowedOwners []string `protobuf:"bytes,3,rep,name=allowed_owners,json=allowedOwners,proto3" json:"allowed_owners,omitempty"`
	// contains filtered or unexported fields
}

FileCheckBypassRule provides a way to bypass the rule: "the current revision shouldn't make any file changes compared with the initial revision". It is a list of requirements, all of which must be met for Rubber-Stamper to bypass the file change rule.

func (*CleanCherryPickPattern_FileCheckBypassRule) Descriptor deprecated

Deprecated: Use CleanCherryPickPattern_FileCheckBypassRule.ProtoReflect.Descriptor instead.

func (*CleanCherryPickPattern_FileCheckBypassRule) GetAllowedOwners

func (x *CleanCherryPickPattern_FileCheckBypassRule) GetAllowedOwners() []string

func (*CleanCherryPickPattern_FileCheckBypassRule) GetHashtag

func (*CleanCherryPickPattern_FileCheckBypassRule) GetIncludedPaths

func (x *CleanCherryPickPattern_FileCheckBypassRule) GetIncludedPaths() []string

func (*CleanCherryPickPattern_FileCheckBypassRule) ProtoMessage

func (*CleanCherryPickPattern_FileCheckBypassRule) ProtoReflect

func (*CleanCherryPickPattern_FileCheckBypassRule) Reset

func (*CleanCherryPickPattern_FileCheckBypassRule) String

type CleanRevertPattern

type CleanRevertPattern struct {

	// The length of time in <int><unit> form. Reverts need to be within this
	// time_window to be valid.
	// Valid units are "s", "m", "h", "d", meaning "seconds", "minutes",
	// "hours", "days" respectively.
	TimeWindow string `protobuf:"bytes,1,opt,name=time_window,json=timeWindow,proto3" json:"time_window,omitempty"`
	// Paths that must have a human reviewer.
	ExcludedPaths []string `protobuf:"bytes,2,rep,name=excluded_paths,json=excludedPaths,proto3" json:"excluded_paths,omitempty"`
	// contains filtered or unexported fields
}

CleanRevertPattern describes pattern of clean reverts.

func (*CleanRevertPattern) Descriptor deprecated

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

Deprecated: Use CleanRevertPattern.ProtoReflect.Descriptor instead.

func (*CleanRevertPattern) GetExcludedPaths

func (x *CleanRevertPattern) GetExcludedPaths() []string

func (*CleanRevertPattern) GetTimeWindow

func (x *CleanRevertPattern) GetTimeWindow() string

func (*CleanRevertPattern) ProtoMessage

func (*CleanRevertPattern) ProtoMessage()

func (*CleanRevertPattern) ProtoReflect

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

func (*CleanRevertPattern) Reset

func (x *CleanRevertPattern) Reset()

func (*CleanRevertPattern) String

func (x *CleanRevertPattern) String() string

type Config

type Config struct {

	// A map stores configs for all the Gerrit hosts, where keys are names of
	// hosts (e.g. "chromium" or "chrome-internal"), values are corresponding
	// configs.
	HostConfigs map[string]*HostConfig `` /* 168-byte string literal not displayed */
	// A global default time window for clean reverts and cherry picks. The
	// format is the same as that of CleanRevertPattern.time_window.
	DefaultTimeWindow string `protobuf:"bytes,2,opt,name=default_time_window,json=defaultTimeWindow,proto3" json:"default_time_window,omitempty"`
	// contains filtered or unexported fields
}

Config is the service-wide configuration data for rubber-stamper.

func Get

func Get(c context.Context) (*Config, error)

Get returns the config stored in the cachedCfg.

func (*Config) Descriptor deprecated

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

Deprecated: Use Config.ProtoReflect.Descriptor instead.

func (*Config) GetDefaultTimeWindow

func (x *Config) GetDefaultTimeWindow() string

func (*Config) GetHostConfigs

func (x *Config) GetHostConfigs() map[string]*HostConfig

func (*Config) ProtoMessage

func (*Config) ProtoMessage()

func (*Config) ProtoReflect

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

func (*Config) Reset

func (x *Config) Reset()

func (*Config) String

func (x *Config) String() string

type HostConfig

type HostConfig struct {

	// A map stores config for repositories, where keys are names of repos (e.g.
	// "chromium/src", "go.chromium.org/infra/infra") and values are corresponding configs.
	RepoConfigs map[string]*RepoConfig `` /* 168-byte string literal not displayed */
	// The default valid time window for clean reverts. This time window is
	// applied at a host-level and the time window configured in repo-level
	// configs will override this one. The format is the same as that of
	// CleanRevertPattern.time_window.
	CleanRevertTimeWindow string `` /* 128-byte string literal not displayed */
	// The default valid time window for clean cherry-picks. This time window is
	// applied at a host-level and the time window configured in repo-level
	// configs will override this one. The format is the same as that of
	// CleanCherryPickPattern.time_window.
	CleanCherryPickTimeWindow string `` /* 142-byte string literal not displayed */
	// An array stores configs for repositories whose names are contained in
	// regular expressions.
	RepoRegexpConfigs []*HostConfig_RepoRegexpConfigPair `protobuf:"bytes,4,rep,name=repo_regexp_configs,json=repoRegexpConfigs,proto3" json:"repo_regexp_configs,omitempty"`
	// contains filtered or unexported fields
}

HostConfig describes the config to be used for a Gerrit host.

func (*HostConfig) Descriptor deprecated

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

Deprecated: Use HostConfig.ProtoReflect.Descriptor instead.

func (*HostConfig) GetCleanCherryPickTimeWindow

func (x *HostConfig) GetCleanCherryPickTimeWindow() string

func (*HostConfig) GetCleanRevertTimeWindow

func (x *HostConfig) GetCleanRevertTimeWindow() string

func (*HostConfig) GetRepoConfigs

func (x *HostConfig) GetRepoConfigs() map[string]*RepoConfig

func (*HostConfig) GetRepoRegexpConfigs

func (x *HostConfig) GetRepoRegexpConfigs() []*HostConfig_RepoRegexpConfigPair

func (*HostConfig) ProtoMessage

func (*HostConfig) ProtoMessage()

func (*HostConfig) ProtoReflect

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

func (*HostConfig) Reset

func (x *HostConfig) Reset()

func (*HostConfig) String

func (x *HostConfig) String() string

type HostConfig_RepoRegexpConfigPair

type HostConfig_RepoRegexpConfigPair struct {

	// The key is a regular expression of repository names.
	Key string `protobuf:"bytes,1,opt,name=key,proto3" json:"key,omitempty"`
	// The value is the corresponding RepoConfig that should be applied to
	// those repos.
	Value *RepoConfig `protobuf:"bytes,2,opt,name=value,proto3" json:"value,omitempty"`
	// contains filtered or unexported fields
}

RepoRegexpConfigPair is a pair of repository name's regular expression and the corresponding RepoConfig. It makes maintenance work easier, as there are repositories which have some sort of naming pattern that should share the same RepoConfig.

When a repository can be matched by both the exact match and regular expression, Rubber Stamper will use the result from the exact match.

When there are multiple regular expression matches, the first match, which is decided by their locations in the config, will be selected.

func (*HostConfig_RepoRegexpConfigPair) Descriptor deprecated

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

Deprecated: Use HostConfig_RepoRegexpConfigPair.ProtoReflect.Descriptor instead.

func (*HostConfig_RepoRegexpConfigPair) GetKey

func (*HostConfig_RepoRegexpConfigPair) GetValue

func (*HostConfig_RepoRegexpConfigPair) ProtoMessage

func (*HostConfig_RepoRegexpConfigPair) ProtoMessage()

func (*HostConfig_RepoRegexpConfigPair) ProtoReflect

func (*HostConfig_RepoRegexpConfigPair) Reset

func (*HostConfig_RepoRegexpConfigPair) String

type RepoConfig

type RepoConfig struct {
	BenignFilePattern      *BenignFilePattern      `protobuf:"bytes,1,opt,name=benign_file_pattern,json=benignFilePattern,proto3" json:"benign_file_pattern,omitempty"`
	CleanRevertPattern     *CleanRevertPattern     `protobuf:"bytes,2,opt,name=clean_revert_pattern,json=cleanRevertPattern,proto3" json:"clean_revert_pattern,omitempty"`
	CleanCherryPickPattern *CleanCherryPickPattern `` /* 131-byte string literal not displayed */
	// Whether Rubber Stamper is disabled in this repository.
	Disabled bool `protobuf:"varint,4,opt,name=disabled,proto3" json:"disabled,omitempty"`
	// contains filtered or unexported fields
}

RepoConfig describes the config to be used for a Gerrit repository.

func RetrieveRepoRegexpConfig

func RetrieveRepoRegexpConfig(ctx context.Context, repo string, rrcfgs []*HostConfig_RepoRegexpConfigPair) *RepoConfig

RetrieveRepoRegexpConfig retrieves a RepoConfig from a given RepoRegexpConfig lists, where the given repository's name should be matched with the RepoRegexpConfig's Key.

When there are multiple matches, the first match, which is decided by their locations in the config, will be selected.

Returns a RepoConfig (the RepoRegexpConfig's Value) when a match is found. Otherwise, return nil.

func (*RepoConfig) Descriptor deprecated

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

Deprecated: Use RepoConfig.ProtoReflect.Descriptor instead.

func (*RepoConfig) GetBenignFilePattern

func (x *RepoConfig) GetBenignFilePattern() *BenignFilePattern

func (*RepoConfig) GetCleanCherryPickPattern

func (x *RepoConfig) GetCleanCherryPickPattern() *CleanCherryPickPattern

func (*RepoConfig) GetCleanRevertPattern

func (x *RepoConfig) GetCleanRevertPattern() *CleanRevertPattern

func (*RepoConfig) GetDisabled

func (x *RepoConfig) GetDisabled() bool

func (*RepoConfig) ProtoMessage

func (*RepoConfig) ProtoMessage()

func (*RepoConfig) ProtoReflect

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

func (*RepoConfig) Reset

func (x *RepoConfig) Reset()

func (*RepoConfig) String

func (x *RepoConfig) String() string

Jump to

Keyboard shortcuts

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