id
int32
0
167k
repo
stringlengths
5
54
path
stringlengths
4
155
func_name
stringlengths
1
118
original_string
stringlengths
52
85.5k
language
stringclasses
1 value
code
stringlengths
52
85.5k
code_tokens
list
docstring
stringlengths
6
2.61k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
85
252
7,500
luci/luci-go
common/data/rand/mathrand/mathrand.go
getGlobalRand
func getGlobalRand() (*Locking, *rand.Rand) { globalOnce.Do(func() { globalRandBase = newRand() globalRand = &Locking{R: wrapped{globalRandBase}} }) return globalRand, globalRandBase }
go
func getGlobalRand() (*Locking, *rand.Rand) { globalOnce.Do(func() { globalRandBase = newRand() globalRand = &Locking{R: wrapped{globalRandBase}} }) return globalRand, globalRandBase }
[ "func", "getGlobalRand", "(", ")", "(", "*", "Locking", ",", "*", "rand", ".", "Rand", ")", "{", "globalOnce", ".", "Do", "(", "func", "(", ")", "{", "globalRandBase", "=", "newRand", "(", ")", "\n", "globalRand", "=", "&", "Locking", "{", "R", ":"...
// getGlobalRand returns globalRand and its Locking wrapper. This must be used // instead of direct variable access in order to ensure that everything is // initialized. // // We use a Once to perform this initialization so that we can enable // applications to set the seed via rand.Seed if they wish.
[ "getGlobalRand", "returns", "globalRand", "and", "its", "Locking", "wrapper", ".", "This", "must", "be", "used", "instead", "of", "direct", "variable", "access", "in", "order", "to", "ensure", "that", "everything", "is", "initialized", ".", "We", "use", "a", ...
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/common/data/rand/mathrand/mathrand.go#L53-L59
7,501
luci/luci-go
common/data/rand/mathrand/mathrand.go
getRand
func getRand(c context.Context) Rand { if r, ok := c.Value(&key).(Rand); ok { return r } return nil }
go
func getRand(c context.Context) Rand { if r, ok := c.Value(&key).(Rand); ok { return r } return nil }
[ "func", "getRand", "(", "c", "context", ".", "Context", ")", "Rand", "{", "if", "r", ",", "ok", ":=", "c", ".", "Value", "(", "&", "key", ")", ".", "(", "Rand", ")", ";", "ok", "{", "return", "r", "\n", "}", "\n", "return", "nil", "\n", "}" ]
// getRand returns the Rand installed in c, or nil if no Rand is installed.
[ "getRand", "returns", "the", "Rand", "installed", "in", "c", "or", "nil", "if", "no", "Rand", "is", "installed", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/common/data/rand/mathrand/mathrand.go#L64-L69
7,502
luci/luci-go
tokenserver/cmd/luci_machine_tokend/token_file.go
readTokenFile
func readTokenFile(ctx context.Context, path string) (*tokenserver.TokenFile, *stateInToken) { blob, err := ioutil.ReadFile(path) if err != nil { if !os.IsNotExist(err) { logging.Warningf(ctx, "Failed to read token file from %q - %s", path, err) } return &tokenserver.TokenFile{}, &stateInToken{} } out := &...
go
func readTokenFile(ctx context.Context, path string) (*tokenserver.TokenFile, *stateInToken) { blob, err := ioutil.ReadFile(path) if err != nil { if !os.IsNotExist(err) { logging.Warningf(ctx, "Failed to read token file from %q - %s", path, err) } return &tokenserver.TokenFile{}, &stateInToken{} } out := &...
[ "func", "readTokenFile", "(", "ctx", "context", ".", "Context", ",", "path", "string", ")", "(", "*", "tokenserver", ".", "TokenFile", ",", "*", "stateInToken", ")", "{", "blob", ",", "err", ":=", "ioutil", ".", "ReadFile", "(", "path", ")", "\n", "if"...
// readTokenFile reads the token file from disk. // // In case of problems, logs errors and returns default structs.
[ "readTokenFile", "reads", "the", "token", "file", "from", "disk", ".", "In", "case", "of", "problems", "logs", "errors", "and", "returns", "default", "structs", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/tokenserver/cmd/luci_machine_tokend/token_file.go#L43-L63
7,503
luci/luci-go
logdog/appengine/coordinator/flex/logs/http.go
viewerURL
func (ld *logData) viewerURL() string { for _, s := range ld.logStreams { desc, err := s.DescriptorValue() if err != nil { continue } if u, ok := desc.Tags["logdog.viewer_url"]; ok { return u } } return "" }
go
func (ld *logData) viewerURL() string { for _, s := range ld.logStreams { desc, err := s.DescriptorValue() if err != nil { continue } if u, ok := desc.Tags["logdog.viewer_url"]; ok { return u } } return "" }
[ "func", "(", "ld", "*", "logData", ")", "viewerURL", "(", ")", "string", "{", "for", "_", ",", "s", ":=", "range", "ld", ".", "logStreams", "{", "desc", ",", "err", ":=", "s", ".", "DescriptorValue", "(", ")", "\n", "if", "err", "!=", "nil", "{",...
// viewerURL is a convenience function to extract the logdog.viewer_url tag // out of a logStream, if available. // If given multiple streams, it will return the first one found with the viewer_url tag.
[ "viewerURL", "is", "a", "convenience", "function", "to", "extract", "the", "logdog", ".", "viewer_url", "tag", "out", "of", "a", "logStream", "if", "available", ".", "If", "given", "multiple", "streams", "it", "will", "return", "the", "first", "one", "found"...
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/logdog/appengine/coordinator/flex/logs/http.go#L146-L157
7,504
luci/luci-go
logdog/appengine/coordinator/flex/logs/http.go
resolveStreams
func resolveStreams(c context.Context, options userOptions) ([]*coordinator.LogStream, error) { prefix, name := options.path.Split() streams := []*coordinator.LogStream{} var err error if options.wildcard { q := datastore.NewQuery("LogStream").Eq("Prefix", prefix.String()).Eq("Purged", false) err = datastore.Ge...
go
func resolveStreams(c context.Context, options userOptions) ([]*coordinator.LogStream, error) { prefix, name := options.path.Split() streams := []*coordinator.LogStream{} var err error if options.wildcard { q := datastore.NewQuery("LogStream").Eq("Prefix", prefix.String()).Eq("Purged", false) err = datastore.Ge...
[ "func", "resolveStreams", "(", "c", "context", ".", "Context", ",", "options", "userOptions", ")", "(", "[", "]", "*", "coordinator", ".", "LogStream", ",", "error", ")", "{", "prefix", ",", "name", ":=", "options", ".", "path", ".", "Split", "(", ")",...
// resolveStreams takes a path containing a wildcard and resolves it to the list // of all known paths. Purge checks are also performed here.
[ "resolveStreams", "takes", "a", "path", "containing", "a", "wildcard", "and", "resolves", "it", "to", "the", "list", "of", "all", "known", "paths", ".", "Purge", "checks", "are", "also", "performed", "here", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/logdog/appengine/coordinator/flex/logs/http.go#L297-L328
7,505
luci/luci-go
logdog/appengine/coordinator/flex/logs/http.go
initParams
func initParams(c context.Context, streams []*coordinator.LogStream, project types.ProjectName) ([]fetchParams, error) { states := make([]*coordinator.LogStreamState, len(streams)) for i, stream := range streams { states[i] = stream.State(c) } // Get the log states, which we use to fetch the backend storage. swi...
go
func initParams(c context.Context, streams []*coordinator.LogStream, project types.ProjectName) ([]fetchParams, error) { states := make([]*coordinator.LogStreamState, len(streams)) for i, stream := range streams { states[i] = stream.State(c) } // Get the log states, which we use to fetch the backend storage. swi...
[ "func", "initParams", "(", "c", "context", ".", "Context", ",", "streams", "[", "]", "*", "coordinator", ".", "LogStream", ",", "project", "types", ".", "ProjectName", ")", "(", "[", "]", "fetchParams", ",", "error", ")", "{", "states", ":=", "make", "...
// initParams generates a set of params for each LogStream given.
[ "initParams", "generates", "a", "set", "of", "params", "for", "each", "LogStream", "given", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/logdog/appengine/coordinator/flex/logs/http.go#L331-L359
7,506
luci/luci-go
logdog/appengine/coordinator/flex/logs/http.go
fetch
func fetch(c context.Context, ch chan<- logResp, allParams []fetchParams) { defer close(ch) // Close the channel when we're done fetching. // TODO(hinoka): Remove this check once multistream view is supported. if len(allParams) > 1 { streamPaths := make([]string, len(allParams)) for i, p := range allParams { ...
go
func fetch(c context.Context, ch chan<- logResp, allParams []fetchParams) { defer close(ch) // Close the channel when we're done fetching. // TODO(hinoka): Remove this check once multistream view is supported. if len(allParams) > 1 { streamPaths := make([]string, len(allParams)) for i, p := range allParams { ...
[ "func", "fetch", "(", "c", "context", ".", "Context", ",", "ch", "chan", "<-", "logResp", ",", "allParams", "[", "]", "fetchParams", ")", "{", "defer", "close", "(", "ch", ")", "// Close the channel when we're done fetching.", "\n\n", "// TODO(hinoka): Remove this...
// fetch is a goroutine that fetches log entries from all storage layers and // sends it through ch in the order of prefix index. // The LogStreamState is used purely for checking Terminal Indices.
[ "fetch", "is", "a", "goroutine", "that", "fetches", "log", "entries", "from", "all", "storage", "layers", "and", "sends", "it", "through", "ch", "in", "the", "order", "of", "prefix", "index", ".", "The", "LogStreamState", "is", "used", "purely", "for", "ch...
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/logdog/appengine/coordinator/flex/logs/http.go#L417-L492
7,507
luci/luci-go
logdog/appengine/coordinator/flex/logs/http.go
fetchOnce
func fetchOnce(c context.Context, ch chan<- logResp, index types.MessageIndex, params fetchParams) (types.MessageIndex, error) { // Extract just the parameters we need. st := params.storage // This is the backend storage instance. archived := params.state.ArchivalState().Archived() path := params.stream.Path() re...
go
func fetchOnce(c context.Context, ch chan<- logResp, index types.MessageIndex, params fetchParams) (types.MessageIndex, error) { // Extract just the parameters we need. st := params.storage // This is the backend storage instance. archived := params.state.ArchivalState().Archived() path := params.stream.Path() re...
[ "func", "fetchOnce", "(", "c", "context", ".", "Context", ",", "ch", "chan", "<-", "logResp", ",", "index", "types", ".", "MessageIndex", ",", "params", "fetchParams", ")", "(", "types", ".", "MessageIndex", ",", "error", ")", "{", "// Extract just the param...
// fetchOnce does one backend storage request for logs, which may produce multiple log entries. // // Log entries are pushed into ch. // Returns the next stream index to fetch. // It is possible for the next index to be the terminal index + 1, so the calling // code has to test for that.
[ "fetchOnce", "does", "one", "backend", "storage", "request", "for", "logs", "which", "may", "produce", "multiple", "log", "entries", ".", "Log", "entries", "are", "pushed", "into", "ch", ".", "Returns", "the", "next", "stream", "index", "to", "fetch", ".", ...
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/logdog/appengine/coordinator/flex/logs/http.go#L500-L546
7,508
luci/luci-go
logdog/appengine/coordinator/flex/logs/http.go
writeOKHeaders
func writeOKHeaders(ctx *router.Context, data logData) { // Tell nginx not to buffer anything. ctx.Writer.Header().Set("X-Accel-Buffering", "no") // Tell the browser to prefer https. ctx.Writer.Header().Set("Strict-Transport-Security", "max-age=31536000; includeSubDomains") // Set the correct content type based of...
go
func writeOKHeaders(ctx *router.Context, data logData) { // Tell nginx not to buffer anything. ctx.Writer.Header().Set("X-Accel-Buffering", "no") // Tell the browser to prefer https. ctx.Writer.Header().Set("Strict-Transport-Security", "max-age=31536000; includeSubDomains") // Set the correct content type based of...
[ "func", "writeOKHeaders", "(", "ctx", "*", "router", ".", "Context", ",", "data", "logData", ")", "{", "// Tell nginx not to buffer anything.", "ctx", ".", "Writer", ".", "Header", "(", ")", ".", "Set", "(", "\"", "\"", ",", "\"", "\"", ")", "\n", "// Te...
// writeOKHeaders writes the http response headers in accordence with the // log stream type and user options. The error is passed through.
[ "writeOKHeaders", "writes", "the", "http", "response", "headers", "in", "accordence", "with", "the", "log", "stream", "type", "and", "user", "options", ".", "The", "error", "is", "passed", "through", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/logdog/appengine/coordinator/flex/logs/http.go#L583-L599
7,509
luci/luci-go
logdog/appengine/coordinator/flex/logs/http.go
writeErrorPage
func writeErrorPage(ctx *router.Context, err error, data logData) { ierr := errors.New("LogDog encountered an internal error") switch code := grpcutil.Code(err); code { case codes.Unauthenticated: // Redirect to login screen. var u string u, ierr = auth.LoginURL(ctx.Context, ctx.Request.URL.RequestURI()) if ...
go
func writeErrorPage(ctx *router.Context, err error, data logData) { ierr := errors.New("LogDog encountered an internal error") switch code := grpcutil.Code(err); code { case codes.Unauthenticated: // Redirect to login screen. var u string u, ierr = auth.LoginURL(ctx.Context, ctx.Request.URL.RequestURI()) if ...
[ "func", "writeErrorPage", "(", "ctx", "*", "router", ".", "Context", ",", "err", "error", ",", "data", "logData", ")", "{", "ierr", ":=", "errors", ".", "New", "(", "\"", "\"", ")", "\n", "switch", "code", ":=", "grpcutil", ".", "Code", "(", "err", ...
// writeErrorPage renders an error page.
[ "writeErrorPage", "renders", "an", "error", "page", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/logdog/appengine/coordinator/flex/logs/http.go#L602-L626
7,510
luci/luci-go
logdog/appengine/coordinator/flex/logs/http.go
gradient
func gradient(from, to color.RGBA, scale float64) (result color.RGBA) { scale = math.Max(math.Min(scale, 1.0), 0.0) result.R = linearScale(from.R, to.R, scale) result.G = linearScale(from.G, to.G, scale) result.B = linearScale(from.B, to.B, scale) return }
go
func gradient(from, to color.RGBA, scale float64) (result color.RGBA) { scale = math.Max(math.Min(scale, 1.0), 0.0) result.R = linearScale(from.R, to.R, scale) result.G = linearScale(from.G, to.G, scale) result.B = linearScale(from.B, to.B, scale) return }
[ "func", "gradient", "(", "from", ",", "to", "color", ".", "RGBA", ",", "scale", "float64", ")", "(", "result", "color", ".", "RGBA", ")", "{", "scale", "=", "math", ".", "Max", "(", "math", ".", "Min", "(", "scale", ",", "1.0", ")", ",", "0.0", ...
// gradient produces a color between from and to colors // given a scale between 0.0 to 1.0, with each of the color // components multiplied.
[ "gradient", "produces", "a", "color", "between", "from", "and", "to", "colors", "given", "a", "scale", "between", "0", ".", "0", "to", "1", ".", "0", "with", "each", "of", "the", "color", "components", "multiplied", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/logdog/appengine/coordinator/flex/logs/http.go#L690-L696
7,511
luci/luci-go
logdog/appengine/coordinator/flex/logs/http.go
serve
func serve(c context.Context, data logData, w http.ResponseWriter) (err error) { // Note: Always put errors in merr instead of returning err. // The following defer will drop whatever err is in the named return // and replace it with merr. // This is done so that all errors can be aggregated. merr := errors.MultiE...
go
func serve(c context.Context, data logData, w http.ResponseWriter) (err error) { // Note: Always put errors in merr instead of returning err. // The following defer will drop whatever err is in the named return // and replace it with merr. // This is done so that all errors can be aggregated. merr := errors.MultiE...
[ "func", "serve", "(", "c", "context", ".", "Context", ",", "data", "logData", ",", "w", "http", ".", "ResponseWriter", ")", "(", "err", "error", ")", "{", "// Note: Always put errors in merr instead of returning err.", "// The following defer will drop whatever err is in ...
// serve reads log entries from data.ch and writes into w.
[ "serve", "reads", "log", "entries", "from", "data", ".", "ch", "and", "writes", "into", "w", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/logdog/appengine/coordinator/flex/logs/http.go#L762-L841
7,512
luci/luci-go
logdog/appengine/coordinator/flex/logs/http.go
GetHandler
func GetHandler(ctx *router.Context) { start := clock.Now(ctx.Context) // Start the fetcher and wait for fetched logs to arrive into ch. data, err := startFetch(ctx.Context, ctx.Request, ctx.Params.ByName("path")) if err != nil { logging.WithError(err).Errorf(ctx.Context, "failed to start fetch") writeErrorPage...
go
func GetHandler(ctx *router.Context) { start := clock.Now(ctx.Context) // Start the fetcher and wait for fetched logs to arrive into ch. data, err := startFetch(ctx.Context, ctx.Request, ctx.Params.ByName("path")) if err != nil { logging.WithError(err).Errorf(ctx.Context, "failed to start fetch") writeErrorPage...
[ "func", "GetHandler", "(", "ctx", "*", "router", ".", "Context", ")", "{", "start", ":=", "clock", ".", "Now", "(", "ctx", ".", "Context", ")", "\n", "// Start the fetcher and wait for fetched logs to arrive into ch.", "data", ",", "err", ":=", "startFetch", "("...
// GetHandler is an HTTP handler for retrieving logs.
[ "GetHandler", "is", "an", "HTTP", "handler", "for", "retrieving", "logs", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/logdog/appengine/coordinator/flex/logs/http.go#L844-L861
7,513
luci/luci-go
grpc/internal/svctool/parser.go
parsePackage
func (p *parser) parsePackage(fileNames []string) error { if len(fileNames) == 0 { return fmt.Errorf("fileNames is empty") } for i, name := range fileNames { if i > 0 && filepath.Dir(name) != filepath.Dir(fileNames[0]) { return fmt.Errorf("Go files belong to different directories") } if !strings.HasSuffix...
go
func (p *parser) parsePackage(fileNames []string) error { if len(fileNames) == 0 { return fmt.Errorf("fileNames is empty") } for i, name := range fileNames { if i > 0 && filepath.Dir(name) != filepath.Dir(fileNames[0]) { return fmt.Errorf("Go files belong to different directories") } if !strings.HasSuffix...
[ "func", "(", "p", "*", "parser", ")", "parsePackage", "(", "fileNames", "[", "]", "string", ")", "error", "{", "if", "len", "(", "fileNames", ")", "==", "0", "{", "return", "fmt", ".", "Errorf", "(", "\"", "\"", ")", "\n", "}", "\n", "for", "i", ...
// parsePackage parses .go files and fills in p.files with the ASTs. // Files must be in the same directory and have the same package name.
[ "parsePackage", "parses", ".", "go", "files", "and", "fills", "in", "p", ".", "files", "with", "the", "ASTs", ".", "Files", "must", "be", "in", "the", "same", "directory", "and", "have", "the", "same", "package", "name", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/grpc/internal/svctool/parser.go#L50-L74
7,514
luci/luci-go
grpc/internal/svctool/parser.go
recordImport
func (p *parser) recordImport(f *ast.File, typ ast.Expr) error { if star, ok := typ.(*ast.StarExpr); ok { typ = star.X } sel, ok := typ.(*ast.SelectorExpr) if !ok { return nil } pkgID, ok := sel.X.(*ast.Ident) if !ok { return nil } if _, ok := p.extraImports[pkgID.Name]; ok { return nil } path := ...
go
func (p *parser) recordImport(f *ast.File, typ ast.Expr) error { if star, ok := typ.(*ast.StarExpr); ok { typ = star.X } sel, ok := typ.(*ast.SelectorExpr) if !ok { return nil } pkgID, ok := sel.X.(*ast.Ident) if !ok { return nil } if _, ok := p.extraImports[pkgID.Name]; ok { return nil } path := ...
[ "func", "(", "p", "*", "parser", ")", "recordImport", "(", "f", "*", "ast", ".", "File", ",", "typ", "ast", ".", "Expr", ")", "error", "{", "if", "star", ",", "ok", ":=", "typ", ".", "(", "*", "ast", ".", "StarExpr", ")", ";", "ok", "{", "typ...
// recordImport extracts the package referenced by type expression typ, // resolves its path and saves to p.extraImports.
[ "recordImport", "extracts", "the", "package", "referenced", "by", "type", "expression", "typ", "resolves", "its", "path", "and", "saves", "to", "p", ".", "extraImports", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/grpc/internal/svctool/parser.go#L89-L122
7,515
luci/luci-go
grpc/internal/svctool/parser.go
exprString
func (p *parser) exprString(expr ast.Expr) (string, error) { p.exprStrBuf.Reset() err := printer.Fprint(&p.exprStrBuf, p.fileSet, expr) return p.exprStrBuf.String(), err }
go
func (p *parser) exprString(expr ast.Expr) (string, error) { p.exprStrBuf.Reset() err := printer.Fprint(&p.exprStrBuf, p.fileSet, expr) return p.exprStrBuf.String(), err }
[ "func", "(", "p", "*", "parser", ")", "exprString", "(", "expr", "ast", ".", "Expr", ")", "(", "string", ",", "error", ")", "{", "p", ".", "exprStrBuf", ".", "Reset", "(", ")", "\n", "err", ":=", "printer", ".", "Fprint", "(", "&", "p", ".", "e...
// exprString renders expr to string.
[ "exprString", "renders", "expr", "to", "string", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/grpc/internal/svctool/parser.go#L237-L241
7,516
luci/luci-go
dm/appengine/mutate/timeout_execution.go
ResetExecutionTimeout
func ResetExecutionTimeout(c context.Context, e *model.Execution) error { howLong := time.Duration(0) switch e.State { case dm.Execution_SCHEDULING: howLong = e.TimeToStart case dm.Execution_RUNNING: howLong = e.TimeToRun case dm.Execution_STOPPING: howLong = e.TimeToStop } eid := e.GetEID() key := model....
go
func ResetExecutionTimeout(c context.Context, e *model.Execution) error { howLong := time.Duration(0) switch e.State { case dm.Execution_SCHEDULING: howLong = e.TimeToStart case dm.Execution_RUNNING: howLong = e.TimeToRun case dm.Execution_STOPPING: howLong = e.TimeToStop } eid := e.GetEID() key := model....
[ "func", "ResetExecutionTimeout", "(", "c", "context", ".", "Context", ",", "e", "*", "model", ".", "Execution", ")", "error", "{", "howLong", ":=", "time", ".", "Duration", "(", "0", ")", "\n", "switch", "e", ".", "State", "{", "case", "dm", ".", "Ex...
// ResetExecutionTimeout schedules a Timeout for this Execution. It inspects the // Execution's State to determine which timeout should be set, if any. If no // timeout should be active, this will cancel any existing timeouts for this // Execution.
[ "ResetExecutionTimeout", "schedules", "a", "Timeout", "for", "this", "Execution", ".", "It", "inspects", "the", "Execution", "s", "State", "to", "determine", "which", "timeout", "should", "be", "set", "if", "any", ".", "If", "no", "timeout", "should", "be", ...
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/dm/appengine/mutate/timeout_execution.go#L143-L161
7,517
luci/luci-go
lucicfg/cli/cmds/generate/generate.go
Cmd
func Cmd(params base.Parameters) *subcommands.Command { return &subcommands.Command{ UsageLine: "generate SCRIPT", ShortDesc: "interprets a high-level config, generating *.cfg files", LongDesc: `Interprets a high-level config, generating *.cfg files. Writes generated configs to the directory given via -config-d...
go
func Cmd(params base.Parameters) *subcommands.Command { return &subcommands.Command{ UsageLine: "generate SCRIPT", ShortDesc: "interprets a high-level config, generating *.cfg files", LongDesc: `Interprets a high-level config, generating *.cfg files. Writes generated configs to the directory given via -config-d...
[ "func", "Cmd", "(", "params", "base", ".", "Parameters", ")", "*", "subcommands", ".", "Command", "{", "return", "&", "subcommands", ".", "Command", "{", "UsageLine", ":", "\"", "\"", ",", "ShortDesc", ":", "\"", "\"", ",", "LongDesc", ":", "`Interprets ...
// Cmd is 'generate' subcommand.
[ "Cmd", "is", "generate", "subcommand", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/lucicfg/cli/cmds/generate/generate.go#L33-L58
7,518
luci/luci-go
logdog/appengine/coordinator/flex/logs/get.go
Get
func (s *server) Get(c context.Context, req *logdog.GetRequest) (*logdog.GetResponse, error) { return s.getImpl(c, req, false) }
go
func (s *server) Get(c context.Context, req *logdog.GetRequest) (*logdog.GetResponse, error) { return s.getImpl(c, req, false) }
[ "func", "(", "s", "*", "server", ")", "Get", "(", "c", "context", ".", "Context", ",", "req", "*", "logdog", ".", "GetRequest", ")", "(", "*", "logdog", ".", "GetResponse", ",", "error", ")", "{", "return", "s", ".", "getImpl", "(", "c", ",", "re...
// Get returns state and log data for a single log stream.
[ "Get", "returns", "state", "and", "log", "data", "for", "a", "single", "log", "stream", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/logdog/appengine/coordinator/flex/logs/get.go#L57-L59
7,519
luci/luci-go
logdog/appengine/coordinator/flex/logs/get.go
Tail
func (s *server) Tail(c context.Context, req *logdog.TailRequest) (*logdog.GetResponse, error) { r := logdog.GetRequest{ Project: req.Project, Path: req.Path, State: req.State, } return s.getImpl(c, &r, true) }
go
func (s *server) Tail(c context.Context, req *logdog.TailRequest) (*logdog.GetResponse, error) { r := logdog.GetRequest{ Project: req.Project, Path: req.Path, State: req.State, } return s.getImpl(c, &r, true) }
[ "func", "(", "s", "*", "server", ")", "Tail", "(", "c", "context", ".", "Context", ",", "req", "*", "logdog", ".", "TailRequest", ")", "(", "*", "logdog", ".", "GetResponse", ",", "error", ")", "{", "r", ":=", "logdog", ".", "GetRequest", "{", "Pro...
// Tail returns the last log entry for a given log stream.
[ "Tail", "returns", "the", "last", "log", "entry", "for", "a", "given", "log", "stream", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/logdog/appengine/coordinator/flex/logs/get.go#L62-L69
7,520
luci/luci-go
logdog/appengine/coordinator/flex/logs/get.go
getImpl
func (s *server) getImpl(c context.Context, req *logdog.GetRequest, tail bool) (*logdog.GetResponse, error) { log.Fields{ "project": req.Project, "path": req.Path, "index": req.Index, "tail": tail, }.Debugf(c, "Received get request.") path := types.StreamPath(req.Path) if err := path.Validate(); er...
go
func (s *server) getImpl(c context.Context, req *logdog.GetRequest, tail bool) (*logdog.GetResponse, error) { log.Fields{ "project": req.Project, "path": req.Path, "index": req.Index, "tail": tail, }.Debugf(c, "Received get request.") path := types.StreamPath(req.Path) if err := path.Validate(); er...
[ "func", "(", "s", "*", "server", ")", "getImpl", "(", "c", "context", ".", "Context", ",", "req", "*", "logdog", ".", "GetRequest", ",", "tail", "bool", ")", "(", "*", "logdog", ".", "GetResponse", ",", "error", ")", "{", "log", ".", "Fields", "{",...
// getImpl is common code shared between Get and Tail endpoints.
[ "getImpl", "is", "common", "code", "shared", "between", "Get", "and", "Tail", "endpoints", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/logdog/appengine/coordinator/flex/logs/get.go#L72-L136
7,521
luci/luci-go
buildbucket/luciexe/listen.go
StreamRegistrationCallback
func (l *buildListener) StreamRegistrationCallback(desc *logpb.LogStreamDescriptor) bundler.StreamChunkCallback { if desc.Name == l.buildStreamName { switch { case desc.ContentType != protoutil.BuildMediaType: l.report(errors.Reason("stream %q has content type %q, expected %q", desc.Name, desc.ContentType, prot...
go
func (l *buildListener) StreamRegistrationCallback(desc *logpb.LogStreamDescriptor) bundler.StreamChunkCallback { if desc.Name == l.buildStreamName { switch { case desc.ContentType != protoutil.BuildMediaType: l.report(errors.Reason("stream %q has content type %q, expected %q", desc.Name, desc.ContentType, prot...
[ "func", "(", "l", "*", "buildListener", ")", "StreamRegistrationCallback", "(", "desc", "*", "logpb", ".", "LogStreamDescriptor", ")", "bundler", ".", "StreamChunkCallback", "{", "if", "desc", ".", "Name", "==", "l", ".", "buildStreamName", "{", "switch", "{",...
// StreamRegistrationCallback can be used as logdogServer.StreamRegistrationCallback.
[ "StreamRegistrationCallback", "can", "be", "used", "as", "logdogServer", ".", "StreamRegistrationCallback", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/buildbucket/luciexe/listen.go#L67-L82
7,522
luci/luci-go
buildbucket/luciexe/listen.go
Build
func (l *buildListener) Build() *pb.Build { l.buildMU.Lock() defer l.buildMU.Unlock() if l.build == nil { return nil } return proto.Clone(l.build).(*pb.Build) }
go
func (l *buildListener) Build() *pb.Build { l.buildMU.Lock() defer l.buildMU.Unlock() if l.build == nil { return nil } return proto.Clone(l.build).(*pb.Build) }
[ "func", "(", "l", "*", "buildListener", ")", "Build", "(", ")", "*", "pb", ".", "Build", "{", "l", ".", "buildMU", ".", "Lock", "(", ")", "\n", "defer", "l", ".", "buildMU", ".", "Unlock", "(", ")", "\n\n", "if", "l", ".", "build", "==", "nil",...
// Build returns most recently retrieved Build message.
[ "Build", "returns", "most", "recently", "retrieved", "Build", "message", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/buildbucket/luciexe/listen.go#L118-L126
7,523
luci/luci-go
buildbucket/luciexe/listen.go
report
func (l *buildListener) report(err error) { l.onErr(errors.Annotate(err, "LUCI executable protocol violation").Err()) }
go
func (l *buildListener) report(err error) { l.onErr(errors.Annotate(err, "LUCI executable protocol violation").Err()) }
[ "func", "(", "l", "*", "buildListener", ")", "report", "(", "err", "error", ")", "{", "l", ".", "onErr", "(", "errors", ".", "Annotate", "(", "err", ",", "\"", "\"", ")", ".", "Err", "(", ")", ")", "\n", "}" ]
// report reports a LUCI executable protocol violation via l.onErr.
[ "report", "reports", "a", "LUCI", "executable", "protocol", "violation", "via", "l", ".", "onErr", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/buildbucket/luciexe/listen.go#L149-L151
7,524
luci/luci-go
milo/buildsource/buildbucket/builder.go
NewBuilderID
func NewBuilderID(v1Bucket, builder string) (bid BuilderID) { bid.Project, bid.Bucket = deprecated.BucketNameToV2(v1Bucket) bid.Builder = builder return }
go
func NewBuilderID(v1Bucket, builder string) (bid BuilderID) { bid.Project, bid.Bucket = deprecated.BucketNameToV2(v1Bucket) bid.Builder = builder return }
[ "func", "NewBuilderID", "(", "v1Bucket", ",", "builder", "string", ")", "(", "bid", "BuilderID", ")", "{", "bid", ".", "Project", ",", "bid", ".", "Bucket", "=", "deprecated", ".", "BucketNameToV2", "(", "v1Bucket", ")", "\n", "bid", ".", "Builder", "=",...
// NewBuilderID does what it says.
[ "NewBuilderID", "does", "what", "it", "says", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/milo/buildsource/buildbucket/builder.go#L55-L59
7,525
luci/luci-go
milo/buildsource/buildbucket/builder.go
V1Bucket
func (b BuilderID) V1Bucket() string { return fmt.Sprintf("luci.%s.%s", b.Project, b.Bucket) }
go
func (b BuilderID) V1Bucket() string { return fmt.Sprintf("luci.%s.%s", b.Project, b.Bucket) }
[ "func", "(", "b", "BuilderID", ")", "V1Bucket", "(", ")", "string", "{", "return", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "b", ".", "Project", ",", "b", ".", "Bucket", ")", "\n", "}" ]
// V1Bucket returns the buildbucket v1 representation of the bucket name, which // is what we use in Milo.
[ "V1Bucket", "returns", "the", "buildbucket", "v1", "representation", "of", "the", "bucket", "name", "which", "is", "what", "we", "use", "in", "Milo", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/milo/buildsource/buildbucket/builder.go#L63-L65
7,526
luci/luci-go
milo/buildsource/buildbucket/builder.go
String
func (b BuilderID) String() string { return fmt.Sprintf("buildbucket/%s/%s", b.V1Bucket(), b.Builder) }
go
func (b BuilderID) String() string { return fmt.Sprintf("buildbucket/%s/%s", b.V1Bucket(), b.Builder) }
[ "func", "(", "b", "BuilderID", ")", "String", "(", ")", "string", "{", "return", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "b", ".", "V1Bucket", "(", ")", ",", "b", ".", "Builder", ")", "\n", "}" ]
// String returns the canonical format of BuilderID.
[ "String", "returns", "the", "canonical", "format", "of", "BuilderID", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/milo/buildsource/buildbucket/builder.go#L68-L70
7,527
luci/luci-go
milo/buildsource/buildbucket/builder.go
fetchBuilds
func fetchBuilds(c context.Context, client *bbv1.Service, bid BuilderID, status string, limit int, cursor string) ([]*bbv1.ApiCommonBuildMessage, string, error) { c, _ = context.WithTimeout(c, bbRPCTimeout) search := client.Search() search.Context(c) search.Bucket(bid.V1Bucket()) search.Status(status) search.Ta...
go
func fetchBuilds(c context.Context, client *bbv1.Service, bid BuilderID, status string, limit int, cursor string) ([]*bbv1.ApiCommonBuildMessage, string, error) { c, _ = context.WithTimeout(c, bbRPCTimeout) search := client.Search() search.Context(c) search.Bucket(bid.V1Bucket()) search.Status(status) search.Ta...
[ "func", "fetchBuilds", "(", "c", "context", ".", "Context", ",", "client", "*", "bbv1", ".", "Service", ",", "bid", "BuilderID", ",", "status", "string", ",", "limit", "int", ",", "cursor", "string", ")", "(", "[", "]", "*", "bbv1", ".", "ApiCommonBuil...
// fetchBuilds fetches builds given a criteria. // The returned builds are sorted by build creation descending. // count defines maximum number of builds to fetch; if <0, defaults to 100.
[ "fetchBuilds", "fetches", "builds", "given", "a", "criteria", ".", "The", "returned", "builds", "are", "sorted", "by", "build", "creation", "descending", ".", "count", "defines", "maximum", "number", "of", "builds", "to", "fetch", ";", "if", "<0", "defaults", ...
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/milo/buildsource/buildbucket/builder.go#L75-L98
7,528
luci/luci-go
milo/buildsource/buildbucket/builder.go
ensureDefined
func ensureDefined(c context.Context, host string, bid BuilderID) error { client, err := newSwarmbucketClient(c, host) if err != nil { return err } getBuilders := client.GetBuilders() getBuilders.Bucket(bid.V1Bucket()) getBuilders.Fields(googleapi.Field("buckets/(builders/name,name)")) res, err := getBuilders....
go
func ensureDefined(c context.Context, host string, bid BuilderID) error { client, err := newSwarmbucketClient(c, host) if err != nil { return err } getBuilders := client.GetBuilders() getBuilders.Bucket(bid.V1Bucket()) getBuilders.Fields(googleapi.Field("buckets/(builders/name,name)")) res, err := getBuilders....
[ "func", "ensureDefined", "(", "c", "context", ".", "Context", ",", "host", "string", ",", "bid", "BuilderID", ")", "error", "{", "client", ",", "err", ":=", "newSwarmbucketClient", "(", "c", ",", "host", ")", "\n", "if", "err", "!=", "nil", "{", "retur...
// ensureDefined returns grpcutil.NotFoundTag tagged error if a builder is not // defined in its swarmbucket.
[ "ensureDefined", "returns", "grpcutil", ".", "NotFoundTag", "tagged", "error", "if", "a", "builder", "is", "not", "defined", "in", "its", "swarmbucket", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/milo/buildsource/buildbucket/builder.go#L102-L126
7,529
luci/luci-go
milo/buildsource/buildbucket/builder.go
backCursor
func backCursor(c context.Context, bid BuilderID, limit int, thisCursor, nextCursor string) string { memcacheKey := func(cursor string) string { key := fmt.Sprintf("%s:%d:%s", bid.String(), limit, cursor) blob := sha1.Sum([]byte(key)) encoded := base64.StdEncoding.EncodeToString(blob[:]) return "cursors:buildb...
go
func backCursor(c context.Context, bid BuilderID, limit int, thisCursor, nextCursor string) string { memcacheKey := func(cursor string) string { key := fmt.Sprintf("%s:%d:%s", bid.String(), limit, cursor) blob := sha1.Sum([]byte(key)) encoded := base64.StdEncoding.EncodeToString(blob[:]) return "cursors:buildb...
[ "func", "backCursor", "(", "c", "context", ".", "Context", ",", "bid", "BuilderID", ",", "limit", "int", ",", "thisCursor", ",", "nextCursor", "string", ")", "string", "{", "memcacheKey", ":=", "func", "(", "cursor", "string", ")", "string", "{", "key", ...
// backCursor implements bidirectional cursors with forward-only datastore // cursors by storing a map for cursor -> prevCursor in memcache. // backCursor returns a previous cursor given thisCursor, and caches thisCursor // to be the previous cursor of nextCursor.
[ "backCursor", "implements", "bidirectional", "cursors", "with", "forward", "-", "only", "datastore", "cursors", "by", "storing", "a", "map", "for", "cursor", "-", ">", "prevCursor", "in", "memcache", ".", "backCursor", "returns", "a", "previous", "cursor", "give...
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/milo/buildsource/buildbucket/builder.go#L181-L206
7,530
luci/luci-go
milo/buildsource/buildbucket/builder.go
toMiloBuildsSummaries
func toMiloBuildsSummaries(c context.Context, msgs []*bbv1.ApiCommonBuildMessage) []*ui.BuildSummary { result := make([]*ui.BuildSummary, len(msgs)) // For each build, toMiloBuild may query Gerrit to fetch associated CL's // author email. Unfortunately, as of June 2018 Gerrit is often taking >5s to // report back. ...
go
func toMiloBuildsSummaries(c context.Context, msgs []*bbv1.ApiCommonBuildMessage) []*ui.BuildSummary { result := make([]*ui.BuildSummary, len(msgs)) // For each build, toMiloBuild may query Gerrit to fetch associated CL's // author email. Unfortunately, as of June 2018 Gerrit is often taking >5s to // report back. ...
[ "func", "toMiloBuildsSummaries", "(", "c", "context", ".", "Context", ",", "msgs", "[", "]", "*", "bbv1", ".", "ApiCommonBuildMessage", ")", "[", "]", "*", "ui", ".", "BuildSummary", "{", "result", ":=", "make", "(", "[", "]", "*", "ui", ".", "BuildSum...
// toMiloBuildsSummaries computes summary for each build in parallel.
[ "toMiloBuildsSummaries", "computes", "summary", "for", "each", "build", "in", "parallel", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/milo/buildsource/buildbucket/builder.go#L209-L242
7,531
luci/luci-go
milo/buildsource/buildbucket/builder.go
GetBuilder
func GetBuilder(c context.Context, bid BuilderID, limit int, cursor string) (*ui.Builder, error) { host, err := getHost(c) if err != nil { return nil, err } if limit < 0 { limit = 20 } result := &ui.Builder{ Name: bid.Builder, } if host == "debug" { return result, getDebugBuilds(c, bid, limit, result)...
go
func GetBuilder(c context.Context, bid BuilderID, limit int, cursor string) (*ui.Builder, error) { host, err := getHost(c) if err != nil { return nil, err } if limit < 0 { limit = 20 } result := &ui.Builder{ Name: bid.Builder, } if host == "debug" { return result, getDebugBuilds(c, bid, limit, result)...
[ "func", "GetBuilder", "(", "c", "context", ".", "Context", ",", "bid", "BuilderID", ",", "limit", "int", ",", "cursor", "string", ")", "(", "*", "ui", ".", "Builder", ",", "error", ")", "{", "host", ",", "err", ":=", "getHost", "(", "c", ")", "\n",...
// GetBuilder is used by buildsource.BuilderID.Get to obtain the resp.Builder.
[ "GetBuilder", "is", "used", "by", "buildsource", ".", "BuilderID", ".", "Get", "to", "obtain", "the", "resp", ".", "Builder", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/milo/buildsource/buildbucket/builder.go#L245-L297
7,532
luci/luci-go
gce/api/config/v1/config.go
Validate
func (cfg *Config) Validate(c *validation.Context) { c.Enter("amount") cfg.GetAmount().Validate(c) c.Exit() c.Enter("attributes") cfg.GetAttributes().Validate(c) c.Exit() c.Enter("lifetime") cfg.GetLifetime().Validate(c) switch n, err := cfg.Lifetime.ToSeconds(); { case err != nil: c.Errorf("%s", err) case...
go
func (cfg *Config) Validate(c *validation.Context) { c.Enter("amount") cfg.GetAmount().Validate(c) c.Exit() c.Enter("attributes") cfg.GetAttributes().Validate(c) c.Exit() c.Enter("lifetime") cfg.GetLifetime().Validate(c) switch n, err := cfg.Lifetime.ToSeconds(); { case err != nil: c.Errorf("%s", err) case...
[ "func", "(", "cfg", "*", "Config", ")", "Validate", "(", "c", "*", "validation", ".", "Context", ")", "{", "c", ".", "Enter", "(", "\"", "\"", ")", "\n", "cfg", ".", "GetAmount", "(", ")", ".", "Validate", "(", "c", ")", "\n", "c", ".", "Exit",...
// Validate validates this config. Kind must already be applied.
[ "Validate", "validates", "this", "config", ".", "Kind", "must", "already", "be", "applied", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/gce/api/config/v1/config.go#L41-L66
7,533
luci/luci-go
appengine/gaeauth/server/oauth.go
GetUserCredentials
func (m *OAuth2Method) GetUserCredentials(c context.Context, r *http.Request) (*oauth2.Token, error) { chunks := strings.SplitN(r.Header.Get("Authorization"), " ", 2) if len(chunks) != 2 || (chunks[0] != "OAuth" && chunks[0] != "Bearer") { return nil, errBadAuthHeader } return &oauth2.Token{ AccessToken: chunks...
go
func (m *OAuth2Method) GetUserCredentials(c context.Context, r *http.Request) (*oauth2.Token, error) { chunks := strings.SplitN(r.Header.Get("Authorization"), " ", 2) if len(chunks) != 2 || (chunks[0] != "OAuth" && chunks[0] != "Bearer") { return nil, errBadAuthHeader } return &oauth2.Token{ AccessToken: chunks...
[ "func", "(", "m", "*", "OAuth2Method", ")", "GetUserCredentials", "(", "c", "context", ".", "Context", ",", "r", "*", "http", ".", "Request", ")", "(", "*", "oauth2", ".", "Token", ",", "error", ")", "{", "chunks", ":=", "strings", ".", "SplitN", "("...
// GetUserCredentials implements auth.UserCredentialsGetter.
[ "GetUserCredentials", "implements", "auth", ".", "UserCredentialsGetter", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/appengine/gaeauth/server/oauth.go#L99-L108
7,534
luci/luci-go
logdog/client/butlerlib/streamclient/stream.go
WriteDatagram
func (s *BaseStream) WriteDatagram(dg []byte) error { if !s.isDatagramStream() { return errors.New("not a datagram stream") } return s.writeRecord(dg) }
go
func (s *BaseStream) WriteDatagram(dg []byte) error { if !s.isDatagramStream() { return errors.New("not a datagram stream") } return s.writeRecord(dg) }
[ "func", "(", "s", "*", "BaseStream", ")", "WriteDatagram", "(", "dg", "[", "]", "byte", ")", "error", "{", "if", "!", "s", ".", "isDatagramStream", "(", ")", "{", "return", "errors", ".", "New", "(", "\"", "\"", ")", "\n", "}", "\n\n", "return", ...
// WriteDatagram implements StreamClient.
[ "WriteDatagram", "implements", "StreamClient", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/logdog/client/butlerlib/streamclient/stream.go#L54-L60
7,535
luci/luci-go
logdog/client/butlerlib/streamclient/stream.go
Write
func (s *BaseStream) Write(data []byte) (int, error) { if s.isDatagramStream() { return 0, errors.New("cannot use Write with datagram stream") } return s.writeRaw(data) }
go
func (s *BaseStream) Write(data []byte) (int, error) { if s.isDatagramStream() { return 0, errors.New("cannot use Write with datagram stream") } return s.writeRaw(data) }
[ "func", "(", "s", "*", "BaseStream", ")", "Write", "(", "data", "[", "]", "byte", ")", "(", "int", ",", "error", ")", "{", "if", "s", ".", "isDatagramStream", "(", ")", "{", "return", "0", ",", "errors", ".", "New", "(", "\"", "\"", ")", "\n", ...
// Write implements StreamClient.
[ "Write", "implements", "StreamClient", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/logdog/client/butlerlib/streamclient/stream.go#L63-L69
7,536
luci/luci-go
common/logging/memlogger/memory.go
Debugf
func (m *MemLogger) Debugf(format string, args ...interface{}) { m.LogCall(logging.Debug, 1, format, args) }
go
func (m *MemLogger) Debugf(format string, args ...interface{}) { m.LogCall(logging.Debug, 1, format, args) }
[ "func", "(", "m", "*", "MemLogger", ")", "Debugf", "(", "format", "string", ",", "args", "...", "interface", "{", "}", ")", "{", "m", ".", "LogCall", "(", "logging", ".", "Debug", ",", "1", ",", "format", ",", "args", ")", "\n", "}" ]
// Debugf implements the logging.Logger interface.
[ "Debugf", "implements", "the", "logging", ".", "Logger", "interface", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/common/logging/memlogger/memory.go#L48-L50
7,537
luci/luci-go
common/logging/memlogger/memory.go
Infof
func (m *MemLogger) Infof(format string, args ...interface{}) { m.LogCall(logging.Info, 1, format, args) }
go
func (m *MemLogger) Infof(format string, args ...interface{}) { m.LogCall(logging.Info, 1, format, args) }
[ "func", "(", "m", "*", "MemLogger", ")", "Infof", "(", "format", "string", ",", "args", "...", "interface", "{", "}", ")", "{", "m", ".", "LogCall", "(", "logging", ".", "Info", ",", "1", ",", "format", ",", "args", ")", "\n", "}" ]
// Infof implements the logging.Logger interface.
[ "Infof", "implements", "the", "logging", ".", "Logger", "interface", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/common/logging/memlogger/memory.go#L53-L55
7,538
luci/luci-go
common/logging/memlogger/memory.go
Warningf
func (m *MemLogger) Warningf(format string, args ...interface{}) { m.LogCall(logging.Warning, 1, format, args) }
go
func (m *MemLogger) Warningf(format string, args ...interface{}) { m.LogCall(logging.Warning, 1, format, args) }
[ "func", "(", "m", "*", "MemLogger", ")", "Warningf", "(", "format", "string", ",", "args", "...", "interface", "{", "}", ")", "{", "m", ".", "LogCall", "(", "logging", ".", "Warning", ",", "1", ",", "format", ",", "args", ")", "\n", "}" ]
// Warningf implements the logging.Logger interface.
[ "Warningf", "implements", "the", "logging", ".", "Logger", "interface", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/common/logging/memlogger/memory.go#L58-L60
7,539
luci/luci-go
common/logging/memlogger/memory.go
Errorf
func (m *MemLogger) Errorf(format string, args ...interface{}) { m.LogCall(logging.Error, 1, format, args) }
go
func (m *MemLogger) Errorf(format string, args ...interface{}) { m.LogCall(logging.Error, 1, format, args) }
[ "func", "(", "m", "*", "MemLogger", ")", "Errorf", "(", "format", "string", ",", "args", "...", "interface", "{", "}", ")", "{", "m", ".", "LogCall", "(", "logging", ".", "Error", ",", "1", ",", "format", ",", "args", ")", "\n", "}" ]
// Errorf implements the logging.Logger interface.
[ "Errorf", "implements", "the", "logging", ".", "Logger", "interface", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/common/logging/memlogger/memory.go#L63-L65
7,540
luci/luci-go
common/logging/memlogger/memory.go
LogCall
func (m *MemLogger) LogCall(lvl logging.Level, calldepth int, format string, args []interface{}) { if m.lock != nil { m.lock.Lock() defer m.lock.Unlock() } if m.data == nil { m.data = new([]LogEntry) } *m.data = append(*m.data, LogEntry{lvl, fmt.Sprintf(format, args...), m.fields, calldepth + 1}) }
go
func (m *MemLogger) LogCall(lvl logging.Level, calldepth int, format string, args []interface{}) { if m.lock != nil { m.lock.Lock() defer m.lock.Unlock() } if m.data == nil { m.data = new([]LogEntry) } *m.data = append(*m.data, LogEntry{lvl, fmt.Sprintf(format, args...), m.fields, calldepth + 1}) }
[ "func", "(", "m", "*", "MemLogger", ")", "LogCall", "(", "lvl", "logging", ".", "Level", ",", "calldepth", "int", ",", "format", "string", ",", "args", "[", "]", "interface", "{", "}", ")", "{", "if", "m", ".", "lock", "!=", "nil", "{", "m", ".",...
// LogCall implements the logging.Logger interface.
[ "LogCall", "implements", "the", "logging", ".", "Logger", "interface", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/common/logging/memlogger/memory.go#L68-L77
7,541
luci/luci-go
common/logging/memlogger/memory.go
Messages
func (m *MemLogger) Messages() []LogEntry { if m.lock != nil { m.lock.Lock() defer m.lock.Unlock() } if m.data == nil || len(*m.data) == 0 { return nil } ret := make([]LogEntry, len(*m.data)) copy(ret, *m.data) return ret }
go
func (m *MemLogger) Messages() []LogEntry { if m.lock != nil { m.lock.Lock() defer m.lock.Unlock() } if m.data == nil || len(*m.data) == 0 { return nil } ret := make([]LogEntry, len(*m.data)) copy(ret, *m.data) return ret }
[ "func", "(", "m", "*", "MemLogger", ")", "Messages", "(", ")", "[", "]", "LogEntry", "{", "if", "m", ".", "lock", "!=", "nil", "{", "m", ".", "lock", ".", "Lock", "(", ")", "\n", "defer", "m", ".", "lock", ".", "Unlock", "(", ")", "\n", "}", ...
// Messages returns all of the log messages that this memory logger has // recorded.
[ "Messages", "returns", "all", "of", "the", "log", "messages", "that", "this", "memory", "logger", "has", "recorded", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/common/logging/memlogger/memory.go#L81-L92
7,542
luci/luci-go
common/logging/memlogger/memory.go
Reset
func (m *MemLogger) Reset() { if m.lock != nil { m.lock.Lock() defer m.lock.Unlock() } if m.data != nil { *m.data = nil } }
go
func (m *MemLogger) Reset() { if m.lock != nil { m.lock.Lock() defer m.lock.Unlock() } if m.data != nil { *m.data = nil } }
[ "func", "(", "m", "*", "MemLogger", ")", "Reset", "(", ")", "{", "if", "m", ".", "lock", "!=", "nil", "{", "m", ".", "lock", ".", "Lock", "(", ")", "\n", "defer", "m", ".", "lock", ".", "Unlock", "(", ")", "\n", "}", "\n", "if", "m", ".", ...
// Reset resets the logged messages recorded so far.
[ "Reset", "resets", "the", "logged", "messages", "recorded", "so", "far", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/common/logging/memlogger/memory.go#L95-L103
7,543
luci/luci-go
common/logging/memlogger/memory.go
GetFunc
func (m *MemLogger) GetFunc(f func(*LogEntry) bool) *LogEntry { if m.lock != nil { m.lock.Lock() defer m.lock.Unlock() } if m.data == nil { return nil } for _, ent := range *m.data { if f(&ent) { clone := ent return &clone } } return nil }
go
func (m *MemLogger) GetFunc(f func(*LogEntry) bool) *LogEntry { if m.lock != nil { m.lock.Lock() defer m.lock.Unlock() } if m.data == nil { return nil } for _, ent := range *m.data { if f(&ent) { clone := ent return &clone } } return nil }
[ "func", "(", "m", "*", "MemLogger", ")", "GetFunc", "(", "f", "func", "(", "*", "LogEntry", ")", "bool", ")", "*", "LogEntry", "{", "if", "m", ".", "lock", "!=", "nil", "{", "m", ".", "lock", ".", "Lock", "(", ")", "\n", "defer", "m", ".", "l...
// GetFunc returns the first matching log entry.
[ "GetFunc", "returns", "the", "first", "matching", "log", "entry", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/common/logging/memlogger/memory.go#L106-L121
7,544
luci/luci-go
common/logging/memlogger/memory.go
Get
func (m *MemLogger) Get(lvl logging.Level, msg string, data map[string]interface{}) *LogEntry { return m.GetFunc(func(ent *LogEntry) bool { return ent.Level == lvl && ent.Msg == msg && reflect.DeepEqual(data, ent.Data) }) }
go
func (m *MemLogger) Get(lvl logging.Level, msg string, data map[string]interface{}) *LogEntry { return m.GetFunc(func(ent *LogEntry) bool { return ent.Level == lvl && ent.Msg == msg && reflect.DeepEqual(data, ent.Data) }) }
[ "func", "(", "m", "*", "MemLogger", ")", "Get", "(", "lvl", "logging", ".", "Level", ",", "msg", "string", ",", "data", "map", "[", "string", "]", "interface", "{", "}", ")", "*", "LogEntry", "{", "return", "m", ".", "GetFunc", "(", "func", "(", ...
// Get returns the first matching log entry. // Note that lvl, msg and data have to match the entry precisely.
[ "Get", "returns", "the", "first", "matching", "log", "entry", ".", "Note", "that", "lvl", "msg", "and", "data", "have", "to", "match", "the", "entry", "precisely", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/common/logging/memlogger/memory.go#L125-L129
7,545
luci/luci-go
common/logging/memlogger/memory.go
HasFunc
func (m *MemLogger) HasFunc(f func(*LogEntry) bool) bool { return m.GetFunc(f) != nil }
go
func (m *MemLogger) HasFunc(f func(*LogEntry) bool) bool { return m.GetFunc(f) != nil }
[ "func", "(", "m", "*", "MemLogger", ")", "HasFunc", "(", "f", "func", "(", "*", "LogEntry", ")", "bool", ")", "bool", "{", "return", "m", ".", "GetFunc", "(", "f", ")", "!=", "nil", "\n", "}" ]
// HasFunc returns true iff the MemLogger contains a matching log message.
[ "HasFunc", "returns", "true", "iff", "the", "MemLogger", "contains", "a", "matching", "log", "message", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/common/logging/memlogger/memory.go#L132-L134
7,546
luci/luci-go
common/logging/memlogger/memory.go
Has
func (m *MemLogger) Has(lvl logging.Level, msg string, data map[string]interface{}) bool { return m.Get(lvl, msg, data) != nil }
go
func (m *MemLogger) Has(lvl logging.Level, msg string, data map[string]interface{}) bool { return m.Get(lvl, msg, data) != nil }
[ "func", "(", "m", "*", "MemLogger", ")", "Has", "(", "lvl", "logging", ".", "Level", ",", "msg", "string", ",", "data", "map", "[", "string", "]", "interface", "{", "}", ")", "bool", "{", "return", "m", ".", "Get", "(", "lvl", ",", "msg", ",", ...
// Has returns true iff the MemLogger contains the specified log message. // Note that lvl, msg and data have to match the entry precisely.
[ "Has", "returns", "true", "iff", "the", "MemLogger", "contains", "the", "specified", "log", "message", ".", "Note", "that", "lvl", "msg", "and", "data", "have", "to", "match", "the", "entry", "precisely", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/common/logging/memlogger/memory.go#L138-L140
7,547
luci/luci-go
common/logging/memlogger/memory.go
Dump
func (m *MemLogger) Dump(w io.Writer) (n int, err error) { amt := 0 for i, msg := range m.Messages() { if i == 0 { amt, err = fmt.Fprintf(w, "\nDUMP LOG:\n") n += amt if err != nil { return } } if msg.Data == nil { amt, err = fmt.Fprintf(w, " %s: %s\n", msg.Level, msg.Msg) n += amt if ...
go
func (m *MemLogger) Dump(w io.Writer) (n int, err error) { amt := 0 for i, msg := range m.Messages() { if i == 0 { amt, err = fmt.Fprintf(w, "\nDUMP LOG:\n") n += amt if err != nil { return } } if msg.Data == nil { amt, err = fmt.Fprintf(w, " %s: %s\n", msg.Level, msg.Msg) n += amt if ...
[ "func", "(", "m", "*", "MemLogger", ")", "Dump", "(", "w", "io", ".", "Writer", ")", "(", "n", "int", ",", "err", "error", ")", "{", "amt", ":=", "0", "\n", "for", "i", ",", "msg", ":=", "range", "m", ".", "Messages", "(", ")", "{", "if", "...
// Dump dumps the current memory logger contents to the given writer in a // human-readable format.
[ "Dump", "dumps", "the", "current", "memory", "logger", "contents", "to", "the", "given", "writer", "in", "a", "human", "-", "readable", "format", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/common/logging/memlogger/memory.go#L144-L169
7,548
luci/luci-go
common/logging/memlogger/memory.go
Dump
func Dump(c context.Context, w io.Writer) (n int, err error) { return logging.Get(c).(*MemLogger).Dump(w) }
go
func Dump(c context.Context, w io.Writer) (n int, err error) { return logging.Get(c).(*MemLogger).Dump(w) }
[ "func", "Dump", "(", "c", "context", ".", "Context", ",", "w", "io", ".", "Writer", ")", "(", "n", "int", ",", "err", "error", ")", "{", "return", "logging", ".", "Get", "(", "c", ")", ".", "(", "*", "MemLogger", ")", ".", "Dump", "(", "w", "...
// Dump is a convenience function to dump the current contents of the memory // logger to the writer. // // This will panic if the current logger is not a memory logger.
[ "Dump", "is", "a", "convenience", "function", "to", "dump", "the", "current", "contents", "of", "the", "memory", "logger", "to", "the", "writer", ".", "This", "will", "panic", "if", "the", "current", "logger", "is", "not", "a", "memory", "logger", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/common/logging/memlogger/memory.go#L193-L195
7,549
luci/luci-go
common/logging/memlogger/memory.go
MustDumpStdout
func MustDumpStdout(c context.Context) { _, err := logging.Get(c).(*MemLogger).Dump(os.Stdout) if err != nil { panic(err) } }
go
func MustDumpStdout(c context.Context) { _, err := logging.Get(c).(*MemLogger).Dump(os.Stdout) if err != nil { panic(err) } }
[ "func", "MustDumpStdout", "(", "c", "context", ".", "Context", ")", "{", "_", ",", "err", ":=", "logging", ".", "Get", "(", "c", ")", ".", "(", "*", "MemLogger", ")", ".", "Dump", "(", "os", ".", "Stdout", ")", "\n", "if", "err", "!=", "nil", "...
// MustDumpStdout is a convenience function to dump the current contents of the // memory logger to stdout. // // This will panic if the current logger is not a memory logger.
[ "MustDumpStdout", "is", "a", "convenience", "function", "to", "dump", "the", "current", "contents", "of", "the", "memory", "logger", "to", "stdout", ".", "This", "will", "panic", "if", "the", "current", "logger", "is", "not", "a", "memory", "logger", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/common/logging/memlogger/memory.go#L201-L206
7,550
luci/luci-go
mp/cmd/mpagent/agent_windows.go
configureAutoMount
func (WindowsStrategy) configureAutoMount(ctx context.Context, disk string) error { // TODO(smut): Mount the specified disk. return errors.New("mounting disks is unsupported on Windows") }
go
func (WindowsStrategy) configureAutoMount(ctx context.Context, disk string) error { // TODO(smut): Mount the specified disk. return errors.New("mounting disks is unsupported on Windows") }
[ "func", "(", "WindowsStrategy", ")", "configureAutoMount", "(", "ctx", "context", ".", "Context", ",", "disk", "string", ")", "error", "{", "// TODO(smut): Mount the specified disk.", "return", "errors", ".", "New", "(", "\"", "\"", ")", "\n", "}" ]
// configureAutoMount mounts the specified disk and configures mount on startup. // // Assumes the disk is already formatted as ntfs.
[ "configureAutoMount", "mounts", "the", "specified", "disk", "and", "configures", "mount", "on", "startup", ".", "Assumes", "the", "disk", "is", "already", "formatted", "as", "ntfs", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/mp/cmd/mpagent/agent_windows.go#L43-L46
7,551
luci/luci-go
mp/cmd/mpagent/agent_windows.go
getAgent
func getAgent(ctx context.Context) (*Agent, error) { agent := Agent{ agentAutoStartPath: "C:\\Users\\{{.User}}\\Start Menu\\Programs\\Startup\\machine-provider-agent.bat", agentAutoStartTemplate: "machine-provider-agent.bat.tmpl", logsDir: "C:\\logs", swarmingAutoStartPath: "C:\...
go
func getAgent(ctx context.Context) (*Agent, error) { agent := Agent{ agentAutoStartPath: "C:\\Users\\{{.User}}\\Start Menu\\Programs\\Startup\\machine-provider-agent.bat", agentAutoStartTemplate: "machine-provider-agent.bat.tmpl", logsDir: "C:\\logs", swarmingAutoStartPath: "C:\...
[ "func", "getAgent", "(", "ctx", "context", ".", "Context", ")", "(", "*", "Agent", ",", "error", ")", "{", "agent", ":=", "Agent", "{", "agentAutoStartPath", ":", "\"", "\\\\", "\\\\", "\\\\", "\\\\", "\\\\", "\\\\", "\"", ",", "agentAutoStartTemplate", ...
// getAgent returns an agent which runs on Windows.
[ "getAgent", "returns", "an", "agent", "which", "runs", "on", "Windows", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/mp/cmd/mpagent/agent_windows.go#L72-L84
7,552
luci/luci-go
auth/internal/user.go
NewUserAuthTokenProvider
func NewUserAuthTokenProvider(ctx context.Context, clientID, clientSecret string, scopes []string) (TokenProvider, error) { return &userAuthTokenProvider{ config: &oauth2.Config{ ClientID: clientID, ClientSecret: clientSecret, Endpoint: oauth2.Endpoint{ AuthURL: "https://accounts.google.com/o/oauth...
go
func NewUserAuthTokenProvider(ctx context.Context, clientID, clientSecret string, scopes []string) (TokenProvider, error) { return &userAuthTokenProvider{ config: &oauth2.Config{ ClientID: clientID, ClientSecret: clientSecret, Endpoint: oauth2.Endpoint{ AuthURL: "https://accounts.google.com/o/oauth...
[ "func", "NewUserAuthTokenProvider", "(", "ctx", "context", ".", "Context", ",", "clientID", ",", "clientSecret", "string", ",", "scopes", "[", "]", "string", ")", "(", "TokenProvider", ",", "error", ")", "{", "return", "&", "userAuthTokenProvider", "{", "confi...
// NewUserAuthTokenProvider returns TokenProvider that can perform 3-legged // OAuth flow involving interaction with a user.
[ "NewUserAuthTokenProvider", "returns", "TokenProvider", "that", "can", "perform", "3", "-", "legged", "OAuth", "flow", "involving", "interaction", "with", "a", "user", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/auth/internal/user.go#L36-L53
7,553
luci/luci-go
logdog/appengine/coordinator/endpoints/context.go
WithServices
func WithServices(c context.Context, s Services) context.Context { return context.WithValue(c, &servicesKey, s) }
go
func WithServices(c context.Context, s Services) context.Context { return context.WithValue(c, &servicesKey, s) }
[ "func", "WithServices", "(", "c", "context", ".", "Context", ",", "s", "Services", ")", "context", ".", "Context", "{", "return", "context", ".", "WithValue", "(", "c", ",", "&", "servicesKey", ",", "s", ")", "\n", "}" ]
// WithServices installs the supplied Services instance into a Context.
[ "WithServices", "installs", "the", "supplied", "Services", "instance", "into", "a", "Context", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/logdog/appengine/coordinator/endpoints/context.go#L22-L24
7,554
luci/luci-go
common/system/filesystem/tempdir.go
With
func (td *TempDir) With(fn func(string) error) error { tdir, err := ioutil.TempDir(td.Dir, td.Prefix) if err != nil { return err } defer func() { if rmErr := RemoveAll(tdir); rmErr != nil { if cef := td.CleanupErrFunc; cef != nil { cef(tdir, rmErr) } } }() return fn(tdir) }
go
func (td *TempDir) With(fn func(string) error) error { tdir, err := ioutil.TempDir(td.Dir, td.Prefix) if err != nil { return err } defer func() { if rmErr := RemoveAll(tdir); rmErr != nil { if cef := td.CleanupErrFunc; cef != nil { cef(tdir, rmErr) } } }() return fn(tdir) }
[ "func", "(", "td", "*", "TempDir", ")", "With", "(", "fn", "func", "(", "string", ")", "error", ")", "error", "{", "tdir", ",", "err", ":=", "ioutil", ".", "TempDir", "(", "td", ".", "Dir", ",", "td", ".", "Prefix", ")", "\n", "if", "err", "!="...
// With creates a temporary directory and passes it to fn. After fn exits, the // directory and all of its contents is deleted. // // Any error that happens during setup or execution of the callback is returned. // If an error occurs during cleanup, the optional CleanupErrFunc will be // called.
[ "With", "creates", "a", "temporary", "directory", "and", "passes", "it", "to", "fn", ".", "After", "fn", "exits", "the", "directory", "and", "all", "of", "its", "contents", "is", "deleted", ".", "Any", "error", "that", "happens", "during", "setup", "or", ...
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/common/system/filesystem/tempdir.go#L43-L56
7,555
luci/luci-go
cipd/appengine/impl/admin/mappers.go
initMapper
func initMapper(d mapperDef) { if _, ok := mappers[d.Kind]; ok { panic(fmt.Sprintf("mapper with kind %s has already been initialized", d.Kind)) } mappers[d.Kind] = &d }
go
func initMapper(d mapperDef) { if _, ok := mappers[d.Kind]; ok { panic(fmt.Sprintf("mapper with kind %s has already been initialized", d.Kind)) } mappers[d.Kind] = &d }
[ "func", "initMapper", "(", "d", "mapperDef", ")", "{", "if", "_", ",", "ok", ":=", "mappers", "[", "d", ".", "Kind", "]", ";", "ok", "{", "panic", "(", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "d", ".", "Kind", ")", ")", "\n", "}", "\n", ...
// initMapper is called during init time to register some mapper kind.
[ "initMapper", "is", "called", "during", "init", "time", "to", "register", "some", "mapper", "kind", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/cipd/appengine/impl/admin/mappers.go#L36-L41
7,556
luci/luci-go
cipd/appengine/impl/admin/mappers.go
newMapper
func (m *mapperDef) newMapper(c context.Context, j *mapper.Job, shardIdx int) (mapper.Mapper, error) { cfg := &api.JobConfig{} if err := proto.Unmarshal(j.Config.Params, cfg); err != nil { return nil, errors.Annotate(err, "failed to unmarshal JobConfig").Err() } return func(c context.Context, keys []*datastore.Ke...
go
func (m *mapperDef) newMapper(c context.Context, j *mapper.Job, shardIdx int) (mapper.Mapper, error) { cfg := &api.JobConfig{} if err := proto.Unmarshal(j.Config.Params, cfg); err != nil { return nil, errors.Annotate(err, "failed to unmarshal JobConfig").Err() } return func(c context.Context, keys []*datastore.Ke...
[ "func", "(", "m", "*", "mapperDef", ")", "newMapper", "(", "c", "context", ".", "Context", ",", "j", "*", "mapper", ".", "Job", ",", "shardIdx", "int", ")", "(", "mapper", ".", "Mapper", ",", "error", ")", "{", "cfg", ":=", "&", "api", ".", "JobC...
// newMapper creates new instance of a mapping function.
[ "newMapper", "creates", "new", "instance", "of", "a", "mapping", "function", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/cipd/appengine/impl/admin/mappers.go#L59-L67
7,557
luci/luci-go
logdog/common/storage/bigtable/bigtable.go
getReadItem
func getReadItem(row bigtable.Row, family, column string) *bigtable.ReadItem { // Get the row for our family. items, ok := row[logColumnFamily] if !ok { return nil } // Get the specific ReadItem for our column colName := fmt.Sprintf("%s:%s", family, column) for _, item := range items { if item.Column == col...
go
func getReadItem(row bigtable.Row, family, column string) *bigtable.ReadItem { // Get the row for our family. items, ok := row[logColumnFamily] if !ok { return nil } // Get the specific ReadItem for our column colName := fmt.Sprintf("%s:%s", family, column) for _, item := range items { if item.Column == col...
[ "func", "getReadItem", "(", "row", "bigtable", ".", "Row", ",", "family", ",", "column", "string", ")", "*", "bigtable", ".", "ReadItem", "{", "// Get the row for our family.", "items", ",", "ok", ":=", "row", "[", "logColumnFamily", "]", "\n", "if", "!", ...
// getReadItem retrieves a specific RowItem from the supplied Row.
[ "getReadItem", "retrieves", "a", "specific", "RowItem", "from", "the", "supplied", "Row", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/logdog/common/storage/bigtable/bigtable.go#L209-L224
7,558
luci/luci-go
scheduler/appengine/task/urlfetch/urlfetch.go
isTextContent
func isTextContent(h http.Header) bool { for _, header := range h["Content-Type"] { for _, good := range textContentTypes { if strings.HasPrefix(header, good) { return true } } } return false }
go
func isTextContent(h http.Header) bool { for _, header := range h["Content-Type"] { for _, good := range textContentTypes { if strings.HasPrefix(header, good) { return true } } } return false }
[ "func", "isTextContent", "(", "h", "http", ".", "Header", ")", "bool", "{", "for", "_", ",", "header", ":=", "range", "h", "[", "\"", "\"", "]", "{", "for", "_", ",", "good", ":=", "range", "textContentTypes", "{", "if", "strings", ".", "HasPrefix", ...
// isTextContent returns True if Content-Type header corresponds to some // readable text type.
[ "isTextContent", "returns", "True", "if", "Content", "-", "Type", "header", "corresponds", "to", "some", "readable", "text", "type", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/scheduler/appengine/task/urlfetch/urlfetch.go#L240-L249
7,559
luci/luci-go
vpython/venv/config.go
WithoutWheels
func (cfg *Config) WithoutWheels() *Config { if !cfg.HasWheels() { return cfg } clone := *cfg clone.OverrideName = "" clone.Spec = clone.Spec.Clone() clone.Spec.Wheel = nil return &clone }
go
func (cfg *Config) WithoutWheels() *Config { if !cfg.HasWheels() { return cfg } clone := *cfg clone.OverrideName = "" clone.Spec = clone.Spec.Clone() clone.Spec.Wheel = nil return &clone }
[ "func", "(", "cfg", "*", "Config", ")", "WithoutWheels", "(", ")", "*", "Config", "{", "if", "!", "cfg", ".", "HasWheels", "(", ")", "{", "return", "cfg", "\n", "}", "\n\n", "clone", ":=", "*", "cfg", "\n", "clone", ".", "OverrideName", "=", "\"", ...
// WithoutWheels returns a clone of cfg that depends on no additional packages. // // If cfg is already an empty it will be returned directly.
[ "WithoutWheels", "returns", "a", "clone", "of", "cfg", "that", "depends", "on", "no", "additional", "packages", ".", "If", "cfg", "is", "already", "an", "empty", "it", "will", "be", "returned", "directly", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/vpython/venv/config.go#L127-L137
7,560
luci/luci-go
vpython/venv/config.go
HasWheels
func (cfg *Config) HasWheels() bool { return cfg.Spec != nil && len(cfg.Spec.Wheel) > 0 }
go
func (cfg *Config) HasWheels() bool { return cfg.Spec != nil && len(cfg.Spec.Wheel) > 0 }
[ "func", "(", "cfg", "*", "Config", ")", "HasWheels", "(", ")", "bool", "{", "return", "cfg", ".", "Spec", "!=", "nil", "&&", "len", "(", "cfg", ".", "Spec", ".", "Wheel", ")", ">", "0", "\n", "}" ]
// HasWheels returns true if this environment declares wheel dependencies.
[ "HasWheels", "returns", "true", "if", "this", "environment", "declares", "wheel", "dependencies", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/vpython/venv/config.go#L140-L142
7,561
luci/luci-go
vpython/venv/config.go
makeEnv
func (cfg *Config) makeEnv(c context.Context, e *vpython.Environment) (*Env, error) { // We MUST have a package loader. if cfg.Loader == nil { return nil, errors.New("no package loader provided") } // Resolve our base directory, if one is not supplied. if cfg.BaseDir == "" { // Use one in a temporary director...
go
func (cfg *Config) makeEnv(c context.Context, e *vpython.Environment) (*Env, error) { // We MUST have a package loader. if cfg.Loader == nil { return nil, errors.New("no package loader provided") } // Resolve our base directory, if one is not supplied. if cfg.BaseDir == "" { // Use one in a temporary director...
[ "func", "(", "cfg", "*", "Config", ")", "makeEnv", "(", "c", "context", ".", "Context", ",", "e", "*", "vpython", ".", "Environment", ")", "(", "*", "Env", ",", "error", ")", "{", "// We MUST have a package loader.", "if", "cfg", ".", "Loader", "==", "...
// makeEnv processes the config, validating and, where appropriate, populating // any components. Upon success, it returns a configured Env instance. // // The supplied vpython.Environment is derived externally, and may be nil if // this is a bootstrapped Environment. // // The returned Env instance may or may not actu...
[ "makeEnv", "processes", "the", "config", "validating", "and", "where", "appropriate", "populating", "any", "components", ".", "Upon", "success", "it", "returns", "a", "configured", "Env", "instance", ".", "The", "supplied", "vpython", ".", "Environment", "is", "...
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/vpython/venv/config.go#L152-L212
7,562
luci/luci-go
vpython/venv/config.go
envNameForSpec
func (cfg *Config) envNameForSpec(c context.Context, s *vpython.Spec, rt *vpython.Runtime) string { uid := "<unknown>" if user, err := user.Current(); err == nil { uid = user.Uid } else { logging.Warningf(c, "Unable to find current user ID: %s", err) } name := spec.Hash(s, rt, EnvironmentVersion, string(ass...
go
func (cfg *Config) envNameForSpec(c context.Context, s *vpython.Spec, rt *vpython.Runtime) string { uid := "<unknown>" if user, err := user.Current(); err == nil { uid = user.Uid } else { logging.Warningf(c, "Unable to find current user ID: %s", err) } name := spec.Hash(s, rt, EnvironmentVersion, string(ass...
[ "func", "(", "cfg", "*", "Config", ")", "envNameForSpec", "(", "c", "context", ".", "Context", ",", "s", "*", "vpython", ".", "Spec", ",", "rt", "*", "vpython", ".", "Runtime", ")", "string", "{", "uid", ":=", "\"", "\"", "\n", "if", "user", ",", ...
// EnvName returns the VirtualEnv environment name for the environment that cfg // describes.
[ "EnvName", "returns", "the", "VirtualEnv", "environment", "name", "for", "the", "environment", "that", "cfg", "describes", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/vpython/venv/config.go#L216-L230
7,563
luci/luci-go
vpython/venv/config.go
Prune
func (cfg *Config) Prune(c context.Context) error { if err := prune(c, cfg, nil); err != nil { return errors.Annotate(err, "").Err() } return nil }
go
func (cfg *Config) Prune(c context.Context) error { if err := prune(c, cfg, nil); err != nil { return errors.Annotate(err, "").Err() } return nil }
[ "func", "(", "cfg", "*", "Config", ")", "Prune", "(", "c", "context", ".", "Context", ")", "error", "{", "if", "err", ":=", "prune", "(", "c", ",", "cfg", ",", "nil", ")", ";", "err", "!=", "nil", "{", "return", "errors", ".", "Annotate", "(", ...
// Prune performs a pruning round on the environment set described by this // Config.
[ "Prune", "performs", "a", "pruning", "round", "on", "the", "environment", "set", "described", "by", "this", "Config", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/vpython/venv/config.go#L234-L239
7,564
luci/luci-go
vpython/venv/config.go
envForName
func (cfg *Config) envForName(name string, e *vpython.Environment) *Env { // Env-specific root directory: <BaseDir>/<name> venvRoot := filepath.Join(cfg.BaseDir, name) binDir := venvBinDir(venvRoot) return &Env{ Config: cfg, Root: venvRoot, Name: name, Python: ...
go
func (cfg *Config) envForName(name string, e *vpython.Environment) *Env { // Env-specific root directory: <BaseDir>/<name> venvRoot := filepath.Join(cfg.BaseDir, name) binDir := venvBinDir(venvRoot) return &Env{ Config: cfg, Root: venvRoot, Name: name, Python: ...
[ "func", "(", "cfg", "*", "Config", ")", "envForName", "(", "name", "string", ",", "e", "*", "vpython", ".", "Environment", ")", "*", "Env", "{", "// Env-specific root directory: <BaseDir>/<name>", "venvRoot", ":=", "filepath", ".", "Join", "(", "cfg", ".", "...
// envForName creates an Env for a named directory. // // The Environment, e, can be nil; however, code paths that require it may not // be called.
[ "envForName", "creates", "an", "Env", "for", "a", "named", "directory", ".", "The", "Environment", "e", "can", "be", "nil", ";", "however", "code", "paths", "that", "require", "it", "may", "not", "be", "called", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/vpython/venv/config.go#L245-L261
7,565
luci/luci-go
vpython/venv/config.go
fillRuntime
func fillRuntime(c context.Context, i *python.Interpreter, r *vpython.Runtime) error { // JSON fields correspond to "vpython.Runtime" fields. const script = `` + `import json, sys;` + `json.dump({` + `'path': sys.executable,` + `'prefix': sys.prefix,` + `}, sys.stdout)` // Probe the runtime information. ...
go
func fillRuntime(c context.Context, i *python.Interpreter, r *vpython.Runtime) error { // JSON fields correspond to "vpython.Runtime" fields. const script = `` + `import json, sys;` + `json.dump({` + `'path': sys.executable,` + `'prefix': sys.prefix,` + `}, sys.stdout)` // Probe the runtime information. ...
[ "func", "fillRuntime", "(", "c", "context", ".", "Context", ",", "i", "*", "python", ".", "Interpreter", ",", "r", "*", "vpython", ".", "Runtime", ")", "error", "{", "// JSON fields correspond to \"vpython.Runtime\" fields.", "const", "script", "=", "``", "+", ...
// fillRuntime returns the runtime information of the specified interpreter. // // Identifying this information requires the interpreter to be run.
[ "fillRuntime", "returns", "the", "runtime", "information", "of", "the", "specified", "interpreter", ".", "Identifying", "this", "information", "requires", "the", "interpreter", "to", "be", "run", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/vpython/venv/config.go#L303-L343
7,566
luci/luci-go
grpc/cmd/cproto/discovery.go
gofmt
func gofmt(blob []byte) ([]byte, error) { out := bytes.Buffer{} cmd := exec.Command("gofmt", "-s") cmd.Stdin = bytes.NewReader(blob) cmd.Stdout = &out cmd.Stderr = os.Stderr if err := cmd.Run(); err != nil { return nil, err } return out.Bytes(), nil }
go
func gofmt(blob []byte) ([]byte, error) { out := bytes.Buffer{} cmd := exec.Command("gofmt", "-s") cmd.Stdin = bytes.NewReader(blob) cmd.Stdout = &out cmd.Stderr = os.Stderr if err := cmd.Run(); err != nil { return nil, err } return out.Bytes(), nil }
[ "func", "gofmt", "(", "blob", "[", "]", "byte", ")", "(", "[", "]", "byte", ",", "error", ")", "{", "out", ":=", "bytes", ".", "Buffer", "{", "}", "\n", "cmd", ":=", "exec", ".", "Command", "(", "\"", "\"", ",", "\"", "\"", ")", "\n", "cmd", ...
// gofmt applies "gofmt -s" to the content of the buffer.
[ "gofmt", "applies", "gofmt", "-", "s", "to", "the", "content", "of", "the", "buffer", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/grpc/cmd/cproto/discovery.go#L143-L153
7,567
luci/luci-go
grpc/cmd/cproto/discovery.go
compress
func compress(data []byte) ([]byte, error) { var buf bytes.Buffer w := gzip.NewWriter(&buf) if _, err := w.Write(data); err != nil { return nil, err } if err := w.Close(); err != nil { return nil, err } return buf.Bytes(), nil }
go
func compress(data []byte) ([]byte, error) { var buf bytes.Buffer w := gzip.NewWriter(&buf) if _, err := w.Write(data); err != nil { return nil, err } if err := w.Close(); err != nil { return nil, err } return buf.Bytes(), nil }
[ "func", "compress", "(", "data", "[", "]", "byte", ")", "(", "[", "]", "byte", ",", "error", ")", "{", "var", "buf", "bytes", ".", "Buffer", "\n", "w", ":=", "gzip", ".", "NewWriter", "(", "&", "buf", ")", "\n", "if", "_", ",", "err", ":=", "...
// compress compresses data with gzip.
[ "compress", "compresses", "data", "with", "gzip", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/grpc/cmd/cproto/discovery.go#L156-L166
7,568
luci/luci-go
tokenserver/cmd/luci_machine_tokend/main.go
calcDigest
func calcDigest(inputs map[string][]byte) string { keys := make([]string, 0, len(inputs)) for k := range inputs { keys = append(keys, k) } sort.Strings(keys) h := sha1.New() for _, k := range keys { v := inputs[k] fmt.Fprintf(h, "%s\n%d\n", k, len(v)) h.Write(v) } blob := h.Sum(nil) return hex.EncodeTo...
go
func calcDigest(inputs map[string][]byte) string { keys := make([]string, 0, len(inputs)) for k := range inputs { keys = append(keys, k) } sort.Strings(keys) h := sha1.New() for _, k := range keys { v := inputs[k] fmt.Fprintf(h, "%s\n%d\n", k, len(v)) h.Write(v) } blob := h.Sum(nil) return hex.EncodeTo...
[ "func", "calcDigest", "(", "inputs", "map", "[", "string", "]", "[", "]", "byte", ")", "string", "{", "keys", ":=", "make", "(", "[", "]", "string", ",", "0", ",", "len", "(", "inputs", ")", ")", "\n", "for", "k", ":=", "range", "inputs", "{", ...
// calcDigest produces a digest of a given map using some stable serialization.
[ "calcDigest", "produces", "a", "digest", "of", "a", "given", "map", "using", "some", "stable", "serialization", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/tokenserver/cmd/luci_machine_tokend/main.go#L314-L328
7,569
luci/luci-go
scheduler/appengine/engine/policy/policy.go
Default
func Default() Func { f, err := New(&defaultPolicy) if err != nil { panic(fmt.Errorf("failed to instantiate default triggering policy - %s", err)) } return f }
go
func Default() Func { f, err := New(&defaultPolicy) if err != nil { panic(fmt.Errorf("failed to instantiate default triggering policy - %s", err)) } return f }
[ "func", "Default", "(", ")", "Func", "{", "f", ",", "err", ":=", "New", "(", "&", "defaultPolicy", ")", "\n", "if", "err", "!=", "nil", "{", "panic", "(", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "err", ")", ")", "\n", "}", "\n", "return", ...
// Default instantiates default triggering policy function. // // Is is used if jobs do not define a triggering policy or it can't be // understood.
[ "Default", "instantiates", "default", "triggering", "policy", "function", ".", "Is", "is", "used", "if", "jobs", "do", "not", "define", "a", "triggering", "policy", "or", "it", "can", "t", "be", "understood", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/scheduler/appengine/engine/policy/policy.go#L106-L112
7,570
luci/luci-go
scheduler/appengine/engine/policy/policy.go
UnmarshalDefinition
func UnmarshalDefinition(b []byte) (*messages.TriggeringPolicy, error) { msg := &messages.TriggeringPolicy{} if len(b) != 0 { if err := proto.Unmarshal(b, msg); err != nil { return nil, errors.Annotate(err, "failed to unmarshal TriggeringPolicy").Err() } } if msg.Kind == 0 { msg.Kind = defaultPolicy.Kind ...
go
func UnmarshalDefinition(b []byte) (*messages.TriggeringPolicy, error) { msg := &messages.TriggeringPolicy{} if len(b) != 0 { if err := proto.Unmarshal(b, msg); err != nil { return nil, errors.Annotate(err, "failed to unmarshal TriggeringPolicy").Err() } } if msg.Kind == 0 { msg.Kind = defaultPolicy.Kind ...
[ "func", "UnmarshalDefinition", "(", "b", "[", "]", "byte", ")", "(", "*", "messages", ".", "TriggeringPolicy", ",", "error", ")", "{", "msg", ":=", "&", "messages", ".", "TriggeringPolicy", "{", "}", "\n", "if", "len", "(", "b", ")", "!=", "0", "{", ...
// UnmarshalDefinition deserializes TriggeringPolicy, filling in defaults.
[ "UnmarshalDefinition", "deserializes", "TriggeringPolicy", "filling", "in", "defaults", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/scheduler/appengine/engine/policy/policy.go#L115-L132
7,571
luci/luci-go
server/templates/loaders.go
readFilesInDir
func readFilesInDir(dir string, out map[string]string) error { _, err := os.Stat(dir) if os.IsNotExist(err) { return nil } return filepath.Walk(dir, func(path string, info os.FileInfo, err error) error { if err != nil || info.IsDir() { return err } body, err := ioutil.ReadFile(path) if err == nil { ...
go
func readFilesInDir(dir string, out map[string]string) error { _, err := os.Stat(dir) if os.IsNotExist(err) { return nil } return filepath.Walk(dir, func(path string, info os.FileInfo, err error) error { if err != nil || info.IsDir() { return err } body, err := ioutil.ReadFile(path) if err == nil { ...
[ "func", "readFilesInDir", "(", "dir", "string", ",", "out", "map", "[", "string", "]", "string", ")", "error", "{", "_", ",", "err", ":=", "os", ".", "Stat", "(", "dir", ")", "\n", "if", "os", ".", "IsNotExist", "(", "err", ")", "{", "return", "n...
// readFilesInDir loads content of files into a map "file path" => content. // // Used only for small HTML templates, and thus it's fine to load them // in memory. // // Does nothing is 'dir' is missing.
[ "readFilesInDir", "loads", "content", "of", "files", "into", "a", "map", "file", "path", "=", ">", "content", ".", "Used", "only", "for", "small", "HTML", "templates", "and", "thus", "it", "s", "fine", "to", "load", "them", "in", "memory", ".", "Does", ...
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/server/templates/loaders.go#L111-L126
7,572
luci/luci-go
tokenserver/appengine/impl/services/admin/adminsrv/service.go
NewServer
func NewServer() *AdminServer { signer := gaesigner.Signer{} return &AdminServer{ ImportDelegationConfigsRPC: delegation.ImportDelegationConfigsRPC{ RulesCache: delegation.GlobalRulesCache, }, InspectDelegationTokenRPC: delegation.InspectDelegationTokenRPC{ Signer: signer, }, InspectMachineTokenRPC: m...
go
func NewServer() *AdminServer { signer := gaesigner.Signer{} return &AdminServer{ ImportDelegationConfigsRPC: delegation.ImportDelegationConfigsRPC{ RulesCache: delegation.GlobalRulesCache, }, InspectDelegationTokenRPC: delegation.InspectDelegationTokenRPC{ Signer: signer, }, InspectMachineTokenRPC: m...
[ "func", "NewServer", "(", ")", "*", "AdminServer", "{", "signer", ":=", "gaesigner", ".", "Signer", "{", "}", "\n", "return", "&", "AdminServer", "{", "ImportDelegationConfigsRPC", ":", "delegation", ".", "ImportDelegationConfigsRPC", "{", "RulesCache", ":", "de...
// NewServer returns prod AdminServer implementation. // // It assumes authorization has happened already.
[ "NewServer", "returns", "prod", "AdminServer", "implementation", ".", "It", "assumes", "authorization", "has", "happened", "already", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/tokenserver/appengine/impl/services/admin/adminsrv/service.go#L44-L65
7,573
luci/luci-go
gce/appengine/rpc/common.go
isReadOnly
func isReadOnly(methodName string) bool { return strings.HasPrefix(methodName, "Get") || strings.HasPrefix(methodName, "List") }
go
func isReadOnly(methodName string) bool { return strings.HasPrefix(methodName, "Get") || strings.HasPrefix(methodName, "List") }
[ "func", "isReadOnly", "(", "methodName", "string", ")", "bool", "{", "return", "strings", ".", "HasPrefix", "(", "methodName", ",", "\"", "\"", ")", "||", "strings", ".", "HasPrefix", "(", "methodName", ",", "\"", "\"", ")", "\n", "}" ]
// isReadOnly returns whether the given method name is for a read-only method.
[ "isReadOnly", "returns", "whether", "the", "given", "method", "name", "is", "for", "a", "read", "-", "only", "method", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/gce/appengine/rpc/common.go#L40-L42
7,574
luci/luci-go
gce/appengine/rpc/common.go
readOnlyAuthPrelude
func readOnlyAuthPrelude(c context.Context, methodName string, req proto.Message) (context.Context, error) { if !isReadOnly(methodName) { return c, status.Errorf(codes.PermissionDenied, "unauthorized user") } switch is, err := auth.IsMember(c, admins, writers, readers); { case err != nil: return c, err case is...
go
func readOnlyAuthPrelude(c context.Context, methodName string, req proto.Message) (context.Context, error) { if !isReadOnly(methodName) { return c, status.Errorf(codes.PermissionDenied, "unauthorized user") } switch is, err := auth.IsMember(c, admins, writers, readers); { case err != nil: return c, err case is...
[ "func", "readOnlyAuthPrelude", "(", "c", "context", ".", "Context", ",", "methodName", "string", ",", "req", "proto", ".", "Message", ")", "(", "context", ".", "Context", ",", "error", ")", "{", "if", "!", "isReadOnly", "(", "methodName", ")", "{", "retu...
// readOnlyAuthPrelude ensures the user is authorized to use read API methods. // Always returns permission denied for write API methods.
[ "readOnlyAuthPrelude", "ensures", "the", "user", "is", "authorized", "to", "use", "read", "API", "methods", ".", "Always", "returns", "permission", "denied", "for", "write", "API", "methods", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/gce/appengine/rpc/common.go#L46-L58
7,575
luci/luci-go
gce/appengine/rpc/common.go
vmAccessPrelude
func vmAccessPrelude(c context.Context, methodName string, req proto.Message) (context.Context, error) { groups := []string{admins, writers} if isReadOnly(methodName) { groups = append(groups, readers) } switch is, err := auth.IsMember(c, groups...); { case err != nil: return c, err case is: logging.Debugf(...
go
func vmAccessPrelude(c context.Context, methodName string, req proto.Message) (context.Context, error) { groups := []string{admins, writers} if isReadOnly(methodName) { groups = append(groups, readers) } switch is, err := auth.IsMember(c, groups...); { case err != nil: return c, err case is: logging.Debugf(...
[ "func", "vmAccessPrelude", "(", "c", "context", ".", "Context", ",", "methodName", "string", ",", "req", "proto", ".", "Message", ")", "(", "context", ".", "Context", ",", "error", ")", "{", "groups", ":=", "[", "]", "string", "{", "admins", ",", "writ...
// vmAccessPrelude ensures the user is authorized to use the API or has // presented a valid GCE VM token and is attempting to use VM-accessible API. // Users of this prelude must perform additional authorization checks in methods // accepted by isVMAccessible.
[ "vmAccessPrelude", "ensures", "the", "user", "is", "authorized", "to", "use", "the", "API", "or", "has", "presented", "a", "valid", "GCE", "VM", "token", "and", "is", "attempting", "to", "use", "VM", "-", "accessible", "API", ".", "Users", "of", "this", ...
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/gce/appengine/rpc/common.go#L71-L88
7,576
luci/luci-go
common/errors/filter.go
Filter
func Filter(err error, exclude error, others ...error) error { return FilterFunc(err, func(e error) bool { if e == exclude { return true } for _, v := range others { if e == v { return true } } return false }) }
go
func Filter(err error, exclude error, others ...error) error { return FilterFunc(err, func(e error) bool { if e == exclude { return true } for _, v := range others { if e == v { return true } } return false }) }
[ "func", "Filter", "(", "err", "error", ",", "exclude", "error", ",", "others", "...", "error", ")", "error", "{", "return", "FilterFunc", "(", "err", ",", "func", "(", "e", "error", ")", "bool", "{", "if", "e", "==", "exclude", "{", "return", "true",...
// Filter examines a supplied error and removes instances of excluded errors // from it. If the entire supplied error is excluded, Filter will return nil. // // If a MultiError is supplied to Filter, it will be recursively traversed, and // its child errors will be turned into nil if they match the supplied filter. // ...
[ "Filter", "examines", "a", "supplied", "error", "and", "removes", "instances", "of", "excluded", "errors", "from", "it", ".", "If", "the", "entire", "supplied", "error", "is", "excluded", "Filter", "will", "return", "nil", ".", "If", "a", "MultiError", "is",...
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/common/errors/filter.go#L24-L36
7,577
luci/luci-go
common/errors/filter.go
FilterFunc
func FilterFunc(err error, shouldFilter func(error) bool) error { switch { case shouldFilter == nil: return err case err == nil: return nil case shouldFilter(err): return nil } if merr, ok := err.(MultiError); ok { var lme MultiError for i, e := range merr { if e != nil { e = FilterFunc(e, shoul...
go
func FilterFunc(err error, shouldFilter func(error) bool) error { switch { case shouldFilter == nil: return err case err == nil: return nil case shouldFilter(err): return nil } if merr, ok := err.(MultiError); ok { var lme MultiError for i, e := range merr { if e != nil { e = FilterFunc(e, shoul...
[ "func", "FilterFunc", "(", "err", "error", ",", "shouldFilter", "func", "(", "error", ")", "bool", ")", "error", "{", "switch", "{", "case", "shouldFilter", "==", "nil", ":", "return", "err", "\n", "case", "err", "==", "nil", ":", "return", "nil", "\n"...
// FilterFunc examines a supplied error and removes instances of errors that // match the supplied filter function. If the entire supplied error is removed, // FilterFunc will return nil. // // If a MultiError is supplied to FilterFunc, it will be recursively traversed, // and its child errors will be turned into nil i...
[ "FilterFunc", "examines", "a", "supplied", "error", "and", "removes", "instances", "of", "errors", "that", "match", "the", "supplied", "filter", "function", ".", "If", "the", "entire", "supplied", "error", "is", "removed", "FilterFunc", "will", "return", "nil", ...
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/common/errors/filter.go#L49-L79
7,578
luci/luci-go
cipd/appengine/impl/cas/upload/operation.go
ToProto
func (op *Operation) ToProto(wrappedID string) *api.UploadOperation { var ref *api.ObjectRef if op.Status == api.UploadStatus_PUBLISHED { ref = &api.ObjectRef{ HashAlgo: op.HashAlgo, HexDigest: op.HexDigest, } } return &api.UploadOperation{ OperationId: wrappedID, UploadUrl: op.UploadURL, Statu...
go
func (op *Operation) ToProto(wrappedID string) *api.UploadOperation { var ref *api.ObjectRef if op.Status == api.UploadStatus_PUBLISHED { ref = &api.ObjectRef{ HashAlgo: op.HashAlgo, HexDigest: op.HexDigest, } } return &api.UploadOperation{ OperationId: wrappedID, UploadUrl: op.UploadURL, Statu...
[ "func", "(", "op", "*", "Operation", ")", "ToProto", "(", "wrappedID", "string", ")", "*", "api", ".", "UploadOperation", "{", "var", "ref", "*", "api", ".", "ObjectRef", "\n", "if", "op", ".", "Status", "==", "api", ".", "UploadStatus_PUBLISHED", "{", ...
// ToProto constructs UploadOperation proto message. // // The caller must prepare the ID in advance using WrapOpID.
[ "ToProto", "constructs", "UploadOperation", "proto", "message", ".", "The", "caller", "must", "prepare", "the", "ID", "in", "advance", "using", "WrapOpID", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/cipd/appengine/impl/cas/upload/operation.go#L54-L69
7,579
luci/luci-go
logdog/appengine/coordinator/config/config.go
ServiceConfigPath
func ServiceConfigPath(c context.Context) (config.Set, string) { return cfgclient.CurrentServiceConfigSet(c), svcconfig.ServiceConfigPath }
go
func ServiceConfigPath(c context.Context) (config.Set, string) { return cfgclient.CurrentServiceConfigSet(c), svcconfig.ServiceConfigPath }
[ "func", "ServiceConfigPath", "(", "c", "context", ".", "Context", ")", "(", "config", ".", "Set", ",", "string", ")", "{", "return", "cfgclient", ".", "CurrentServiceConfigSet", "(", "c", ")", ",", "svcconfig", ".", "ServiceConfigPath", "\n", "}" ]
// ServiceConfigPath returns the config set and path for this application's // service configuration.
[ "ServiceConfigPath", "returns", "the", "config", "set", "and", "path", "for", "this", "application", "s", "service", "configuration", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/logdog/appengine/coordinator/config/config.go#L51-L53
7,580
luci/luci-go
logdog/appengine/coordinator/config/config.go
validateServiceConfig
func validateServiceConfig(cc *svcconfig.Config) error { switch { case cc == nil: return errors.New("configuration is nil") case cc.GetCoordinator() == nil: return errors.New("no Coordinator configuration") default: return nil } }
go
func validateServiceConfig(cc *svcconfig.Config) error { switch { case cc == nil: return errors.New("configuration is nil") case cc.GetCoordinator() == nil: return errors.New("no Coordinator configuration") default: return nil } }
[ "func", "validateServiceConfig", "(", "cc", "*", "svcconfig", ".", "Config", ")", "error", "{", "switch", "{", "case", "cc", "==", "nil", ":", "return", "errors", ".", "New", "(", "\"", "\"", ")", "\n", "case", "cc", ".", "GetCoordinator", "(", ")", ...
// validateServiceConfig checks the supplied service config object to ensure // that it meets a minimum configuration standard expected by our endpoitns and // handlers.
[ "validateServiceConfig", "checks", "the", "supplied", "service", "config", "object", "to", "ensure", "that", "it", "meets", "a", "minimum", "configuration", "standard", "expected", "by", "our", "endpoitns", "and", "handlers", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/logdog/appengine/coordinator/config/config.go#L98-L107
7,581
luci/luci-go
milo/common/acl.go
IsAllowed
func IsAllowed(c context.Context, project string) (bool, error) { switch admin, err := IsAdmin(c); { case err != nil: return false, err case admin: return true, nil } // Get the project, because that's where the ACLs lie. err := access.Check(c, backend.AsUser, config.ProjectSet(project)) innerError := error...
go
func IsAllowed(c context.Context, project string) (bool, error) { switch admin, err := IsAdmin(c); { case err != nil: return false, err case admin: return true, nil } // Get the project, because that's where the ACLs lie. err := access.Check(c, backend.AsUser, config.ProjectSet(project)) innerError := error...
[ "func", "IsAllowed", "(", "c", "context", ".", "Context", ",", "project", "string", ")", "(", "bool", ",", "error", ")", "{", "switch", "admin", ",", "err", ":=", "IsAdmin", "(", "c", ")", ";", "{", "case", "err", "!=", "nil", ":", "return", "false...
// Helper functions for ACL checking. // IsAllowed checks to see if the user in the context is allowed to access // the given project.
[ "Helper", "functions", "for", "ACL", "checking", ".", "IsAllowed", "checks", "to", "see", "if", "the", "user", "in", "the", "context", "is", "allowed", "to", "access", "the", "given", "project", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/milo/common/acl.go#L40-L62
7,582
luci/luci-go
milo/common/acl.go
NewAccessClient
func NewAccessClient(c context.Context) (*AccessClient, error) { settings := GetSettings(c) if settings.Buildbucket.GetHost() == "" { return nil, errors.Reason("no buildbucket host found").Err() } t, err := auth.GetRPCTransport(c, auth.AsUser) if err != nil { return nil, errors.Annotate(err, "getting RPC Trans...
go
func NewAccessClient(c context.Context) (*AccessClient, error) { settings := GetSettings(c) if settings.Buildbucket.GetHost() == "" { return nil, errors.Reason("no buildbucket host found").Err() } t, err := auth.GetRPCTransport(c, auth.AsUser) if err != nil { return nil, errors.Annotate(err, "getting RPC Trans...
[ "func", "NewAccessClient", "(", "c", "context", ".", "Context", ")", "(", "*", "AccessClient", ",", "error", ")", "{", "settings", ":=", "GetSettings", "(", "c", ")", "\n", "if", "settings", ".", "Buildbucket", ".", "GetHost", "(", ")", "==", "\"", "\"...
// NewAccessClient creates a new AccessClient for talking to this milo instance's buildbucket instance.
[ "NewAccessClient", "creates", "a", "new", "AccessClient", "for", "talking", "to", "this", "milo", "instance", "s", "buildbucket", "instance", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/milo/common/acl.go#L79-L92
7,583
luci/luci-go
milo/common/acl.go
WithAccessClient
func WithAccessClient(c context.Context, a *AccessClient) context.Context { return context.WithValue(c, &accessClientKey, a) }
go
func WithAccessClient(c context.Context, a *AccessClient) context.Context { return context.WithValue(c, &accessClientKey, a) }
[ "func", "WithAccessClient", "(", "c", "context", ".", "Context", ",", "a", "*", "AccessClient", ")", "context", ".", "Context", "{", "return", "context", ".", "WithValue", "(", "c", ",", "&", "accessClientKey", ",", "a", ")", "\n", "}" ]
// WithAccessClient attaches an AccessClient to the given context.
[ "WithAccessClient", "attaches", "an", "AccessClient", "to", "the", "given", "context", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/milo/common/acl.go#L95-L97
7,584
luci/luci-go
milo/common/acl.go
GetAccessClient
func GetAccessClient(c context.Context) *AccessClient { if client, ok := c.Value(&accessClientKey).(*AccessClient); !ok { panic("access client not found in context") } else { return client } }
go
func GetAccessClient(c context.Context) *AccessClient { if client, ok := c.Value(&accessClientKey).(*AccessClient); !ok { panic("access client not found in context") } else { return client } }
[ "func", "GetAccessClient", "(", "c", "context", ".", "Context", ")", "*", "AccessClient", "{", "if", "client", ",", "ok", ":=", "c", ".", "Value", "(", "&", "accessClientKey", ")", ".", "(", "*", "AccessClient", ")", ";", "!", "ok", "{", "panic", "("...
// GetAccessClient retrieves an AccessClient from the given context.
[ "GetAccessClient", "retrieves", "an", "AccessClient", "from", "the", "given", "context", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/milo/common/acl.go#L100-L106
7,585
luci/luci-go
tokenserver/appengine/frontend/main.go
adminPrelude
func adminPrelude(serviceName string) func(context.Context, string, proto.Message) (context.Context, error) { return func(c context.Context, method string, _ proto.Message) (context.Context, error) { logging.Infof(c, "%s: %q is calling %q", serviceName, auth.CurrentIdentity(c), method) switch admin, err := auth.Is...
go
func adminPrelude(serviceName string) func(context.Context, string, proto.Message) (context.Context, error) { return func(c context.Context, method string, _ proto.Message) (context.Context, error) { logging.Infof(c, "%s: %q is calling %q", serviceName, auth.CurrentIdentity(c), method) switch admin, err := auth.Is...
[ "func", "adminPrelude", "(", "serviceName", "string", ")", "func", "(", "context", ".", "Context", ",", "string", ",", "proto", ".", "Message", ")", "(", "context", ".", "Context", ",", "error", ")", "{", "return", "func", "(", "c", "context", ".", "Co...
// adminPrelude returns a prelude that authorizes only administrators.
[ "adminPrelude", "returns", "a", "prelude", "that", "authorizes", "only", "administrators", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/tokenserver/appengine/frontend/main.go#L47-L58
7,586
luci/luci-go
common/data/text/templateproto/normalize.go
Normalize
func (t *File_Template) Normalize() error { if t.Body == "" { return errors.New("body is empty") } defaultParams := make(map[string]*Value, len(t.Param)) for k, param := range t.Param { if k == "" { return fmt.Errorf("param %q: invalid name", k) } if !ParamRegex.MatchString(k) { return fmt.Errorf("pa...
go
func (t *File_Template) Normalize() error { if t.Body == "" { return errors.New("body is empty") } defaultParams := make(map[string]*Value, len(t.Param)) for k, param := range t.Param { if k == "" { return fmt.Errorf("param %q: invalid name", k) } if !ParamRegex.MatchString(k) { return fmt.Errorf("pa...
[ "func", "(", "t", "*", "File_Template", ")", "Normalize", "(", ")", "error", "{", "if", "t", ".", "Body", "==", "\"", "\"", "{", "return", "errors", ".", "New", "(", "\"", "\"", ")", "\n", "}", "\n\n", "defaultParams", ":=", "make", "(", "map", "...
// Normalize will normalize the Template message, returning an error if it is // invalid.
[ "Normalize", "will", "normalize", "the", "Template", "message", "returning", "an", "error", "if", "it", "is", "invalid", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/common/data/text/templateproto/normalize.go#L50-L86
7,587
luci/luci-go
common/data/text/templateproto/normalize.go
Normalize
func (p *File_Template_Parameter) Normalize() error { if p == nil { return errors.New("is nil") } if err := p.Schema.Normalize(); err != nil { return fmt.Errorf("schema: %s", err) } if p.Default != nil { if err := p.Default.Normalize(); err != nil { return fmt.Errorf("default value: %s", err) } if err...
go
func (p *File_Template_Parameter) Normalize() error { if p == nil { return errors.New("is nil") } if err := p.Schema.Normalize(); err != nil { return fmt.Errorf("schema: %s", err) } if p.Default != nil { if err := p.Default.Normalize(); err != nil { return fmt.Errorf("default value: %s", err) } if err...
[ "func", "(", "p", "*", "File_Template_Parameter", ")", "Normalize", "(", ")", "error", "{", "if", "p", "==", "nil", "{", "return", "errors", ".", "New", "(", "\"", "\"", ")", "\n", "}", "\n", "if", "err", ":=", "p", ".", "Schema", ".", "Normalize",...
// Normalize will normalize the Parameter, returning an error if it is invalid.
[ "Normalize", "will", "normalize", "the", "Parameter", "returning", "an", "error", "if", "it", "is", "invalid", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/common/data/text/templateproto/normalize.go#L89-L105
7,588
luci/luci-go
common/data/text/templateproto/normalize.go
Accepts
func (p *File_Template_Parameter) Accepts(v *Value) error { if v.IsNull() { if !p.Nullable { return errors.New("not nullable") } } else if err := p.Schema.Accepts(v); err != nil { return err } else if err := v.Check(p.Schema); err != nil { return err } return nil }
go
func (p *File_Template_Parameter) Accepts(v *Value) error { if v.IsNull() { if !p.Nullable { return errors.New("not nullable") } } else if err := p.Schema.Accepts(v); err != nil { return err } else if err := v.Check(p.Schema); err != nil { return err } return nil }
[ "func", "(", "p", "*", "File_Template_Parameter", ")", "Accepts", "(", "v", "*", "Value", ")", "error", "{", "if", "v", ".", "IsNull", "(", ")", "{", "if", "!", "p", ".", "Nullable", "{", "return", "errors", ".", "New", "(", "\"", "\"", ")", "\n"...
// Accepts returns nil if this Parameter can accept the Value.
[ "Accepts", "returns", "nil", "if", "this", "Parameter", "can", "accept", "the", "Value", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/common/data/text/templateproto/normalize.go#L108-L119
7,589
luci/luci-go
common/data/text/templateproto/normalize.go
Normalize
func (s *Schema) Normalize() error { if s == nil { return errors.New("is nil") } if s.Schema == nil { return errors.New("has no type") } if enum := s.GetEnum(); enum != nil { return enum.Normalize() } return nil }
go
func (s *Schema) Normalize() error { if s == nil { return errors.New("is nil") } if s.Schema == nil { return errors.New("has no type") } if enum := s.GetEnum(); enum != nil { return enum.Normalize() } return nil }
[ "func", "(", "s", "*", "Schema", ")", "Normalize", "(", ")", "error", "{", "if", "s", "==", "nil", "{", "return", "errors", ".", "New", "(", "\"", "\"", ")", "\n", "}", "\n", "if", "s", ".", "Schema", "==", "nil", "{", "return", "errors", ".", ...
// Normalize will normalize the Schema, returning an error if it is invalid.
[ "Normalize", "will", "normalize", "the", "Schema", "returning", "an", "error", "if", "it", "is", "invalid", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/common/data/text/templateproto/normalize.go#L122-L133
7,590
luci/luci-go
common/data/text/templateproto/normalize.go
Normalize
func (s *Schema_Set) Normalize() error { if len(s.Entry) == 0 { return errors.New("set requires entries") } set := stringset.New(len(s.Entry)) for _, entry := range s.Entry { if entry.Token == "" { return errors.New("blank token") } if !set.Add(entry.Token) { return fmt.Errorf("duplicate token %q", en...
go
func (s *Schema_Set) Normalize() error { if len(s.Entry) == 0 { return errors.New("set requires entries") } set := stringset.New(len(s.Entry)) for _, entry := range s.Entry { if entry.Token == "" { return errors.New("blank token") } if !set.Add(entry.Token) { return fmt.Errorf("duplicate token %q", en...
[ "func", "(", "s", "*", "Schema_Set", ")", "Normalize", "(", ")", "error", "{", "if", "len", "(", "s", ".", "Entry", ")", "==", "0", "{", "return", "errors", ".", "New", "(", "\"", "\"", ")", "\n", "}", "\n", "set", ":=", "stringset", ".", "New"...
// Normalize will normalize the Schema_Set, returning an error if it is // invalid.
[ "Normalize", "will", "normalize", "the", "Schema_Set", "returning", "an", "error", "if", "it", "is", "invalid", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/common/data/text/templateproto/normalize.go#L137-L151
7,591
luci/luci-go
common/data/text/templateproto/normalize.go
Has
func (s *Schema_Set) Has(token string) bool { for _, tok := range s.Entry { if tok.Token == token { return true } } return false }
go
func (s *Schema_Set) Has(token string) bool { for _, tok := range s.Entry { if tok.Token == token { return true } } return false }
[ "func", "(", "s", "*", "Schema_Set", ")", "Has", "(", "token", "string", ")", "bool", "{", "for", "_", ",", "tok", ":=", "range", "s", ".", "Entry", "{", "if", "tok", ".", "Token", "==", "token", "{", "return", "true", "\n", "}", "\n", "}", "\n...
// Has returns true iff the given token is a valid value for this enumeration.
[ "Has", "returns", "true", "iff", "the", "given", "token", "is", "a", "valid", "value", "for", "this", "enumeration", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/common/data/text/templateproto/normalize.go#L154-L161
7,592
luci/luci-go
common/data/text/templateproto/normalize.go
IsNull
func (v *Value) IsNull() bool { _, ret := v.Value.(*Value_Null) return ret }
go
func (v *Value) IsNull() bool { _, ret := v.Value.(*Value_Null) return ret }
[ "func", "(", "v", "*", "Value", ")", "IsNull", "(", ")", "bool", "{", "_", ",", "ret", ":=", "v", ".", "Value", ".", "(", "*", "Value_Null", ")", "\n", "return", "ret", "\n", "}" ]
// IsNull returns true if this Value is the null value.
[ "IsNull", "returns", "true", "if", "this", "Value", "is", "the", "null", "value", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/common/data/text/templateproto/normalize.go#L164-L167
7,593
luci/luci-go
common/data/text/templateproto/normalize.go
Check
func (v *Value) Check(s *Schema) error { check, needsCheck := v.Value.(interface { Check(*Schema) error }) if !needsCheck { return nil } return check.Check(s) }
go
func (v *Value) Check(s *Schema) error { check, needsCheck := v.Value.(interface { Check(*Schema) error }) if !needsCheck { return nil } return check.Check(s) }
[ "func", "(", "v", "*", "Value", ")", "Check", "(", "s", "*", "Schema", ")", "error", "{", "check", ",", "needsCheck", ":=", "v", ".", "Value", ".", "(", "interface", "{", "Check", "(", "*", "Schema", ")", "error", "\n", "}", ")", "\n", "if", "!...
// Check ensures that this value conforms to the given schema.
[ "Check", "ensures", "that", "this", "value", "conforms", "to", "the", "given", "schema", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/common/data/text/templateproto/normalize.go#L170-L178
7,594
luci/luci-go
common/data/text/templateproto/normalize.go
Normalize
func (v *Value) Normalize() error { norm, needsNormalization := v.Value.(interface { Normalize() error }) if !needsNormalization { return nil } return norm.Normalize() }
go
func (v *Value) Normalize() error { norm, needsNormalization := v.Value.(interface { Normalize() error }) if !needsNormalization { return nil } return norm.Normalize() }
[ "func", "(", "v", "*", "Value", ")", "Normalize", "(", ")", "error", "{", "norm", ",", "needsNormalization", ":=", "v", ".", "Value", ".", "(", "interface", "{", "Normalize", "(", ")", "error", "\n", "}", ")", "\n", "if", "!", "needsNormalization", "...
// Normalize returns a non-nil error if the Value is invalid for its nominal type.
[ "Normalize", "returns", "a", "non", "-", "nil", "error", "if", "the", "Value", "is", "invalid", "for", "its", "nominal", "type", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/common/data/text/templateproto/normalize.go#L181-L189
7,595
luci/luci-go
common/data/text/templateproto/normalize.go
Check
func (v *Value_Bytes) Check(schema *Schema) error { s := schema.GetBytes() if s.MaxLength > 0 && uint32(len(v.Bytes)) > s.MaxLength { return fmt.Errorf("value is too large: %d > %d", len(v.Bytes), s.MaxLength) } return nil }
go
func (v *Value_Bytes) Check(schema *Schema) error { s := schema.GetBytes() if s.MaxLength > 0 && uint32(len(v.Bytes)) > s.MaxLength { return fmt.Errorf("value is too large: %d > %d", len(v.Bytes), s.MaxLength) } return nil }
[ "func", "(", "v", "*", "Value_Bytes", ")", "Check", "(", "schema", "*", "Schema", ")", "error", "{", "s", ":=", "schema", ".", "GetBytes", "(", ")", "\n", "if", "s", ".", "MaxLength", ">", "0", "&&", "uint32", "(", "len", "(", "v", ".", "Bytes", ...
// Check returns nil iff this Value meets the max length criteria.
[ "Check", "returns", "nil", "iff", "this", "Value", "meets", "the", "max", "length", "criteria", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/common/data/text/templateproto/normalize.go#L192-L198
7,596
luci/luci-go
common/data/text/templateproto/normalize.go
Check
func (v *Value_Object) Check(schema *Schema) error { s := schema.GetObject() if s.MaxLength > 0 && uint32(len(v.Object)) > s.MaxLength { return fmt.Errorf("value is too large: %d > %d", len(v.Object), s.MaxLength) } return nil }
go
func (v *Value_Object) Check(schema *Schema) error { s := schema.GetObject() if s.MaxLength > 0 && uint32(len(v.Object)) > s.MaxLength { return fmt.Errorf("value is too large: %d > %d", len(v.Object), s.MaxLength) } return nil }
[ "func", "(", "v", "*", "Value_Object", ")", "Check", "(", "schema", "*", "Schema", ")", "error", "{", "s", ":=", "schema", ".", "GetObject", "(", ")", "\n", "if", "s", ".", "MaxLength", ">", "0", "&&", "uint32", "(", "len", "(", "v", ".", "Object...
// Check returns nil iff this Value correctly parses as a JSON object.
[ "Check", "returns", "nil", "iff", "this", "Value", "correctly", "parses", "as", "a", "JSON", "object", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/common/data/text/templateproto/normalize.go#L223-L229
7,597
luci/luci-go
common/data/text/templateproto/normalize.go
Normalize
func (v *Value_Object) Normalize() error { newObj, err := NormalizeJSON(v.Object, true) if err != nil { return err } v.Object = newObj return nil }
go
func (v *Value_Object) Normalize() error { newObj, err := NormalizeJSON(v.Object, true) if err != nil { return err } v.Object = newObj return nil }
[ "func", "(", "v", "*", "Value_Object", ")", "Normalize", "(", ")", "error", "{", "newObj", ",", "err", ":=", "NormalizeJSON", "(", "v", ".", "Object", ",", "true", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "v", "...
// Normalize returns nil iff this Value correctly parses as a JSON object.
[ "Normalize", "returns", "nil", "iff", "this", "Value", "correctly", "parses", "as", "a", "JSON", "object", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/common/data/text/templateproto/normalize.go#L232-L239
7,598
luci/luci-go
common/data/text/templateproto/normalize.go
Check
func (v *Value_Array) Check(schema *Schema) error { s := schema.GetArray() if s.MaxLength > 0 && uint32(len(v.Array)) > s.MaxLength { return fmt.Errorf("value is too large: %d > %d", len(v.Array), s.MaxLength) } return nil }
go
func (v *Value_Array) Check(schema *Schema) error { s := schema.GetArray() if s.MaxLength > 0 && uint32(len(v.Array)) > s.MaxLength { return fmt.Errorf("value is too large: %d > %d", len(v.Array), s.MaxLength) } return nil }
[ "func", "(", "v", "*", "Value_Array", ")", "Check", "(", "schema", "*", "Schema", ")", "error", "{", "s", ":=", "schema", ".", "GetArray", "(", ")", "\n", "if", "s", ".", "MaxLength", ">", "0", "&&", "uint32", "(", "len", "(", "v", ".", "Array", ...
// Check returns nil iff this Value correctly parses as a JSON array.
[ "Check", "returns", "nil", "iff", "this", "Value", "correctly", "parses", "as", "a", "JSON", "array", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/common/data/text/templateproto/normalize.go#L242-L248
7,599
luci/luci-go
common/data/text/templateproto/normalize.go
Normalize
func (v *Value_Array) Normalize() error { newAry, err := NormalizeJSON(v.Array, false) if err != nil { return err } v.Array = newAry return nil }
go
func (v *Value_Array) Normalize() error { newAry, err := NormalizeJSON(v.Array, false) if err != nil { return err } v.Array = newAry return nil }
[ "func", "(", "v", "*", "Value_Array", ")", "Normalize", "(", ")", "error", "{", "newAry", ",", "err", ":=", "NormalizeJSON", "(", "v", ".", "Array", ",", "false", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "v", "....
// Normalize returns nil iff this Value correctly parses as a JSON array.
[ "Normalize", "returns", "nil", "iff", "this", "Value", "correctly", "parses", "as", "a", "JSON", "array", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/common/data/text/templateproto/normalize.go#L251-L258