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
130,900
luci/luci-go
common/data/chunkstream/view.go
CloneLimit
func (r *View) CloneLimit(limit int64) *View { c := *r if c.size > limit { c.size = limit } return &c }
go
func (r *View) CloneLimit(limit int64) *View { c := *r if c.size > limit { c.size = limit } return &c }
[ "func", "(", "r", "*", "View", ")", "CloneLimit", "(", "limit", "int64", ")", "*", "View", "{", "c", ":=", "*", "r", "\n", "if", "c", ".", "size", ">", "limit", "{", "c", ".", "size", "=", "limit", "\n", "}", "\n", "return", "&", "c", "\n", ...
// CloneLimit returns a copy of the View view, optionally truncating it. // // The clone is bound to the same underlying Buffer as the source.
[ "CloneLimit", "returns", "a", "copy", "of", "the", "View", "view", "optionally", "truncating", "it", ".", "The", "clone", "is", "bound", "to", "the", "same", "underlying", "Buffer", "as", "the", "source", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/common/data/chunkstream/view.go#L206-L212
130,901
luci/luci-go
appengine/gaesettings/gaesettings.go
GetConsistencyTime
func (s Storage) GetConsistencyTime(c context.Context) (time.Time, error) { c = defaultContext(c) latest := latestSettings() switch err := ds.Get(c, &latest); err { case nil: return latest.When.Add(s.expirationDuration(c)), nil case ds.ErrNoSuchEntity: return time.Time{}, nil default: return time.Time{}, tr...
go
func (s Storage) GetConsistencyTime(c context.Context) (time.Time, error) { c = defaultContext(c) latest := latestSettings() switch err := ds.Get(c, &latest); err { case nil: return latest.When.Add(s.expirationDuration(c)), nil case ds.ErrNoSuchEntity: return time.Time{}, nil default: return time.Time{}, tr...
[ "func", "(", "s", "Storage", ")", "GetConsistencyTime", "(", "c", "context", ".", "Context", ")", "(", "time", ".", "Time", ",", "error", ")", "{", "c", "=", "defaultContext", "(", "c", ")", "\n", "latest", ":=", "latestSettings", "(", ")", "\n", "sw...
// GetConsistencyTime returns "last modification time" + "expiration period". // // It indicates moment in time when last setting change is fully propagated to // all instances. // // Returns zero time if there are no settings stored.
[ "GetConsistencyTime", "returns", "last", "modification", "time", "+", "expiration", "period", ".", "It", "indicates", "moment", "in", "time", "when", "last", "setting", "change", "is", "fully", "propagated", "to", "all", "instances", ".", "Returns", "zero", "tim...
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/appengine/gaesettings/gaesettings.go#L174-L185
130,902
luci/luci-go
starlark/starlarkproto/type.go
onAlternativePicked
func (g *oneofGroup) onAlternativePicked(alt *oneofAlternative, dict starlark.StringDict) { for _, a := range g.alternatives { if a != alt { delete(dict, a.name) } } }
go
func (g *oneofGroup) onAlternativePicked(alt *oneofAlternative, dict starlark.StringDict) { for _, a := range g.alternatives { if a != alt { delete(dict, a.name) } } }
[ "func", "(", "g", "*", "oneofGroup", ")", "onAlternativePicked", "(", "alt", "*", "oneofAlternative", ",", "dict", "starlark", ".", "StringDict", ")", "{", "for", "_", ",", "a", ":=", "range", "g", ".", "alternatives", "{", "if", "a", "!=", "alt", "{",...
// onAlternativePicked is called when one oneof alternative was set to. // // It clears all others.
[ "onAlternativePicked", "is", "called", "when", "one", "oneof", "alternative", "was", "set", "to", ".", "It", "clears", "all", "others", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/starlark/starlarkproto/type.go#L302-L308
130,903
luci/luci-go
starlark/starlarkproto/type.go
onReadingAlternative
func (g *oneofGroup) onReadingAlternative(alt *oneofAlternative, msg reflect.Value) reflect.Value { switch wrap := msg.Field(g.fieldIdx); { case wrap.IsNil(): return reflect.Value{} // no alternatives are set case wrap.Elem().Type() != alt.outerTyp: return reflect.Value{} // some other alternative is set defaul...
go
func (g *oneofGroup) onReadingAlternative(alt *oneofAlternative, msg reflect.Value) reflect.Value { switch wrap := msg.Field(g.fieldIdx); { case wrap.IsNil(): return reflect.Value{} // no alternatives are set case wrap.Elem().Type() != alt.outerTyp: return reflect.Value{} // some other alternative is set defaul...
[ "func", "(", "g", "*", "oneofGroup", ")", "onReadingAlternative", "(", "alt", "*", "oneofAlternative", ",", "msg", "reflect", ".", "Value", ")", "reflect", ".", "Value", "{", "switch", "wrap", ":=", "msg", ".", "Field", "(", "g", ".", "fieldIdx", ")", ...
// onReadingAlternative is called when reading a value from the proto message. // // If returns a valid reflect.Value if the given alternative is realized in // the 'msg' or an invalid zero reflect.Value otherwise.
[ "onReadingAlternative", "is", "called", "when", "reading", "a", "value", "from", "the", "proto", "message", ".", "If", "returns", "a", "valid", "reflect", ".", "Value", "if", "the", "given", "alternative", "is", "realized", "in", "the", "msg", "or", "an", ...
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/starlark/starlarkproto/type.go#L324-L333
130,904
luci/luci-go
lucictx/lucictx.go
Get
func Get(ctx context.Context, section string, out interface{}) error { _, err := Lookup(ctx, section, out) return err }
go
func Get(ctx context.Context, section string, out interface{}) error { _, err := Lookup(ctx, section, out) return err }
[ "func", "Get", "(", "ctx", "context", ".", "Context", ",", "section", "string", ",", "out", "interface", "{", "}", ")", "error", "{", "_", ",", "err", ":=", "Lookup", "(", "ctx", ",", "section", ",", "out", ")", "\n", "return", "err", "\n", "}" ]
// Get retrieves the current section from the current LUCI_CONTEXT, and // deserializes it into out. Out may be any target for json.Unmarshal. If the // section exists, it deserializes it into the provided out object. If not, then // out is unmodified.
[ "Get", "retrieves", "the", "current", "section", "from", "the", "current", "LUCI_CONTEXT", "and", "deserializes", "it", "into", "out", ".", "Out", "may", "be", "any", "target", "for", "json", ".", "Unmarshal", ".", "If", "the", "section", "exists", "it", "...
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/lucictx/lucictx.go#L126-L129
130,905
luci/luci-go
lucictx/lucictx.go
Set
func Set(ctx context.Context, section string, in interface{}) (context.Context, error) { var err error var data json.RawMessage if in != nil { if data, err = json.Marshal(in); err != nil { return ctx, err } if data[0] != '{' { return ctx, errors.New("LUCI_CONTEXT sections must always be JSON Objects") ...
go
func Set(ctx context.Context, section string, in interface{}) (context.Context, error) { var err error var data json.RawMessage if in != nil { if data, err = json.Marshal(in); err != nil { return ctx, err } if data[0] != '{' { return ctx, errors.New("LUCI_CONTEXT sections must always be JSON Objects") ...
[ "func", "Set", "(", "ctx", "context", ".", "Context", ",", "section", "string", ",", "in", "interface", "{", "}", ")", "(", "context", ".", "Context", ",", "error", ")", "{", "var", "err", "error", "\n", "var", "data", "json", ".", "RawMessage", "\n"...
// Set writes the json serialization of `in` as the given section into the // LUCI_CONTEXT, returning the new ctx object containing it. This ctx can be // passed to Export to serialize it to disk. // // If in is nil, it will clear that section of the LUCI_CONTEXT. // // The returned context is always safe to use, even ...
[ "Set", "writes", "the", "json", "serialization", "of", "in", "as", "the", "given", "section", "into", "the", "LUCI_CONTEXT", "returning", "the", "new", "ctx", "object", "containing", "it", ".", "This", "ctx", "can", "be", "passed", "to", "Export", "to", "s...
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/lucictx/lucictx.go#L151-L174
130,906
luci/luci-go
appengine/gaesecrets/gaesecrets.go
Use
func Use(c context.Context, cfg *Config) context.Context { config := Config{} if cfg != nil { config = *cfg } if strings.Contains(config.Prefix, ":") { panic("forbidden character ':' in Prefix") } if config.SecretLen == 0 { config.SecretLen = 32 } if config.Entropy == nil { config.Entropy = rand.Reader ...
go
func Use(c context.Context, cfg *Config) context.Context { config := Config{} if cfg != nil { config = *cfg } if strings.Contains(config.Prefix, ":") { panic("forbidden character ':' in Prefix") } if config.SecretLen == 0 { config.SecretLen = 32 } if config.Entropy == nil { config.Entropy = rand.Reader ...
[ "func", "Use", "(", "c", "context", ".", "Context", ",", "cfg", "*", "Config", ")", "context", ".", "Context", "{", "config", ":=", "Config", "{", "}", "\n", "if", "cfg", "!=", "nil", "{", "config", "=", "*", "cfg", "\n", "}", "\n", "if", "string...
// Use injects the GAE implementation of secrets.Store into the context. // The context must be configured with GAE datastore implementation already.
[ "Use", "injects", "the", "GAE", "implementation", "of", "secrets", ".", "Store", "into", "the", "context", ".", "The", "context", "must", "be", "configured", "with", "GAE", "datastore", "implementation", "already", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/appengine/gaesecrets/gaesecrets.go#L55-L72
130,907
luci/luci-go
appengine/gaesecrets/gaesecrets.go
GetSecret
func (s *storeImpl) GetSecret(k secrets.Key) (secrets.Secret, error) { secret, err := secretsCache.LRU(s.ctx).GetOrCreate(s.ctx, s.cfg.Prefix+":"+string(k), func() (interface{}, time.Duration, error) { secret, err := s.getSecretFromDatastore(k) if err != nil { return nil, 0, err } return secret, cacheExp, n...
go
func (s *storeImpl) GetSecret(k secrets.Key) (secrets.Secret, error) { secret, err := secretsCache.LRU(s.ctx).GetOrCreate(s.ctx, s.cfg.Prefix+":"+string(k), func() (interface{}, time.Duration, error) { secret, err := s.getSecretFromDatastore(k) if err != nil { return nil, 0, err } return secret, cacheExp, n...
[ "func", "(", "s", "*", "storeImpl", ")", "GetSecret", "(", "k", "secrets", ".", "Key", ")", "(", "secrets", ".", "Secret", ",", "error", ")", "{", "secret", ",", "err", ":=", "secretsCache", ".", "LRU", "(", "s", ".", "ctx", ")", ".", "GetOrCreate"...
// GetSecret returns a secret by its key.
[ "GetSecret", "returns", "a", "secret", "by", "its", "key", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/appengine/gaesecrets/gaesecrets.go#L84-L96
130,908
luci/luci-go
client/cmd/swarming/trigger.go
mapToArray
func mapToArray(m stringmapflag.Value) []*swarming.SwarmingRpcsStringPair { a := make([]*swarming.SwarmingRpcsStringPair, 0, len(m)) for k, v := range m { a = append(a, &swarming.SwarmingRpcsStringPair{Key: k, Value: v}) } sort.Sort(array(a)) return a }
go
func mapToArray(m stringmapflag.Value) []*swarming.SwarmingRpcsStringPair { a := make([]*swarming.SwarmingRpcsStringPair, 0, len(m)) for k, v := range m { a = append(a, &swarming.SwarmingRpcsStringPair{Key: k, Value: v}) } sort.Sort(array(a)) return a }
[ "func", "mapToArray", "(", "m", "stringmapflag", ".", "Value", ")", "[", "]", "*", "swarming", ".", "SwarmingRpcsStringPair", "{", "a", ":=", "make", "(", "[", "]", "*", "swarming", ".", "SwarmingRpcsStringPair", ",", "0", ",", "len", "(", "m", ")", ")...
// mapToArray converts a stringmapflag.Value into an array of // swarming.SwarmingRpcsStringPair, sorted by key and then value.
[ "mapToArray", "converts", "a", "stringmapflag", ".", "Value", "into", "an", "array", "of", "swarming", ".", "SwarmingRpcsStringPair", "sorted", "by", "key", "and", "then", "value", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/client/cmd/swarming/trigger.go#L62-L70
130,909
luci/luci-go
appengine/gaeauth/server/internal/authdbimpl/helpers.go
setAuthService
func setAuthService(c context.Context, s authService) context.Context { return context.WithValue(c, contextKey(0), s) }
go
func setAuthService(c context.Context, s authService) context.Context { return context.WithValue(c, contextKey(0), s) }
[ "func", "setAuthService", "(", "c", "context", ".", "Context", ",", "s", "authService", ")", "context", ".", "Context", "{", "return", "context", ".", "WithValue", "(", "c", ",", "contextKey", "(", "0", ")", ",", "s", ")", "\n", "}" ]
// setAuthService injects authService implementation into the context. // // Used in unit tests.
[ "setAuthService", "injects", "authService", "implementation", "into", "the", "context", ".", "Used", "in", "unit", "tests", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/appengine/gaeauth/server/internal/authdbimpl/helpers.go#L41-L43
130,910
luci/luci-go
lucicfg/vars/vars.go
OpenScope
func (v *Vars) OpenScope(th *starlark.Thread) { v.scopes = append(v.scopes, &scope{thread: th}) }
go
func (v *Vars) OpenScope(th *starlark.Thread) { v.scopes = append(v.scopes, &scope{thread: th}) }
[ "func", "(", "v", "*", "Vars", ")", "OpenScope", "(", "th", "*", "starlark", ".", "Thread", ")", "{", "v", ".", "scopes", "=", "append", "(", "v", ".", "scopes", ",", "&", "scope", "{", "thread", ":", "th", "}", ")", "\n", "}" ]
// OpenScope opens a new scope for variables. // // All changes to variables' values made within this scope are discarded when it // is closed.
[ "OpenScope", "opens", "a", "new", "scope", "for", "variables", ".", "All", "changes", "to", "variables", "values", "made", "within", "this", "scope", "are", "discarded", "when", "it", "is", "closed", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/lucicfg/vars/vars.go#L73-L75
130,911
luci/luci-go
lucicfg/vars/vars.go
CloseScope
func (v *Vars) CloseScope(th *starlark.Thread) { switch { case len(v.scopes) == 0: panic("unexpected CloseScope call without matching OpenScope") case v.scopes[len(v.scopes)-1].thread != th: // This check may fail if Interpreter is using multiple goroutines to // execute 'exec's. It shouldn't. If this ever hap...
go
func (v *Vars) CloseScope(th *starlark.Thread) { switch { case len(v.scopes) == 0: panic("unexpected CloseScope call without matching OpenScope") case v.scopes[len(v.scopes)-1].thread != th: // This check may fail if Interpreter is using multiple goroutines to // execute 'exec's. It shouldn't. If this ever hap...
[ "func", "(", "v", "*", "Vars", ")", "CloseScope", "(", "th", "*", "starlark", ".", "Thread", ")", "{", "switch", "{", "case", "len", "(", "v", ".", "scopes", ")", "==", "0", ":", "panic", "(", "\"", "\"", ")", "\n", "case", "v", ".", "scopes", ...
// CloseScope discards changes made to variables since the matching OpenScope.
[ "CloseScope", "discards", "changes", "made", "to", "variables", "since", "the", "matching", "OpenScope", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/lucicfg/vars/vars.go#L78-L92
130,912
luci/luci-go
lucicfg/vars/vars.go
ClearValues
func (v *Vars) ClearValues() { for _, s := range v.scopes { s.values = nil } }
go
func (v *Vars) ClearValues() { for _, s := range v.scopes { s.values = nil } }
[ "func", "(", "v", "*", "Vars", ")", "ClearValues", "(", ")", "{", "for", "_", ",", "s", ":=", "range", "v", ".", "scopes", "{", "s", ".", "values", "=", "nil", "\n", "}", "\n", "}" ]
// ClearValues resets values of all variables, in all scopes. // // Should be used only from tests that want a clean slate.
[ "ClearValues", "resets", "values", "of", "all", "variables", "in", "all", "scopes", ".", "Should", "be", "used", "only", "from", "tests", "that", "want", "a", "clean", "slate", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/lucicfg/vars/vars.go#L97-L101
130,913
luci/luci-go
lucicfg/vars/vars.go
checkVarsAccess
func (v *Vars) checkVarsAccess(th *starlark.Thread, id ID) error { switch { case interpreter.GetThreadKind(th) != interpreter.ThreadExecing: return fmt.Errorf("only code that is being exec'ed is allowed to get or set variables") case len(v.scopes) == 0: return fmt.Errorf("not inside an exec scope") // shouldn't ...
go
func (v *Vars) checkVarsAccess(th *starlark.Thread, id ID) error { switch { case interpreter.GetThreadKind(th) != interpreter.ThreadExecing: return fmt.Errorf("only code that is being exec'ed is allowed to get or set variables") case len(v.scopes) == 0: return fmt.Errorf("not inside an exec scope") // shouldn't ...
[ "func", "(", "v", "*", "Vars", ")", "checkVarsAccess", "(", "th", "*", "starlark", ".", "Thread", ",", "id", "ID", ")", "error", "{", "switch", "{", "case", "interpreter", ".", "GetThreadKind", "(", "th", ")", "!=", "interpreter", ".", "ThreadExecing", ...
// checkVarsAccess verifies the variable is being used in an allowed context.
[ "checkVarsAccess", "verifies", "the", "variable", "is", "being", "used", "in", "an", "allowed", "context", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/lucicfg/vars/vars.go#L157-L168
130,914
luci/luci-go
lucicfg/vars/vars.go
lookup
func (v *Vars) lookup(id ID) *varValue { for idx := len(v.scopes) - 1; idx >= 0; idx-- { if val, ok := v.scopes[idx].values[id]; ok { return &val } } return nil }
go
func (v *Vars) lookup(id ID) *varValue { for idx := len(v.scopes) - 1; idx >= 0; idx-- { if val, ok := v.scopes[idx].values[id]; ok { return &val } } return nil }
[ "func", "(", "v", "*", "Vars", ")", "lookup", "(", "id", "ID", ")", "*", "varValue", "{", "for", "idx", ":=", "len", "(", "v", ".", "scopes", ")", "-", "1", ";", "idx", ">=", "0", ";", "idx", "--", "{", "if", "val", ",", "ok", ":=", "v", ...
// lookup finds the variable's value in the current scope or any of parent // scopes.
[ "lookup", "finds", "the", "variable", "s", "value", "in", "the", "current", "scope", "or", "any", "of", "parent", "scopes", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/lucicfg/vars/vars.go#L172-L179
130,915
luci/luci-go
lucicfg/vars/vars.go
assign
func (v *Vars) assign(th *starlark.Thread, id ID, value starlark.Value, auto bool) error { // Forbid sneaky cross-scope communication through in-place mutations of the // variable's value. value.Freeze() // Remember where assignment happened, for the error message in Set(). trace, err := builtins.CaptureStacktrac...
go
func (v *Vars) assign(th *starlark.Thread, id ID, value starlark.Value, auto bool) error { // Forbid sneaky cross-scope communication through in-place mutations of the // variable's value. value.Freeze() // Remember where assignment happened, for the error message in Set(). trace, err := builtins.CaptureStacktrac...
[ "func", "(", "v", "*", "Vars", ")", "assign", "(", "th", "*", "starlark", ".", "Thread", ",", "id", "ID", ",", "value", "starlark", ".", "Value", ",", "auto", "bool", ")", "error", "{", "// Forbid sneaky cross-scope communication through in-place mutations of th...
// assign sets the variable's value in the innermost scope.
[ "assign", "sets", "the", "variable", "s", "value", "in", "the", "innermost", "scope", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/lucicfg/vars/vars.go#L182-L200
130,916
luci/luci-go
lucicfg/normalize/cq.go
CQ
func CQ(c context.Context, cfg *pb.Config) error { // Normalize each ConfigGroup individually first. for _, cg := range cfg.ConfigGroups { for _, g := range cg.Gerrit { normalizeGerrit(g) } sort.Slice(cg.Gerrit, func(i, j int) bool { return cg.Gerrit[i].Url < cg.Gerrit[j].Url }) if cg.Verifiers != nil...
go
func CQ(c context.Context, cfg *pb.Config) error { // Normalize each ConfigGroup individually first. for _, cg := range cfg.ConfigGroups { for _, g := range cg.Gerrit { normalizeGerrit(g) } sort.Slice(cg.Gerrit, func(i, j int) bool { return cg.Gerrit[i].Url < cg.Gerrit[j].Url }) if cg.Verifiers != nil...
[ "func", "CQ", "(", "c", "context", ".", "Context", ",", "cfg", "*", "pb", ".", "Config", ")", "error", "{", "// Normalize each ConfigGroup individually first.", "for", "_", ",", "cg", ":=", "range", "cfg", ".", "ConfigGroups", "{", "for", "_", ",", "g", ...
// CQ normalizes cq.cfg config.
[ "CQ", "normalizes", "cq", ".", "cfg", "config", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/lucicfg/normalize/cq.go#L26-L53
130,917
luci/luci-go
logdog/common/types/streamname.go
Construct
func Construct(parts ...string) string { pidx := 0 for _, v := range parts { if v == "" { continue } parts[pidx] = strings.Trim(v, StreamNameSepStr) pidx++ } return strings.Join(parts[:pidx], StreamNameSepStr) }
go
func Construct(parts ...string) string { pidx := 0 for _, v := range parts { if v == "" { continue } parts[pidx] = strings.Trim(v, StreamNameSepStr) pidx++ } return strings.Join(parts[:pidx], StreamNameSepStr) }
[ "func", "Construct", "(", "parts", "...", "string", ")", "string", "{", "pidx", ":=", "0", "\n", "for", "_", ",", "v", ":=", "range", "parts", "{", "if", "v", "==", "\"", "\"", "{", "continue", "\n", "}", "\n", "parts", "[", "pidx", "]", "=", "...
// Construct builds a path string from a series of individual path components. // Any leading and trailing separators will be stripped from the components. // // The result value will be a valid StreamName if all of the parts are // valid StreamName strings. Likewise, it may be a valid StreamPath if // StreamPathSep is...
[ "Construct", "builds", "a", "path", "string", "from", "a", "series", "of", "individual", "path", "components", ".", "Any", "leading", "and", "trailing", "separators", "will", "be", "stripped", "from", "the", "components", ".", "The", "result", "value", "will",...
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/logdog/common/types/streamname.go#L68-L78
130,918
luci/luci-go
logdog/common/types/streamname.go
Join
func (s StreamName) Join(o StreamName) StreamPath { return StreamPath(fmt.Sprintf("%s%c%c%c%s", s.Trim(), StreamNameSep, StreamPathSep, StreamNameSep, o.Trim())) }
go
func (s StreamName) Join(o StreamName) StreamPath { return StreamPath(fmt.Sprintf("%s%c%c%c%s", s.Trim(), StreamNameSep, StreamPathSep, StreamNameSep, o.Trim())) }
[ "func", "(", "s", "StreamName", ")", "Join", "(", "o", "StreamName", ")", "StreamPath", "{", "return", "StreamPath", "(", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "s", ".", "Trim", "(", ")", ",", "StreamNameSep", ",", "StreamPathSep", ",", "StreamN...
// Join concatenates a stream name onto the end of the current name, separating // it with a separator character.
[ "Join", "concatenates", "a", "stream", "name", "onto", "the", "end", "of", "the", "current", "name", "separating", "it", "with", "a", "separator", "character", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/logdog/common/types/streamname.go#L166-L169
130,919
luci/luci-go
logdog/common/types/streamname.go
Concat
func (s StreamName) Concat(o ...StreamName) StreamName { parts := make([]string, len(o)+1) parts[0] = string(s) for i, c := range o { parts[i+1] = string(c) } return StreamName(Construct(parts...)) }
go
func (s StreamName) Concat(o ...StreamName) StreamName { parts := make([]string, len(o)+1) parts[0] = string(s) for i, c := range o { parts[i+1] = string(c) } return StreamName(Construct(parts...)) }
[ "func", "(", "s", "StreamName", ")", "Concat", "(", "o", "...", "StreamName", ")", "StreamName", "{", "parts", ":=", "make", "(", "[", "]", "string", ",", "len", "(", "o", ")", "+", "1", ")", "\n", "parts", "[", "0", "]", "=", "string", "(", "s...
// Concat constructs a StreamName by concatenating several StreamName components // together.
[ "Concat", "constructs", "a", "StreamName", "by", "concatenating", "several", "StreamName", "components", "together", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/logdog/common/types/streamname.go#L173-L180
130,920
luci/luci-go
logdog/common/types/streamname.go
Validate
func (s StreamName) Validate() error { if len(s) == 0 { return errors.New("must contain at least one character") } if len(s) > MaxStreamNameLength { return fmt.Errorf("stream name is too long (%d > %d)", len(s), MaxStreamNameLength) } var lastRune rune var segmentIdx int for idx, r := range s { // Alphanu...
go
func (s StreamName) Validate() error { if len(s) == 0 { return errors.New("must contain at least one character") } if len(s) > MaxStreamNameLength { return fmt.Errorf("stream name is too long (%d > %d)", len(s), MaxStreamNameLength) } var lastRune rune var segmentIdx int for idx, r := range s { // Alphanu...
[ "func", "(", "s", "StreamName", ")", "Validate", "(", ")", "error", "{", "if", "len", "(", "s", ")", "==", "0", "{", "return", "errors", ".", "New", "(", "\"", "\"", ")", "\n", "}", "\n", "if", "len", "(", "s", ")", ">", "MaxStreamNameLength", ...
// Validate tests whether the stream name is valid.
[ "Validate", "tests", "whether", "the", "stream", "name", "is", "valid", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/logdog/common/types/streamname.go#L196-L230
130,921
luci/luci-go
logdog/common/types/streamname.go
Segments
func (s StreamName) Segments() []string { if len(s) == 0 { return nil } return strings.Split(string(s), string(StreamNameSep)) }
go
func (s StreamName) Segments() []string { if len(s) == 0 { return nil } return strings.Split(string(s), string(StreamNameSep)) }
[ "func", "(", "s", "StreamName", ")", "Segments", "(", ")", "[", "]", "string", "{", "if", "len", "(", "s", ")", "==", "0", "{", "return", "nil", "\n", "}", "\n", "return", "strings", ".", "Split", "(", "string", "(", "s", ")", ",", "string", "(...
// Segments returns the individual StreamName segments by splitting splitting // the StreamName with StreamNameSep.
[ "Segments", "returns", "the", "individual", "StreamName", "segments", "by", "splitting", "splitting", "the", "StreamName", "with", "StreamNameSep", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/logdog/common/types/streamname.go#L234-L239
130,922
luci/luci-go
logdog/common/types/streamname.go
Append
func (p StreamPath) Append(n string) StreamPath { return StreamPath(Construct(string(p), n)) }
go
func (p StreamPath) Append(n string) StreamPath { return StreamPath(Construct(string(p), n)) }
[ "func", "(", "p", "StreamPath", ")", "Append", "(", "n", "string", ")", "StreamPath", "{", "return", "StreamPath", "(", "Construct", "(", "string", "(", "p", ")", ",", "n", ")", ")", "\n", "}" ]
// Append returns a StreamPath consisting of the current StreamPath with the // supplied StreamName appended to the end. // // Append will return a valid StreamPath if p and n are both valid.
[ "Append", "returns", "a", "StreamPath", "consisting", "of", "the", "current", "StreamPath", "with", "the", "supplied", "StreamName", "appended", "to", "the", "end", ".", "Append", "will", "return", "a", "valid", "StreamPath", "if", "p", "and", "n", "are", "b...
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/logdog/common/types/streamname.go#L401-L403
130,923
luci/luci-go
dm/api/service/v1/quest_desc_normalize.go
IsEmpty
func (q *Quest_Desc_Meta_Retry) IsEmpty() bool { return q.Crashed == 0 && q.Expired == 0 && q.Failed == 0 && q.TimedOut == 0 }
go
func (q *Quest_Desc_Meta_Retry) IsEmpty() bool { return q.Crashed == 0 && q.Expired == 0 && q.Failed == 0 && q.TimedOut == 0 }
[ "func", "(", "q", "*", "Quest_Desc_Meta_Retry", ")", "IsEmpty", "(", ")", "bool", "{", "return", "q", ".", "Crashed", "==", "0", "&&", "q", ".", "Expired", "==", "0", "&&", "q", ".", "Failed", "==", "0", "&&", "q", ".", "TimedOut", "==", "0", "\n...
// IsEmpty returns true if this metadata retry message only contains // zero-values.
[ "IsEmpty", "returns", "true", "if", "this", "metadata", "retry", "message", "only", "contains", "zero", "-", "values", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/dm/api/service/v1/quest_desc_normalize.go#L29-L31
130,924
luci/luci-go
dm/api/service/v1/quest_desc_normalize.go
Normalize
func (t *Quest_Desc_Meta_Timeouts) Normalize() error { if d := google.DurationFromProto(t.Start); d < 0 { return fmt.Errorf("desc.meta.timeouts.start < 0: %s", d) } if d := google.DurationFromProto(t.Run); d < 0 { return fmt.Errorf("desc.meta.timeouts.run < 0: %s", d) } if d := google.DurationFromProto(t.Stop)...
go
func (t *Quest_Desc_Meta_Timeouts) Normalize() error { if d := google.DurationFromProto(t.Start); d < 0 { return fmt.Errorf("desc.meta.timeouts.start < 0: %s", d) } if d := google.DurationFromProto(t.Run); d < 0 { return fmt.Errorf("desc.meta.timeouts.run < 0: %s", d) } if d := google.DurationFromProto(t.Stop)...
[ "func", "(", "t", "*", "Quest_Desc_Meta_Timeouts", ")", "Normalize", "(", ")", "error", "{", "if", "d", ":=", "google", ".", "DurationFromProto", "(", "t", ".", "Start", ")", ";", "d", "<", "0", "{", "return", "fmt", ".", "Errorf", "(", "\"", "\"", ...
// Normalize ensures that all timeouts are >= 0
[ "Normalize", "ensures", "that", "all", "timeouts", "are", ">", "=", "0" ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/dm/api/service/v1/quest_desc_normalize.go#L34-L45
130,925
luci/luci-go
dm/api/service/v1/quest_desc_normalize.go
Normalize
func (q *Quest_Desc) Normalize() error { if q.Meta == nil { q.Meta = &Quest_Desc_Meta{ Retry: &Quest_Desc_Meta_Retry{}, Timeouts: &Quest_Desc_Meta_Timeouts{}, } } else { if q.Meta.Retry == nil { q.Meta.Retry = &Quest_Desc_Meta_Retry{} } if q.Meta.Timeouts == nil { q.Meta.Timeouts = &Quest_Des...
go
func (q *Quest_Desc) Normalize() error { if q.Meta == nil { q.Meta = &Quest_Desc_Meta{ Retry: &Quest_Desc_Meta_Retry{}, Timeouts: &Quest_Desc_Meta_Timeouts{}, } } else { if q.Meta.Retry == nil { q.Meta.Retry = &Quest_Desc_Meta_Retry{} } if q.Meta.Timeouts == nil { q.Meta.Timeouts = &Quest_Des...
[ "func", "(", "q", "*", "Quest_Desc", ")", "Normalize", "(", ")", "error", "{", "if", "q", ".", "Meta", "==", "nil", "{", "q", ".", "Meta", "=", "&", "Quest_Desc_Meta", "{", "Retry", ":", "&", "Quest_Desc_Meta_Retry", "{", "}", ",", "Timeouts", ":", ...
// Normalize returns an error iff the Quest_Desc is invalid.
[ "Normalize", "returns", "an", "error", "iff", "the", "Quest_Desc", "is", "invalid", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/dm/api/service/v1/quest_desc_normalize.go#L63-L98
130,926
luci/luci-go
common/gcloud/iam/client.go
GetIAMPolicy
func (cl *Client) GetIAMPolicy(c context.Context, resource string) (*Policy, error) { response := &Policy{} if err := cl.iamAPIRequest(c, resource, "getIamPolicy", nil, response); err != nil { return nil, err } return response, nil }
go
func (cl *Client) GetIAMPolicy(c context.Context, resource string) (*Policy, error) { response := &Policy{} if err := cl.iamAPIRequest(c, resource, "getIamPolicy", nil, response); err != nil { return nil, err } return response, nil }
[ "func", "(", "cl", "*", "Client", ")", "GetIAMPolicy", "(", "c", "context", ".", "Context", ",", "resource", "string", ")", "(", "*", "Policy", ",", "error", ")", "{", "response", ":=", "&", "Policy", "{", "}", "\n", "if", "err", ":=", "cl", ".", ...
// GetIAMPolicy fetches an IAM policy of a resource. // // On non-success HTTP status codes returns googleapi.Error.
[ "GetIAMPolicy", "fetches", "an", "IAM", "policy", "of", "a", "resource", ".", "On", "non", "-", "success", "HTTP", "status", "codes", "returns", "googleapi", ".", "Error", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/common/gcloud/iam/client.go#L145-L151
130,927
luci/luci-go
common/gcloud/iam/client.go
iamAPIRequest
func (cl *Client) iamAPIRequest(c context.Context, resource, action string, body, resp interface{}) error { if cl.BasePath != "" { // We are in "testing" base, err := url.Parse(cl.BasePath) if err != nil { return err } return cl.genericAPIRequest(c, base, resource, action, body, resp) } return cl.generi...
go
func (cl *Client) iamAPIRequest(c context.Context, resource, action string, body, resp interface{}) error { if cl.BasePath != "" { // We are in "testing" base, err := url.Parse(cl.BasePath) if err != nil { return err } return cl.genericAPIRequest(c, base, resource, action, body, resp) } return cl.generi...
[ "func", "(", "cl", "*", "Client", ")", "iamAPIRequest", "(", "c", "context", ".", "Context", ",", "resource", ",", "action", "string", ",", "body", ",", "resp", "interface", "{", "}", ")", "error", "{", "if", "cl", ".", "BasePath", "!=", "\"", "\"", ...
// iamAPIRequest performs HTTP POST to the core IAM API endpoint.
[ "iamAPIRequest", "performs", "HTTP", "POST", "to", "the", "core", "IAM", "API", "endpoint", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/common/gcloud/iam/client.go#L237-L247
130,928
luci/luci-go
common/gcloud/iam/client.go
genericAPIRequest
func (cl *Client) genericAPIRequest(c context.Context, base *url.URL, resource, action string, body, resp interface{}) error { query, err := url.Parse(fmt.Sprintf("v1/%s:%s?alt=json", resource, action)) if err != nil { return err } endpoint := base.ResolveReference(query) // Serialize the body. var reader io.R...
go
func (cl *Client) genericAPIRequest(c context.Context, base *url.URL, resource, action string, body, resp interface{}) error { query, err := url.Parse(fmt.Sprintf("v1/%s:%s?alt=json", resource, action)) if err != nil { return err } endpoint := base.ResolveReference(query) // Serialize the body. var reader io.R...
[ "func", "(", "cl", "*", "Client", ")", "genericAPIRequest", "(", "c", "context", ".", "Context", ",", "base", "*", "url", ".", "URL", ",", "resource", ",", "action", "string", ",", "body", ",", "resp", "interface", "{", "}", ")", "error", "{", "query...
// genericAPIRequest performs HTTP POST to an IAM API endpoint.
[ "genericAPIRequest", "performs", "HTTP", "POST", "to", "an", "IAM", "API", "endpoint", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/common/gcloud/iam/client.go#L263-L302
130,929
luci/luci-go
cipd/appengine/impl/model/instance.go
Proto
func (e *Instance) Proto() *api.Instance { return &api.Instance{ Package: e.Package.StringID(), Instance: common.InstanceIDToObjectRef(e.InstanceID), RegisteredBy: e.RegisteredBy, RegisteredTs: google.NewTimestamp(e.RegisteredTs), } }
go
func (e *Instance) Proto() *api.Instance { return &api.Instance{ Package: e.Package.StringID(), Instance: common.InstanceIDToObjectRef(e.InstanceID), RegisteredBy: e.RegisteredBy, RegisteredTs: google.NewTimestamp(e.RegisteredTs), } }
[ "func", "(", "e", "*", "Instance", ")", "Proto", "(", ")", "*", "api", ".", "Instance", "{", "return", "&", "api", ".", "Instance", "{", "Package", ":", "e", ".", "Package", ".", "StringID", "(", ")", ",", "Instance", ":", "common", ".", "InstanceI...
// Proto returns cipd.Instance proto with information from this entity.
[ "Proto", "returns", "cipd", ".", "Instance", "proto", "with", "information", "from", "this", "entity", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/cipd/appengine/impl/model/instance.go#L61-L68
130,930
luci/luci-go
cipd/appengine/impl/model/instance.go
FromProto
func (e *Instance) FromProto(c context.Context, p *api.Instance) *Instance { e.InstanceID = common.ObjectRefToInstanceID(p.Instance) e.Package = PackageKey(c, p.Package) return e }
go
func (e *Instance) FromProto(c context.Context, p *api.Instance) *Instance { e.InstanceID = common.ObjectRefToInstanceID(p.Instance) e.Package = PackageKey(c, p.Package) return e }
[ "func", "(", "e", "*", "Instance", ")", "FromProto", "(", "c", "context", ".", "Context", ",", "p", "*", "api", ".", "Instance", ")", "*", "Instance", "{", "e", ".", "InstanceID", "=", "common", ".", "ObjectRefToInstanceID", "(", "p", ".", "Instance", ...
// FromProto fills in the entity based on the proto message. // // Returns the entity itself for easier chaining. // // Doesn't touch output-only fields at all.
[ "FromProto", "fills", "in", "the", "entity", "based", "on", "the", "proto", "message", ".", "Returns", "the", "entity", "itself", "for", "easier", "chaining", ".", "Doesn", "t", "touch", "output", "-", "only", "fields", "at", "all", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/cipd/appengine/impl/model/instance.go#L75-L79
130,931
luci/luci-go
cipd/appengine/impl/model/instance.go
CheckInstanceExists
func CheckInstanceExists(c context.Context, inst *Instance) error { switch err := datastore.Get(c, inst); { case err == datastore.ErrNoSuchEntity: // Maybe the package is missing completely? if err := CheckPackageExists(c, inst.Package.StringID()); err != nil { return err } return errors.Reason("no such in...
go
func CheckInstanceExists(c context.Context, inst *Instance) error { switch err := datastore.Get(c, inst); { case err == datastore.ErrNoSuchEntity: // Maybe the package is missing completely? if err := CheckPackageExists(c, inst.Package.StringID()); err != nil { return err } return errors.Reason("no such in...
[ "func", "CheckInstanceExists", "(", "c", "context", ".", "Context", ",", "inst", "*", "Instance", ")", "error", "{", "switch", "err", ":=", "datastore", ".", "Get", "(", "c", ",", "inst", ")", ";", "{", "case", "err", "==", "datastore", ".", "ErrNoSuch...
// CheckInstanceExists fetches the instance and verifies it exists. // // Can be called as part of a transaction. Updates 'inst' in place. // // Returns gRPC-tagged NotFound error if there's no such instance or package.
[ "CheckInstanceExists", "fetches", "the", "instance", "and", "verifies", "it", "exists", ".", "Can", "be", "called", "as", "part", "of", "a", "transaction", ".", "Updates", "inst", "in", "place", ".", "Returns", "gRPC", "-", "tagged", "NotFound", "error", "if...
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/cipd/appengine/impl/model/instance.go#L197-L210
130,932
luci/luci-go
tokenserver/cmd/luci_machine_tokend/status.go
OutcomeFromRPCError
func OutcomeFromRPCError(err error) UpdateOutcome { if err == nil { return OutcomeUpdateSuccess } if details, ok := err.(client.RPCError); ok { if details.GrpcCode != codes.OK { return UpdateOutcome(fmt.Sprintf("GRPC_ERROR_%d", details.GrpcCode)) } return UpdateOutcome(fmt.Sprintf("MINT_TOKEN_ERROR_%s", d...
go
func OutcomeFromRPCError(err error) UpdateOutcome { if err == nil { return OutcomeUpdateSuccess } if details, ok := err.(client.RPCError); ok { if details.GrpcCode != codes.OK { return UpdateOutcome(fmt.Sprintf("GRPC_ERROR_%d", details.GrpcCode)) } return UpdateOutcome(fmt.Sprintf("MINT_TOKEN_ERROR_%s", d...
[ "func", "OutcomeFromRPCError", "(", "err", "error", ")", "UpdateOutcome", "{", "if", "err", "==", "nil", "{", "return", "OutcomeUpdateSuccess", "\n", "}", "\n", "if", "details", ",", "ok", ":=", "err", ".", "(", "client", ".", "RPCError", ")", ";", "ok",...
// OutcomeFromRPCError transform MintToken error into an update outcome.
[ "OutcomeFromRPCError", "transform", "MintToken", "error", "into", "an", "update", "outcome", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/tokenserver/cmd/luci_machine_tokend/status.go#L52-L63
130,933
luci/luci-go
tokenserver/cmd/luci_machine_tokend/status.go
Report
func (s *StatusReport) Report() *Report { rep := &Report{ TokendVersion: s.Version, ServiceVersion: s.ServiceVersion, StartedTS: s.Started.Unix(), TotalDuration: s.Finished.Sub(s.Started).Nanoseconds() / 1000, RPCDuration: s.MintTokenDuration.Nanoseconds() / 1000, UpdateOutcome: string(s.UpdateO...
go
func (s *StatusReport) Report() *Report { rep := &Report{ TokendVersion: s.Version, ServiceVersion: s.ServiceVersion, StartedTS: s.Started.Unix(), TotalDuration: s.Finished.Sub(s.Started).Nanoseconds() / 1000, RPCDuration: s.MintTokenDuration.Nanoseconds() / 1000, UpdateOutcome: string(s.UpdateO...
[ "func", "(", "s", "*", "StatusReport", ")", "Report", "(", ")", "*", "Report", "{", "rep", ":=", "&", "Report", "{", "TokendVersion", ":", "s", ".", "Version", ",", "ServiceVersion", ":", "s", ".", "ServiceVersion", ",", "StartedTS", ":", "s", ".", "...
// Report gathers the report into single JSON-serializable struct.
[ "Report", "gathers", "the", "report", "into", "single", "JSON", "-", "serializable", "struct", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/tokenserver/cmd/luci_machine_tokend/status.go#L109-L128
130,934
luci/luci-go
tokenserver/cmd/luci_machine_tokend/status.go
SaveToFile
func (s *StatusReport) SaveToFile(ctx context.Context, l *memlogger.MemLogger, path string) error { report := s.Report() buf := bytes.Buffer{} l.Dump(&buf) report.LogDump = buf.String() blob, err := json.MarshalIndent(report, "", " ") if err != nil { return err } return AtomicWriteFile(ctx, path, blob, 064...
go
func (s *StatusReport) SaveToFile(ctx context.Context, l *memlogger.MemLogger, path string) error { report := s.Report() buf := bytes.Buffer{} l.Dump(&buf) report.LogDump = buf.String() blob, err := json.MarshalIndent(report, "", " ") if err != nil { return err } return AtomicWriteFile(ctx, path, blob, 064...
[ "func", "(", "s", "*", "StatusReport", ")", "SaveToFile", "(", "ctx", "context", ".", "Context", ",", "l", "*", "memlogger", ".", "MemLogger", ",", "path", "string", ")", "error", "{", "report", ":=", "s", ".", "Report", "(", ")", "\n\n", "buf", ":="...
// SaveToFile saves the status report and log to a file on disk.
[ "SaveToFile", "saves", "the", "status", "report", "and", "log", "to", "a", "file", "on", "disk", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/tokenserver/cmd/luci_machine_tokend/status.go#L131-L143
130,935
luci/luci-go
tokenserver/cmd/luci_machine_tokend/status.go
SendMetrics
func (s *StatusReport) SendMetrics(c context.Context) error { c, _ = context.WithTimeout(c, 10*time.Second) rep := s.Report() metricVersion.Set(c, rep.TokendVersion) if rep.ServiceVersion != "" { metricServiceVersion.Set(c, rep.ServiceVersion) } if rep.TokenExpiryTS != 0 { metricTokenExpiry.Set(c, rep.TokenE...
go
func (s *StatusReport) SendMetrics(c context.Context) error { c, _ = context.WithTimeout(c, 10*time.Second) rep := s.Report() metricVersion.Set(c, rep.TokendVersion) if rep.ServiceVersion != "" { metricServiceVersion.Set(c, rep.ServiceVersion) } if rep.TokenExpiryTS != 0 { metricTokenExpiry.Set(c, rep.TokenE...
[ "func", "(", "s", "*", "StatusReport", ")", "SendMetrics", "(", "c", "context", ".", "Context", ")", "error", "{", "c", ",", "_", "=", "context", ".", "WithTimeout", "(", "c", ",", "10", "*", "time", ".", "Second", ")", "\n", "rep", ":=", "s", "....
// SendMetrics is called at the end of the token update process. // // It dumps all relevant metrics to tsmon.
[ "SendMetrics", "is", "called", "at", "the", "end", "of", "the", "token", "update", "process", ".", "It", "dumps", "all", "relevant", "metrics", "to", "tsmon", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/tokenserver/cmd/luci_machine_tokend/status.go#L211-L234
130,936
luci/luci-go
grpc/cmd/prpc/printer.go
SetFile
func (p *printer) SetFile(f *descriptor.FileDescriptorProto) error { p.file = f var err error p.sourceCodeInfo, err = descutil.IndexSourceCodeInfo(f) return err }
go
func (p *printer) SetFile(f *descriptor.FileDescriptorProto) error { p.file = f var err error p.sourceCodeInfo, err = descutil.IndexSourceCodeInfo(f) return err }
[ "func", "(", "p", "*", "printer", ")", "SetFile", "(", "f", "*", "descriptor", ".", "FileDescriptorProto", ")", "error", "{", "p", ".", "file", "=", "f", "\n", "var", "err", "error", "\n", "p", ".", "sourceCodeInfo", ",", "err", "=", "descutil", ".",...
// SetFile specifies the file containing the descriptors being printed. // Used to relativize names and print comments.
[ "SetFile", "specifies", "the", "file", "containing", "the", "descriptors", "being", "printed", ".", "Used", "to", "relativize", "names", "and", "print", "comments", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/grpc/cmd/prpc/printer.go#L46-L51
130,937
luci/luci-go
grpc/cmd/prpc/printer.go
Printf
func (p *printer) Printf(format string, a ...interface{}) { if p.Err == nil { _, p.Err = fmt.Fprintf(&p.Out, format, a...) } }
go
func (p *printer) Printf(format string, a ...interface{}) { if p.Err == nil { _, p.Err = fmt.Fprintf(&p.Out, format, a...) } }
[ "func", "(", "p", "*", "printer", ")", "Printf", "(", "format", "string", ",", "a", "...", "interface", "{", "}", ")", "{", "if", "p", ".", "Err", "==", "nil", "{", "_", ",", "p", ".", "Err", "=", "fmt", ".", "Fprintf", "(", "&", "p", ".", ...
// Printf prints to p.Out unless there was an error.
[ "Printf", "prints", "to", "p", ".", "Out", "unless", "there", "was", "an", "error", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/grpc/cmd/prpc/printer.go#L54-L58
130,938
luci/luci-go
grpc/cmd/prpc/printer.go
MaybeLeadingComments
func (p *printer) MaybeLeadingComments(ptr interface{}) { comments := p.sourceCodeInfo[ptr].GetLeadingComments() // print comments, but insert "//" before each newline. for len(comments) > 0 { var toPrint string if lineEnd := strings.Index(comments, "\n"); lineEnd >= 0 { toPrint = comments[:lineEnd+1] // incl...
go
func (p *printer) MaybeLeadingComments(ptr interface{}) { comments := p.sourceCodeInfo[ptr].GetLeadingComments() // print comments, but insert "//" before each newline. for len(comments) > 0 { var toPrint string if lineEnd := strings.Index(comments, "\n"); lineEnd >= 0 { toPrint = comments[:lineEnd+1] // incl...
[ "func", "(", "p", "*", "printer", ")", "MaybeLeadingComments", "(", "ptr", "interface", "{", "}", ")", "{", "comments", ":=", "p", ".", "sourceCodeInfo", "[", "ptr", "]", ".", "GetLeadingComments", "(", ")", "\n", "// print comments, but insert \"//\" before eac...
// MaybeLeadingComments prints leading comments of the descriptor proto // if found.
[ "MaybeLeadingComments", "prints", "leading", "comments", "of", "the", "descriptor", "proto", "if", "found", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/grpc/cmd/prpc/printer.go#L80-L96
130,939
luci/luci-go
grpc/cmd/prpc/printer.go
shorten
func (p *printer) shorten(name string) string { name = strings.TrimPrefix(name, ".") if p.file.GetPackage() != "" { name = strings.TrimPrefix(name, p.file.GetPackage()+".") } return name }
go
func (p *printer) shorten(name string) string { name = strings.TrimPrefix(name, ".") if p.file.GetPackage() != "" { name = strings.TrimPrefix(name, p.file.GetPackage()+".") } return name }
[ "func", "(", "p", "*", "printer", ")", "shorten", "(", "name", "string", ")", "string", "{", "name", "=", "strings", ".", "TrimPrefix", "(", "name", ",", "\"", "\"", ")", "\n", "if", "p", ".", "file", ".", "GetPackage", "(", ")", "!=", "\"", "\""...
// shorten removes leading "." and trims package name if it matches p.file.
[ "shorten", "removes", "leading", ".", "and", "trims", "package", "name", "if", "it", "matches", "p", ".", "file", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/grpc/cmd/prpc/printer.go#L99-L105
130,940
luci/luci-go
grpc/cmd/prpc/printer.go
Service
func (p *printer) Service(service *descriptor.ServiceDescriptorProto, methodIndex int) { p.MaybeLeadingComments(service) defer p.open("service %s", service.GetName())() if methodIndex < 0 { for i := range service.Method { p.Method(service.Method[i]) } } else { p.Method(service.Method[methodIndex]) if le...
go
func (p *printer) Service(service *descriptor.ServiceDescriptorProto, methodIndex int) { p.MaybeLeadingComments(service) defer p.open("service %s", service.GetName())() if methodIndex < 0 { for i := range service.Method { p.Method(service.Method[i]) } } else { p.Method(service.Method[methodIndex]) if le...
[ "func", "(", "p", "*", "printer", ")", "Service", "(", "service", "*", "descriptor", ".", "ServiceDescriptorProto", ",", "methodIndex", "int", ")", "{", "p", ".", "MaybeLeadingComments", "(", "service", ")", "\n", "defer", "p", ".", "open", "(", "\"", "\...
// Service prints a service definition. // If methodIndex != -1, only one method is printed. // If serviceIndex != -1, leading comments are printed if found.
[ "Service", "prints", "a", "service", "definition", ".", "If", "methodIndex", "!", "=", "-", "1", "only", "one", "method", "is", "printed", ".", "If", "serviceIndex", "!", "=", "-", "1", "leading", "comments", "are", "printed", "if", "found", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/grpc/cmd/prpc/printer.go#L110-L124
130,941
luci/luci-go
grpc/cmd/prpc/printer.go
Method
func (p *printer) Method(method *descriptor.MethodDescriptorProto) { p.MaybeLeadingComments(method) p.Printf( "rpc %s(%s) returns (%s) {};\n", method.GetName(), p.shorten(method.GetInputType()), p.shorten(method.GetOutputType()), ) }
go
func (p *printer) Method(method *descriptor.MethodDescriptorProto) { p.MaybeLeadingComments(method) p.Printf( "rpc %s(%s) returns (%s) {};\n", method.GetName(), p.shorten(method.GetInputType()), p.shorten(method.GetOutputType()), ) }
[ "func", "(", "p", "*", "printer", ")", "Method", "(", "method", "*", "descriptor", ".", "MethodDescriptorProto", ")", "{", "p", ".", "MaybeLeadingComments", "(", "method", ")", "\n", "p", ".", "Printf", "(", "\"", "\\n", "\"", ",", "method", ".", "GetN...
// Method prints a service method definition.
[ "Method", "prints", "a", "service", "method", "definition", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/grpc/cmd/prpc/printer.go#L127-L135
130,942
luci/luci-go
grpc/cmd/prpc/printer.go
Field
func (p *printer) Field(field *descriptor.FieldDescriptorProto) { p.MaybeLeadingComments(field) if descutil.Repeated(field) { p.Printf("repeated ") } typeName := fieldTypeName[field.GetType()] if typeName == "" { typeName = p.shorten(field.GetTypeName()) } if typeName == "" { typeName = "<unsupported type...
go
func (p *printer) Field(field *descriptor.FieldDescriptorProto) { p.MaybeLeadingComments(field) if descutil.Repeated(field) { p.Printf("repeated ") } typeName := fieldTypeName[field.GetType()] if typeName == "" { typeName = p.shorten(field.GetTypeName()) } if typeName == "" { typeName = "<unsupported type...
[ "func", "(", "p", "*", "printer", ")", "Field", "(", "field", "*", "descriptor", ".", "FieldDescriptorProto", ")", "{", "p", ".", "MaybeLeadingComments", "(", "field", ")", "\n", "if", "descutil", ".", "Repeated", "(", "field", ")", "{", "p", ".", "Pri...
// Field prints a field definition.
[ "Field", "prints", "a", "field", "definition", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/grpc/cmd/prpc/printer.go#L156-L170
130,943
luci/luci-go
grpc/cmd/prpc/printer.go
Message
func (p *printer) Message(msg *descriptor.DescriptorProto) { p.MaybeLeadingComments(msg) defer p.open("message %s", msg.GetName())() for i := range msg.GetOneofDecl() { p.OneOf(msg, i) } for i, f := range msg.Field { if f.OneofIndex == nil { p.Field(msg.Field[i]) } } }
go
func (p *printer) Message(msg *descriptor.DescriptorProto) { p.MaybeLeadingComments(msg) defer p.open("message %s", msg.GetName())() for i := range msg.GetOneofDecl() { p.OneOf(msg, i) } for i, f := range msg.Field { if f.OneofIndex == nil { p.Field(msg.Field[i]) } } }
[ "func", "(", "p", "*", "printer", ")", "Message", "(", "msg", "*", "descriptor", ".", "DescriptorProto", ")", "{", "p", ".", "MaybeLeadingComments", "(", "msg", ")", "\n", "defer", "p", ".", "open", "(", "\"", "\"", ",", "msg", ".", "GetName", "(", ...
// Message prints a message definition.
[ "Message", "prints", "a", "message", "definition", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/grpc/cmd/prpc/printer.go#L173-L186
130,944
luci/luci-go
grpc/cmd/prpc/printer.go
OneOf
func (p *printer) OneOf(msg *descriptor.DescriptorProto, oneOfIndex int) { of := msg.GetOneofDecl()[oneOfIndex] p.MaybeLeadingComments(of) defer p.open("oneof %s", of.GetName())() for i, f := range msg.Field { if f.OneofIndex != nil && int(f.GetOneofIndex()) == oneOfIndex { p.Field(msg.Field[i]) } } }
go
func (p *printer) OneOf(msg *descriptor.DescriptorProto, oneOfIndex int) { of := msg.GetOneofDecl()[oneOfIndex] p.MaybeLeadingComments(of) defer p.open("oneof %s", of.GetName())() for i, f := range msg.Field { if f.OneofIndex != nil && int(f.GetOneofIndex()) == oneOfIndex { p.Field(msg.Field[i]) } } }
[ "func", "(", "p", "*", "printer", ")", "OneOf", "(", "msg", "*", "descriptor", ".", "DescriptorProto", ",", "oneOfIndex", "int", ")", "{", "of", ":=", "msg", ".", "GetOneofDecl", "(", ")", "[", "oneOfIndex", "]", "\n", "p", ".", "MaybeLeadingComments", ...
// OneOf prints a oneof definition.
[ "OneOf", "prints", "a", "oneof", "definition", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/grpc/cmd/prpc/printer.go#L189-L199
130,945
luci/luci-go
grpc/cmd/prpc/printer.go
Enum
func (p *printer) Enum(enum *descriptor.EnumDescriptorProto) { p.MaybeLeadingComments(enum) defer p.open("enum %s", enum.GetName())() for _, v := range enum.Value { p.EnumValue(v) } }
go
func (p *printer) Enum(enum *descriptor.EnumDescriptorProto) { p.MaybeLeadingComments(enum) defer p.open("enum %s", enum.GetName())() for _, v := range enum.Value { p.EnumValue(v) } }
[ "func", "(", "p", "*", "printer", ")", "Enum", "(", "enum", "*", "descriptor", ".", "EnumDescriptorProto", ")", "{", "p", ".", "MaybeLeadingComments", "(", "enum", ")", "\n", "defer", "p", ".", "open", "(", "\"", "\"", ",", "enum", ".", "GetName", "(...
// Enum prints an enum definition.
[ "Enum", "prints", "an", "enum", "definition", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/grpc/cmd/prpc/printer.go#L202-L209
130,946
luci/luci-go
grpc/cmd/prpc/printer.go
EnumValue
func (p *printer) EnumValue(v *descriptor.EnumValueDescriptorProto) { p.MaybeLeadingComments(v) p.Printf("%s = %d;\n", v.GetName(), v.GetNumber()) }
go
func (p *printer) EnumValue(v *descriptor.EnumValueDescriptorProto) { p.MaybeLeadingComments(v) p.Printf("%s = %d;\n", v.GetName(), v.GetNumber()) }
[ "func", "(", "p", "*", "printer", ")", "EnumValue", "(", "v", "*", "descriptor", ".", "EnumValueDescriptorProto", ")", "{", "p", ".", "MaybeLeadingComments", "(", "v", ")", "\n", "p", ".", "Printf", "(", "\"", "\\n", "\"", ",", "v", ".", "GetName", "...
// EnumValue prints an enum value definition.
[ "EnumValue", "prints", "an", "enum", "value", "definition", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/grpc/cmd/prpc/printer.go#L212-L215
130,947
luci/luci-go
cipd/client/cipd/acl.go
prefixMetadataToACLs
func prefixMetadataToACLs(m *api.InheritedPrefixMetadata) (out []PackageACL) { for _, p := range m.PerPrefixMetadata { var acls []PackageACL for _, acl := range p.Acls { role := acl.Role.String() found := false for i, existing := range acls { if existing.Role == role { acls[i].Principals = append...
go
func prefixMetadataToACLs(m *api.InheritedPrefixMetadata) (out []PackageACL) { for _, p := range m.PerPrefixMetadata { var acls []PackageACL for _, acl := range p.Acls { role := acl.Role.String() found := false for i, existing := range acls { if existing.Role == role { acls[i].Principals = append...
[ "func", "prefixMetadataToACLs", "(", "m", "*", "api", ".", "InheritedPrefixMetadata", ")", "(", "out", "[", "]", "PackageACL", ")", "{", "for", "_", ",", "p", ":=", "range", "m", ".", "PerPrefixMetadata", "{", "var", "acls", "[", "]", "PackageACL", "\n",...
// prefixMetadataToACLs extracts ACLs for a prefix and all its parent prefixes // from the prefix's metadata.
[ "prefixMetadataToACLs", "extracts", "ACLs", "for", "a", "prefix", "and", "all", "its", "parent", "prefixes", "from", "the", "prefix", "s", "metadata", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/cipd/client/cipd/acl.go#L67-L93
130,948
luci/luci-go
common/sync/promise/promise.go
New
func New(c context.Context, gen Generator) *Promise { p := Promise{ signalC: make(chan struct{}), } // Execute our generator function in a separate goroutine. go p.runGen(c, gen) return &p }
go
func New(c context.Context, gen Generator) *Promise { p := Promise{ signalC: make(chan struct{}), } // Execute our generator function in a separate goroutine. go p.runGen(c, gen) return &p }
[ "func", "New", "(", "c", "context", ".", "Context", ",", "gen", "Generator", ")", "*", "Promise", "{", "p", ":=", "Promise", "{", "signalC", ":", "make", "(", "chan", "struct", "{", "}", ")", ",", "}", "\n\n", "// Execute our generator function in a separa...
// New instantiates a new, empty Promise instance. The Promise's value will be // the value returned by the supplied generator function. // // The generator will be invoked immediately in its own goroutine.
[ "New", "instantiates", "a", "new", "empty", "Promise", "instance", ".", "The", "Promise", "s", "value", "will", "be", "the", "value", "returned", "by", "the", "supplied", "generator", "function", ".", "The", "generator", "will", "be", "invoked", "immediately",...
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/common/sync/promise/promise.go#L53-L61
130,949
luci/luci-go
common/sync/promise/promise.go
NewDeferred
func NewDeferred(gen Generator) *Promise { var startOnce sync.Once p := Promise{ signalC: make(chan struct{}), } p.onGet = func(c context.Context) { startOnce.Do(func() { p.runGen(c, gen) }) } return &p }
go
func NewDeferred(gen Generator) *Promise { var startOnce sync.Once p := Promise{ signalC: make(chan struct{}), } p.onGet = func(c context.Context) { startOnce.Do(func() { p.runGen(c, gen) }) } return &p }
[ "func", "NewDeferred", "(", "gen", "Generator", ")", "*", "Promise", "{", "var", "startOnce", "sync", ".", "Once", "\n\n", "p", ":=", "Promise", "{", "signalC", ":", "make", "(", "chan", "struct", "{", "}", ")", ",", "}", "\n", "p", ".", "onGet", "...
// NewDeferred instantiates a new, empty Promise instance. The Promise's value // will be the value returned by the supplied generator function. // // Unlike New, the generator function will not be immediately executed. Instead, // it will be run when the first call to Get is made, and will use one of the // Get caller...
[ "NewDeferred", "instantiates", "a", "new", "empty", "Promise", "instance", ".", "The", "Promise", "s", "value", "will", "be", "the", "value", "returned", "by", "the", "supplied", "generator", "function", ".", "Unlike", "New", "the", "generator", "function", "w...
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/common/sync/promise/promise.go#L70-L80
130,950
luci/luci-go
common/sync/promise/promise.go
Get
func (p *Promise) Get(c context.Context) (interface{}, error) { // If we have an onGet function, run it (deferred case). if p.onGet != nil { p.onGet(c) } // Block until at least one of these conditions is satisfied. If both are, // "select" will choose one pseudo-randomly. select { case <-p.signalC: return ...
go
func (p *Promise) Get(c context.Context) (interface{}, error) { // If we have an onGet function, run it (deferred case). if p.onGet != nil { p.onGet(c) } // Block until at least one of these conditions is satisfied. If both are, // "select" will choose one pseudo-randomly. select { case <-p.signalC: return ...
[ "func", "(", "p", "*", "Promise", ")", "Get", "(", "c", "context", ".", "Context", ")", "(", "interface", "{", "}", ",", "error", ")", "{", "// If we have an onGet function, run it (deferred case).", "if", "p", ".", "onGet", "!=", "nil", "{", "p", ".", "...
// Get returns the promise's value. If the value isn't set, Get will block until // the value is available, following the Context's timeout parameters. // // If the value is available, it will be returned with its error status. If the // context times out or is cancelled, the appropriate context error will be // return...
[ "Get", "returns", "the", "promise", "s", "value", ".", "If", "the", "value", "isn", "t", "set", "Get", "will", "block", "until", "the", "value", "is", "available", "following", "the", "Context", "s", "timeout", "parameters", ".", "If", "the", "value", "i...
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/common/sync/promise/promise.go#L93-L115
130,951
luci/luci-go
common/sync/promise/promise.go
Peek
func (p *Promise) Peek() (interface{}, error) { select { case <-p.signalC: return p.data, p.err default: return nil, ErrNoData } }
go
func (p *Promise) Peek() (interface{}, error) { select { case <-p.signalC: return p.data, p.err default: return nil, ErrNoData } }
[ "func", "(", "p", "*", "Promise", ")", "Peek", "(", ")", "(", "interface", "{", "}", ",", "error", ")", "{", "select", "{", "case", "<-", "p", ".", "signalC", ":", "return", "p", ".", "data", ",", "p", ".", "err", "\n\n", "default", ":", "retur...
// Peek returns the promise's current value. If the value isn't set, Peek will // return immediately with ErrNoData.
[ "Peek", "returns", "the", "promise", "s", "current", "value", ".", "If", "the", "value", "isn", "t", "set", "Peek", "will", "return", "immediately", "with", "ErrNoData", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/common/sync/promise/promise.go#L119-L127
130,952
luci/luci-go
buildbucket/cli/print.go
f
func (p *printer) f(format string, args ...interface{}) { if p.Err != nil { return } if _, err := fmt.Fprintf(&p.indent, format, args...); err != nil && err != io.ErrShortWrite { p.Err = err } }
go
func (p *printer) f(format string, args ...interface{}) { if p.Err != nil { return } if _, err := fmt.Fprintf(&p.indent, format, args...); err != nil && err != io.ErrShortWrite { p.Err = err } }
[ "func", "(", "p", "*", "printer", ")", "f", "(", "format", "string", ",", "args", "...", "interface", "{", "}", ")", "{", "if", "p", ".", "Err", "!=", "nil", "{", "return", "\n", "}", "\n", "if", "_", ",", "err", ":=", "fmt", ".", "Fprintf", ...
// f prints a formatted message.
[ "f", "prints", "a", "formatted", "message", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/buildbucket/cli/print.go#L91-L98
130,953
luci/luci-go
buildbucket/cli/print.go
fw
func (p *printer) fw(minWidth int, format string, args ...interface{}) { s := fmt.Sprintf(format, args...) pad := minWidth - utf8.RuneCountInString(s) if pad < 1 { pad = 1 } p.f("%s%s", s, strings.Repeat(" ", pad)) }
go
func (p *printer) fw(minWidth int, format string, args ...interface{}) { s := fmt.Sprintf(format, args...) pad := minWidth - utf8.RuneCountInString(s) if pad < 1 { pad = 1 } p.f("%s%s", s, strings.Repeat(" ", pad)) }
[ "func", "(", "p", "*", "printer", ")", "fw", "(", "minWidth", "int", ",", "format", "string", ",", "args", "...", "interface", "{", "}", ")", "{", "s", ":=", "fmt", ".", "Sprintf", "(", "format", ",", "args", "...", ")", "\n", "pad", ":=", "minWi...
// fw is like f, but appends whitespace such that the printed string takes at // least minWidth. // Appends at least one space.
[ "fw", "is", "like", "f", "but", "appends", "whitespace", "such", "that", "the", "printed", "string", "takes", "at", "least", "minWidth", ".", "Appends", "at", "least", "one", "space", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/buildbucket/cli/print.go#L103-L110
130,954
luci/luci-go
buildbucket/cli/print.go
JSONPB
func (p *printer) JSONPB(pb proto.Message) { m := &jsonpb.Marshaler{} buf := &bytes.Buffer{} if err := m.Marshal(buf, pb); err != nil { panic(fmt.Errorf("failed to marshal a message: %s", err)) } // Note: json.Marshal indents JSON more nicely than jsonpb.Marshaler.Indent. indented := &bytes.Buffer{} if err :=...
go
func (p *printer) JSONPB(pb proto.Message) { m := &jsonpb.Marshaler{} buf := &bytes.Buffer{} if err := m.Marshal(buf, pb); err != nil { panic(fmt.Errorf("failed to marshal a message: %s", err)) } // Note: json.Marshal indents JSON more nicely than jsonpb.Marshaler.Indent. indented := &bytes.Buffer{} if err :=...
[ "func", "(", "p", "*", "printer", ")", "JSONPB", "(", "pb", "proto", ".", "Message", ")", "{", "m", ":=", "&", "jsonpb", ".", "Marshaler", "{", "}", "\n", "buf", ":=", "&", "bytes", ".", "Buffer", "{", "}", "\n", "if", "err", ":=", "m", ".", ...
// JSONPB prints pb in JSON format, indented.
[ "JSONPB", "prints", "pb", "in", "JSON", "format", "indented", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/buildbucket/cli/print.go#L113-L126
130,955
luci/luci-go
buildbucket/cli/print.go
Build
func (p *printer) Build(b *pb.Build) { // Print the build URL bold, underline and a color matching the status. p.f("%s%s%shttp://ci.chromium.org/b/%d", ansiWhiteBold, ansiWhiteUnderline, ansiStatus[b.Status], b.Id) // Undo underline. p.f("%s%s%s ", ansi.Reset, ansiWhiteBold, ansiStatus[b.Status]) p.fw(10, "%s", b....
go
func (p *printer) Build(b *pb.Build) { // Print the build URL bold, underline and a color matching the status. p.f("%s%s%shttp://ci.chromium.org/b/%d", ansiWhiteBold, ansiWhiteUnderline, ansiStatus[b.Status], b.Id) // Undo underline. p.f("%s%s%s ", ansi.Reset, ansiWhiteBold, ansiStatus[b.Status]) p.fw(10, "%s", b....
[ "func", "(", "p", "*", "printer", ")", "Build", "(", "b", "*", "pb", ".", "Build", ")", "{", "// Print the build URL bold, underline and a color matching the status.", "p", ".", "f", "(", "\"", "\"", ",", "ansiWhiteBold", ",", "ansiWhiteUnderline", ",", "ansiSta...
// Build prints b.
[ "Build", "prints", "b", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/buildbucket/cli/print.go#L129-L189
130,956
luci/luci-go
buildbucket/cli/print.go
commit
func (p *printer) commit(c *pb.GitilesCommit) { if c.Id == "" { p.linkf("https://%s/%s/+/%s", c.Host, c.Project, c.Ref) return } switch c.Host { // This shamelessly hardcodes https://cr-rev.appspot.com/_ah/api/crrev/v1/projects response // TODO(nodir): make an RPC and cache on the file system. case "aomedi...
go
func (p *printer) commit(c *pb.GitilesCommit) { if c.Id == "" { p.linkf("https://%s/%s/+/%s", c.Host, c.Project, c.Ref) return } switch c.Host { // This shamelessly hardcodes https://cr-rev.appspot.com/_ah/api/crrev/v1/projects response // TODO(nodir): make an RPC and cache on the file system. case "aomedi...
[ "func", "(", "p", "*", "printer", ")", "commit", "(", "c", "*", "pb", ".", "GitilesCommit", ")", "{", "if", "c", ".", "Id", "==", "\"", "\"", "{", "p", ".", "linkf", "(", "\"", "\"", ",", "c", ".", "Host", ",", "c", ".", "Project", ",", "c"...
// commit prints c.
[ "commit", "prints", "c", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/buildbucket/cli/print.go#L192-L214
130,957
luci/luci-go
buildbucket/cli/print.go
change
func (p *printer) change(cl *pb.GerritChange) { switch { case cl.Host == "chromium-review.googlesource.com": p.linkf("https://crrev.com/c/%d/%d", cl.Change, cl.Patchset) case cl.Host == "chrome-internal-review.googlesource.com": p.linkf("https://crrev.com/i/%d/%d", cl.Change, cl.Patchset) default: p.linkf("ht...
go
func (p *printer) change(cl *pb.GerritChange) { switch { case cl.Host == "chromium-review.googlesource.com": p.linkf("https://crrev.com/c/%d/%d", cl.Change, cl.Patchset) case cl.Host == "chrome-internal-review.googlesource.com": p.linkf("https://crrev.com/i/%d/%d", cl.Change, cl.Patchset) default: p.linkf("ht...
[ "func", "(", "p", "*", "printer", ")", "change", "(", "cl", "*", "pb", ".", "GerritChange", ")", "{", "switch", "{", "case", "cl", ".", "Host", "==", "\"", "\"", ":", "p", ".", "linkf", "(", "\"", "\"", ",", "cl", ".", "Change", ",", "cl", "....
// change prints cl.
[ "change", "prints", "cl", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/buildbucket/cli/print.go#L217-L226
130,958
luci/luci-go
buildbucket/cli/print.go
steps
func (p *printer) steps(steps []*pb.Step) { maxNameWidth := 0 for _, s := range steps { if w := utf8.RuneCountInString(s.Name); w > maxNameWidth { maxNameWidth = w } } for _, s := range steps { p.f("%sStep ", ansiStatus[s.Status]) p.fw(maxNameWidth+5, "%q", s.Name) p.fw(10, "%s", s.Status) // Print...
go
func (p *printer) steps(steps []*pb.Step) { maxNameWidth := 0 for _, s := range steps { if w := utf8.RuneCountInString(s.Name); w > maxNameWidth { maxNameWidth = w } } for _, s := range steps { p.f("%sStep ", ansiStatus[s.Status]) p.fw(maxNameWidth+5, "%q", s.Name) p.fw(10, "%s", s.Status) // Print...
[ "func", "(", "p", "*", "printer", ")", "steps", "(", "steps", "[", "]", "*", "pb", ".", "Step", ")", "{", "maxNameWidth", ":=", "0", "\n", "for", "_", ",", "s", ":=", "range", "steps", "{", "if", "w", ":=", "utf8", ".", "RuneCountInString", "(", ...
// steps print steps.
[ "steps", "print", "steps", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/buildbucket/cli/print.go#L229-L278
130,959
luci/luci-go
buildbucket/cli/print.go
Error
func (p *printer) Error(err error) { st, _ := status.FromError(err) p.f("%s", st.Message()) }
go
func (p *printer) Error(err error) { st, _ := status.FromError(err) p.f("%s", st.Message()) }
[ "func", "(", "p", "*", "printer", ")", "Error", "(", "err", "error", ")", "{", "st", ",", "_", ":=", "status", ".", "FromError", "(", "err", ")", "\n", "p", ".", "f", "(", "\"", "\"", ",", "st", ".", "Message", "(", ")", ")", "\n", "}" ]
// Error prints the err. If err is a gRPC error, then prints only the message // without the code.
[ "Error", "prints", "the", "err", ".", "If", "err", "is", "a", "gRPC", "error", "then", "prints", "only", "the", "message", "without", "the", "code", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/buildbucket/cli/print.go#L391-L394
130,960
luci/luci-go
buildbucket/cli/print.go
readTimestamp
func readTimestamp(ts *timestamp.Timestamp) time.Time { t, err := ptypes.Timestamp(ts) if err != nil { return time.Time{} } return t }
go
func readTimestamp(ts *timestamp.Timestamp) time.Time { t, err := ptypes.Timestamp(ts) if err != nil { return time.Time{} } return t }
[ "func", "readTimestamp", "(", "ts", "*", "timestamp", ".", "Timestamp", ")", "time", ".", "Time", "{", "t", ",", "err", ":=", "ptypes", ".", "Timestamp", "(", "ts", ")", "\n", "if", "err", "!=", "nil", "{", "return", "time", ".", "Time", "{", "}", ...
// readTimestamp converts ts to time.Time. // Returns zero if ts is invalid.
[ "readTimestamp", "converts", "ts", "to", "time", ".", "Time", ".", "Returns", "zero", "if", "ts", "is", "invalid", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/buildbucket/cli/print.go#L398-L404
130,961
luci/luci-go
buildbucket/cli/print.go
truncateDuration
func truncateDuration(d time.Duration) time.Duration { for _, t := range durTransactions { if d > t.threshold { return d.Round(t.round) } } return d }
go
func truncateDuration(d time.Duration) time.Duration { for _, t := range durTransactions { if d > t.threshold { return d.Round(t.round) } } return d }
[ "func", "truncateDuration", "(", "d", "time", ".", "Duration", ")", "time", ".", "Duration", "{", "for", "_", ",", "t", ":=", "range", "durTransactions", "{", "if", "d", ">", "t", ".", "threshold", "{", "return", "d", ".", "Round", "(", "t", ".", "...
// truncateDuration truncates d to make it more human-readable.
[ "truncateDuration", "truncates", "d", "to", "make", "it", "more", "human", "-", "readable", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/buildbucket/cli/print.go#L421-L428
130,962
luci/luci-go
machine-db/client/cli/dracs.go
printDRACs
func printDRACs(tsv bool, dracs ...*crimson.DRAC) { if len(dracs) > 0 { p := newStdoutPrinter(tsv) defer p.Flush() if !tsv { p.Row("Name", "Machine", "MAC Address", "Switch", "Port", "IP Address", "VLAN") } for _, d := range dracs { p.Row(d.Name, d.Machine, d.MacAddress, d.Switch, d.Switchport, d.Ipv4,...
go
func printDRACs(tsv bool, dracs ...*crimson.DRAC) { if len(dracs) > 0 { p := newStdoutPrinter(tsv) defer p.Flush() if !tsv { p.Row("Name", "Machine", "MAC Address", "Switch", "Port", "IP Address", "VLAN") } for _, d := range dracs { p.Row(d.Name, d.Machine, d.MacAddress, d.Switch, d.Switchport, d.Ipv4,...
[ "func", "printDRACs", "(", "tsv", "bool", ",", "dracs", "...", "*", "crimson", ".", "DRAC", ")", "{", "if", "len", "(", "dracs", ")", ">", "0", "{", "p", ":=", "newStdoutPrinter", "(", "tsv", ")", "\n", "defer", "p", ".", "Flush", "(", ")", "\n",...
// printDRACs prints DRAC data to stdout in tab-separated columns.
[ "printDRACs", "prints", "DRAC", "data", "to", "stdout", "in", "tab", "-", "separated", "columns", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/machine-db/client/cli/dracs.go#L28-L39
130,963
luci/luci-go
machine-db/client/cli/dracs.go
Run
func (c *AddDRACCmd) Run(app subcommands.Application, args []string, env subcommands.Env) int { ctx := cli.GetContext(app, c, env) // TODO(smut): Validate required fields client-side. req := &crimson.CreateDRACRequest{ Drac: &c.drac, } client := getClient(ctx) resp, err := client.CreateDRAC(ctx, req) if err !=...
go
func (c *AddDRACCmd) Run(app subcommands.Application, args []string, env subcommands.Env) int { ctx := cli.GetContext(app, c, env) // TODO(smut): Validate required fields client-side. req := &crimson.CreateDRACRequest{ Drac: &c.drac, } client := getClient(ctx) resp, err := client.CreateDRAC(ctx, req) if err !=...
[ "func", "(", "c", "*", "AddDRACCmd", ")", "Run", "(", "app", "subcommands", ".", "Application", ",", "args", "[", "]", "string", ",", "env", "subcommands", ".", "Env", ")", "int", "{", "ctx", ":=", "cli", ".", "GetContext", "(", "app", ",", "c", ",...
// Run runs the command to add a DRAC.
[ "Run", "runs", "the", "command", "to", "add", "a", "DRAC", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/machine-db/client/cli/dracs.go#L48-L62
130,964
luci/luci-go
machine-db/client/cli/dracs.go
addDRACCmd
func addDRACCmd(params *Parameters) *subcommands.Command { return &subcommands.Command{ UsageLine: "add-drac -name <name> -machine <machine> -mac <mac address> -switch <switch> -port <port> -ip <ip address>", ShortDesc: "adds a DRAC", LongDesc: "Adds a DRAC to the database.\n\nExample:\ncrimson add-drac -name s...
go
func addDRACCmd(params *Parameters) *subcommands.Command { return &subcommands.Command{ UsageLine: "add-drac -name <name> -machine <machine> -mac <mac address> -switch <switch> -port <port> -ip <ip address>", ShortDesc: "adds a DRAC", LongDesc: "Adds a DRAC to the database.\n\nExample:\ncrimson add-drac -name s...
[ "func", "addDRACCmd", "(", "params", "*", "Parameters", ")", "*", "subcommands", ".", "Command", "{", "return", "&", "subcommands", ".", "Command", "{", "UsageLine", ":", "\"", "\"", ",", "ShortDesc", ":", "\"", "\"", ",", "LongDesc", ":", "\"", "\\n", ...
// addDRACCmd returns a command to add a DRAC.
[ "addDRACCmd", "returns", "a", "command", "to", "add", "a", "DRAC", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/machine-db/client/cli/dracs.go#L65-L82
130,965
luci/luci-go
machine-db/client/cli/dracs.go
Run
func (c *EditDRACCmd) Run(app subcommands.Application, args []string, env subcommands.Env) int { ctx := cli.GetContext(app, c, env) // TODO(smut): Validate required fields client-side. req := &crimson.UpdateDRACRequest{ Drac: &c.drac, UpdateMask: getUpdateMask(&c.Flags, map[string]string{ "machine": "machine"...
go
func (c *EditDRACCmd) Run(app subcommands.Application, args []string, env subcommands.Env) int { ctx := cli.GetContext(app, c, env) // TODO(smut): Validate required fields client-side. req := &crimson.UpdateDRACRequest{ Drac: &c.drac, UpdateMask: getUpdateMask(&c.Flags, map[string]string{ "machine": "machine"...
[ "func", "(", "c", "*", "EditDRACCmd", ")", "Run", "(", "app", "subcommands", ".", "Application", ",", "args", "[", "]", "string", ",", "env", "subcommands", ".", "Env", ")", "int", "{", "ctx", ":=", "cli", ".", "GetContext", "(", "app", ",", "c", "...
// Run runs the command to edit a DRAC.
[ "Run", "runs", "the", "command", "to", "edit", "a", "DRAC", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/machine-db/client/cli/dracs.go#L91-L111
130,966
luci/luci-go
machine-db/client/cli/dracs.go
Run
func (c *GetDRACsCmd) Run(app subcommands.Application, args []string, env subcommands.Env) int { ctx := cli.GetContext(app, c, env) client := getClient(ctx) resp, err := client.ListDRACs(ctx, &c.req) if err != nil { errors.Log(ctx, err) return 1 } printDRACs(c.f.tsv, resp.Dracs...) return 0 }
go
func (c *GetDRACsCmd) Run(app subcommands.Application, args []string, env subcommands.Env) int { ctx := cli.GetContext(app, c, env) client := getClient(ctx) resp, err := client.ListDRACs(ctx, &c.req) if err != nil { errors.Log(ctx, err) return 1 } printDRACs(c.f.tsv, resp.Dracs...) return 0 }
[ "func", "(", "c", "*", "GetDRACsCmd", ")", "Run", "(", "app", "subcommands", ".", "Application", ",", "args", "[", "]", "string", ",", "env", "subcommands", ".", "Env", ")", "int", "{", "ctx", ":=", "cli", ".", "GetContext", "(", "app", ",", "c", "...
// Run runs the command to get DRACs.
[ "Run", "runs", "the", "command", "to", "get", "DRACs", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/machine-db/client/cli/dracs.go#L139-L149
130,967
luci/luci-go
machine-db/client/cli/dracs.go
getDRACsCmd
func getDRACsCmd(params *Parameters) *subcommands.Command { return &subcommands.Command{ UsageLine: "get-dracs [-name <name>]... [-machine <machine>]... [-mac <mac address>]... [-switch <switch>]... [-ip <ip address>]... [-vlan <id>]...", ShortDesc: "retrieves DRACs", LongDesc: "Retrieves DRACs matching the giv...
go
func getDRACsCmd(params *Parameters) *subcommands.Command { return &subcommands.Command{ UsageLine: "get-dracs [-name <name>]... [-machine <machine>]... [-mac <mac address>]... [-switch <switch>]... [-ip <ip address>]... [-vlan <id>]...", ShortDesc: "retrieves DRACs", LongDesc: "Retrieves DRACs matching the giv...
[ "func", "getDRACsCmd", "(", "params", "*", "Parameters", ")", "*", "subcommands", ".", "Command", "{", "return", "&", "subcommands", ".", "Command", "{", "UsageLine", ":", "\"", "\"", ",", "ShortDesc", ":", "\"", "\"", ",", "LongDesc", ":", "\"", "\\n", ...
// getDRACCmd returns a command to get DRACs.
[ "getDRACCmd", "returns", "a", "command", "to", "get", "DRACs", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/machine-db/client/cli/dracs.go#L152-L169
130,968
luci/luci-go
common/clock/clockcontext.go
WithDeadline
func WithDeadline(parent context.Context, deadline time.Time) (context.Context, context.CancelFunc) { if cur, ok := parent.Deadline(); ok && cur.Before(deadline) { // The current deadline is already sooner than the new one. return context.WithCancel(parent) } parent, cancelFunc := context.WithCancel(parent) c ...
go
func WithDeadline(parent context.Context, deadline time.Time) (context.Context, context.CancelFunc) { if cur, ok := parent.Deadline(); ok && cur.Before(deadline) { // The current deadline is already sooner than the new one. return context.WithCancel(parent) } parent, cancelFunc := context.WithCancel(parent) c ...
[ "func", "WithDeadline", "(", "parent", "context", ".", "Context", ",", "deadline", "time", ".", "Time", ")", "(", "context", ".", "Context", ",", "context", ".", "CancelFunc", ")", "{", "if", "cur", ",", "ok", ":=", "parent", ".", "Deadline", "(", ")",...
// WithDeadline is a clock library implementation of context.WithDeadline that // uses the clock library's time features instead of the Go time library. // // For more information, see context.WithDeadline.
[ "WithDeadline", "is", "a", "clock", "library", "implementation", "of", "context", ".", "WithDeadline", "that", "uses", "the", "clock", "library", "s", "time", "features", "instead", "of", "the", "Go", "time", "library", ".", "For", "more", "information", "see"...
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/common/clock/clockcontext.go#L65-L106
130,969
luci/luci-go
machine-db/appengine/rpc/platforms.go
ListPlatforms
func (*Service) ListPlatforms(c context.Context, req *crimson.ListPlatformsRequest) (*crimson.ListPlatformsResponse, error) { platforms, err := listPlatforms(c, req) if err != nil { return nil, err } return &crimson.ListPlatformsResponse{ Platforms: platforms, }, nil }
go
func (*Service) ListPlatforms(c context.Context, req *crimson.ListPlatformsRequest) (*crimson.ListPlatformsResponse, error) { platforms, err := listPlatforms(c, req) if err != nil { return nil, err } return &crimson.ListPlatformsResponse{ Platforms: platforms, }, nil }
[ "func", "(", "*", "Service", ")", "ListPlatforms", "(", "c", "context", ".", "Context", ",", "req", "*", "crimson", ".", "ListPlatformsRequest", ")", "(", "*", "crimson", ".", "ListPlatformsResponse", ",", "error", ")", "{", "platforms", ",", "err", ":=", ...
// ListPlatforms handles a request to retrieve platforms.
[ "ListPlatforms", "handles", "a", "request", "to", "retrieve", "platforms", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/machine-db/appengine/rpc/platforms.go#L29-L37
130,970
luci/luci-go
machine-db/appengine/rpc/platforms.go
listPlatforms
func listPlatforms(c context.Context, req *crimson.ListPlatformsRequest) ([]*crimson.Platform, error) { stmt := squirrel.Select("name", "description", "manufacturer").From("platforms") stmt = selectInString(stmt, "name", req.Names) stmt = selectInString(stmt, "manufacturer", req.Manufacturers) query, args, err := s...
go
func listPlatforms(c context.Context, req *crimson.ListPlatformsRequest) ([]*crimson.Platform, error) { stmt := squirrel.Select("name", "description", "manufacturer").From("platforms") stmt = selectInString(stmt, "name", req.Names) stmt = selectInString(stmt, "manufacturer", req.Manufacturers) query, args, err := s...
[ "func", "listPlatforms", "(", "c", "context", ".", "Context", ",", "req", "*", "crimson", ".", "ListPlatformsRequest", ")", "(", "[", "]", "*", "crimson", ".", "Platform", ",", "error", ")", "{", "stmt", ":=", "squirrel", ".", "Select", "(", "\"", "\""...
// listPlatforms returns a slice of platforms in the database.
[ "listPlatforms", "returns", "a", "slice", "of", "platforms", "in", "the", "database", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/machine-db/appengine/rpc/platforms.go#L40-L65
130,971
luci/luci-go
config/impl/memory/memory.go
SetError
func SetError(impl config.Interface, err error) { impl.(*memoryImpl).err = err }
go
func SetError(impl config.Interface, err error) { impl.(*memoryImpl).err = err }
[ "func", "SetError", "(", "impl", "config", ".", "Interface", ",", "err", "error", ")", "{", "impl", ".", "(", "*", "memoryImpl", ")", ".", "err", "=", "err", "\n", "}" ]
// SetError artificially pins the error code returned by impl to err. If err is // nil, impl will behave normally. // // impl must be a memory config isntance created with New, else SetError will // panic.
[ "SetError", "artificially", "pins", "the", "error", "code", "returned", "by", "impl", "to", "err", ".", "If", "err", "is", "nil", "impl", "will", "behave", "normally", ".", "impl", "must", "be", "a", "memory", "config", "isntance", "created", "with", "New"...
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/config/impl/memory/memory.go#L44-L46
130,972
luci/luci-go
config/impl/memory/memory.go
configMaybe
func (b Files) configMaybe(configSet config.Set, path string, metaOnly bool) *config.Config { if body, ok := b[path]; ok { cfg := &config.Config{ Meta: config.Meta{ ConfigSet: configSet, Path: path, ContentHash: hash(body), Revision: b.rev(), ViewURL: fmt.Sprintf("https://examp...
go
func (b Files) configMaybe(configSet config.Set, path string, metaOnly bool) *config.Config { if body, ok := b[path]; ok { cfg := &config.Config{ Meta: config.Meta{ ConfigSet: configSet, Path: path, ContentHash: hash(body), Revision: b.rev(), ViewURL: fmt.Sprintf("https://examp...
[ "func", "(", "b", "Files", ")", "configMaybe", "(", "configSet", "config", ".", "Set", ",", "path", "string", ",", "metaOnly", "bool", ")", "*", "config", ".", "Config", "{", "if", "body", ",", "ok", ":=", "b", "[", "path", "]", ";", "ok", "{", "...
// configMaybe returns config.Config if such config is in the set, else nil.
[ "configMaybe", "returns", "config", ".", "Config", "if", "such", "config", "is", "in", "the", "set", "else", "nil", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/config/impl/memory/memory.go#L190-L207
130,973
luci/luci-go
config/impl/memory/memory.go
rev
func (b Files) rev() string { keys := make([]string, 0, len(b)) for k := range b { keys = append(keys, k) } sort.Strings(keys) buf := sha256.New() for _, k := range keys { buf.Write([]byte(k)) buf.Write([]byte{0}) buf.Write([]byte(b[k])) buf.Write([]byte{0}) } return hex.EncodeToString(buf.Sum(nil))[:...
go
func (b Files) rev() string { keys := make([]string, 0, len(b)) for k := range b { keys = append(keys, k) } sort.Strings(keys) buf := sha256.New() for _, k := range keys { buf.Write([]byte(k)) buf.Write([]byte{0}) buf.Write([]byte(b[k])) buf.Write([]byte{0}) } return hex.EncodeToString(buf.Sum(nil))[:...
[ "func", "(", "b", "Files", ")", "rev", "(", ")", "string", "{", "keys", ":=", "make", "(", "[", "]", "string", ",", "0", ",", "len", "(", "b", ")", ")", "\n", "for", "k", ":=", "range", "b", "{", "keys", "=", "append", "(", "keys", ",", "k"...
// rev returns fake revision of given config set.
[ "rev", "returns", "fake", "revision", "of", "given", "config", "set", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/config/impl/memory/memory.go#L210-L224
130,974
luci/luci-go
config/impl/memory/memory.go
hash
func hash(body string) string { buf := sha256.New() fmt.Fprintf(buf, "blob %d", len(body)) buf.Write([]byte{0}) buf.Write([]byte(body)) return "v2:" + hex.EncodeToString(buf.Sum(nil)) }
go
func hash(body string) string { buf := sha256.New() fmt.Fprintf(buf, "blob %d", len(body)) buf.Write([]byte{0}) buf.Write([]byte(body)) return "v2:" + hex.EncodeToString(buf.Sum(nil)) }
[ "func", "hash", "(", "body", "string", ")", "string", "{", "buf", ":=", "sha256", ".", "New", "(", ")", "\n", "fmt", ".", "Fprintf", "(", "buf", ",", "\"", "\"", ",", "len", "(", "body", ")", ")", "\n", "buf", ".", "Write", "(", "[", "]", "by...
// hash returns generated ContentHash of a config file.
[ "hash", "returns", "generated", "ContentHash", "of", "a", "config", "file", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/config/impl/memory/memory.go#L227-L233
130,975
luci/luci-go
milo/git/gitacls/acls.go
FromConfig
func FromConfig(c context.Context, cfg []*config.Settings_SourceAcls) (*ACLs, error) { ctx := validation.Context{Context: c} ACLs := &ACLs{} ACLs.load(&ctx, cfg) if err := ctx.Finalize(); err != nil { return nil, err } return ACLs, nil }
go
func FromConfig(c context.Context, cfg []*config.Settings_SourceAcls) (*ACLs, error) { ctx := validation.Context{Context: c} ACLs := &ACLs{} ACLs.load(&ctx, cfg) if err := ctx.Finalize(); err != nil { return nil, err } return ACLs, nil }
[ "func", "FromConfig", "(", "c", "context", ".", "Context", ",", "cfg", "[", "]", "*", "config", ".", "Settings_SourceAcls", ")", "(", "*", "ACLs", ",", "error", ")", "{", "ctx", ":=", "validation", ".", "Context", "{", "Context", ":", "c", "}", "\n",...
// FromConfig returns ACLs if config is valid.
[ "FromConfig", "returns", "ACLs", "if", "config", "is", "valid", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/milo/git/gitacls/acls.go#L34-L42
130,976
luci/luci-go
milo/git/gitacls/acls.go
ValidateConfig
func ValidateConfig(ctx *validation.Context, cfg []*config.Settings_SourceAcls) { var ACLs ACLs ACLs.load(ctx, cfg) }
go
func ValidateConfig(ctx *validation.Context, cfg []*config.Settings_SourceAcls) { var ACLs ACLs ACLs.load(ctx, cfg) }
[ "func", "ValidateConfig", "(", "ctx", "*", "validation", ".", "Context", ",", "cfg", "[", "]", "*", "config", ".", "Settings_SourceAcls", ")", "{", "var", "ACLs", "ACLs", "\n", "ACLs", ".", "load", "(", "ctx", ",", "cfg", ")", "\n", "}" ]
// ValidateConfig passes all validation errors through validation context.
[ "ValidateConfig", "passes", "all", "validation", "errors", "through", "validation", "context", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/milo/git/gitacls/acls.go#L45-L48
130,977
luci/luci-go
milo/git/gitacls/acls.go
belongsTo
func (a *ACLs) belongsTo(c context.Context, readerGroups ...[]string) (bool, error) { currentIdentity := auth.CurrentIdentity(c) groups := []string{} for _, readers := range readerGroups { for _, r := range readers { switch { case strings.HasPrefix(r, "group:"): // auth.IsMember expects group names w/o "...
go
func (a *ACLs) belongsTo(c context.Context, readerGroups ...[]string) (bool, error) { currentIdentity := auth.CurrentIdentity(c) groups := []string{} for _, readers := range readerGroups { for _, r := range readers { switch { case strings.HasPrefix(r, "group:"): // auth.IsMember expects group names w/o "...
[ "func", "(", "a", "*", "ACLs", ")", "belongsTo", "(", "c", "context", ".", "Context", ",", "readerGroups", "...", "[", "]", "string", ")", "(", "bool", ",", "error", ")", "{", "currentIdentity", ":=", "auth", ".", "CurrentIdentity", "(", "c", ")", "\...
// private implementation.
[ "private", "implementation", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/milo/git/gitacls/acls.go#L74-L93
130,978
luci/luci-go
milo/git/gitacls/acls.go
load
func (a *ACLs) load(ctx *validation.Context, cfg []*config.Settings_SourceAcls) { a.hosts = map[string]*hostACLs{} for i, group := range cfg { ctx.Enter("source_acls #%d", i) if len(group.Readers) == 0 { ctx.Errorf("at least 1 reader required") } if len(group.Hosts)+len(group.Projects) == 0 { ctx.Error...
go
func (a *ACLs) load(ctx *validation.Context, cfg []*config.Settings_SourceAcls) { a.hosts = map[string]*hostACLs{} for i, group := range cfg { ctx.Enter("source_acls #%d", i) if len(group.Readers) == 0 { ctx.Errorf("at least 1 reader required") } if len(group.Hosts)+len(group.Projects) == 0 { ctx.Error...
[ "func", "(", "a", "*", "ACLs", ")", "load", "(", "ctx", "*", "validation", ".", "Context", ",", "cfg", "[", "]", "*", "config", ".", "Settings_SourceAcls", ")", "{", "a", ".", "hosts", "=", "map", "[", "string", "]", "*", "hostACLs", "{", "}", "\...
// load validates and loads ACLs from config.
[ "load", "validates", "and", "loads", "ACLs", "from", "config", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/milo/git/gitacls/acls.go#L106-L131
130,979
luci/luci-go
milo/git/gitacls/acls.go
loadReaders
func (a *ACLs) loadReaders(ctx *validation.Context, readers []string) []string { known := stringset.New(len(readers)) for _, r := range readers { id := r switch { case strings.HasPrefix(r, "group:"): if r[len("group:"):] == "" { ctx.Errorf("invalid readers %q: needs a group name", r) } case !strings...
go
func (a *ACLs) loadReaders(ctx *validation.Context, readers []string) []string { known := stringset.New(len(readers)) for _, r := range readers { id := r switch { case strings.HasPrefix(r, "group:"): if r[len("group:"):] == "" { ctx.Errorf("invalid readers %q: needs a group name", r) } case !strings...
[ "func", "(", "a", "*", "ACLs", ")", "loadReaders", "(", "ctx", "*", "validation", ".", "Context", ",", "readers", "[", "]", "string", ")", "[", "]", "string", "{", "known", ":=", "stringset", ".", "New", "(", "len", "(", "readers", ")", ")", "\n", ...
// loadReaders validates readers and returns slice of valid identities.
[ "loadReaders", "validates", "readers", "and", "returns", "slice", "of", "valid", "identities", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/milo/git/gitacls/acls.go#L134-L159
130,980
luci/luci-go
milo/git/gitacls/acls.go
validateURL
func validateURL(ctx *validation.Context, s string) (*url.URL, bool) { // url.Parse considers "example.com/a/b" to be a path, so ensure a scheme. if !strings.HasPrefix(s, "https://") { s = "https://" + s } u, err := url.Parse(s) if err != nil { ctx.Error(errors.Annotate(err, "not a valid URL").Err()) return ...
go
func validateURL(ctx *validation.Context, s string) (*url.URL, bool) { // url.Parse considers "example.com/a/b" to be a path, so ensure a scheme. if !strings.HasPrefix(s, "https://") { s = "https://" + s } u, err := url.Parse(s) if err != nil { ctx.Error(errors.Annotate(err, "not a valid URL").Err()) return ...
[ "func", "validateURL", "(", "ctx", "*", "validation", ".", "Context", ",", "s", "string", ")", "(", "*", "url", ".", "URL", ",", "bool", ")", "{", "// url.Parse considers \"example.com/a/b\" to be a path, so ensure a scheme.", "if", "!", "strings", ".", "HasPrefix...
// validateURL returns parsed URL and whether it has passed validation.
[ "validateURL", "returns", "parsed", "URL", "and", "whether", "it", "has", "passed", "validation", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/milo/git/gitacls/acls.go#L237-L261
130,981
luci/luci-go
lucicfg/protos.go
protoLoader
func protoLoader() interpreter.Loader { mapping := make(map[string]string, len(publicProtos)) for path, proto := range publicProtos { mapping[path] = proto.goPath } return interpreter.ProtoLoader(mapping) }
go
func protoLoader() interpreter.Loader { mapping := make(map[string]string, len(publicProtos)) for path, proto := range publicProtos { mapping[path] = proto.goPath } return interpreter.ProtoLoader(mapping) }
[ "func", "protoLoader", "(", ")", "interpreter", ".", "Loader", "{", "mapping", ":=", "make", "(", "map", "[", "string", "]", "string", ",", "len", "(", "publicProtos", ")", ")", "\n", "for", "path", ",", "proto", ":=", "range", "publicProtos", "{", "ma...
// protoLoader returns a loader that is capable of loading publicProtos.
[ "protoLoader", "returns", "a", "loader", "that", "is", "capable", "of", "loading", "publicProtos", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/lucicfg/protos.go#L216-L222
130,982
luci/luci-go
lucicfg/protos.go
protoMessageDoc
func protoMessageDoc(msg proto.Message) (name, doc string) { withDesc, ok := msg.(descriptor.Message) if !ok { return "", "" } fd, md := descriptor.ForMessage(withDesc) if fd == nil || md == nil { return "", "" } for _, info := range publicProtos { // Find the exact same *.proto file within publicProtos ...
go
func protoMessageDoc(msg proto.Message) (name, doc string) { withDesc, ok := msg.(descriptor.Message) if !ok { return "", "" } fd, md := descriptor.ForMessage(withDesc) if fd == nil || md == nil { return "", "" } for _, info := range publicProtos { // Find the exact same *.proto file within publicProtos ...
[ "func", "protoMessageDoc", "(", "msg", "proto", ".", "Message", ")", "(", "name", ",", "doc", "string", ")", "{", "withDesc", ",", "ok", ":=", "msg", ".", "(", "descriptor", ".", "Message", ")", "\n", "if", "!", "ok", "{", "return", "\"", "\"", ","...
// protoMessageDoc returns the message name and a link to its schema doc. // // If there's no documentation, returns two empty strings.
[ "protoMessageDoc", "returns", "the", "message", "name", "and", "a", "link", "to", "its", "schema", "doc", ".", "If", "there", "s", "no", "documentation", "returns", "two", "empty", "strings", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/lucicfg/protos.go#L227-L249
130,983
luci/luci-go
starlark/interpreter/loaders.go
FileSystemLoader
func FileSystemLoader(root string) Loader { root, err := filepath.Abs(root) if err != nil { panic(err) } return func(path string) (_ starlark.StringDict, src string, err error) { abs := filepath.Join(root, filepath.FromSlash(path)) rel, err := filepath.Rel(root, abs) if err != nil { return nil, "", error...
go
func FileSystemLoader(root string) Loader { root, err := filepath.Abs(root) if err != nil { panic(err) } return func(path string) (_ starlark.StringDict, src string, err error) { abs := filepath.Join(root, filepath.FromSlash(path)) rel, err := filepath.Rel(root, abs) if err != nil { return nil, "", error...
[ "func", "FileSystemLoader", "(", "root", "string", ")", "Loader", "{", "root", ",", "err", ":=", "filepath", ".", "Abs", "(", "root", ")", "\n", "if", "err", "!=", "nil", "{", "panic", "(", "err", ")", "\n", "}", "\n", "return", "func", "(", "path"...
// FileSystemLoader returns a loader that loads files from the file system.
[ "FileSystemLoader", "returns", "a", "loader", "that", "loads", "files", "from", "the", "file", "system", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/starlark/interpreter/loaders.go#L30-L50
130,984
luci/luci-go
starlark/interpreter/loaders.go
MemoryLoader
func MemoryLoader(files map[string]string) Loader { return func(path string) (_ starlark.StringDict, src string, err error) { body, ok := files[path] if !ok { return nil, "", ErrNoModule } return nil, body, nil } }
go
func MemoryLoader(files map[string]string) Loader { return func(path string) (_ starlark.StringDict, src string, err error) { body, ok := files[path] if !ok { return nil, "", ErrNoModule } return nil, body, nil } }
[ "func", "MemoryLoader", "(", "files", "map", "[", "string", "]", "string", ")", "Loader", "{", "return", "func", "(", "path", "string", ")", "(", "_", "starlark", ".", "StringDict", ",", "src", "string", ",", "err", "error", ")", "{", "body", ",", "o...
// MemoryLoader returns a loader that loads files from the given map. // // Useful together with 'assets' package to embed Starlark code into the // interpreter binary.
[ "MemoryLoader", "returns", "a", "loader", "that", "loads", "files", "from", "the", "given", "map", ".", "Useful", "together", "with", "assets", "package", "to", "embed", "Starlark", "code", "into", "the", "interpreter", "binary", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/starlark/interpreter/loaders.go#L56-L64
130,985
luci/luci-go
server/auth/xsrf/xsrf.go
Check
func Check(c context.Context, tok string) error { _, err := xsrfToken.Validate(c, tok, state(c)) return err }
go
func Check(c context.Context, tok string) error { _, err := xsrfToken.Validate(c, tok, state(c)) return err }
[ "func", "Check", "(", "c", "context", ".", "Context", ",", "tok", "string", ")", "error", "{", "_", ",", "err", ":=", "xsrfToken", ".", "Validate", "(", "c", ",", "tok", ",", "state", "(", "c", ")", ")", "\n", "return", "err", "\n", "}" ]
// Check returns nil if XSRF token is valid.
[ "Check", "returns", "nil", "if", "XSRF", "token", "is", "valid", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/server/auth/xsrf/xsrf.go#L61-L64
130,986
luci/luci-go
server/auth/xsrf/xsrf.go
replyError
func replyError(c context.Context, rw http.ResponseWriter, code int, msg string, args ...interface{}) { text := fmt.Sprintf(msg, args...) logging.Errorf(c, "xsrf: %s", text) http.Error(rw, text, code) }
go
func replyError(c context.Context, rw http.ResponseWriter, code int, msg string, args ...interface{}) { text := fmt.Sprintf(msg, args...) logging.Errorf(c, "xsrf: %s", text) http.Error(rw, text, code) }
[ "func", "replyError", "(", "c", "context", ".", "Context", ",", "rw", "http", ".", "ResponseWriter", ",", "code", "int", ",", "msg", "string", ",", "args", "...", "interface", "{", "}", ")", "{", "text", ":=", "fmt", ".", "Sprintf", "(", "msg", ",", ...
// replyError sends error response and logs it.
[ "replyError", "sends", "error", "response", "and", "logs", "it", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/server/auth/xsrf/xsrf.go#L107-L111
130,987
luci/luci-go
logdog/client/cmd/logdog_butler/prefix.go
generateRandomUserPrefix
func generateRandomUserPrefix(ctx context.Context) (types.StreamName, error) { username, err := getCurrentUser() if err != nil { log.Warningf(log.SetError(ctx, err), "Failed to lookup current user name.") username = "user" } buf := make([]byte, userPrefixBytes) c, err := rand.Read(buf) if err != nil { retu...
go
func generateRandomUserPrefix(ctx context.Context) (types.StreamName, error) { username, err := getCurrentUser() if err != nil { log.Warningf(log.SetError(ctx, err), "Failed to lookup current user name.") username = "user" } buf := make([]byte, userPrefixBytes) c, err := rand.Read(buf) if err != nil { retu...
[ "func", "generateRandomUserPrefix", "(", "ctx", "context", ".", "Context", ")", "(", "types", ".", "StreamName", ",", "error", ")", "{", "username", ",", "err", ":=", "getCurrentUser", "(", ")", "\n", "if", "err", "!=", "nil", "{", "log", ".", "Warningf"...
// generateRandomPrefix generates a new log prefix in the "user" space.
[ "generateRandomPrefix", "generates", "a", "new", "log", "prefix", "in", "the", "user", "space", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/logdog/client/cmd/logdog_butler/prefix.go#L46-L67
130,988
luci/luci-go
milo/frontend/view_console.go
validateFaviconURL
func validateFaviconURL(faviconURL string) error { parsedFaviconURL, err := url.Parse(faviconURL) if err != nil { return err } host := strings.SplitN(parsedFaviconURL.Host, ":", 2)[0] if host != "storage.googleapis.com" { return fmt.Errorf("%q is not a valid FaviconURL hostname", host) } return nil }
go
func validateFaviconURL(faviconURL string) error { parsedFaviconURL, err := url.Parse(faviconURL) if err != nil { return err } host := strings.SplitN(parsedFaviconURL.Host, ":", 2)[0] if host != "storage.googleapis.com" { return fmt.Errorf("%q is not a valid FaviconURL hostname", host) } return nil }
[ "func", "validateFaviconURL", "(", "faviconURL", "string", ")", "error", "{", "parsedFaviconURL", ",", "err", ":=", "url", ".", "Parse", "(", "faviconURL", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "host", ":=", "strings...
// validateFaviconURL checks to see if the URL is well-formed and the host is in // the whitelist.
[ "validateFaviconURL", "checks", "to", "see", "if", "the", "URL", "is", "well", "-", "formed", "and", "the", "host", "is", "in", "the", "whitelist", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/milo/frontend/view_console.go#L74-L84
130,989
luci/luci-go
milo/frontend/view_console.go
getConsoleGroups
func getConsoleGroups(def *config.Header, summaries map[common.ConsoleID]*ui.BuilderSummaryGroup) []ui.ConsoleGroup { if def == nil || len(def.GetConsoleGroups()) == 0 { // No header, no console groups. return nil } groups := def.GetConsoleGroups() consoleGroups := make([]ui.ConsoleGroup, len(groups)) for i, g...
go
func getConsoleGroups(def *config.Header, summaries map[common.ConsoleID]*ui.BuilderSummaryGroup) []ui.ConsoleGroup { if def == nil || len(def.GetConsoleGroups()) == 0 { // No header, no console groups. return nil } groups := def.GetConsoleGroups() consoleGroups := make([]ui.ConsoleGroup, len(groups)) for i, g...
[ "func", "getConsoleGroups", "(", "def", "*", "config", ".", "Header", ",", "summaries", "map", "[", "common", ".", "ConsoleID", "]", "*", "ui", ".", "BuilderSummaryGroup", ")", "[", "]", "ui", ".", "ConsoleGroup", "{", "if", "def", "==", "nil", "||", "...
// getConsoleGroups extracts the console summaries for all header summaries // out of the summaries map into console groups for the header.
[ "getConsoleGroups", "extracts", "the", "console", "summaries", "for", "all", "header", "summaries", "out", "of", "the", "summaries", "map", "into", "console", "groups", "for", "the", "header", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/milo/frontend/view_console.go#L131-L162
130,990
luci/luci-go
milo/frontend/view_console.go
getJSONData
func getJSONData(c context.Context, url string, expiration time.Duration, target interface{}) error { // Try memcache first. item := memcache.NewItem(c, "url:"+url) if err := memcache.Get(c, item); err == nil { if err = json.Unmarshal(item.Value(), target); err == nil { return nil } logging.WithError(err).W...
go
func getJSONData(c context.Context, url string, expiration time.Duration, target interface{}) error { // Try memcache first. item := memcache.NewItem(c, "url:"+url) if err := memcache.Get(c, item); err == nil { if err = json.Unmarshal(item.Value(), target); err == nil { return nil } logging.WithError(err).W...
[ "func", "getJSONData", "(", "c", "context", ".", "Context", ",", "url", "string", ",", "expiration", "time", ".", "Duration", ",", "target", "interface", "{", "}", ")", "error", "{", "// Try memcache first.", "item", ":=", "memcache", ".", "NewItem", "(", ...
// getJSONData fetches data from the given URL into the target, caching it // for expiration seconds in memcache.
[ "getJSONData", "fetches", "data", "from", "the", "given", "URL", "into", "the", "target", "caching", "it", "for", "expiration", "seconds", "in", "memcache", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/milo/frontend/view_console.go#L291-L328
130,991
luci/luci-go
milo/frontend/view_console.go
getTreeStatus
func getTreeStatus(c context.Context, host string) *ui.TreeStatus { q := url.Values{} q.Add("format", "json") url := url.URL{ Scheme: "https", Host: host, Path: "current", RawQuery: q.Encode(), } status := &ui.TreeStatus{} if err := getJSONData(c, url.String(), 30*time.Second, status); err != n...
go
func getTreeStatus(c context.Context, host string) *ui.TreeStatus { q := url.Values{} q.Add("format", "json") url := url.URL{ Scheme: "https", Host: host, Path: "current", RawQuery: q.Encode(), } status := &ui.TreeStatus{} if err := getJSONData(c, url.String(), 30*time.Second, status); err != n...
[ "func", "getTreeStatus", "(", "c", "context", ".", "Context", ",", "host", "string", ")", "*", "ui", ".", "TreeStatus", "{", "q", ":=", "url", ".", "Values", "{", "}", "\n", "q", ".", "Add", "(", "\"", "\"", ",", "\"", "\"", ")", "\n", "url", "...
// getTreeStatus returns the current tree status from the chromium-status app. // This never errors, instead it constructs a fake purple TreeStatus
[ "getTreeStatus", "returns", "the", "current", "tree", "status", "from", "the", "chromium", "-", "status", "app", ".", "This", "never", "errors", "instead", "it", "constructs", "a", "fake", "purple", "TreeStatus" ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/milo/frontend/view_console.go#L332-L353
130,992
luci/luci-go
milo/frontend/view_console.go
getOncallData
func getOncallData(c context.Context, name, url string) (ui.Oncall, error) { result := ui.Oncall{} err := getJSONData(c, url, 10*time.Minute, &result) // Set the name, this is not loaded from the sheriff JSON. result.Name = name return result, err }
go
func getOncallData(c context.Context, name, url string) (ui.Oncall, error) { result := ui.Oncall{} err := getJSONData(c, url, 10*time.Minute, &result) // Set the name, this is not loaded from the sheriff JSON. result.Name = name return result, err }
[ "func", "getOncallData", "(", "c", "context", ".", "Context", ",", "name", ",", "url", "string", ")", "(", "ui", ".", "Oncall", ",", "error", ")", "{", "result", ":=", "ui", ".", "Oncall", "{", "}", "\n", "err", ":=", "getJSONData", "(", "c", ",", ...
// getOncallData fetches oncall data and caches it for 10 minutes.
[ "getOncallData", "fetches", "oncall", "data", "and", "caches", "it", "for", "10", "minutes", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/milo/frontend/view_console.go#L356-L362
130,993
luci/luci-go
milo/frontend/view_console.go
ConsoleTable
func (c consoleRenderer) ConsoleTable() template.HTML { var buffer bytes.Buffer // The first node is a dummy node for _, column := range c.Table.Children() { column.RenderHTML(&buffer, 1, c.MaxDepth) } return template.HTML(buffer.String()) }
go
func (c consoleRenderer) ConsoleTable() template.HTML { var buffer bytes.Buffer // The first node is a dummy node for _, column := range c.Table.Children() { column.RenderHTML(&buffer, 1, c.MaxDepth) } return template.HTML(buffer.String()) }
[ "func", "(", "c", "consoleRenderer", ")", "ConsoleTable", "(", ")", "template", ".", "HTML", "{", "var", "buffer", "bytes", ".", "Buffer", "\n", "// The first node is a dummy node", "for", "_", ",", "column", ":=", "range", "c", ".", "Table", ".", "Children"...
// ConsoleTable generates the main console table html. // // This cannot be generated with templates due to the 'recursive' nature of // this layout.
[ "ConsoleTable", "generates", "the", "main", "console", "table", "html", ".", "This", "cannot", "be", "generated", "with", "templates", "due", "to", "the", "recursive", "nature", "of", "this", "layout", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/milo/frontend/view_console.go#L447-L454
130,994
luci/luci-go
milo/frontend/view_console.go
consoleHeaderGroupIDs
func consoleHeaderGroupIDs(project string, config []*config.ConsoleSummaryGroup) ([]common.ConsoleID, error) { consoleIDSet := map[common.ConsoleID]struct{}{} for _, group := range config { for _, id := range group.ConsoleIds { if cid, err := common.ParseConsoleID(id); err != nil { return nil, err } else ...
go
func consoleHeaderGroupIDs(project string, config []*config.ConsoleSummaryGroup) ([]common.ConsoleID, error) { consoleIDSet := map[common.ConsoleID]struct{}{} for _, group := range config { for _, id := range group.ConsoleIds { if cid, err := common.ParseConsoleID(id); err != nil { return nil, err } else ...
[ "func", "consoleHeaderGroupIDs", "(", "project", "string", ",", "config", "[", "]", "*", "config", ".", "ConsoleSummaryGroup", ")", "(", "[", "]", "common", ".", "ConsoleID", ",", "error", ")", "{", "consoleIDSet", ":=", "map", "[", "common", ".", "Console...
// consoleHeaderGroupIDs extracts the console group IDs out of the header config.
[ "consoleHeaderGroupIDs", "extracts", "the", "console", "group", "IDs", "out", "of", "the", "header", "config", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/milo/frontend/view_console.go#L476-L492
130,995
luci/luci-go
milo/frontend/view_console.go
filterUnauthorizedBuildersFromConsoles
func filterUnauthorizedBuildersFromConsoles(c context.Context, cons []*common.Console) error { buckets := stringset.New(0) for _, con := range cons { buckets = buckets.Union(con.Buckets()) } perms, err := common.BucketPermissions(c, buckets.ToSlice()...) if err != nil { return err } for _, con := range cons ...
go
func filterUnauthorizedBuildersFromConsoles(c context.Context, cons []*common.Console) error { buckets := stringset.New(0) for _, con := range cons { buckets = buckets.Union(con.Buckets()) } perms, err := common.BucketPermissions(c, buckets.ToSlice()...) if err != nil { return err } for _, con := range cons ...
[ "func", "filterUnauthorizedBuildersFromConsoles", "(", "c", "context", ".", "Context", ",", "cons", "[", "]", "*", "common", ".", "Console", ")", "error", "{", "buckets", ":=", "stringset", ".", "New", "(", "0", ")", "\n", "for", "_", ",", "con", ":=", ...
// filterUnauthorizedBuildersFromConsoles filters out builders the user does not have access to.
[ "filterUnauthorizedBuildersFromConsoles", "filters", "out", "builders", "the", "user", "does", "not", "have", "access", "to", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/milo/frontend/view_console.go#L495-L508
130,996
luci/luci-go
milo/frontend/view_console.go
ConsoleHandler
func ConsoleHandler(c *router.Context) error { project := c.Params.ByName("project") if project == "" { return errors.New("missing project", grpcutil.InvalidArgumentTag) } group := c.Params.ByName("group") // Get console from datastore and filter out builders from the definition. con, err := common.GetConsole(...
go
func ConsoleHandler(c *router.Context) error { project := c.Params.ByName("project") if project == "" { return errors.New("missing project", grpcutil.InvalidArgumentTag) } group := c.Params.ByName("group") // Get console from datastore and filter out builders from the definition. con, err := common.GetConsole(...
[ "func", "ConsoleHandler", "(", "c", "*", "router", ".", "Context", ")", "error", "{", "project", ":=", "c", ".", "Params", ".", "ByName", "(", "\"", "\"", ")", "\n", "if", "project", "==", "\"", "\"", "{", "return", "errors", ".", "New", "(", "\"",...
// ConsoleHandler renders the console page.
[ "ConsoleHandler", "renders", "the", "console", "page", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/milo/frontend/view_console.go#L511-L573
130,997
luci/luci-go
milo/buildsource/swarming/memoryClient.go
addToStreams
func (c *memoryClient) addToStreams(s *rawpresentation.Streams, anno *miloProto.Step) error { if lds := anno.StdoutStream; lds != nil { if err := c.addLogDogTextStream(s, lds); err != nil { return fmt.Errorf( "Encountered error while processing step streams for STDOUT: %s", err) } } if lds := anno.StderrS...
go
func (c *memoryClient) addToStreams(s *rawpresentation.Streams, anno *miloProto.Step) error { if lds := anno.StdoutStream; lds != nil { if err := c.addLogDogTextStream(s, lds); err != nil { return fmt.Errorf( "Encountered error while processing step streams for STDOUT: %s", err) } } if lds := anno.StderrS...
[ "func", "(", "c", "*", "memoryClient", ")", "addToStreams", "(", "s", "*", "rawpresentation", ".", "Streams", ",", "anno", "*", "miloProto", ".", "Step", ")", "error", "{", "if", "lds", ":=", "anno", ".", "StdoutStream", ";", "lds", "!=", "nil", "{", ...
// addToStreams adds the set of stream with a given base path to the logdog // stream map. A base path is assumed to have a stream named "annotations".
[ "addToStreams", "adds", "the", "set", "of", "stream", "with", "a", "given", "base", "path", "to", "the", "logdog", "stream", "map", ".", "A", "base", "path", "is", "assumed", "to", "have", "a", "stream", "named", "annotations", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/milo/buildsource/swarming/memoryClient.go#L118-L159
130,998
luci/luci-go
vpython/spec/spec.go
NormalizeSpec
func NormalizeSpec(spec *vpython.Spec, tags []*vpython.PEP425Tag) error { // If we have a VirtualEnv package, validate and normalize it. if pkg := spec.Virtualenv; pkg != nil { if len(pkg.MatchTag) > 0 { // The VirtualEnv package may not specify a match tag. pkg.MatchTag = nil } } // Apply match filters,...
go
func NormalizeSpec(spec *vpython.Spec, tags []*vpython.PEP425Tag) error { // If we have a VirtualEnv package, validate and normalize it. if pkg := spec.Virtualenv; pkg != nil { if len(pkg.MatchTag) > 0 { // The VirtualEnv package may not specify a match tag. pkg.MatchTag = nil } } // Apply match filters,...
[ "func", "NormalizeSpec", "(", "spec", "*", "vpython", ".", "Spec", ",", "tags", "[", "]", "*", "vpython", ".", "PEP425Tag", ")", "error", "{", "// If we have a VirtualEnv package, validate and normalize it.", "if", "pkg", ":=", "spec", ".", "Virtualenv", ";", "p...
// NormalizeSpec normalizes the specification Message such that two messages // with identical meaning will have identical representation. // // If multiple wheel entries exist for the same package name, they must also // share a version. If they don't, an error will be returned. Otherwise, they // will be merged into ...
[ "NormalizeSpec", "normalizes", "the", "specification", "Message", "such", "that", "two", "messages", "with", "identical", "meaning", "will", "have", "identical", "representation", ".", "If", "multiple", "wheel", "entries", "exist", "for", "the", "same", "package", ...
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/vpython/spec/spec.go#L43-L91
130,999
luci/luci-go
vpython/spec/spec.go
Hash
func Hash(spec *vpython.Spec, rt *vpython.Runtime, extra ...string) string { mustMarshal := func(msg proto.Message) []byte { data, err := proto.Marshal(msg) if err != nil { panic(fmt.Errorf("failed to marshal proto: %v", err)) } return data } specData := mustMarshal(spec) rtData := mustMarshal(rt) must...
go
func Hash(spec *vpython.Spec, rt *vpython.Runtime, extra ...string) string { mustMarshal := func(msg proto.Message) []byte { data, err := proto.Marshal(msg) if err != nil { panic(fmt.Errorf("failed to marshal proto: %v", err)) } return data } specData := mustMarshal(spec) rtData := mustMarshal(rt) must...
[ "func", "Hash", "(", "spec", "*", "vpython", ".", "Spec", ",", "rt", "*", "vpython", ".", "Runtime", ",", "extra", "...", "string", ")", "string", "{", "mustMarshal", ":=", "func", "(", "msg", "proto", ".", "Message", ")", "[", "]", "byte", "{", "d...
// Hash hashes the contents of the supplied "spec" and "rt" and returns the // result as a hex-encoded string. // // If not empty, the contents of extra are prefixed to hash string. This can // be used to factor additional influences into the spec hash.
[ "Hash", "hashes", "the", "contents", "of", "the", "supplied", "spec", "and", "rt", "and", "returns", "the", "result", "as", "a", "hex", "-", "encoded", "string", ".", "If", "not", "empty", "the", "contents", "of", "extra", "are", "prefixed", "to", "hash"...
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/vpython/spec/spec.go#L98-L124