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
listlengths
21
1.41k
docstring
stringlengths
6
2.61k
docstring_tokens
listlengths
3
215
sha
stringlengths
40
40
url
stringlengths
85
252
129,500
luci/luci-go
logdog/appengine/coordinator/logStream.go
Path
func (s *LogStream) Path() types.StreamPath { return types.StreamName(s.Prefix).Join(types.StreamName(s.Name)) }
go
func (s *LogStream) Path() types.StreamPath { return types.StreamName(s.Prefix).Join(types.StreamName(s.Name)) }
[ "func", "(", "s", "*", "LogStream", ")", "Path", "(", ")", "types", ".", "StreamPath", "{", "return", "types", ".", "StreamName", "(", "s", ".", "Prefix", ")", ".", "Join", "(", "types", ".", "StreamName", "(", "s", ".", "Name", ")", ")", "\n", "...
// Path returns the LogDog path for this log stream.
[ "Path", "returns", "the", "LogDog", "path", "for", "this", "log", "stream", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/logdog/appengine/coordinator/logStream.go#L158-L160
129,501
luci/luci-go
logdog/appengine/coordinator/logStream.go
DescriptorValue
func (s *LogStream) DescriptorValue() (*logpb.LogStreamDescriptor, error) { pb := logpb.LogStreamDescriptor{} if err := proto.Unmarshal(s.Descriptor, &pb); err != nil { return nil, err } return &pb, nil }
go
func (s *LogStream) DescriptorValue() (*logpb.LogStreamDescriptor, error) { pb := logpb.LogStreamDescriptor{} if err := proto.Unmarshal(s.Descriptor, &pb); err != nil { return nil, err } return &pb, nil }
[ "func", "(", "s", "*", "LogStream", ")", "DescriptorValue", "(", ")", "(", "*", "logpb", ".", "LogStreamDescriptor", ",", "error", ")", "{", "pb", ":=", "logpb", ".", "LogStreamDescriptor", "{", "}", "\n", "if", "err", ":=", "proto", ".", "Unmarshal", ...
// DescriptorValue returns the unmarshalled Descriptor field protobuf.
[ "DescriptorValue", "returns", "the", "unmarshalled", "Descriptor", "field", "protobuf", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/logdog/appengine/coordinator/logStream.go#L269-L275
129,502
luci/luci-go
logdog/appengine/coordinator/logStream.go
DescriptorProto
func (s *LogStream) DescriptorProto() (*logpb.LogStreamDescriptor, error) { desc := logpb.LogStreamDescriptor{} if err := proto.Unmarshal(s.Descriptor, &desc); err != nil { return nil, err } return &desc, nil }
go
func (s *LogStream) DescriptorProto() (*logpb.LogStreamDescriptor, error) { desc := logpb.LogStreamDescriptor{} if err := proto.Unmarshal(s.Descriptor, &desc); err != nil { return nil, err } return &desc, nil }
[ "func", "(", "s", "*", "LogStream", ")", "DescriptorProto", "(", ")", "(", "*", "logpb", ".", "LogStreamDescriptor", ",", "error", ")", "{", "desc", ":=", "logpb", ".", "LogStreamDescriptor", "{", "}", "\n", "if", "err", ":=", "proto", ".", "Unmarshal", ...
// DescriptorProto unmarshals a LogStreamDescriptor from the stream's Descriptor // field. It will return an error if the unmarshalling fails.
[ "DescriptorProto", "unmarshals", "a", "LogStreamDescriptor", "from", "the", "stream", "s", "Descriptor", "field", ".", "It", "will", "return", "an", "error", "if", "the", "unmarshalling", "fails", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/logdog/appengine/coordinator/logStream.go#L314-L320
129,503
luci/luci-go
logdog/appengine/coordinator/logStream.go
generatePathComponents
func generatePathComponents(prefix, name string) ds.PropertySlice { ps, ns := types.StreamName(prefix).Segments(), types.StreamName(name).Segments() // Allocate our components array. For each component, there are two entries // (forward and reverse), as well as one count entry per component type. c := make(ds.Prop...
go
func generatePathComponents(prefix, name string) ds.PropertySlice { ps, ns := types.StreamName(prefix).Segments(), types.StreamName(name).Segments() // Allocate our components array. For each component, there are two entries // (forward and reverse), as well as one count entry per component type. c := make(ds.Prop...
[ "func", "generatePathComponents", "(", "prefix", ",", "name", "string", ")", "ds", ".", "PropertySlice", "{", "ps", ",", "ns", ":=", "types", ".", "StreamName", "(", "prefix", ")", ".", "Segments", "(", ")", ",", "types", ".", "StreamName", "(", "name", ...
// generatePathComponents generates the "_C" property path components for path // glob querying. // // See the comment on LogStream for more infromation.
[ "generatePathComponents", "generates", "the", "_C", "property", "path", "components", "for", "path", "glob", "querying", ".", "See", "the", "comment", "on", "LogStream", "for", "more", "infromation", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/logdog/appengine/coordinator/logStream.go#L334-L358
129,504
luci/luci-go
logdog/appengine/coordinator/logStream.go
AddLogStreamPathFilter
func AddLogStreamPathFilter(q *ds.Query, path string) (*ds.Query, error) { prefix, name := types.StreamPath(path).Split() err := error(nil) q, err = addComponentFilter(q, "Prefix", "_C", "P", prefix) if err != nil { return nil, err } q, err = addComponentFilter(q, "Name", "_C", "N", name) if err != nil { re...
go
func AddLogStreamPathFilter(q *ds.Query, path string) (*ds.Query, error) { prefix, name := types.StreamPath(path).Split() err := error(nil) q, err = addComponentFilter(q, "Prefix", "_C", "P", prefix) if err != nil { return nil, err } q, err = addComponentFilter(q, "Name", "_C", "N", name) if err != nil { re...
[ "func", "AddLogStreamPathFilter", "(", "q", "*", "ds", ".", "Query", ",", "path", "string", ")", "(", "*", "ds", ".", "Query", ",", "error", ")", "{", "prefix", ",", "name", ":=", "types", ".", "StreamPath", "(", "path", ")", ".", "Split", "(", ")"...
// AddLogStreamPathFilter constructs a compiled LogStreamPathQuery. It will // return an error if the supllied query string describes an invalid query.
[ "AddLogStreamPathFilter", "constructs", "a", "compiled", "LogStreamPathQuery", ".", "It", "will", "return", "an", "error", "if", "the", "supllied", "query", "string", "describes", "an", "invalid", "query", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/logdog/appengine/coordinator/logStream.go#L443-L456
129,505
luci/luci-go
logdog/appengine/coordinator/logStream.go
AddLogStreamTerminatedFilter
func AddLogStreamTerminatedFilter(q *ds.Query, v bool) *ds.Query { return q.Eq("_Terminated", v) }
go
func AddLogStreamTerminatedFilter(q *ds.Query, v bool) *ds.Query { return q.Eq("_Terminated", v) }
[ "func", "AddLogStreamTerminatedFilter", "(", "q", "*", "ds", ".", "Query", ",", "v", "bool", ")", "*", "ds", ".", "Query", "{", "return", "q", ".", "Eq", "(", "\"", "\"", ",", "v", ")", "\n", "}" ]
// AddLogStreamTerminatedFilter returns a derived query that asserts that a log // stream has been terminated.
[ "AddLogStreamTerminatedFilter", "returns", "a", "derived", "query", "that", "asserts", "that", "a", "log", "stream", "has", "been", "terminated", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/logdog/appengine/coordinator/logStream.go#L460-L462
129,506
luci/luci-go
logdog/appengine/coordinator/logStream.go
AddLogStreamArchivedFilter
func AddLogStreamArchivedFilter(q *ds.Query, v bool) *ds.Query { return q.Eq("_Archived", v) }
go
func AddLogStreamArchivedFilter(q *ds.Query, v bool) *ds.Query { return q.Eq("_Archived", v) }
[ "func", "AddLogStreamArchivedFilter", "(", "q", "*", "ds", ".", "Query", ",", "v", "bool", ")", "*", "ds", ".", "Query", "{", "return", "q", ".", "Eq", "(", "\"", "\"", ",", "v", ")", "\n", "}" ]
// AddLogStreamArchivedFilter returns a derived query that asserts that a log // stream has been archived.
[ "AddLogStreamArchivedFilter", "returns", "a", "derived", "query", "that", "asserts", "that", "a", "log", "stream", "has", "been", "archived", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/logdog/appengine/coordinator/logStream.go#L466-L468
129,507
luci/luci-go
logdog/appengine/coordinator/logStream.go
AddLogStreamPurgedFilter
func AddLogStreamPurgedFilter(q *ds.Query, v bool) *ds.Query { return q.Eq("Purged", v) }
go
func AddLogStreamPurgedFilter(q *ds.Query, v bool) *ds.Query { return q.Eq("Purged", v) }
[ "func", "AddLogStreamPurgedFilter", "(", "q", "*", "ds", ".", "Query", ",", "v", "bool", ")", "*", "ds", ".", "Query", "{", "return", "q", ".", "Eq", "(", "\"", "\"", ",", "v", ")", "\n", "}" ]
// AddLogStreamPurgedFilter returns a derived query that asserts that a log // stream has been archived.
[ "AddLogStreamPurgedFilter", "returns", "a", "derived", "query", "that", "asserts", "that", "a", "log", "stream", "has", "been", "archived", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/logdog/appengine/coordinator/logStream.go#L472-L474
129,508
luci/luci-go
logdog/appengine/coordinator/logStream.go
AddOlderFilter
func AddOlderFilter(q *ds.Query, t time.Time) *ds.Query { return q.Lt("Created", t.UTC()).Order("-Created") }
go
func AddOlderFilter(q *ds.Query, t time.Time) *ds.Query { return q.Lt("Created", t.UTC()).Order("-Created") }
[ "func", "AddOlderFilter", "(", "q", "*", "ds", ".", "Query", ",", "t", "time", ".", "Time", ")", "*", "ds", ".", "Query", "{", "return", "q", ".", "Lt", "(", "\"", "\"", ",", "t", ".", "UTC", "(", ")", ")", ".", "Order", "(", "\"", "\"", ")...
// AddOlderFilter adds a filter to queries that restricts them to results that // were created before the supplied time.
[ "AddOlderFilter", "adds", "a", "filter", "to", "queries", "that", "restricts", "them", "to", "results", "that", "were", "created", "before", "the", "supplied", "time", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/logdog/appengine/coordinator/logStream.go#L478-L480
129,509
luci/luci-go
logdog/appengine/coordinator/logStream.go
AddNewerFilter
func AddNewerFilter(q *ds.Query, t time.Time) *ds.Query { return q.Gt("Created", t.UTC()).Order("-Created") }
go
func AddNewerFilter(q *ds.Query, t time.Time) *ds.Query { return q.Gt("Created", t.UTC()).Order("-Created") }
[ "func", "AddNewerFilter", "(", "q", "*", "ds", ".", "Query", ",", "t", "time", ".", "Time", ")", "*", "ds", ".", "Query", "{", "return", "q", ".", "Gt", "(", "\"", "\"", ",", "t", ".", "UTC", "(", ")", ")", ".", "Order", "(", "\"", "\"", ")...
// AddNewerFilter adds a filter to queries that restricts them to results that // were created after the supplied time.
[ "AddNewerFilter", "adds", "a", "filter", "to", "queries", "that", "restricts", "them", "to", "results", "that", "were", "created", "after", "the", "supplied", "time", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/logdog/appengine/coordinator/logStream.go#L484-L486
129,510
luci/luci-go
server/templates/context.go
Get
func Get(c context.Context, name string) (*template.Template, error) { if b, _ := c.Value(&contextKey).(*boundBundle); b != nil { return b.Get(name) } return nil, errNoBundle }
go
func Get(c context.Context, name string) (*template.Template, error) { if b, _ := c.Value(&contextKey).(*boundBundle); b != nil { return b.Get(name) } return nil, errNoBundle }
[ "func", "Get", "(", "c", "context", ".", "Context", ",", "name", "string", ")", "(", "*", "template", ".", "Template", ",", "error", ")", "{", "if", "b", ",", "_", ":=", "c", ".", "Value", "(", "&", "contextKey", ")", ".", "(", "*", "boundBundle"...
// Get returns template from the currently loaded bundle or error if not found.
[ "Get", "returns", "template", "from", "the", "currently", "loaded", "bundle", "or", "error", "if", "not", "found", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/server/templates/context.go#L50-L55
129,511
luci/luci-go
server/templates/context.go
MustRender
func MustRender(c context.Context, out io.Writer, name string, args Args) { if b, _ := c.Value(&contextKey).(*boundBundle); b != nil { b.MustRender(c, b.Extra, out, name, args) return } panic(errNoBundle) }
go
func MustRender(c context.Context, out io.Writer, name string, args Args) { if b, _ := c.Value(&contextKey).(*boundBundle); b != nil { b.MustRender(c, b.Extra, out, name, args) return } panic(errNoBundle) }
[ "func", "MustRender", "(", "c", "context", ".", "Context", ",", "out", "io", ".", "Writer", ",", "name", "string", ",", "args", "Args", ")", "{", "if", "b", ",", "_", ":=", "c", ".", "Value", "(", "&", "contextKey", ")", ".", "(", "*", "boundBund...
// MustRender renders the template into the output writer or panics. // // It never writes partial output. It also panics if attempt to write to // the output fails.
[ "MustRender", "renders", "the", "template", "into", "the", "output", "writer", "or", "panics", ".", "It", "never", "writes", "partial", "output", ".", "It", "also", "panics", "if", "attempt", "to", "write", "to", "the", "output", "fails", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/server/templates/context.go#L73-L79
129,512
luci/luci-go
gce/api/config/v1/amount.go
Validate
func (a *Amount) Validate(c *validation.Context) { if a.GetDefault() < 0 { c.Errorf("default amount must be non-negative") } // The algorithm works with any time 7 days greater than the zero time. now := time.Date(2018, 1, 1, 12, 0, 0, 0, time.UTC) schs := make([]indexedSchedule, len(a.GetChange())) for i, s :=...
go
func (a *Amount) Validate(c *validation.Context) { if a.GetDefault() < 0 { c.Errorf("default amount must be non-negative") } // The algorithm works with any time 7 days greater than the zero time. now := time.Date(2018, 1, 1, 12, 0, 0, 0, time.UTC) schs := make([]indexedSchedule, len(a.GetChange())) for i, s :=...
[ "func", "(", "a", "*", "Amount", ")", "Validate", "(", "c", "*", "validation", ".", "Context", ")", "{", "if", "a", ".", "GetDefault", "(", ")", "<", "0", "{", "c", ".", "Errorf", "(", "\"", "\"", ")", "\n", "}", "\n", "// The algorithm works with ...
// Validate validates this amount.
[ "Validate", "validates", "this", "amount", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/gce/api/config/v1/amount.go#L58-L110
129,513
luci/luci-go
starlark/starlarkproto/default.go
newDefaultValue
func newDefaultValue(typ reflect.Type) (starlark.Value, error) { switch typ.Kind() { case reflect.Bool: return starlark.False, nil case reflect.Float32, reflect.Float64: return starlark.Float(0), nil case reflect.Int32, reflect.Int64, reflect.Uint32, reflect.Uint64: return starlark.MakeInt(0), nil case re...
go
func newDefaultValue(typ reflect.Type) (starlark.Value, error) { switch typ.Kind() { case reflect.Bool: return starlark.False, nil case reflect.Float32, reflect.Float64: return starlark.Float(0), nil case reflect.Int32, reflect.Int64, reflect.Uint32, reflect.Uint64: return starlark.MakeInt(0), nil case re...
[ "func", "newDefaultValue", "(", "typ", "reflect", ".", "Type", ")", "(", "starlark", ".", "Value", ",", "error", ")", "{", "switch", "typ", ".", "Kind", "(", ")", "{", "case", "reflect", ".", "Bool", ":", "return", "starlark", ".", "False", ",", "nil...
// newDefaultValue returns a new "zero" starlark value for a field described by // the given Go type.
[ "newDefaultValue", "returns", "a", "new", "zero", "starlark", "value", "for", "a", "field", "described", "by", "the", "given", "Go", "type", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/starlark/starlarkproto/default.go#L26-L58
129,514
luci/luci-go
tokenserver/appengine/impl/utils/tokensigning/inspector.go
checkLifetime
func (i *Inspector) checkLifetime(c context.Context, body proto.Message) string { lifespan := i.Lifespan(body) now := clock.Now(c) switch { case lifespan.NotAfter == lifespan.NotBefore: return "can't extract the token lifespan" case now.Before(lifespan.NotBefore): return "not active yet" case now.After(lifesp...
go
func (i *Inspector) checkLifetime(c context.Context, body proto.Message) string { lifespan := i.Lifespan(body) now := clock.Now(c) switch { case lifespan.NotAfter == lifespan.NotBefore: return "can't extract the token lifespan" case now.Before(lifespan.NotBefore): return "not active yet" case now.After(lifesp...
[ "func", "(", "i", "*", "Inspector", ")", "checkLifetime", "(", "c", "context", ".", "Context", ",", "body", "proto", ".", "Message", ")", "string", "{", "lifespan", ":=", "i", ".", "Lifespan", "(", "body", ")", "\n", "now", ":=", "clock", ".", "Now",...
// checkLifetime checks that token has not expired yet. // // Returns "" if it hasn't expire yet, or an invalidity reason if it has.
[ "checkLifetime", "checks", "that", "token", "has", "not", "expired", "yet", ".", "Returns", "if", "it", "hasn", "t", "expire", "yet", "or", "an", "invalidity", "reason", "if", "it", "has", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/tokenserver/appengine/impl/utils/tokensigning/inspector.go#L145-L158
129,515
luci/luci-go
tokenserver/appengine/impl/utils/tokensigning/inspector.go
checkSignature
func (i *Inspector) checkSignature(c context.Context, unwrapped *Unwrapped) (string, error) { certsBundle, err := i.Certificates.Certificates(c) if err != nil { return "", transient.Tag.Apply(err) } cert, err := certsBundle.CertificateForKey(unwrapped.KeyID) if err != nil { return fmt.Sprintf("invalid signing ...
go
func (i *Inspector) checkSignature(c context.Context, unwrapped *Unwrapped) (string, error) { certsBundle, err := i.Certificates.Certificates(c) if err != nil { return "", transient.Tag.Apply(err) } cert, err := certsBundle.CertificateForKey(unwrapped.KeyID) if err != nil { return fmt.Sprintf("invalid signing ...
[ "func", "(", "i", "*", "Inspector", ")", "checkSignature", "(", "c", "context", ".", "Context", ",", "unwrapped", "*", "Unwrapped", ")", "(", "string", ",", "error", ")", "{", "certsBundle", ",", "err", ":=", "i", ".", "Certificates", ".", "Certificates"...
// checkSignature verifies the signature of the token. // // Returns "" if the signature is correct, or an invalidity reason if it is not.
[ "checkSignature", "verifies", "the", "signature", "of", "the", "token", ".", "Returns", "if", "the", "signature", "is", "correct", "or", "an", "invalidity", "reason", "if", "it", "is", "not", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/tokenserver/appengine/impl/utils/tokensigning/inspector.go#L163-L178
129,516
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
129,517
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
129,518
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
129,519
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
129,520
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
129,521
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
129,522
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
129,523
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
129,524
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
129,525
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
129,526
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
129,527
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
129,528
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
129,529
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
129,530
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
129,531
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
129,532
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
129,533
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
129,534
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
129,535
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
129,536
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
129,537
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
129,538
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
129,539
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
129,540
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
129,541
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
129,542
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
129,543
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
129,544
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
129,545
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
129,546
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
129,547
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
129,548
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
129,549
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
129,550
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
129,551
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
129,552
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
129,553
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
129,554
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
129,555
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
129,556
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
129,557
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
129,558
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
129,559
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
129,560
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
129,561
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
129,562
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
129,563
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
129,564
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
129,565
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
129,566
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
129,567
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
129,568
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
129,569
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
129,570
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
129,571
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
129,572
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
129,573
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
129,574
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
129,575
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
129,576
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
129,577
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
129,578
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
129,579
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
129,580
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
129,581
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
129,582
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
129,583
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
129,584
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
129,585
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
129,586
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
129,587
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
129,588
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
129,589
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
129,590
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
129,591
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
129,592
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
129,593
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
129,594
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
129,595
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
129,596
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
129,597
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
129,598
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
129,599
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