Documentation ¶
Overview ¶
Package projectconfig contains all code for managing configurations for projects supported by Milo (e.g. ChromeOS, Chromium).
Not to be confused with config, which manages Milo's global service configuration.
Index ¶
- Constants
- Variables
- func CheckACL(c context.Context, acl ACL) (bool, error)
- func IsAllowed(c context.Context, project string) (bool, error)
- func UpdateProjectConfigsHandler(c context.Context) error
- func UpdateProjects(c context.Context) error
- type ACL
- type Console
- func GetAllConsoles(c context.Context, builderID string) ([]*Console, error)
- func GetConsole(c context.Context, proj, id string) (*Console, error)
- func GetConsoles(c context.Context, consoles []ConsoleID) ([]*Console, error)
- func GetProjectConsoles(c context.Context, projectID string) ([]*Console, error)
- type ConsoleID
- type Project
- type ServiceConfig
Constants ¶
const ServiceConfigID = "service_config"
ServiceConfigID is the key for the service config entity in datastore.
Variables ¶
var ErrConsoleNotFound = errors.New("console not found")
ErrConsoleNotFound is returned from GetConsole if the requested console isn't known to exist.
Functions ¶
func CheckACL ¶
CheckACL returns true if the caller is in the ACL.
Returns an internal error if the check itself fails.
func IsAllowed ¶
IsAllowed checks to see if the user in the context is allowed to access the given project.
Returns false for unknown projects. Returns an internal error if the check itself fails.
func UpdateProjectConfigsHandler ¶
UpdateProjectConfigsHandler is an HTTP handler that handles project configuration update requests.
func UpdateProjects ¶
UpdateProjects reads project configs from LUCI Config and updates entities.
Visits all LUCI projects (not only ones that have Milo config) to grab their visibility ACL from project.cfg file.
Types ¶
type ACL ¶
ACL lists groups and identities that are allowed to see consoles in a project.
Fetched from project.cfg config file in fetchProjectACL.
type Console ¶
type Console struct { // Parent is a key to the parent Project entity where this console was // defined in. Parent *datastore.Key `gae:"$parent"` // ID is the ID of the console. // This ID is local to the console, i.e. it should equal .Def.Id and not // Def.ExternalId. ID string `gae:"$id"` // Ordinal specifies the console's ordering in its project's consoles list. Ordinal int // The URL to the luci-config definition of this console. ConfigURL string // The luci-config revision from when this Console was retrieved. ConfigRevision string `gae:",noindex"` // (indexed) All builder IDs mentioned by this console config. Builders []string // Def is the actual underlying proto Console definition. // If this console is external (i.e. a reference to a console from // another project), this will contain the resolved Console definition, // but with ExternalId and ExternalProject also set. Def projectconfigpb.Console `gae:",noindex"` // Realm that the console exists under. Realm string // contains filtered or unexported fields }
Console is a datastore entity representing a single console.
func GetAllConsoles ¶
GetAllConsoles returns all Consoles (across all projects) which contain the builder ID. If builderID is empty, then this retrieves all Consoles.
TODO-perf(iannucci): Maybe memcache this too.
func GetConsole ¶
GetConsole returns the requested console.
TODO-perf(iannucci,hinoka): Memcache this.
func GetConsoles ¶
GetConsoles returns the requested consoles. Excludes references to external consoles that the user does not have access to.
TODO-perf(iannucci,hinoka): Memcache this.
func GetProjectConsoles ¶
GetProjectConsoles returns all consoles for the given project ordered as in config. Excludes references to external consoles that the user does not have access to.
func (*Console) BuilderRealms ¶
BuilderRealms returns all realms referenced by this Console's Builders.
func (*Console) ConsoleID ¶
ConsoleID returns a struct containing ID strings for the console and its parent project.
func (*Console) FilterBuilders ¶
FilterBuilders filters out builder IDs and builders with realms not listed in `allowedRealms`. Deprecated: use `projectconfigpb.Console.AllowedBuilders` instead. Favor functional code over modifying the object in place.
func (*Console) IsExternal ¶
IsExternal returns whether the console is a reference to a console from another project. If this is the case, the console will have Def.ExternalProject and Def.ExternalId set.
type ConsoleID ¶
ConsoleID is a reference to a console.
func ParseConsoleID ¶
ParseConsoleID reformats the string into a ConsoleID.
type Project ¶
type Project struct { ID string `gae:"$id"` HasConfig bool ACL ACL `gae:",noindex"` LogoURL string BugURLTemplate string // IgnoredBuilderIds is a list of builder IDs to be ignored by pubsub handler. // ID format: <bucket>/<builder> IgnoredBuilderIDs []string // ExternalBuilderIDs is a list of builder IDs that are not in this project // but are referenced by this project. // ID format: <project>/<bucket>/<builder> ExternalBuilderIDs []string MetadataConfig []byte `gae:",noindex"` // contains filtered or unexported fields }
Project is a datastore entity representing a single project.
Its children are consoles. This entity exists even if the project doesn't define milo.cfg config file. It has HasConfig == false in this case. We still need the entity to be able to check project's ACLs when accessing individual build pages.
func GetProject ¶
GetProject loads the project from the datastore.
func GetVisibleProjects ¶
GetVisibleProjects returns all projects with consoles the current user has access to.
Skips projects that do not have Milo config file.
func (*Project) BuilderIsIgnored ¶
func (p *Project) BuilderIsIgnored(builderID *buildbucketpb.BuilderID) bool
BuilderIsIgnored checks if the builder is marked as ignored in this project.
type ServiceConfig ¶
type ServiceConfig struct { // ID is the datastore key. This should be static, as there should only be // one service config. ID string `gae:"$id"` // Revision is the revision of the config, taken from luci-config. This is used // to determine if the entry needs to be refreshed. Revision string // Data is the binary proto of the config. Data []byte `gae:",noindex"` // Text is the text format of the config. For human consumption only. Text string `gae:",noindex"` // LastUpdated is the time this config was last updated. LastUpdated time.Time }
ServiceConfig is a container for the instance's service config.