config

package
v0.0.0-...-aaca28b Latest Latest
Warning

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

Go to latest
Published: Feb 27, 2025 License: Apache-2.0 Imports: 21 Imported by: 0

Documentation

Overview

Package config validates and gives access to ResultDB LUCI config.

Index

Constants

This section is empty.

Variables

View Source
var (
	// Returned if configuration for a given project does not exist.
	ErrNotFoundProjectConfig = fmt.Errorf("no project config found")
)
View Source
var GCSBucketRE = regexp.MustCompile(`^[a-z0-9_\.\-]{3,222}$`)
View Source
var HumanReadableRE = regexp.MustCompile(`^[[:print:]]{1,100}$`)
View Source
var SchemeIDRE = regexp.MustCompile(`^[a-z][a-z0-9]{0,19}$`)

Functions

func CreatePlaceHolderServiceConfig

func CreatePlaceHolderServiceConfig() *configpb.Config

func CreatePlaceholderProjectConfig

func CreatePlaceholderProjectConfig() *configpb.ProjectConfig

CreatePlaceholderProjectConfig creates a placeholder project config with default values.

func GetServiceConfig

func GetServiceConfig(ctx context.Context) (*configpb.Config, error)

GetServiceConfig returns the cached service-level config

func Project

func Project(ctx context.Context, project string) (*configpb.ProjectConfig, error)

Project returns the configurations of the requested project. Returns an ErrNotFoundProjectConfig error if config for the given project does not exist.

func Projects

func Projects(ctx context.Context) (map[string]*configpb.ProjectConfig, error)

Projects returns all project configurations, in a map by project name. Uses in-memory cache to avoid hitting datastore all the time. Note that the config may be stale by up to 1 minute.

func SetServiceConfigForTesting

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

SetServiceConfigForTesting installs the service configuration into the context ctx. This is only used for the purpose of testing.

func SetServiceConfigWithMetaForTesting

func SetServiceConfigWithMetaForTesting(ctx context.Context, cfg *configpb.Config, meta *config.Meta) error

SetServiceConfigWithMetaForTesting installs the service configuration into the context ctx, with the given metadata. This is only used for the purpose of testing.

func SetTestProjectConfig

func SetTestProjectConfig(ctx context.Context, cfg map[string]*configpb.ProjectConfig) error

SetTestProjectConfig sets test project configuration in datastore. It should be used from unit/integration tests only.

func UpdateConfig

func UpdateConfig(ctx context.Context) error

UpdateConfig is called from a cron periodically; it fetches the latest service-wide config and project config from the LUCI Config service and caches them into the datastore

func UpdateProjects

func UpdateProjects(ctx context.Context) error

UpdateProjects fetches fresh project-level configuration from LUCI Config service and stores it in datastore.

func UpdateServiceConfig

func UpdateServiceConfig(ctx context.Context) error

UpdateServiceConfig fetches the latest service config and caches it in datastore.

Types

type CompiledServiceConfig

type CompiledServiceConfig struct {
	// The raw service configuration.
	Config   *configpb.Config
	Revision string
	// The compiled scheme configuration, by scheme ID.
	Schemes map[string]*Scheme
}

CompiledServiceConfig is a copy of service configuration with regular expression pre-compiled. This object must be treated as immutable.

func NewCompiledServiceConfig

func NewCompiledServiceConfig(cfg *configpb.Config, revision string) (*CompiledServiceConfig, error)

NewCompiledServiceConfig compiles the given raw service config into a form that is faster to apply.

func Service

func Service(ctx context.Context) (*CompiledServiceConfig, error)

Service returns the compiled configuration for the service.

type Scheme

type Scheme struct {
	// The identifier of the scheme.
	ID string
	// The human readable scheme name.
	HumanReadableName string
	// Configuration for the coarse name level.
	// If set, the scheme uses the coarse name level.
	Coarse *SchemeLevel
	// Configuration for the fine name level.
	// If set, the fine name.
	Fine *SchemeLevel
	// Configuration for the case name level.
	// Always set.
	Case *SchemeLevel
}

Scheme represents the configuration for a type of test. For example, JUnit or GTest.

type SchemeLevel

type SchemeLevel struct {
	// The human readable name of the level.
	HumanReadableName string
	// The compiled validation regular expression.
	// May be nil if no validation is to be appled.
	ValidationRegexp *regexp.Regexp
}

SchemeLevel represents a test hierarchy level in a test scheme.

func NewSchemeLevel

func NewSchemeLevel(level *configpb.Scheme_Level) (*SchemeLevel, error)

Jump to

Keyboard shortcuts

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