Documentation ¶
Index ¶
- Constants
- Variables
- func BuilderFromProto(cb []*config.Builder) []string
- func EnsurePubSubSubscribed(c context.Context, settings *config.Settings) error
- func GetSettings(c context.Context) *config.Settings
- func IsAllowed(c context.Context, project string) (bool, error)
- func IsAllowedInternal(c context.Context) (bool, error)
- func LuciConfigURL(c context.Context, configSet, path, revision string) string
- func UpdateConsoles(c context.Context) error
- func UpdateServiceConfig(c context.Context) (*config.Settings, error)
- type BuilderMeta
- type Console
- type ErrorCode
- type PubSubMessage
- type PubSubSubscription
- type ServiceConfig
- type TestBundle
Constants ¶
const ServiceConfigID = "service_config"
The key for the service config entity in datastore.
Variables ¶
ErrorTag should be used to tag errors in the milo ecosystem to categorize them so they can be rendered properly in the frontend.
Functions ¶
func BuilderFromProto ¶
BuilderFromProto tranforms a luci-config proto builder format into the datastore format.
func EnsurePubSubSubscribed ¶
EnsurePubSubSubscribed makes sure the following subscriptions are in place: * buildbucket, via the settings.Buildbucket.Topic setting
func GetSettings ¶
GetServiceConfig returns the service (aka global) config for the current instance of Milo from the datastore. Returns an empty config and warn heavily if none is found. TODO(hinoka): Use process cache to cache configs.
func IsAllowed ¶
IsAllowed checks to see if the user in the context is allowed to access the given project.
func IsAllowedInternal ¶
IsAllowedInternal is a shorthand for checking to see if the user is a reader of a magic project named "chrome".
func LuciConfigURL ¶
LuciConfigURL returns a user friendly URL that specifies where to view this console definition.
func UpdateConsoles ¶
UpdateConsoles updates internal console definitions entities based off luci-config.
Types ¶
type BuilderMeta ¶
BuilderMeta is a struct containing metadata about a builder.
func BuilderRefFromProto ¶
func BuilderRefFromProto(cb []*config.Builder) []BuilderMeta
BuilderRefFromProto tranforms a luci-config proto builder format into the BuilderMeta format.
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. ID string `gae:"$id"` // RepoURL and Ref combined defines the commits the show up on the left // hand side of a Console. RepoURL string // RepoURL and Ref combined defines the commits the show up on the left // hand side of a Console. Ref string // ManifestName is the name of the manifest to look for when querying for // builds under this console. ManifestName string // URL is the URL to the luci-config definition of this console. URL string // Revision is the luci-config reivision from when this Console was retrieved. Revision string // Builders is a list of universal builder IDs. This is indexed. Builders []string // BuilderMeta is an expanded set of builders containing additional metadata. // This should always match the Builders field. BuilderMetas []BuilderMeta }
Console is a datastore entity representing a single console.
func GetAllConsoles ¶
GetAllConsoles returns all registered projects with the builder name. If builderName is empty, then this retrieves all Consoles.
func GetConsole ¶
GetConsole returns the requested console.
func NewConsole ¶
NewConsole creates a fully populated console out of the luci-config proto definition of a console.
type ErrorCode ¶
type ErrorCode int
ErrorCode represents milo's internal error code system. The subsystems in milo can attach an ErrorCode to an error (using ErrorTag), and then the html and grpc frontends know how to render the error in a way that will help the user.
const ( // CodeUnknown means an error happened, but we weren't able to classify it. CodeUnknown ErrorCode = iota // proceed further. CodeUnauthorized // CodeNoAccess occurs when the currently logged-in user is not permitted to // see the resource. CodeNoAccess // CodeNotFound occurs when we weren't able to find the build that the // user asked for. CodeNotFound // CodeParameterError occurs when one or more of the user-provided parameters // was malformed. CodeParameterError )
func (ErrorCode) GenerateErrorTagValue ¶
GenerateErrorTagValue implements errors.TagValueGenerator so that ErrorCodes can be used like:
errors.Annotate(err).Tag(CodeNotFound) errors.New("terrible thing", CodeNotFound)
func (ErrorCode) HTTPStatus ¶
HTTPStatus returns an HTTP Status code corresponding to this ErrorCode.
type PubSubMessage ¶
type PubSubSubscription ¶
type PubSubSubscription struct { Message PubSubMessage `json:"message"` Subscription string `json:"subscription"` }
func (*PubSubSubscription) GetData ¶
func (m *PubSubSubscription) GetData() ([]byte, error)
GetData returns the expanded form of Data (decoded from base64).
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.
func GetCurrentServiceConfig ¶
func GetCurrentServiceConfig(c context.Context) (*ServiceConfig, error)
GetCurrentServiceConfig gets the service config for the instance from either process cache or datastore cache.