config

package
v0.0.0-...-d3da680 Latest Latest
Warning

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

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

Documentation

Overview

Package config implements service-level config for LUCI Source Index.

Package config implements service-level config for LUCI Source Index.

Index

Constants

This section is empty.

Variables

View Source
var IndexableRefPrefixes = []string{
	"refs/branch-heads/",
	"refs/heads/",
}

IndexableRefPrefixes is a list of ref prefixes from which the commits can be indexed.

We should not index commits of arbitrary refs (e.g. Gerrit CL patch refs) as they may not have been merged into one of the branches. We don't want to resolve commit positions to unmerged CLs.

Keep in sync with the service config documentation `luci.source_index.config.Config.Host.Repository.include_ref_regexes`

View Source
var TestCfg = &configpb.Config{
	Hosts: []*configpb.Config_Host{
		{
			Host: "chromium.googlesource.com",
			Repositories: []*configpb.Config_Host_Repository{
				{
					Name: "chromium/src",
					IncludeRefRegexes: []string{
						"^refs/branch-heads/.+$",

						"refs/heads/main",

						"^refs/arbitrary/.+$",
					},
				},
				{
					Name:              "chromiumos/manifest",
					IncludeRefRegexes: []string{"^refs/heads/staging-snapshot$"},
				},
				{
					Name:              "v8/v8",
					IncludeRefRegexes: []string{"^refs/heads/main$"},
				},
			},
		},
		{
			Host: "webrtc.googlesource.com",
			Repositories: []*configpb.Config_Host_Repository{
				{
					Name:              "src",
					IncludeRefRegexes: []string{"^refs/heads/main$"},
				},
			},
		},
	},
}

TestCfg is a configuration used for testing purpose. It mimics the configuration for the staging environment.

Functions

func RegisterCronHandlers

func RegisterCronHandlers(srv *server.Server) error

RegisterCronHandlers registers cron handlers for managing Source Index's configuration.

func SetTestConfig

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

SetTestConfig set test configs in the cachedCfg.

Types

type Config

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

Config is a wrapper around `*configpb.Config` that provides some methods for interacting with the Config.

func Get

func Get(ctx context.Context) (Config, error)

Get returns the config stored in the context.

func (*Config) HasHost

func (c *Config) HasHost(host string) bool

HasHost returns whether the host is configured.

func (Config) HostConfigs

func (c Config) HostConfigs() []HostConfig

HostConfigs returns a list of host configs.

func (Config) ShouldIndexRef

func (c Config) ShouldIndexRef(host, repo, ref string) bool

ShouldIndexRef returns whether the specified ref should be indexed.

func (Config) ShouldIndexRepo

func (c Config) ShouldIndexRepo(host, repo string) bool

ShouldIndexRepo returns whether the specified repository should be indexed.

type HostConfig

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

HostConfig is a wrapper around `*configpb.Config_Host` that provides some methods for interacting with the host config.

func (HostConfig) Host

func (hc HostConfig) Host() string

Host returns the host name.

func (HostConfig) RepoConfigs

func (hc HostConfig) RepoConfigs() []RepositoryConfig

RepoConfigs returns a list of repository configs.

type RepositoryConfig

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

RepositoryConfig is a wrapper around `*configpb.Config_Host_Repository` that provides some methods for interacting with the repository config.

func (RepositoryConfig) Name

func (rc RepositoryConfig) Name() string

Name returns the name of the repository.

func (RepositoryConfig) ShouldIndexRef

func (rc RepositoryConfig) ShouldIndexRef(ref string) bool

ShouldIndexRef returns whether the specified ref should be indexed.

Jump to

Keyboard shortcuts

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