id
int32
0
167k
repo
stringlengths
5
54
path
stringlengths
4
155
func_name
stringlengths
1
118
original_string
stringlengths
52
85.5k
language
stringclasses
1 value
code
stringlengths
52
85.5k
code_tokens
list
docstring
stringlengths
6
2.61k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
85
252
8,900
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
8,901
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
8,902
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
8,903
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
8,904
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
8,905
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
8,906
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
8,907
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
8,908
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
8,909
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
8,910
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
8,911
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
8,912
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
8,913
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
8,914
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
8,915
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
8,916
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
8,917
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
8,918
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
8,919
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
8,920
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
8,921
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
8,922
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
8,923
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
8,924
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
8,925
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
8,926
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
8,927
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
8,928
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
8,929
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
8,930
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
8,931
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
8,932
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
8,933
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
8,934
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
8,935
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
8,936
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
8,937
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
8,938
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
8,939
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
8,940
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
8,941
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
8,942
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
8,943
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
8,944
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
8,945
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
8,946
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
8,947
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
8,948
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
8,949
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
8,950
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
8,951
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
8,952
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
8,953
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
8,954
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
8,955
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
8,956
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
8,957
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
8,958
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
8,959
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
8,960
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
8,961
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
8,962
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
8,963
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
8,964
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
8,965
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
8,966
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
8,967
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
8,968
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
8,969
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
8,970
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
8,971
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
8,972
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
8,973
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
8,974
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
8,975
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
8,976
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
8,977
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
8,978
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
8,979
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
8,980
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
8,981
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
8,982
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
8,983
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
8,984
luci/luci-go
client/cmd/swarming/collect.go
summarizeResultsPython
func summarizeResultsPython(results []taskResult) ([]byte, error) { var shards []map[string]interface{} for _, result := range results { buf, err := json.Marshal(result.result) if err != nil { return nil, err } var jsonResult map[string]interface{} if err := json.Unmarshal(buf, &jsonResult); err != nil...
go
func summarizeResultsPython(results []taskResult) ([]byte, error) { var shards []map[string]interface{} for _, result := range results { buf, err := json.Marshal(result.result) if err != nil { return nil, err } var jsonResult map[string]interface{} if err := json.Unmarshal(buf, &jsonResult); err != nil...
[ "func", "summarizeResultsPython", "(", "results", "[", "]", "taskResult", ")", "(", "[", "]", "byte", ",", "error", ")", "{", "var", "shards", "[", "]", "map", "[", "string", "]", "interface", "{", "}", "\n\n", "for", "_", ",", "result", ":=", "range...
// summarizeResultsPython generates summary JSON file compatible with python's // swarming client.
[ "summarizeResultsPython", "generates", "summary", "JSON", "file", "compatible", "with", "python", "s", "swarming", "client", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/client/cmd/swarming/collect.go#L317-L340
8,985
luci/luci-go
client/cmd/swarming/collect.go
summarizeResults
func (c *collectRun) summarizeResults(results []taskResult) ([]byte, error) { if c.taskSummaryPython { return summarizeResultsPython(results) } jsonResults := map[string]interface{}{} for _, result := range results { jsonResult := map[string]interface{}{} if result.err != nil { jsonResult["error"] = resul...
go
func (c *collectRun) summarizeResults(results []taskResult) ([]byte, error) { if c.taskSummaryPython { return summarizeResultsPython(results) } jsonResults := map[string]interface{}{} for _, result := range results { jsonResult := map[string]interface{}{} if result.err != nil { jsonResult["error"] = resul...
[ "func", "(", "c", "*", "collectRun", ")", "summarizeResults", "(", "results", "[", "]", "taskResult", ")", "(", "[", "]", "byte", ",", "error", ")", "{", "if", "c", ".", "taskSummaryPython", "{", "return", "summarizeResultsPython", "(", "results", ")", "...
// summarizeResults generate a marshalled JSON summary of the task results.
[ "summarizeResults", "generate", "a", "marshalled", "JSON", "summary", "of", "the", "task", "results", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/client/cmd/swarming/collect.go#L343-L364
8,986
luci/luci-go
cipd/appengine/impl/model/txn.go
Txn
func Txn(c context.Context, name string, cb func(context.Context) error) error { c = logging.SetField(c, "txn", name) var attempt int var innerErr error err := datastore.RunInTransaction(c, func(c context.Context) error { attempt++ if attempt != 1 { logging.Warningf(c, "Retrying the transaction: failed to ...
go
func Txn(c context.Context, name string, cb func(context.Context) error) error { c = logging.SetField(c, "txn", name) var attempt int var innerErr error err := datastore.RunInTransaction(c, func(c context.Context) error { attempt++ if attempt != 1 { logging.Warningf(c, "Retrying the transaction: failed to ...
[ "func", "Txn", "(", "c", "context", ".", "Context", ",", "name", "string", ",", "cb", "func", "(", "context", ".", "Context", ")", "error", ")", "error", "{", "c", "=", "logging", ".", "SetField", "(", "c", ",", "\"", "\"", ",", "name", ")", "\n\...
// Txn runs the callback in a datastore transaction, marking commit errors with // transient tag. // // The given name will be used for logging and error messages.
[ "Txn", "runs", "the", "callback", "in", "a", "datastore", "transaction", "marking", "commit", "errors", "with", "transient", "tag", ".", "The", "given", "name", "will", "be", "used", "for", "logging", "and", "error", "messages", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/cipd/appengine/impl/model/txn.go#L30-L49
8,987
luci/luci-go
logdog/server/service/config/poller.go
Run
func (p *ChangePoller) Run(c context.Context) { if p.Period <= 0 { return } for { // If our Context has been canceled, terminate. select { case <-c.Done(): log.WithError(c.Err()).Warningf(c, "Terminating poll loop: context has been cancelled.") return default: // Continue } log.Fields{ "t...
go
func (p *ChangePoller) Run(c context.Context) { if p.Period <= 0 { return } for { // If our Context has been canceled, terminate. select { case <-c.Done(): log.WithError(c.Err()).Warningf(c, "Terminating poll loop: context has been cancelled.") return default: // Continue } log.Fields{ "t...
[ "func", "(", "p", "*", "ChangePoller", ")", "Run", "(", "c", "context", ".", "Context", ")", "{", "if", "p", ".", "Period", "<=", "0", "{", "return", "\n", "}", "\n\n", "for", "{", "// If our Context has been canceled, terminate.", "select", "{", "case", ...
// Run starts polling for changes. It will stop when the Context is cancelled.
[ "Run", "starts", "polling", "for", "changes", ".", "It", "will", "stop", "when", "the", "Context", "is", "cancelled", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/logdog/server/service/config/poller.go#L54-L98
8,988
luci/luci-go
logdog/server/service/config/poller.go
Refresh
func (p *ChangePoller) Refresh(c context.Context) error { var meta config.Meta if err := cfgclient.Get(c, cfgclient.AsService, p.ConfigSet, p.Path, nil, &meta); err != nil { return errors.Annotate(err, "failed to reload config %s :: %s", p.ConfigSet, p.Path).Err() } p.ContentHash = meta.ContentHash return nil }
go
func (p *ChangePoller) Refresh(c context.Context) error { var meta config.Meta if err := cfgclient.Get(c, cfgclient.AsService, p.ConfigSet, p.Path, nil, &meta); err != nil { return errors.Annotate(err, "failed to reload config %s :: %s", p.ConfigSet, p.Path).Err() } p.ContentHash = meta.ContentHash return nil }
[ "func", "(", "p", "*", "ChangePoller", ")", "Refresh", "(", "c", "context", ".", "Context", ")", "error", "{", "var", "meta", "config", ".", "Meta", "\n", "if", "err", ":=", "cfgclient", ".", "Get", "(", "c", ",", "cfgclient", ".", "AsService", ",", ...
// Refresh reloads the configuration value, updating ContentHash.
[ "Refresh", "reloads", "the", "configuration", "value", "updating", "ContentHash", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/logdog/server/service/config/poller.go#L101-L109
8,989
luci/luci-go
cipd/appengine/impl/settings/settings.go
Get
func Get(ctx context.Context) (*Settings, error) { s := &Settings{} if err := settings.Get(ctx, settingsKey, s); err != nil && err != settings.ErrNoSettings { return nil, errors.Annotate(err, "failed to fetch settings"). Tag(grpcutil.InternalTag, transient.Tag).Err() } if s.StorageGSPath == "" || s.TempGSPath ...
go
func Get(ctx context.Context) (*Settings, error) { s := &Settings{} if err := settings.Get(ctx, settingsKey, s); err != nil && err != settings.ErrNoSettings { return nil, errors.Annotate(err, "failed to fetch settings"). Tag(grpcutil.InternalTag, transient.Tag).Err() } if s.StorageGSPath == "" || s.TempGSPath ...
[ "func", "Get", "(", "ctx", "context", ".", "Context", ")", "(", "*", "Settings", ",", "error", ")", "{", "s", ":=", "&", "Settings", "{", "}", "\n", "if", "err", ":=", "settings", ".", "Get", "(", "ctx", ",", "settingsKey", ",", "s", ")", ";", ...
// Get returns the settings from the local cache, checking they are populated. // // Returns grpc-annotated Internal error if something is wrong.
[ "Get", "returns", "the", "settings", "from", "the", "local", "cache", "checking", "they", "are", "populated", ".", "Returns", "grpc", "-", "annotated", "Internal", "error", "if", "something", "is", "wrong", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/cipd/appengine/impl/settings/settings.go#L63-L74
8,990
luci/luci-go
cipd/appengine/impl/settings/settings.go
ObjectPath
func (s *Settings) ObjectPath(obj *api.ObjectRef) string { return s.StorageGSPath + "/" + obj.HashAlgo.String() + "/" + obj.HexDigest }
go
func (s *Settings) ObjectPath(obj *api.ObjectRef) string { return s.StorageGSPath + "/" + obj.HashAlgo.String() + "/" + obj.HexDigest }
[ "func", "(", "s", "*", "Settings", ")", "ObjectPath", "(", "obj", "*", "api", ".", "ObjectRef", ")", "string", "{", "return", "s", ".", "StorageGSPath", "+", "\"", "\"", "+", "obj", ".", "HashAlgo", ".", "String", "(", ")", "+", "\"", "\"", "+", ...
// ObjectPath constructs a path to the object in the Google Storage, starting // from StorageGSPath root.
[ "ObjectPath", "constructs", "a", "path", "to", "the", "object", "in", "the", "Google", "Storage", "starting", "from", "StorageGSPath", "root", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/cipd/appengine/impl/settings/settings.go#L78-L80
8,991
luci/luci-go
auth/client/authcli/authcli.go
Register
func (fl *Flags) Register(f *flag.FlagSet, defaults auth.Options) { fl.defaults = defaults f.StringVar(&fl.serviceAccountJSON, "service-account-json", fl.defaults.ServiceAccountJSONPath, "Path to JSON file with service account credentials to use.") if fl.RegisterScopesFlag { defaultScopes := strings.Join(defaults....
go
func (fl *Flags) Register(f *flag.FlagSet, defaults auth.Options) { fl.defaults = defaults f.StringVar(&fl.serviceAccountJSON, "service-account-json", fl.defaults.ServiceAccountJSONPath, "Path to JSON file with service account credentials to use.") if fl.RegisterScopesFlag { defaultScopes := strings.Join(defaults....
[ "func", "(", "fl", "*", "Flags", ")", "Register", "(", "f", "*", "flag", ".", "FlagSet", ",", "defaults", "auth", ".", "Options", ")", "{", "fl", ".", "defaults", "=", "defaults", "\n", "f", ".", "StringVar", "(", "&", "fl", ".", "serviceAccountJSON"...
// Register adds auth related flags to a FlagSet.
[ "Register", "adds", "auth", "related", "flags", "to", "a", "FlagSet", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/auth/client/authcli/authcli.go#L133-L143
8,992
luci/luci-go
auth/client/authcli/authcli.go
Options
func (fl *Flags) Options() (auth.Options, error) { opts := fl.defaults opts.ServiceAccountJSONPath = fl.serviceAccountJSON if fl.RegisterScopesFlag { opts.Scopes = strings.Split(fl.scopes, " ") sort.Strings(opts.Scopes) } return opts, nil }
go
func (fl *Flags) Options() (auth.Options, error) { opts := fl.defaults opts.ServiceAccountJSONPath = fl.serviceAccountJSON if fl.RegisterScopesFlag { opts.Scopes = strings.Split(fl.scopes, " ") sort.Strings(opts.Scopes) } return opts, nil }
[ "func", "(", "fl", "*", "Flags", ")", "Options", "(", ")", "(", "auth", ".", "Options", ",", "error", ")", "{", "opts", ":=", "fl", ".", "defaults", "\n", "opts", ".", "ServiceAccountJSONPath", "=", "fl", ".", "serviceAccountJSON", "\n", "if", "fl", ...
// Options return instance of auth.Options struct with values set accordingly to // parsed command line flags.
[ "Options", "return", "instance", "of", "auth", ".", "Options", "struct", "with", "values", "set", "accordingly", "to", "parsed", "command", "line", "flags", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/auth/client/authcli/authcli.go#L147-L155
8,993
luci/luci-go
auth/client/authcli/authcli.go
SubcommandLoginWithParams
func SubcommandLoginWithParams(params CommandParams) *subcommands.Command { return &subcommands.Command{ Advanced: params.Advanced, UsageLine: params.Name, ShortDesc: "performs interactive login flow", LongDesc: "Performs interactive login flow and caches obtained credentials", CommandRun: func() subcomman...
go
func SubcommandLoginWithParams(params CommandParams) *subcommands.Command { return &subcommands.Command{ Advanced: params.Advanced, UsageLine: params.Name, ShortDesc: "performs interactive login flow", LongDesc: "Performs interactive login flow and caches obtained credentials", CommandRun: func() subcomman...
[ "func", "SubcommandLoginWithParams", "(", "params", "CommandParams", ")", "*", "subcommands", ".", "Command", "{", "return", "&", "subcommands", ".", "Command", "{", "Advanced", ":", "params", ".", "Advanced", ",", "UsageLine", ":", "params", ".", "Name", ",",...
// SubcommandLoginWithParams returns subcommands.Command that can be used to // perform interactive login.
[ "SubcommandLoginWithParams", "returns", "subcommands", ".", "Command", "that", "can", "be", "used", "to", "perform", "interactive", "login", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/auth/client/authcli/authcli.go#L187-L200
8,994
luci/luci-go
auth/client/authcli/authcli.go
SubcommandLogoutWithParams
func SubcommandLogoutWithParams(params CommandParams) *subcommands.Command { return &subcommands.Command{ Advanced: params.Advanced, UsageLine: params.Name, ShortDesc: "removes cached credentials", LongDesc: "Removes cached credentials from the disk", CommandRun: func() subcommands.CommandRun { c := &lo...
go
func SubcommandLogoutWithParams(params CommandParams) *subcommands.Command { return &subcommands.Command{ Advanced: params.Advanced, UsageLine: params.Name, ShortDesc: "removes cached credentials", LongDesc: "Removes cached credentials from the disk", CommandRun: func() subcommands.CommandRun { c := &lo...
[ "func", "SubcommandLogoutWithParams", "(", "params", "CommandParams", ")", "*", "subcommands", ".", "Command", "{", "return", "&", "subcommands", ".", "Command", "{", "Advanced", ":", "params", ".", "Advanced", ",", "UsageLine", ":", "params", ".", "Name", ","...
// SubcommandLogoutWithParams returns subcommands.Command that can be used to purge cached // credentials.
[ "SubcommandLogoutWithParams", "returns", "subcommands", ".", "Command", "that", "can", "be", "used", "to", "purge", "cached", "credentials", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/auth/client/authcli/authcli.go#L231-L244
8,995
luci/luci-go
auth/client/authcli/authcli.go
SubcommandInfoWithParams
func SubcommandInfoWithParams(params CommandParams) *subcommands.Command { return &subcommands.Command{ Advanced: params.Advanced, UsageLine: params.Name, ShortDesc: "prints an email address associated with currently cached token", LongDesc: "Prints an email address associated with currently cached token", ...
go
func SubcommandInfoWithParams(params CommandParams) *subcommands.Command { return &subcommands.Command{ Advanced: params.Advanced, UsageLine: params.Name, ShortDesc: "prints an email address associated with currently cached token", LongDesc: "Prints an email address associated with currently cached token", ...
[ "func", "SubcommandInfoWithParams", "(", "params", "CommandParams", ")", "*", "subcommands", ".", "Command", "{", "return", "&", "subcommands", ".", "Command", "{", "Advanced", ":", "params", ".", "Advanced", ",", "UsageLine", ":", "params", ".", "Name", ",", ...
// SubcommandInfoWithParams returns subcommand.Command that can be used to print // current cached credentials.
[ "SubcommandInfoWithParams", "returns", "subcommand", ".", "Command", "that", "can", "be", "used", "to", "print", "current", "cached", "credentials", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/auth/client/authcli/authcli.go#L275-L288
8,996
luci/luci-go
auth/client/authcli/authcli.go
SubcommandTokenWithParams
func SubcommandTokenWithParams(params CommandParams) *subcommands.Command { return &subcommands.Command{ Advanced: params.Advanced, UsageLine: params.Name, ShortDesc: "prints an access token", LongDesc: "Generates an access token if requested and prints it.", CommandRun: func() subcommands.CommandRun { ...
go
func SubcommandTokenWithParams(params CommandParams) *subcommands.Command { return &subcommands.Command{ Advanced: params.Advanced, UsageLine: params.Name, ShortDesc: "prints an access token", LongDesc: "Generates an access token if requested and prints it.", CommandRun: func() subcommands.CommandRun { ...
[ "func", "SubcommandTokenWithParams", "(", "params", "CommandParams", ")", "*", "subcommands", ".", "Command", "{", "return", "&", "subcommands", ".", "Command", "{", "Advanced", ":", "params", ".", "Advanced", ",", "UsageLine", ":", "params", ".", "Name", ",",...
// SubcommandTokenWithParams returns subcommand.Command that can be used to // print current access token.
[ "SubcommandTokenWithParams", "returns", "subcommand", ".", "Command", "that", "can", "be", "used", "to", "print", "current", "access", "token", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/auth/client/authcli/authcli.go#L323-L343
8,997
luci/luci-go
auth/client/authcli/authcli.go
SubcommandContextWithParams
func SubcommandContextWithParams(params CommandParams) *subcommands.Command { // By default request all scopes used by authctx.Context. params.AuthOptions.Scopes = []string{ "https://www.googleapis.com/auth/cloud-platform", "https://www.googleapis.com/auth/firebase", "https://www.googleapis.com/auth/gerritcoder...
go
func SubcommandContextWithParams(params CommandParams) *subcommands.Command { // By default request all scopes used by authctx.Context. params.AuthOptions.Scopes = []string{ "https://www.googleapis.com/auth/cloud-platform", "https://www.googleapis.com/auth/firebase", "https://www.googleapis.com/auth/gerritcoder...
[ "func", "SubcommandContextWithParams", "(", "params", "CommandParams", ")", "*", "subcommands", ".", "Command", "{", "// By default request all scopes used by authctx.Context.", "params", ".", "AuthOptions", ".", "Scopes", "=", "[", "]", "string", "{", "\"", "\"", ","...
// SubcommandContextWithParams returns subcommand.Command that can be used to // setup new LUCI authentication context for a process tree.
[ "SubcommandContextWithParams", "returns", "subcommand", ".", "Command", "that", "can", "be", "used", "to", "setup", "new", "LUCI", "authentication", "context", "for", "a", "process", "tree", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/auth/client/authcli/authcli.go#L416-L440
8,998
luci/luci-go
milo/api/buildbot/structs.go
ID
func (b *Build) ID() BuildID { return BuildID{ Master: b.Master, Builder: b.Buildername, Number: b.Number, } }
go
func (b *Build) ID() BuildID { return BuildID{ Master: b.Master, Builder: b.Buildername, Number: b.Number, } }
[ "func", "(", "b", "*", "Build", ")", "ID", "(", ")", "BuildID", "{", "return", "BuildID", "{", "Master", ":", "b", ".", "Master", ",", "Builder", ":", "b", ".", "Buildername", ",", "Number", ":", "b", ".", "Number", ",", "}", "\n", "}" ]
// ID returns b's BuildID.
[ "ID", "returns", "b", "s", "BuildID", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/milo/api/buildbot/structs.go#L160-L166
8,999
luci/luci-go
milo/api/buildbot/structs.go
PropertyValue
func (b *Build) PropertyValue(name string) interface{} { for _, prop := range b.Properties { if prop.Name == name { return prop.Value } } // Not returning (nil, false) here because it would complicate all // practical usage of this function, which simply try to cast the // returned value. return PropertyN...
go
func (b *Build) PropertyValue(name string) interface{} { for _, prop := range b.Properties { if prop.Name == name { return prop.Value } } // Not returning (nil, false) here because it would complicate all // practical usage of this function, which simply try to cast the // returned value. return PropertyN...
[ "func", "(", "b", "*", "Build", ")", "PropertyValue", "(", "name", "string", ")", "interface", "{", "}", "{", "for", "_", ",", "prop", ":=", "range", "b", ".", "Properties", "{", "if", "prop", ".", "Name", "==", "name", "{", "return", "prop", ".", ...
// PropertyValue returns the named property value. // If such property does not exist, returns PropertyNotFound.
[ "PropertyValue", "returns", "the", "named", "property", "value", ".", "If", "such", "property", "does", "not", "exist", "returns", "PropertyNotFound", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/milo/api/buildbot/structs.go#L184-L195