id int32 0 167k | repo stringlengths 5 54 | path stringlengths 4 155 | func_name stringlengths 1 118 | original_string stringlengths 52 85.5k | language stringclasses 1
value | code stringlengths 52 85.5k | code_tokens listlengths 21 1.41k | docstring stringlengths 6 2.61k | docstring_tokens listlengths 3 215 | sha stringlengths 40 40 | url stringlengths 85 252 |
|---|---|---|---|---|---|---|---|---|---|---|---|
131,200 | luci/luci-go | machine-db/appengine/rpc/physical_hosts.go | UpdatePhysicalHost | func (*Service) UpdatePhysicalHost(c context.Context, req *crimson.UpdatePhysicalHostRequest) (*crimson.PhysicalHost, error) {
return updatePhysicalHost(c, req.Host, req.UpdateMask)
} | go | func (*Service) UpdatePhysicalHost(c context.Context, req *crimson.UpdatePhysicalHostRequest) (*crimson.PhysicalHost, error) {
return updatePhysicalHost(c, req.Host, req.UpdateMask)
} | [
"func",
"(",
"*",
"Service",
")",
"UpdatePhysicalHost",
"(",
"c",
"context",
".",
"Context",
",",
"req",
"*",
"crimson",
".",
"UpdatePhysicalHostRequest",
")",
"(",
"*",
"crimson",
".",
"PhysicalHost",
",",
"error",
")",
"{",
"return",
"updatePhysicalHost",
... | // UpdatePhysicalHost handles a request to update an existing physical host. | [
"UpdatePhysicalHost",
"handles",
"a",
"request",
"to",
"update",
"an",
"existing",
"physical",
"host",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/machine-db/appengine/rpc/physical_hosts.go#L55-L57 |
131,201 | luci/luci-go | machine-db/appengine/rpc/physical_hosts.go | validatePhysicalHostForCreation | func validatePhysicalHostForCreation(h *crimson.PhysicalHost) error {
switch {
case h == nil:
return status.Error(codes.InvalidArgument, "physical host specification is required")
case h.Name == "":
return status.Error(codes.InvalidArgument, "hostname is required and must be non-empty")
case h.Vlan != 0:
retu... | go | func validatePhysicalHostForCreation(h *crimson.PhysicalHost) error {
switch {
case h == nil:
return status.Error(codes.InvalidArgument, "physical host specification is required")
case h.Name == "":
return status.Error(codes.InvalidArgument, "hostname is required and must be non-empty")
case h.Vlan != 0:
retu... | [
"func",
"validatePhysicalHostForCreation",
"(",
"h",
"*",
"crimson",
".",
"PhysicalHost",
")",
"error",
"{",
"switch",
"{",
"case",
"h",
"==",
"nil",
":",
"return",
"status",
".",
"Error",
"(",
"codes",
".",
"InvalidArgument",
",",
"\"",
"\"",
")",
"\n",
... | // validatePhysicalHostForCreation validates a physical host for creation. | [
"validatePhysicalHostForCreation",
"validates",
"a",
"physical",
"host",
"for",
"creation",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/machine-db/appengine/rpc/physical_hosts.go#L348-L373 |
131,202 | luci/luci-go | machine-db/appengine/rpc/physical_hosts.go | validatePhysicalHostForUpdate | func validatePhysicalHostForUpdate(h *crimson.PhysicalHost, mask *field_mask.FieldMask) error {
switch err := validateUpdateMask(mask); {
case h == nil:
return status.Error(codes.InvalidArgument, "physical host specification is required")
case h.Name == "":
return status.Error(codes.InvalidArgument, "hostname is... | go | func validatePhysicalHostForUpdate(h *crimson.PhysicalHost, mask *field_mask.FieldMask) error {
switch err := validateUpdateMask(mask); {
case h == nil:
return status.Error(codes.InvalidArgument, "physical host specification is required")
case h.Name == "":
return status.Error(codes.InvalidArgument, "hostname is... | [
"func",
"validatePhysicalHostForUpdate",
"(",
"h",
"*",
"crimson",
".",
"PhysicalHost",
",",
"mask",
"*",
"field_mask",
".",
"FieldMask",
")",
"error",
"{",
"switch",
"err",
":=",
"validateUpdateMask",
"(",
"mask",
")",
";",
"{",
"case",
"h",
"==",
"nil",
... | // validatePhysicalHostForUpdate validates a physical host for update. | [
"validatePhysicalHostForUpdate",
"validates",
"a",
"physical",
"host",
"for",
"update",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/machine-db/appengine/rpc/physical_hosts.go#L376-L423 |
131,203 | luci/luci-go | scheduler/appengine/engine/invocation.go | isEqual | func (e *Invocation) isEqual(other *Invocation) bool {
return e == other || (e.ID == other.ID &&
e.MutationsCount == other.MutationsCount && // compare it first, it changes most often
e.JobID == other.JobID &&
e.IndexedJobID == other.IndexedJobID &&
e.Started.Equal(other.Started) &&
e.Finished.Equal(other.Fi... | go | func (e *Invocation) isEqual(other *Invocation) bool {
return e == other || (e.ID == other.ID &&
e.MutationsCount == other.MutationsCount && // compare it first, it changes most often
e.JobID == other.JobID &&
e.IndexedJobID == other.IndexedJobID &&
e.Started.Equal(other.Started) &&
e.Finished.Equal(other.Fi... | [
"func",
"(",
"e",
"*",
"Invocation",
")",
"isEqual",
"(",
"other",
"*",
"Invocation",
")",
"bool",
"{",
"return",
"e",
"==",
"other",
"||",
"(",
"e",
".",
"ID",
"==",
"other",
".",
"ID",
"&&",
"e",
".",
"MutationsCount",
"==",
"other",
".",
"Mutati... | // isEqual returns true iff 'e' is equal to 'other' | [
"isEqual",
"returns",
"true",
"iff",
"e",
"is",
"equal",
"to",
"other"
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/scheduler/appengine/engine/invocation.go#L246-L268 |
131,204 | luci/luci-go | scheduler/appengine/engine/invocation.go | GetProjectID | func (e *Invocation) GetProjectID() string {
parts := strings.Split(e.JobID, "/")
return parts[0]
} | go | func (e *Invocation) GetProjectID() string {
parts := strings.Split(e.JobID, "/")
return parts[0]
} | [
"func",
"(",
"e",
"*",
"Invocation",
")",
"GetProjectID",
"(",
")",
"string",
"{",
"parts",
":=",
"strings",
".",
"Split",
"(",
"e",
".",
"JobID",
",",
"\"",
"\"",
")",
"\n",
"return",
"parts",
"[",
"0",
"]",
"\n",
"}"
] | // GetProjectID parses the ProjectID from the JobID and returns it. | [
"GetProjectID",
"parses",
"the",
"ProjectID",
"from",
"the",
"JobID",
"and",
"returns",
"it",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/scheduler/appengine/engine/invocation.go#L271-L274 |
131,205 | luci/luci-go | scheduler/appengine/engine/invocation.go | debugLog | func (e *Invocation) debugLog(c context.Context, format string, args ...interface{}) {
debugLog(c, &e.DebugLog, format, args...)
} | go | func (e *Invocation) debugLog(c context.Context, format string, args ...interface{}) {
debugLog(c, &e.DebugLog, format, args...)
} | [
"func",
"(",
"e",
"*",
"Invocation",
")",
"debugLog",
"(",
"c",
"context",
".",
"Context",
",",
"format",
"string",
",",
"args",
"...",
"interface",
"{",
"}",
")",
"{",
"debugLog",
"(",
"c",
",",
"&",
"e",
".",
"DebugLog",
",",
"format",
",",
"args... | // debugLog appends a line to DebugLog field. | [
"debugLog",
"appends",
"a",
"line",
"to",
"DebugLog",
"field",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/scheduler/appengine/engine/invocation.go#L277-L279 |
131,206 | luci/luci-go | scheduler/appengine/engine/invocation.go | trimDebugLog | func (e *Invocation) trimDebugLog() {
if len(e.DebugLog) <= debugLogSizeLimit {
return
}
const cutMsg = "--- the log has been cut here ---"
giveUp := func() {
e.DebugLog = e.DebugLog[:debugLogSizeLimit-len(cutMsg)-2] + "\n" + cutMsg + "\n"
}
// We take last debugLogTailLines lines of log and move them "up",... | go | func (e *Invocation) trimDebugLog() {
if len(e.DebugLog) <= debugLogSizeLimit {
return
}
const cutMsg = "--- the log has been cut here ---"
giveUp := func() {
e.DebugLog = e.DebugLog[:debugLogSizeLimit-len(cutMsg)-2] + "\n" + cutMsg + "\n"
}
// We take last debugLogTailLines lines of log and move them "up",... | [
"func",
"(",
"e",
"*",
"Invocation",
")",
"trimDebugLog",
"(",
")",
"{",
"if",
"len",
"(",
"e",
".",
"DebugLog",
")",
"<=",
"debugLogSizeLimit",
"{",
"return",
"\n",
"}",
"\n\n",
"const",
"cutMsg",
"=",
"\"",
"\"",
"\n",
"giveUp",
":=",
"func",
"(",
... | // trimDebugLog makes sure DebugLog field doesn't exceed limits.
//
// It cuts the middle of the log. We need to do this to keep the entity small
// enough to fit the datastore limits. | [
"trimDebugLog",
"makes",
"sure",
"DebugLog",
"field",
"doesn",
"t",
"exceed",
"limits",
".",
"It",
"cuts",
"the",
"middle",
"of",
"the",
"log",
".",
"We",
"need",
"to",
"do",
"this",
"to",
"keep",
"the",
"entity",
"small",
"enough",
"to",
"fit",
"the",
... | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/scheduler/appengine/engine/invocation.go#L285-L350 |
131,207 | luci/luci-go | scheduler/appengine/engine/invocation.go | cleanupUnreferencedInvocations | func cleanupUnreferencedInvocations(c context.Context, invs []*Invocation) {
keysToKill := make([]*datastore.Key, 0, len(invs))
for _, inv := range invs {
if inv != nil {
logging.Warningf(c, "Cleaning up inv %d of job %q", inv.ID, inv.JobID)
keysToKill = append(keysToKill, datastore.KeyForObj(c, inv))
}
}
... | go | func cleanupUnreferencedInvocations(c context.Context, invs []*Invocation) {
keysToKill := make([]*datastore.Key, 0, len(invs))
for _, inv := range invs {
if inv != nil {
logging.Warningf(c, "Cleaning up inv %d of job %q", inv.ID, inv.JobID)
keysToKill = append(keysToKill, datastore.KeyForObj(c, inv))
}
}
... | [
"func",
"cleanupUnreferencedInvocations",
"(",
"c",
"context",
".",
"Context",
",",
"invs",
"[",
"]",
"*",
"Invocation",
")",
"{",
"keysToKill",
":=",
"make",
"(",
"[",
"]",
"*",
"datastore",
".",
"Key",
",",
"0",
",",
"len",
"(",
"invs",
")",
")",
"... | // cleanupUnreferencedInvocations tries to delete given invocations.
//
// This is best effort cleanup after failures. It logs errors, but doesn't
// return them, to indicate that there's nothing we can actually do.
//
// 'invs' is allowed to have nils, they are skipped. Allowed to be called
// within a transaction, ig... | [
"cleanupUnreferencedInvocations",
"tries",
"to",
"delete",
"given",
"invocations",
".",
"This",
"is",
"best",
"effort",
"cleanup",
"after",
"failures",
".",
"It",
"logs",
"errors",
"but",
"doesn",
"t",
"return",
"them",
"to",
"indicate",
"that",
"there",
"s",
... | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/scheduler/appengine/engine/invocation.go#L380-L391 |
131,208 | luci/luci-go | scheduler/appengine/engine/invocation.go | reportOverrunMetrics | func (e *Invocation) reportOverrunMetrics(c context.Context) {
metricInvocationsOverrun.Add(c, 1, e.JobID)
} | go | func (e *Invocation) reportOverrunMetrics(c context.Context) {
metricInvocationsOverrun.Add(c, 1, e.JobID)
} | [
"func",
"(",
"e",
"*",
"Invocation",
")",
"reportOverrunMetrics",
"(",
"c",
"context",
".",
"Context",
")",
"{",
"metricInvocationsOverrun",
".",
"Add",
"(",
"c",
",",
"1",
",",
"e",
".",
"JobID",
")",
"\n",
"}"
] | // reportOverrunMetrics reports overrun to monitoring.
// Should be called after transaction to save this invocation is completed. | [
"reportOverrunMetrics",
"reports",
"overrun",
"to",
"monitoring",
".",
"Should",
"be",
"called",
"after",
"transaction",
"to",
"save",
"this",
"invocation",
"is",
"completed",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/scheduler/appengine/engine/invocation.go#L395-L397 |
131,209 | luci/luci-go | scheduler/appengine/engine/invocation.go | reportCompletionMetrics | func (e *Invocation) reportCompletionMetrics(c context.Context) {
if !e.Status.Final() || e.Finished.IsZero() {
panic(fmt.Errorf("reportCompletionMetrics on incomplete invocation: %v", e))
}
duration := e.Finished.Sub(e.Started)
metricInvocationsDurations.Add(c, duration.Seconds(), e.JobID, string(e.Status))
} | go | func (e *Invocation) reportCompletionMetrics(c context.Context) {
if !e.Status.Final() || e.Finished.IsZero() {
panic(fmt.Errorf("reportCompletionMetrics on incomplete invocation: %v", e))
}
duration := e.Finished.Sub(e.Started)
metricInvocationsDurations.Add(c, duration.Seconds(), e.JobID, string(e.Status))
} | [
"func",
"(",
"e",
"*",
"Invocation",
")",
"reportCompletionMetrics",
"(",
"c",
"context",
".",
"Context",
")",
"{",
"if",
"!",
"e",
".",
"Status",
".",
"Final",
"(",
")",
"||",
"e",
".",
"Finished",
".",
"IsZero",
"(",
")",
"{",
"panic",
"(",
"fmt"... | // reportCompletionMetrics reports invocation stats to monitoring.
// Should be called after transaction to save this invocation is completed. | [
"reportCompletionMetrics",
"reports",
"invocation",
"stats",
"to",
"monitoring",
".",
"Should",
"be",
"called",
"after",
"transaction",
"to",
"save",
"this",
"invocation",
"is",
"completed",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/scheduler/appengine/engine/invocation.go#L401-L407 |
131,210 | luci/luci-go | machine-db/appengine/settings/settings.go | New | func New(c context.Context) *DatabaseSettings {
return &DatabaseSettings{
Server: "",
Username: "",
Password: "",
Database: "",
}
} | go | func New(c context.Context) *DatabaseSettings {
return &DatabaseSettings{
Server: "",
Username: "",
Password: "",
Database: "",
}
} | [
"func",
"New",
"(",
"c",
"context",
".",
"Context",
")",
"*",
"DatabaseSettings",
"{",
"return",
"&",
"DatabaseSettings",
"{",
"Server",
":",
"\"",
"\"",
",",
"Username",
":",
"\"",
"\"",
",",
"Password",
":",
"\"",
"\"",
",",
"Database",
":",
"\"",
... | // New returns a new instance of DatabaseSettings. | [
"New",
"returns",
"a",
"new",
"instance",
"of",
"DatabaseSettings",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/machine-db/appengine/settings/settings.go#L41-L48 |
131,211 | luci/luci-go | machine-db/appengine/settings/settings.go | Get | func Get(c context.Context) (*DatabaseSettings, error) {
databaseSettings := &DatabaseSettings{}
switch err := settings.Get(c, settingsKey, databaseSettings); err {
case nil:
return databaseSettings, nil
case settings.ErrNoSettings:
return New(c), nil
default:
return nil, err
}
} | go | func Get(c context.Context) (*DatabaseSettings, error) {
databaseSettings := &DatabaseSettings{}
switch err := settings.Get(c, settingsKey, databaseSettings); err {
case nil:
return databaseSettings, nil
case settings.ErrNoSettings:
return New(c), nil
default:
return nil, err
}
} | [
"func",
"Get",
"(",
"c",
"context",
".",
"Context",
")",
"(",
"*",
"DatabaseSettings",
",",
"error",
")",
"{",
"databaseSettings",
":=",
"&",
"DatabaseSettings",
"{",
"}",
"\n",
"switch",
"err",
":=",
"settings",
".",
"Get",
"(",
"c",
",",
"settingsKey",... | // Get returns the current settings. This may hit an outdated cache. | [
"Get",
"returns",
"the",
"current",
"settings",
".",
"This",
"may",
"hit",
"an",
"outdated",
"cache",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/machine-db/appengine/settings/settings.go#L51-L61 |
131,212 | luci/luci-go | machine-db/appengine/settings/settings.go | Fields | func (*DatabaseSettings) Fields(c context.Context) ([]portal.Field, error) {
fields := []portal.Field{
{
ID: "Server",
Title: "Server",
Type: portal.FieldText,
Help: "<p>Server to use (for Cloud SQL should be of the form project:region:database)</p>",
},
{
ID: "Username",
Title: "Userna... | go | func (*DatabaseSettings) Fields(c context.Context) ([]portal.Field, error) {
fields := []portal.Field{
{
ID: "Server",
Title: "Server",
Type: portal.FieldText,
Help: "<p>Server to use (for Cloud SQL should be of the form project:region:database)</p>",
},
{
ID: "Username",
Title: "Userna... | [
"func",
"(",
"*",
"DatabaseSettings",
")",
"Fields",
"(",
"c",
"context",
".",
"Context",
")",
"(",
"[",
"]",
"portal",
".",
"Field",
",",
"error",
")",
"{",
"fields",
":=",
"[",
"]",
"portal",
".",
"Field",
"{",
"{",
"ID",
":",
"\"",
"\"",
",",
... | // Fields returns the form fields for configuring these settings. | [
"Fields",
"returns",
"the",
"form",
"fields",
"for",
"configuring",
"these",
"settings",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/machine-db/appengine/settings/settings.go#L87-L115 |
131,213 | luci/luci-go | machine-db/appengine/settings/settings.go | Actions | func (*DatabaseSettings) Actions(c context.Context) ([]portal.Action, error) {
return nil, nil
} | go | func (*DatabaseSettings) Actions(c context.Context) ([]portal.Action, error) {
return nil, nil
} | [
"func",
"(",
"*",
"DatabaseSettings",
")",
"Actions",
"(",
"c",
"context",
".",
"Context",
")",
"(",
"[",
"]",
"portal",
".",
"Action",
",",
"error",
")",
"{",
"return",
"nil",
",",
"nil",
"\n",
"}"
] | // Actions is additional list of actions to present on the page. | [
"Actions",
"is",
"additional",
"list",
"of",
"actions",
"to",
"present",
"on",
"the",
"page",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/machine-db/appengine/settings/settings.go#L118-L120 |
131,214 | luci/luci-go | machine-db/appengine/settings/settings.go | ReadSettings | func (*DatabaseSettings) ReadSettings(c context.Context) (map[string]string, error) {
databaseSettings, err := GetUncached(c)
if err != nil {
return nil, err
}
return map[string]string{
"Server": databaseSettings.Server,
"Username": databaseSettings.Username,
"Password": databaseSettings.Password,
"Dat... | go | func (*DatabaseSettings) ReadSettings(c context.Context) (map[string]string, error) {
databaseSettings, err := GetUncached(c)
if err != nil {
return nil, err
}
return map[string]string{
"Server": databaseSettings.Server,
"Username": databaseSettings.Username,
"Password": databaseSettings.Password,
"Dat... | [
"func",
"(",
"*",
"DatabaseSettings",
")",
"ReadSettings",
"(",
"c",
"context",
".",
"Context",
")",
"(",
"map",
"[",
"string",
"]",
"string",
",",
"error",
")",
"{",
"databaseSettings",
",",
"err",
":=",
"GetUncached",
"(",
"c",
")",
"\n",
"if",
"err"... | // ReadSettings returns settings for display. | [
"ReadSettings",
"returns",
"settings",
"for",
"display",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/machine-db/appengine/settings/settings.go#L123-L135 |
131,215 | luci/luci-go | machine-db/appengine/settings/settings.go | WriteSettings | func (*DatabaseSettings) WriteSettings(c context.Context, values map[string]string, who, why string) error {
databaseSettings := &DatabaseSettings{
Server: values["Server"],
Username: values["Username"],
Password: values["Password"],
Database: values["Database"],
}
return settings.SetIfChanged(c, settings... | go | func (*DatabaseSettings) WriteSettings(c context.Context, values map[string]string, who, why string) error {
databaseSettings := &DatabaseSettings{
Server: values["Server"],
Username: values["Username"],
Password: values["Password"],
Database: values["Database"],
}
return settings.SetIfChanged(c, settings... | [
"func",
"(",
"*",
"DatabaseSettings",
")",
"WriteSettings",
"(",
"c",
"context",
".",
"Context",
",",
"values",
"map",
"[",
"string",
"]",
"string",
",",
"who",
",",
"why",
"string",
")",
"error",
"{",
"databaseSettings",
":=",
"&",
"DatabaseSettings",
"{"... | // WriteSettings commits any changes to the settings. | [
"WriteSettings",
"commits",
"any",
"changes",
"to",
"the",
"settings",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/machine-db/appengine/settings/settings.go#L138-L147 |
131,216 | luci/luci-go | gce/cmd/agent/swarming.go | fetch | func (s *SwarmingClient) fetch(c context.Context, path, user string) error {
botCode := s.server + "/bot_code"
logging.Infof(c, "downloading: %s", botCode)
rsp, err := s.Get(botCode)
if err != nil {
return errors.Annotate(err, "failed to fetch bot code").Err()
}
defer rsp.Body.Close()
if rsp.StatusCode != http... | go | func (s *SwarmingClient) fetch(c context.Context, path, user string) error {
botCode := s.server + "/bot_code"
logging.Infof(c, "downloading: %s", botCode)
rsp, err := s.Get(botCode)
if err != nil {
return errors.Annotate(err, "failed to fetch bot code").Err()
}
defer rsp.Body.Close()
if rsp.StatusCode != http... | [
"func",
"(",
"s",
"*",
"SwarmingClient",
")",
"fetch",
"(",
"c",
"context",
".",
"Context",
",",
"path",
",",
"user",
"string",
")",
"error",
"{",
"botCode",
":=",
"s",
".",
"server",
"+",
"\"",
"\"",
"\n",
"logging",
".",
"Infof",
"(",
"c",
",",
... | // fetch fetches the Swarming bot code. | [
"fetch",
"fetches",
"the",
"Swarming",
"bot",
"code",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/gce/cmd/agent/swarming.go#L52-L80 |
131,217 | luci/luci-go | gce/cmd/agent/swarming.go | Configure | func (s *SwarmingClient) Configure(c context.Context, dir, user string) error {
// 0755 allows the directory structure to be read and listed by all users.
// Useful when SSHing fo the instance.
if err := os.MkdirAll(dir, 0755); err != nil {
return errors.Annotate(err, "failed to create: %s", dir).Err()
}
if err ... | go | func (s *SwarmingClient) Configure(c context.Context, dir, user string) error {
// 0755 allows the directory structure to be read and listed by all users.
// Useful when SSHing fo the instance.
if err := os.MkdirAll(dir, 0755); err != nil {
return errors.Annotate(err, "failed to create: %s", dir).Err()
}
if err ... | [
"func",
"(",
"s",
"*",
"SwarmingClient",
")",
"Configure",
"(",
"c",
"context",
".",
"Context",
",",
"dir",
",",
"user",
"string",
")",
"error",
"{",
"// 0755 allows the directory structure to be read and listed by all users.",
"// Useful when SSHing fo the instance.",
"i... | // Configure fetches the Swarming bot code and configures it to run on startup. | [
"Configure",
"fetches",
"the",
"Swarming",
"bot",
"code",
"and",
"configures",
"it",
"to",
"run",
"on",
"startup",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/gce/cmd/agent/swarming.go#L83-L105 |
131,218 | luci/luci-go | machine-db/appengine/config/config.go | Import | func Import(c context.Context) error {
configSet := cfgclient.CurrentServiceConfigSet(c)
if err := importOSes(c, configSet); err != nil {
return errors.Annotate(err, "failed to import operating systems").Err()
}
platformIds, err := importPlatforms(c, configSet)
if err != nil {
return errors.Annotate(err, "fail... | go | func Import(c context.Context) error {
configSet := cfgclient.CurrentServiceConfigSet(c)
if err := importOSes(c, configSet); err != nil {
return errors.Annotate(err, "failed to import operating systems").Err()
}
platformIds, err := importPlatforms(c, configSet)
if err != nil {
return errors.Annotate(err, "fail... | [
"func",
"Import",
"(",
"c",
"context",
".",
"Context",
")",
"error",
"{",
"configSet",
":=",
"cfgclient",
".",
"CurrentServiceConfigSet",
"(",
"c",
")",
"\n",
"if",
"err",
":=",
"importOSes",
"(",
"c",
",",
"configSet",
")",
";",
"err",
"!=",
"nil",
"{... | // Import fetches, validates, and applies configs from the config service. | [
"Import",
"fetches",
"validates",
"and",
"applies",
"configs",
"from",
"the",
"config",
"service",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/machine-db/appengine/config/config.go#L41-L57 |
131,219 | luci/luci-go | machine-db/appengine/config/config.go | InstallHandlers | func InstallHandlers(r *router.Router, middleware router.MiddlewareChain) {
cronMiddleware := middleware.Extend(gaemiddleware.RequireCron)
r.GET("/internal/cron/import-config", cronMiddleware, importHandler)
} | go | func InstallHandlers(r *router.Router, middleware router.MiddlewareChain) {
cronMiddleware := middleware.Extend(gaemiddleware.RequireCron)
r.GET("/internal/cron/import-config", cronMiddleware, importHandler)
} | [
"func",
"InstallHandlers",
"(",
"r",
"*",
"router",
".",
"Router",
",",
"middleware",
"router",
".",
"MiddlewareChain",
")",
"{",
"cronMiddleware",
":=",
"middleware",
".",
"Extend",
"(",
"gaemiddleware",
".",
"RequireCron",
")",
"\n",
"r",
".",
"GET",
"(",
... | // InstallHandlers installs handlers for HTTP requests pertaining to configs. | [
"InstallHandlers",
"installs",
"handlers",
"for",
"HTTP",
"requests",
"pertaining",
"to",
"configs",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/machine-db/appengine/config/config.go#L60-L63 |
131,220 | luci/luci-go | logdog/appengine/cmd/coordinator/default/dummy_services.go | dummyServicePrelude | func dummyServicePrelude(c context.Context, methodName string, req proto.Message) (context.Context, error) {
return nil, grpcutil.Errf(codes.FailedPrecondition,
"This pRPC endpoint cannot be handled by the default service. It should have been routed to the "+
"appropriate service via dispatch. This error indicate... | go | func dummyServicePrelude(c context.Context, methodName string, req proto.Message) (context.Context, error) {
return nil, grpcutil.Errf(codes.FailedPrecondition,
"This pRPC endpoint cannot be handled by the default service. It should have been routed to the "+
"appropriate service via dispatch. This error indicate... | [
"func",
"dummyServicePrelude",
"(",
"c",
"context",
".",
"Context",
",",
"methodName",
"string",
",",
"req",
"proto",
".",
"Message",
")",
"(",
"context",
".",
"Context",
",",
"error",
")",
"{",
"return",
"nil",
",",
"grpcutil",
".",
"Errf",
"(",
"codes"... | // dummyServicePrelude is a service decorator prelude that always returns
// "codes.FailedPrecondition".
// This is implemented this way so that the decorated service can be made
// discoverable without actually hosting an implementation of that service.
// The actual implementation is hosted in a separate GAE service,... | [
"dummyServicePrelude",
"is",
"a",
"service",
"decorator",
"prelude",
"that",
"always",
"returns",
"codes",
".",
"FailedPrecondition",
".",
"This",
"is",
"implemented",
"this",
"way",
"so",
"that",
"the",
"decorated",
"service",
"can",
"be",
"made",
"discoverable",... | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/logdog/appengine/cmd/coordinator/default/dummy_services.go#L55-L60 |
131,221 | luci/luci-go | mp/cmd/mpagent/main.go | configureAutoMount | func (agent *Agent) configureAutoMount(ctx context.Context, disk string) error {
return agent.strategy.configureAutoMount(ctx, disk)
} | go | func (agent *Agent) configureAutoMount(ctx context.Context, disk string) error {
return agent.strategy.configureAutoMount(ctx, disk)
} | [
"func",
"(",
"agent",
"*",
"Agent",
")",
"configureAutoMount",
"(",
"ctx",
"context",
".",
"Context",
",",
"disk",
"string",
")",
"error",
"{",
"return",
"agent",
".",
"strategy",
".",
"configureAutoMount",
"(",
"ctx",
",",
"disk",
")",
"\n",
"}"
] | // configureAutoMount mounts the specified disk and configures mount on startup.
//
// Assumes the disk is already formatted correctly. | [
"configureAutoMount",
"mounts",
"the",
"specified",
"disk",
"and",
"configures",
"mount",
"on",
"startup",
".",
"Assumes",
"the",
"disk",
"is",
"already",
"formatted",
"correctly",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/mp/cmd/mpagent/main.go#L91-L93 |
131,222 | luci/luci-go | mp/cmd/mpagent/main.go | configureLogging | func (agent *Agent) configureLogging(ctx context.Context) (context.Context, error) {
log := fmt.Sprintf("agent.%s.log", strconv.FormatInt(time.Now().Unix(), 10))
if err := os.MkdirAll(agent.logsDir, 0755); err != nil {
return ctx, err
}
// TODO(smut): Capture logging emitted before configureLogging was called an... | go | func (agent *Agent) configureLogging(ctx context.Context) (context.Context, error) {
log := fmt.Sprintf("agent.%s.log", strconv.FormatInt(time.Now().Unix(), 10))
if err := os.MkdirAll(agent.logsDir, 0755); err != nil {
return ctx, err
}
// TODO(smut): Capture logging emitted before configureLogging was called an... | [
"func",
"(",
"agent",
"*",
"Agent",
")",
"configureLogging",
"(",
"ctx",
"context",
".",
"Context",
")",
"(",
"context",
".",
"Context",
",",
"error",
")",
"{",
"log",
":=",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"strconv",
".",
"FormatInt",
"(... | // configureLogging configures logging to a file, in addition to any other logging.
//
// Returns modified context.Context. | [
"configureLogging",
"configures",
"logging",
"to",
"a",
"file",
"in",
"addition",
"to",
"any",
"other",
"logging",
".",
"Returns",
"modified",
"context",
".",
"Context",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/mp/cmd/mpagent/main.go#L98-L112 |
131,223 | luci/luci-go | mp/cmd/mpagent/main.go | configureMonitoring | func (agent *Agent) configureMonitoring(ctx context.Context) error {
flags := tsmon.NewFlags()
flags.Flush = "manual"
flags.Target.AutoGenHostname = true
flags.Target.TargetType = "task"
flags.Target.TaskJobName = "default"
flags.Target.TaskServiceName = "mpagent"
return tsmon.InitializeFromFlags(ctx, &flags)
} | go | func (agent *Agent) configureMonitoring(ctx context.Context) error {
flags := tsmon.NewFlags()
flags.Flush = "manual"
flags.Target.AutoGenHostname = true
flags.Target.TargetType = "task"
flags.Target.TaskJobName = "default"
flags.Target.TaskServiceName = "mpagent"
return tsmon.InitializeFromFlags(ctx, &flags)
} | [
"func",
"(",
"agent",
"*",
"Agent",
")",
"configureMonitoring",
"(",
"ctx",
"context",
".",
"Context",
")",
"error",
"{",
"flags",
":=",
"tsmon",
".",
"NewFlags",
"(",
")",
"\n",
"flags",
".",
"Flush",
"=",
"\"",
"\"",
"\n",
"flags",
".",
"Target",
"... | // configureMonitoring configures tsmon monitoring. | [
"configureMonitoring",
"configures",
"tsmon",
"monitoring",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/mp/cmd/mpagent/main.go#L115-L123 |
131,224 | luci/luci-go | mp/cmd/mpagent/main.go | configureSwarmingAutoStart | func (agent *Agent) configureSwarmingAutoStart(ctx context.Context, server string) error {
if err := os.MkdirAll(agent.swarmingBotDir, 0755); err != nil {
return err
}
if err := agent.strategy.chown(ctx, agent.swarmingUser, agent.swarmingBotDir); err != nil {
return err
}
path := filepath.Join(agent.swarmingB... | go | func (agent *Agent) configureSwarmingAutoStart(ctx context.Context, server string) error {
if err := os.MkdirAll(agent.swarmingBotDir, 0755); err != nil {
return err
}
if err := agent.strategy.chown(ctx, agent.swarmingUser, agent.swarmingBotDir); err != nil {
return err
}
path := filepath.Join(agent.swarmingB... | [
"func",
"(",
"agent",
"*",
"Agent",
")",
"configureSwarmingAutoStart",
"(",
"ctx",
"context",
".",
"Context",
",",
"server",
"string",
")",
"error",
"{",
"if",
"err",
":=",
"os",
".",
"MkdirAll",
"(",
"agent",
".",
"swarmingBotDir",
",",
"0755",
")",
";"... | // configureSwarmingAutoStart configures auto-connect to the given Swarming server on reboot. | [
"configureSwarmingAutoStart",
"configures",
"auto",
"-",
"connect",
"to",
"the",
"given",
"Swarming",
"server",
"on",
"reboot",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/mp/cmd/mpagent/main.go#L126-L164 |
131,225 | luci/luci-go | mp/cmd/mpagent/main.go | downloadSwarmingBotCode | func (agent *Agent) downloadSwarmingBotCode(ctx context.Context, server, path string) error {
_, err := os.Stat(path)
if err == nil {
logging.Infof(ctx, "Already installed: %s.", path)
return nil
}
logging.Infof(ctx, "Downloading: %s.", path)
response, err := agent.client.Get(server + "/bot_code")
if err != ... | go | func (agent *Agent) downloadSwarmingBotCode(ctx context.Context, server, path string) error {
_, err := os.Stat(path)
if err == nil {
logging.Infof(ctx, "Already installed: %s.", path)
return nil
}
logging.Infof(ctx, "Downloading: %s.", path)
response, err := agent.client.Get(server + "/bot_code")
if err != ... | [
"func",
"(",
"agent",
"*",
"Agent",
")",
"downloadSwarmingBotCode",
"(",
"ctx",
"context",
".",
"Context",
",",
"server",
",",
"path",
"string",
")",
"error",
"{",
"_",
",",
"err",
":=",
"os",
".",
"Stat",
"(",
"path",
")",
"\n",
"if",
"err",
"==",
... | // downloadSwarminBotCode downloads the Swarming bot code from the given server. | [
"downloadSwarminBotCode",
"downloads",
"the",
"Swarming",
"bot",
"code",
"from",
"the",
"given",
"server",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/mp/cmd/mpagent/main.go#L167-L194 |
131,226 | luci/luci-go | mp/cmd/mpagent/main.go | initialize | func (agent *Agent) initialize(ctx context.Context) (context.Context, error) {
ctx, err := agent.configureLogging(ctx)
if err != nil {
return ctx, err
}
if err = agent.configureMonitoring(ctx); err != nil {
return ctx, err
}
// TODO(smut): Remove fallback on metadata server.
if agent.server == "" {
agent.... | go | func (agent *Agent) initialize(ctx context.Context) (context.Context, error) {
ctx, err := agent.configureLogging(ctx)
if err != nil {
return ctx, err
}
if err = agent.configureMonitoring(ctx); err != nil {
return ctx, err
}
// TODO(smut): Remove fallback on metadata server.
if agent.server == "" {
agent.... | [
"func",
"(",
"agent",
"*",
"Agent",
")",
"initialize",
"(",
"ctx",
"context",
".",
"Context",
")",
"(",
"context",
".",
"Context",
",",
"error",
")",
"{",
"ctx",
",",
"err",
":=",
"agent",
".",
"configureLogging",
"(",
"ctx",
")",
"\n",
"if",
"err",
... | // initialize initializes the agent. | [
"initialize",
"initializes",
"the",
"agent",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/mp/cmd/mpagent/main.go#L197-L238 |
131,227 | luci/luci-go | mp/cmd/mpagent/main.go | install | func (agent *Agent) install(ctx context.Context) error {
exe, err := os.Executable()
if err != nil {
return err
}
substitutions := map[string]string{
"Agent": exe,
"Server": agent.server,
"ServiceAccount": agent.serviceAccount,
"User": agent.swarmingUser,
}
content, err := su... | go | func (agent *Agent) install(ctx context.Context) error {
exe, err := os.Executable()
if err != nil {
return err
}
substitutions := map[string]string{
"Agent": exe,
"Server": agent.server,
"ServiceAccount": agent.serviceAccount,
"User": agent.swarmingUser,
}
content, err := su... | [
"func",
"(",
"agent",
"*",
"Agent",
")",
"install",
"(",
"ctx",
"context",
".",
"Context",
")",
"error",
"{",
"exe",
",",
"err",
":=",
"os",
".",
"Executable",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n\n",
"su... | // install installs the agent, starts it, and configures auto-start on reboot. | [
"install",
"installs",
"the",
"agent",
"starts",
"it",
"and",
"configures",
"auto",
"-",
"start",
"on",
"reboot",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/mp/cmd/mpagent/main.go#L241-L283 |
131,228 | luci/luci-go | mp/cmd/mpagent/main.go | poll | func (agent *Agent) poll(ctx context.Context) error {
// Metadata tells us which Machine Provider instance to talk to
// and how to authenticate.
for {
logging.Infof(ctx, "Polling.")
instruction, err := agent.mp.poll(ctx, agent.hostname, "GCE")
if err != nil {
// Log error but don't return. Keep polling.
... | go | func (agent *Agent) poll(ctx context.Context) error {
// Metadata tells us which Machine Provider instance to talk to
// and how to authenticate.
for {
logging.Infof(ctx, "Polling.")
instruction, err := agent.mp.poll(ctx, agent.hostname, "GCE")
if err != nil {
// Log error but don't return. Keep polling.
... | [
"func",
"(",
"agent",
"*",
"Agent",
")",
"poll",
"(",
"ctx",
"context",
".",
"Context",
")",
"error",
"{",
"// Metadata tells us which Machine Provider instance to talk to",
"// and how to authenticate.",
"for",
"{",
"logging",
".",
"Infof",
"(",
"ctx",
",",
"\"",
... | // poll polls for instructions from Machine Provider.
//
// Does not return except in case of error. | [
"poll",
"polls",
"for",
"instructions",
"from",
"Machine",
"Provider",
".",
"Does",
"not",
"return",
"except",
"in",
"case",
"of",
"error",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/mp/cmd/mpagent/main.go#L288-L305 |
131,229 | luci/luci-go | mp/cmd/mpagent/main.go | handle | func (agent *Agent) handle(ctx context.Context, instruction *machine.ComponentsMachineProviderRpcMessagesPollResponse) error {
if instruction.State == "" || instruction.State == "EXECUTED" {
return nil
}
// The only type of instruction that exists is to connect to Swarming.
if instruction.Instruction == nil || i... | go | func (agent *Agent) handle(ctx context.Context, instruction *machine.ComponentsMachineProviderRpcMessagesPollResponse) error {
if instruction.State == "" || instruction.State == "EXECUTED" {
return nil
}
// The only type of instruction that exists is to connect to Swarming.
if instruction.Instruction == nil || i... | [
"func",
"(",
"agent",
"*",
"Agent",
")",
"handle",
"(",
"ctx",
"context",
".",
"Context",
",",
"instruction",
"*",
"machine",
".",
"ComponentsMachineProviderRpcMessagesPollResponse",
")",
"error",
"{",
"if",
"instruction",
".",
"State",
"==",
"\"",
"\"",
"||",... | // handle handles a received instruction. | [
"handle",
"handles",
"a",
"received",
"instruction",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/mp/cmd/mpagent/main.go#L308-L330 |
131,230 | luci/luci-go | mp/cmd/mpagent/main.go | reboot | func (agent *Agent) reboot(ctx context.Context) error {
logging.Infof(ctx, "Rebooting.")
tsmon.Flush(ctx)
for {
if err := agent.strategy.reboot(ctx); err != nil {
return err
}
time.Sleep(60 * time.Second)
logging.Infof(ctx, "Waiting to reboot...")
}
} | go | func (agent *Agent) reboot(ctx context.Context) error {
logging.Infof(ctx, "Rebooting.")
tsmon.Flush(ctx)
for {
if err := agent.strategy.reboot(ctx); err != nil {
return err
}
time.Sleep(60 * time.Second)
logging.Infof(ctx, "Waiting to reboot...")
}
} | [
"func",
"(",
"agent",
"*",
"Agent",
")",
"reboot",
"(",
"ctx",
"context",
".",
"Context",
")",
"error",
"{",
"logging",
".",
"Infof",
"(",
"ctx",
",",
"\"",
"\"",
")",
"\n",
"tsmon",
".",
"Flush",
"(",
"ctx",
")",
"\n",
"for",
"{",
"if",
"err",
... | // reboot attempts to reboot the machine.
//
// Does not return except in case of error. | [
"reboot",
"attempts",
"to",
"reboot",
"the",
"machine",
".",
"Does",
"not",
"return",
"except",
"in",
"case",
"of",
"error",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/mp/cmd/mpagent/main.go#L335-L345 |
131,231 | luci/luci-go | common/isolated/algo.go | GetHash | func GetHash(namespace string) crypto.Hash {
if strings.HasPrefix(namespace, "sha256-") {
return crypto.SHA256
}
if strings.HasPrefix(namespace, "sha512-") {
return crypto.SHA512
}
return crypto.SHA1
} | go | func GetHash(namespace string) crypto.Hash {
if strings.HasPrefix(namespace, "sha256-") {
return crypto.SHA256
}
if strings.HasPrefix(namespace, "sha512-") {
return crypto.SHA512
}
return crypto.SHA1
} | [
"func",
"GetHash",
"(",
"namespace",
"string",
")",
"crypto",
".",
"Hash",
"{",
"if",
"strings",
".",
"HasPrefix",
"(",
"namespace",
",",
"\"",
"\"",
")",
"{",
"return",
"crypto",
".",
"SHA256",
"\n",
"}",
"\n",
"if",
"strings",
".",
"HasPrefix",
"(",
... | // GetHash returns a fresh instance of the hashing algorithm to be used to
// calculate the HexDigest.
//
// A prefix of "sha256-" and "sha512-" respectively returns a sha-256 and
// sha-512 instance. Otherwise a sha-1 instance is returned. | [
"GetHash",
"returns",
"a",
"fresh",
"instance",
"of",
"the",
"hashing",
"algorithm",
"to",
"be",
"used",
"to",
"calculate",
"the",
"HexDigest",
".",
"A",
"prefix",
"of",
"sha256",
"-",
"and",
"sha512",
"-",
"respectively",
"returns",
"a",
"sha",
"-",
"256"... | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/common/isolated/algo.go#L32-L40 |
131,232 | luci/luci-go | common/isolated/algo.go | Validate | func (d HexDigest) Validate(h crypto.Hash) bool {
if l := h.Size() * 2; len(d) != l {
return false
}
for _, c := range d {
if ('0' <= c && c <= '9') || ('a' <= c && c <= 'f') {
continue
}
return false
}
return true
} | go | func (d HexDigest) Validate(h crypto.Hash) bool {
if l := h.Size() * 2; len(d) != l {
return false
}
for _, c := range d {
if ('0' <= c && c <= '9') || ('a' <= c && c <= 'f') {
continue
}
return false
}
return true
} | [
"func",
"(",
"d",
"HexDigest",
")",
"Validate",
"(",
"h",
"crypto",
".",
"Hash",
")",
"bool",
"{",
"if",
"l",
":=",
"h",
".",
"Size",
"(",
")",
"*",
"2",
";",
"len",
"(",
"d",
")",
"!=",
"l",
"{",
"return",
"false",
"\n",
"}",
"\n",
"for",
... | // Validate returns true if the hash is valid. | [
"Validate",
"returns",
"true",
"if",
"the",
"hash",
"is",
"valid",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/common/isolated/algo.go#L72-L83 |
131,233 | luci/luci-go | server/portal/page.go | ReadSettings | func (BasePage) ReadSettings(c context.Context) (map[string]string, error) {
return nil, nil
} | go | func (BasePage) ReadSettings(c context.Context) (map[string]string, error) {
return nil, nil
} | [
"func",
"(",
"BasePage",
")",
"ReadSettings",
"(",
"c",
"context",
".",
"Context",
")",
"(",
"map",
"[",
"string",
"]",
"string",
",",
"error",
")",
"{",
"return",
"nil",
",",
"nil",
"\n",
"}"
] | // ReadSettings returns a map "field ID => field value to display". | [
"ReadSettings",
"returns",
"a",
"map",
"field",
"ID",
"=",
">",
"field",
"value",
"to",
"display",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/server/portal/page.go#L126-L128 |
131,234 | luci/luci-go | server/portal/page.go | WriteSettings | func (BasePage) WriteSettings(c context.Context, values map[string]string, who, why string) error {
return errors.New("not implemented")
} | go | func (BasePage) WriteSettings(c context.Context, values map[string]string, who, why string) error {
return errors.New("not implemented")
} | [
"func",
"(",
"BasePage",
")",
"WriteSettings",
"(",
"c",
"context",
".",
"Context",
",",
"values",
"map",
"[",
"string",
"]",
"string",
",",
"who",
",",
"why",
"string",
")",
"error",
"{",
"return",
"errors",
".",
"New",
"(",
"\"",
"\"",
")",
"\n",
... | // WriteSettings saves settings described as a map "field ID => field value". | [
"WriteSettings",
"saves",
"settings",
"described",
"as",
"a",
"map",
"field",
"ID",
"=",
">",
"field",
"value",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/server/portal/page.go#L131-L133 |
131,235 | luci/luci-go | config/server/cfgclient/naming.go | CurrentServiceConfigSet | func CurrentServiceConfigSet(c context.Context) config.Set {
return config.ServiceSet(CurrentServiceName(c))
} | go | func CurrentServiceConfigSet(c context.Context) config.Set {
return config.ServiceSet(CurrentServiceName(c))
} | [
"func",
"CurrentServiceConfigSet",
"(",
"c",
"context",
".",
"Context",
")",
"config",
".",
"Set",
"{",
"return",
"config",
".",
"ServiceSet",
"(",
"CurrentServiceName",
"(",
"c",
")",
")",
"\n",
"}"
] | // CurrentServiceConfigSet returns the config set for the current AppEngine
// service, based on its current service name. | [
"CurrentServiceConfigSet",
"returns",
"the",
"config",
"set",
"for",
"the",
"current",
"AppEngine",
"service",
"based",
"on",
"its",
"current",
"service",
"name",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/config/server/cfgclient/naming.go#L33-L35 |
131,236 | luci/luci-go | machine-db/client/cli/states.go | Run | func (c *GetStatesCmd) Run(app subcommands.Application, args []string, env subcommands.Env) int {
if c.prefix == "" {
if !c.f.tsv {
fmt.Println("State")
}
for _, state := range common.ValidStates() {
fmt.Println(state.Name())
}
return 0
}
state, err := common.GetState(c.prefix)
if err != nil {
ret... | go | func (c *GetStatesCmd) Run(app subcommands.Application, args []string, env subcommands.Env) int {
if c.prefix == "" {
if !c.f.tsv {
fmt.Println("State")
}
for _, state := range common.ValidStates() {
fmt.Println(state.Name())
}
return 0
}
state, err := common.GetState(c.prefix)
if err != nil {
ret... | [
"func",
"(",
"c",
"*",
"GetStatesCmd",
")",
"Run",
"(",
"app",
"subcommands",
".",
"Application",
",",
"args",
"[",
"]",
"string",
",",
"env",
"subcommands",
".",
"Env",
")",
"int",
"{",
"if",
"c",
".",
"prefix",
"==",
"\"",
"\"",
"{",
"if",
"!",
... | // Run runs the command to get state. | [
"Run",
"runs",
"the",
"command",
"to",
"get",
"state",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/machine-db/client/cli/states.go#L32-L51 |
131,237 | luci/luci-go | machine-db/client/cli/states.go | getStatesCmd | func getStatesCmd(params *Parameters) *subcommands.Command {
return &subcommands.Command{
UsageLine: "get-states [-prefix <prefix>]",
ShortDesc: "retrieves states",
LongDesc: "Retrieves the state matching the given prefix, or all states if prefix is omitted.\n\nExample:\ncrimson get-states",
CommandRun: func(... | go | func getStatesCmd(params *Parameters) *subcommands.Command {
return &subcommands.Command{
UsageLine: "get-states [-prefix <prefix>]",
ShortDesc: "retrieves states",
LongDesc: "Retrieves the state matching the given prefix, or all states if prefix is omitted.\n\nExample:\ncrimson get-states",
CommandRun: func(... | [
"func",
"getStatesCmd",
"(",
"params",
"*",
"Parameters",
")",
"*",
"subcommands",
".",
"Command",
"{",
"return",
"&",
"subcommands",
".",
"Command",
"{",
"UsageLine",
":",
"\"",
"\"",
",",
"ShortDesc",
":",
"\"",
"\"",
",",
"LongDesc",
":",
"\"",
"\\n",... | // getStatesCmd returns a command to get states. | [
"getStatesCmd",
"returns",
"a",
"command",
"to",
"get",
"states",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/machine-db/client/cli/states.go#L54-L66 |
131,238 | luci/luci-go | buildbucket/cli/ls.go | parseSearchRequests | func (r *lsRun) parseSearchRequests(ctx context.Context, args []string) ([]*pb.SearchBuildsRequest, error) {
baseReq, err := r.parseBaseRequest(ctx)
if err != nil {
return nil, err
}
if len(args) == 0 {
return []*pb.SearchBuildsRequest{baseReq}, nil
}
ret := make([]*pb.SearchBuildsRequest, len(args))
for i... | go | func (r *lsRun) parseSearchRequests(ctx context.Context, args []string) ([]*pb.SearchBuildsRequest, error) {
baseReq, err := r.parseBaseRequest(ctx)
if err != nil {
return nil, err
}
if len(args) == 0 {
return []*pb.SearchBuildsRequest{baseReq}, nil
}
ret := make([]*pb.SearchBuildsRequest, len(args))
for i... | [
"func",
"(",
"r",
"*",
"lsRun",
")",
"parseSearchRequests",
"(",
"ctx",
"context",
".",
"Context",
",",
"args",
"[",
"]",
"string",
")",
"(",
"[",
"]",
"*",
"pb",
".",
"SearchBuildsRequest",
",",
"error",
")",
"{",
"baseReq",
",",
"err",
":=",
"r",
... | // parseSearchRequests converts flags and arguments to search requests. | [
"parseSearchRequests",
"converts",
"flags",
"and",
"arguments",
"to",
"search",
"requests",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/buildbucket/cli/ls.go#L148-L167 |
131,239 | luci/luci-go | buildbucket/cli/ls.go | parseBaseRequest | func (r *lsRun) parseBaseRequest(ctx context.Context) (*pb.SearchBuildsRequest, error) {
ret := &pb.SearchBuildsRequest{
Predicate: &pb.BuildPredicate{
Tags: r.Tags(),
Status: r.status,
IncludeExperimental: r.includeExperimental,
},
PageSize: 100,
}
if r.limit > 0 && r.lim... | go | func (r *lsRun) parseBaseRequest(ctx context.Context) (*pb.SearchBuildsRequest, error) {
ret := &pb.SearchBuildsRequest{
Predicate: &pb.BuildPredicate{
Tags: r.Tags(),
Status: r.status,
IncludeExperimental: r.includeExperimental,
},
PageSize: 100,
}
if r.limit > 0 && r.lim... | [
"func",
"(",
"r",
"*",
"lsRun",
")",
"parseBaseRequest",
"(",
"ctx",
"context",
".",
"Context",
")",
"(",
"*",
"pb",
".",
"SearchBuildsRequest",
",",
"error",
")",
"{",
"ret",
":=",
"&",
"pb",
".",
"SearchBuildsRequest",
"{",
"Predicate",
":",
"&",
"pb... | // parseBaseRequest returns a base SearchBuildsRequest without builder filter. | [
"parseBaseRequest",
"returns",
"a",
"base",
"SearchBuildsRequest",
"without",
"builder",
"filter",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/buildbucket/cli/ls.go#L170-L198 |
131,240 | luci/luci-go | common/data/cmpbin/string.go | WriteString | func WriteString(buf io.ByteWriter, s string) (n int, err error) {
return WriteBytes(buf, []byte(s))
} | go | func WriteString(buf io.ByteWriter, s string) (n int, err error) {
return WriteBytes(buf, []byte(s))
} | [
"func",
"WriteString",
"(",
"buf",
"io",
".",
"ByteWriter",
",",
"s",
"string",
")",
"(",
"n",
"int",
",",
"err",
"error",
")",
"{",
"return",
"WriteBytes",
"(",
"buf",
",",
"[",
"]",
"byte",
"(",
"s",
")",
")",
"\n",
"}"
] | // WriteString writes an encoded string to buf, returning the number of bytes
// written, and any write error encountered. | [
"WriteString",
"writes",
"an",
"encoded",
"string",
"to",
"buf",
"returning",
"the",
"number",
"of",
"bytes",
"written",
"and",
"any",
"write",
"error",
"encountered",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/common/data/cmpbin/string.go#L35-L37 |
131,241 | luci/luci-go | common/data/cmpbin/string.go | ReadString | func ReadString(buf io.ByteReader) (ret string, n int, err error) {
b, n, err := ReadBytes(buf)
if err != nil {
return
}
ret = string(b)
return
} | go | func ReadString(buf io.ByteReader) (ret string, n int, err error) {
b, n, err := ReadBytes(buf)
if err != nil {
return
}
ret = string(b)
return
} | [
"func",
"ReadString",
"(",
"buf",
"io",
".",
"ByteReader",
")",
"(",
"ret",
"string",
",",
"n",
"int",
",",
"err",
"error",
")",
"{",
"b",
",",
"n",
",",
"err",
":=",
"ReadBytes",
"(",
"buf",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
... | // ReadString reads an encoded string from buf, returning the number of bytes
// read, and any read error encountered. | [
"ReadString",
"reads",
"an",
"encoded",
"string",
"from",
"buf",
"returning",
"the",
"number",
"of",
"bytes",
"read",
"and",
"any",
"read",
"error",
"encountered",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/common/data/cmpbin/string.go#L41-L48 |
131,242 | luci/luci-go | common/gcloud/gs/gs.go | NewProdClient | func NewProdClient(ctx context.Context, rt http.RoundTripper) (Client, error) {
c := prodClient{
Context: ctx,
rt: rt,
}
var err error
c.baseClient, err = c.newClient()
if err != nil {
return nil, err
}
return &c, nil
} | go | func NewProdClient(ctx context.Context, rt http.RoundTripper) (Client, error) {
c := prodClient{
Context: ctx,
rt: rt,
}
var err error
c.baseClient, err = c.newClient()
if err != nil {
return nil, err
}
return &c, nil
} | [
"func",
"NewProdClient",
"(",
"ctx",
"context",
".",
"Context",
",",
"rt",
"http",
".",
"RoundTripper",
")",
"(",
"Client",
",",
"error",
")",
"{",
"c",
":=",
"prodClient",
"{",
"Context",
":",
"ctx",
",",
"rt",
":",
"rt",
",",
"}",
"\n",
"var",
"e... | // NewProdClient creates a new Client instance that uses production Cloud
// Storage.
//
// The supplied RoundTripper will be used to make connections. If nil, the
// default HTTP client will be used. | [
"NewProdClient",
"creates",
"a",
"new",
"Client",
"instance",
"that",
"uses",
"production",
"Cloud",
"Storage",
".",
"The",
"supplied",
"RoundTripper",
"will",
"be",
"used",
"to",
"make",
"connections",
".",
"If",
"nil",
"the",
"default",
"HTTP",
"client",
"wi... | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/common/gcloud/gs/gs.go#L95-L106 |
131,243 | luci/luci-go | milo/frontend/ui/build_legacy.go | fixComponentDuration | func fixComponentDuration(c context.Context, comp *BuildComponent) Interval {
// Leaf nodes do not require fixing.
if len(comp.Children) == 0 {
return comp.ExecutionTime
}
// Set start and end times to be out of bounds.
// Each variable can have 3 states:
// 1. Undefined. In which case they're set to farFuture... | go | func fixComponentDuration(c context.Context, comp *BuildComponent) Interval {
// Leaf nodes do not require fixing.
if len(comp.Children) == 0 {
return comp.ExecutionTime
}
// Set start and end times to be out of bounds.
// Each variable can have 3 states:
// 1. Undefined. In which case they're set to farFuture... | [
"func",
"fixComponentDuration",
"(",
"c",
"context",
".",
"Context",
",",
"comp",
"*",
"BuildComponent",
")",
"Interval",
"{",
"// Leaf nodes do not require fixing.",
"if",
"len",
"(",
"comp",
".",
"Children",
")",
"==",
"0",
"{",
"return",
"comp",
".",
"Execu... | // fixComponentDuration makes all parent steps have the max duration of all
// of its children. | [
"fixComponentDuration",
"makes",
"all",
"parent",
"steps",
"have",
"the",
"max",
"duration",
"of",
"all",
"of",
"its",
"children",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/milo/frontend/ui/build_legacy.go#L123-L149 |
131,244 | luci/luci-go | milo/frontend/ui/build_legacy.go | BuildSummary | func (b *MiloBuildLegacy) BuildSummary() *BuildSummary {
if b == nil {
return nil
}
result := &BuildSummary{
Link: b.Summary.Label,
Status: b.Summary.Status,
PendingTime: b.Summary.PendingTime,
ExecutionTime: b.Summary.ExecutionTime,
Text: b.Summary.Text,
Blame: b.Bla... | go | func (b *MiloBuildLegacy) BuildSummary() *BuildSummary {
if b == nil {
return nil
}
result := &BuildSummary{
Link: b.Summary.Label,
Status: b.Summary.Status,
PendingTime: b.Summary.PendingTime,
ExecutionTime: b.Summary.ExecutionTime,
Text: b.Summary.Text,
Blame: b.Bla... | [
"func",
"(",
"b",
"*",
"MiloBuildLegacy",
")",
"BuildSummary",
"(",
")",
"*",
"BuildSummary",
"{",
"if",
"b",
"==",
"nil",
"{",
"return",
"nil",
"\n",
"}",
"\n",
"result",
":=",
"&",
"BuildSummary",
"{",
"Link",
":",
"b",
".",
"Summary",
".",
"Label"... | // BuildSummary returns the BuildSummary representation of the MiloBuildLegacy. This
// is the subset of fields that is interesting to the builder view. | [
"BuildSummary",
"returns",
"the",
"BuildSummary",
"representation",
"of",
"the",
"MiloBuildLegacy",
".",
"This",
"is",
"the",
"subset",
"of",
"fields",
"that",
"is",
"interesting",
"to",
"the",
"builder",
"view",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/milo/frontend/ui/build_legacy.go#L176-L192 |
131,245 | luci/luci-go | common/gcloud/iam/policy.go | GrantRole | func (p *Policy) GrantRole(role string, principals ...string) {
if len(principals) == 0 {
return
}
if p.Bindings == nil {
p.Bindings = make(PolicyBindings, 1)
}
members := p.Bindings[role]
if members == nil {
members = make(membersSet, len(principals))
p.Bindings[role] = members
}
for _, principal := ra... | go | func (p *Policy) GrantRole(role string, principals ...string) {
if len(principals) == 0 {
return
}
if p.Bindings == nil {
p.Bindings = make(PolicyBindings, 1)
}
members := p.Bindings[role]
if members == nil {
members = make(membersSet, len(principals))
p.Bindings[role] = members
}
for _, principal := ra... | [
"func",
"(",
"p",
"*",
"Policy",
")",
"GrantRole",
"(",
"role",
"string",
",",
"principals",
"...",
"string",
")",
"{",
"if",
"len",
"(",
"principals",
")",
"==",
"0",
"{",
"return",
"\n",
"}",
"\n",
"if",
"p",
".",
"Bindings",
"==",
"nil",
"{",
... | // GrantRole grants a role to the given set of principals. | [
"GrantRole",
"grants",
"a",
"role",
"to",
"the",
"given",
"set",
"of",
"principals",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/common/gcloud/iam/policy.go#L146-L161 |
131,246 | luci/luci-go | common/gcloud/iam/policy.go | RevokeRole | func (p *Policy) RevokeRole(role string, principals ...string) {
members := p.Bindings[role]
for _, principal := range principals {
delete(members, principal)
}
} | go | func (p *Policy) RevokeRole(role string, principals ...string) {
members := p.Bindings[role]
for _, principal := range principals {
delete(members, principal)
}
} | [
"func",
"(",
"p",
"*",
"Policy",
")",
"RevokeRole",
"(",
"role",
"string",
",",
"principals",
"...",
"string",
")",
"{",
"members",
":=",
"p",
".",
"Bindings",
"[",
"role",
"]",
"\n",
"for",
"_",
",",
"principal",
":=",
"range",
"principals",
"{",
"d... | // RevokeRole removes a role from the given set of principals. | [
"RevokeRole",
"removes",
"a",
"role",
"from",
"the",
"given",
"set",
"of",
"principals",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/common/gcloud/iam/policy.go#L164-L169 |
131,247 | luci/luci-go | server/auth/service/service.go | Acknowledge | func (n *Notification) Acknowledge(c context.Context) error {
if n.service != nil { // may be nil if Notification is generated in tests
return n.service.ackMessages(c, n.subscription, n.ackIDs)
}
return nil
} | go | func (n *Notification) Acknowledge(c context.Context) error {
if n.service != nil { // may be nil if Notification is generated in tests
return n.service.ackMessages(c, n.subscription, n.ackIDs)
}
return nil
} | [
"func",
"(",
"n",
"*",
"Notification",
")",
"Acknowledge",
"(",
"c",
"context",
".",
"Context",
")",
"error",
"{",
"if",
"n",
".",
"service",
"!=",
"nil",
"{",
"// may be nil if Notification is generated in tests",
"return",
"n",
".",
"service",
".",
"ackMessa... | // Acknowledge tells PubSub to stop redelivering this notification. | [
"Acknowledge",
"tells",
"PubSub",
"to",
"stop",
"redelivering",
"this",
"notification",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/server/auth/service/service.go#L56-L61 |
131,248 | luci/luci-go | server/auth/service/service.go | pubSubURL | func (s *AuthService) pubSubURL(path string) string {
if s.pubSubURLRoot != "" {
return s.pubSubURLRoot + path
}
return "https://pubsub.googleapis.com/v1/" + path
} | go | func (s *AuthService) pubSubURL(path string) string {
if s.pubSubURLRoot != "" {
return s.pubSubURLRoot + path
}
return "https://pubsub.googleapis.com/v1/" + path
} | [
"func",
"(",
"s",
"*",
"AuthService",
")",
"pubSubURL",
"(",
"path",
"string",
")",
"string",
"{",
"if",
"s",
".",
"pubSubURLRoot",
"!=",
"\"",
"\"",
"{",
"return",
"s",
".",
"pubSubURLRoot",
"+",
"path",
"\n",
"}",
"\n",
"return",
"\"",
"\"",
"+",
... | // pubSubURL returns full URL to pubsub API endpoint. | [
"pubSubURL",
"returns",
"full",
"URL",
"to",
"pubsub",
"API",
"endpoint",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/server/auth/service/service.go#L95-L100 |
131,249 | luci/luci-go | server/auth/service/service.go | DeleteSubscription | func (s *AuthService) DeleteSubscription(c context.Context, subscription string) error {
var reply struct {
Error struct {
Code int `json:"code"`
} `json:"error"`
}
req := internal.Request{
Method: "DELETE",
URL: s.pubSubURL(subscription),
Scopes: oauthScopes,
Out: &reply,
}
if err := req.Do(c... | go | func (s *AuthService) DeleteSubscription(c context.Context, subscription string) error {
var reply struct {
Error struct {
Code int `json:"code"`
} `json:"error"`
}
req := internal.Request{
Method: "DELETE",
URL: s.pubSubURL(subscription),
Scopes: oauthScopes,
Out: &reply,
}
if err := req.Do(c... | [
"func",
"(",
"s",
"*",
"AuthService",
")",
"DeleteSubscription",
"(",
"c",
"context",
".",
"Context",
",",
"subscription",
"string",
")",
"error",
"{",
"var",
"reply",
"struct",
"{",
"Error",
"struct",
"{",
"Code",
"int",
"`json:\"code\"`",
"\n",
"}",
"`js... | // DeleteSubscription removes PubSub subscription if it exists. | [
"DeleteSubscription",
"removes",
"PubSub",
"subscription",
"if",
"it",
"exists",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/server/auth/service/service.go#L189-L205 |
131,250 | luci/luci-go | server/auth/service/service.go | ackMessages | func (s *AuthService) ackMessages(c context.Context, subscription string, ackIDs []string) error {
if len(ackIDs) == 0 {
return nil
}
request := struct {
AckIDs []string `json:"ackIds"`
}{ackIDs}
req := internal.Request{
Method: "POST",
URL: s.pubSubURL(subscription + ":acknowledge"),
Scopes: oauthSco... | go | func (s *AuthService) ackMessages(c context.Context, subscription string, ackIDs []string) error {
if len(ackIDs) == 0 {
return nil
}
request := struct {
AckIDs []string `json:"ackIds"`
}{ackIDs}
req := internal.Request{
Method: "POST",
URL: s.pubSubURL(subscription + ":acknowledge"),
Scopes: oauthSco... | [
"func",
"(",
"s",
"*",
"AuthService",
")",
"ackMessages",
"(",
"c",
"context",
".",
"Context",
",",
"subscription",
"string",
",",
"ackIDs",
"[",
"]",
"string",
")",
"error",
"{",
"if",
"len",
"(",
"ackIDs",
")",
"==",
"0",
"{",
"return",
"nil",
"\n"... | // ackMessages acknowledges processing of pubsub messages. | [
"ackMessages",
"acknowledges",
"processing",
"of",
"pubsub",
"messages",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/server/auth/service/service.go#L351-L365 |
131,251 | luci/luci-go | server/auth/service/service.go | DeflateAuthDB | func DeflateAuthDB(msg *protocol.AuthDB) ([]byte, error) {
blob, err := proto.Marshal(msg)
if err != nil {
return nil, err
}
out := bytes.Buffer{}
writer := zlib.NewWriter(&out)
_, err1 := io.Copy(writer, bytes.NewReader(blob))
err2 := writer.Close()
if err1 != nil {
return nil, err1
}
if err2 != nil {
... | go | func DeflateAuthDB(msg *protocol.AuthDB) ([]byte, error) {
blob, err := proto.Marshal(msg)
if err != nil {
return nil, err
}
out := bytes.Buffer{}
writer := zlib.NewWriter(&out)
_, err1 := io.Copy(writer, bytes.NewReader(blob))
err2 := writer.Close()
if err1 != nil {
return nil, err1
}
if err2 != nil {
... | [
"func",
"DeflateAuthDB",
"(",
"msg",
"*",
"protocol",
".",
"AuthDB",
")",
"(",
"[",
"]",
"byte",
",",
"error",
")",
"{",
"blob",
",",
"err",
":=",
"proto",
".",
"Marshal",
"(",
"msg",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
","... | // DeflateAuthDB serializes AuthDB to byte buffer and compresses it with zlib. | [
"DeflateAuthDB",
"serializes",
"AuthDB",
"to",
"byte",
"buffer",
"and",
"compresses",
"it",
"with",
"zlib",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/server/auth/service/service.go#L472-L488 |
131,252 | luci/luci-go | server/auth/service/service.go | InflateAuthDB | func InflateAuthDB(blob []byte) (*protocol.AuthDB, error) {
reader, err := zlib.NewReader(bytes.NewReader(blob))
if err != nil {
return nil, err
}
defer reader.Close()
inflated := bytes.Buffer{}
if _, err := io.Copy(&inflated, reader); err != nil {
return nil, err
}
out := &protocol.AuthDB{}
if err := prot... | go | func InflateAuthDB(blob []byte) (*protocol.AuthDB, error) {
reader, err := zlib.NewReader(bytes.NewReader(blob))
if err != nil {
return nil, err
}
defer reader.Close()
inflated := bytes.Buffer{}
if _, err := io.Copy(&inflated, reader); err != nil {
return nil, err
}
out := &protocol.AuthDB{}
if err := prot... | [
"func",
"InflateAuthDB",
"(",
"blob",
"[",
"]",
"byte",
")",
"(",
"*",
"protocol",
".",
"AuthDB",
",",
"error",
")",
"{",
"reader",
",",
"err",
":=",
"zlib",
".",
"NewReader",
"(",
"bytes",
".",
"NewReader",
"(",
"blob",
")",
")",
"\n",
"if",
"err"... | // InflateAuthDB is reverse of DeflateAuthDB. It decompresses and deserializes
// AuthDB message. | [
"InflateAuthDB",
"is",
"reverse",
"of",
"DeflateAuthDB",
".",
"It",
"decompresses",
"and",
"deserializes",
"AuthDB",
"message",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/server/auth/service/service.go#L492-L507 |
131,253 | luci/luci-go | common/retry/exponential.go | Next | func (b *ExponentialBackoff) Next(ctx context.Context, err error) time.Duration {
// Get Limited base delay.
delay := b.Limited.Next(ctx, err)
if delay == Stop {
return Stop
}
// Bound our delay.
if b.MaxDelay > 0 && b.MaxDelay < delay {
delay = b.MaxDelay
} else {
// Calculate the next delay exponentiall... | go | func (b *ExponentialBackoff) Next(ctx context.Context, err error) time.Duration {
// Get Limited base delay.
delay := b.Limited.Next(ctx, err)
if delay == Stop {
return Stop
}
// Bound our delay.
if b.MaxDelay > 0 && b.MaxDelay < delay {
delay = b.MaxDelay
} else {
// Calculate the next delay exponentiall... | [
"func",
"(",
"b",
"*",
"ExponentialBackoff",
")",
"Next",
"(",
"ctx",
"context",
".",
"Context",
",",
"err",
"error",
")",
"time",
".",
"Duration",
"{",
"// Get Limited base delay.",
"delay",
":=",
"b",
".",
"Limited",
".",
"Next",
"(",
"ctx",
",",
"err"... | // Next implements Iterator. | [
"Next",
"implements",
"Iterator",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/common/retry/exponential.go#L35-L54 |
131,254 | luci/luci-go | common/logging/gkelogger/config.go | Use | func Use(c context.Context, out io.Writer) context.Context {
return logging.SetFactory(c, GetFactory(out))
} | go | func Use(c context.Context, out io.Writer) context.Context {
return logging.SetFactory(c, GetFactory(out))
} | [
"func",
"Use",
"(",
"c",
"context",
".",
"Context",
",",
"out",
"io",
".",
"Writer",
")",
"context",
".",
"Context",
"{",
"return",
"logging",
".",
"SetFactory",
"(",
"c",
",",
"GetFactory",
"(",
"out",
")",
")",
"\n",
"}"
] | // Use registers a JSON based logger as default logger of the context that
// emits line to out. | [
"Use",
"registers",
"a",
"JSON",
"based",
"logger",
"as",
"default",
"logger",
"of",
"the",
"context",
"that",
"emits",
"line",
"to",
"out",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/common/logging/gkelogger/config.go#L26-L28 |
131,255 | luci/luci-go | common/retry/retry.go | LogCallback | func LogCallback(c context.Context, opname string) Callback {
return func(err error, delay time.Duration) {
logging.Fields{
logging.ErrorKey: err,
"opname": opname,
"delay": delay,
}.Warningf(c, "operation failed transiently")
}
} | go | func LogCallback(c context.Context, opname string) Callback {
return func(err error, delay time.Duration) {
logging.Fields{
logging.ErrorKey: err,
"opname": opname,
"delay": delay,
}.Warningf(c, "operation failed transiently")
}
} | [
"func",
"LogCallback",
"(",
"c",
"context",
".",
"Context",
",",
"opname",
"string",
")",
"Callback",
"{",
"return",
"func",
"(",
"err",
"error",
",",
"delay",
"time",
".",
"Duration",
")",
"{",
"logging",
".",
"Fields",
"{",
"logging",
".",
"ErrorKey",
... | // LogCallback builds a Callback which logs a Warning with the opname, error
// and delay. | [
"LogCallback",
"builds",
"a",
"Callback",
"which",
"logs",
"a",
"Warning",
"with",
"the",
"opname",
"error",
"and",
"delay",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/common/retry/retry.go#L35-L43 |
131,256 | luci/luci-go | machine-db/appengine/model/switches.go | fetch | func (t *SwitchesTable) fetch(c context.Context) error {
db := database.Get(c)
rows, err := db.QueryContext(c, `
SELECT id, name, description, ports, state, rack_id
FROM switches
`)
if err != nil {
return errors.Annotate(err, "failed to select switches").Err()
}
defer rows.Close()
for rows.Next() {
s := ... | go | func (t *SwitchesTable) fetch(c context.Context) error {
db := database.Get(c)
rows, err := db.QueryContext(c, `
SELECT id, name, description, ports, state, rack_id
FROM switches
`)
if err != nil {
return errors.Annotate(err, "failed to select switches").Err()
}
defer rows.Close()
for rows.Next() {
s := ... | [
"func",
"(",
"t",
"*",
"SwitchesTable",
")",
"fetch",
"(",
"c",
"context",
".",
"Context",
")",
"error",
"{",
"db",
":=",
"database",
".",
"Get",
"(",
"c",
")",
"\n",
"rows",
",",
"err",
":=",
"db",
".",
"QueryContext",
"(",
"c",
",",
"`\n\t\tSELEC... | // fetch fetches the switches from the database. | [
"fetch",
"fetches",
"the",
"switches",
"from",
"the",
"database",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/machine-db/appengine/model/switches.go#L50-L68 |
131,257 | luci/luci-go | machine-db/appengine/model/switches.go | computeChanges | func (t *SwitchesTable) computeChanges(c context.Context, datacenters []*config.Datacenter) error {
cfgs := make(map[string]*Switch, len(datacenters))
for _, dc := range datacenters {
for _, rack := range dc.Rack {
for _, cfg := range rack.Switch {
id, ok := t.racks[rack.Name]
if !ok {
return errors... | go | func (t *SwitchesTable) computeChanges(c context.Context, datacenters []*config.Datacenter) error {
cfgs := make(map[string]*Switch, len(datacenters))
for _, dc := range datacenters {
for _, rack := range dc.Rack {
for _, cfg := range rack.Switch {
id, ok := t.racks[rack.Name]
if !ok {
return errors... | [
"func",
"(",
"t",
"*",
"SwitchesTable",
")",
"computeChanges",
"(",
"c",
"context",
".",
"Context",
",",
"datacenters",
"[",
"]",
"*",
"config",
".",
"Datacenter",
")",
"error",
"{",
"cfgs",
":=",
"make",
"(",
"map",
"[",
"string",
"]",
"*",
"Switch",
... | // computeChanges computes the changes that need to be made to the switches in the database. | [
"computeChanges",
"computes",
"the",
"changes",
"that",
"need",
"to",
"be",
"made",
"to",
"the",
"switches",
"in",
"the",
"database",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/machine-db/appengine/model/switches.go#L76-L126 |
131,258 | luci/luci-go | machine-db/appengine/model/switches.go | add | func (t *SwitchesTable) add(c context.Context) error {
// Avoid using the database connection to prepare unnecessary statements.
if len(t.additions) == 0 {
return nil
}
db := database.Get(c)
stmt, err := db.PrepareContext(c, `
INSERT INTO switches (name, description, ports, state, rack_id)
VALUES (?, ?, ?, ... | go | func (t *SwitchesTable) add(c context.Context) error {
// Avoid using the database connection to prepare unnecessary statements.
if len(t.additions) == 0 {
return nil
}
db := database.Get(c)
stmt, err := db.PrepareContext(c, `
INSERT INTO switches (name, description, ports, state, rack_id)
VALUES (?, ?, ?, ... | [
"func",
"(",
"t",
"*",
"SwitchesTable",
")",
"add",
"(",
"c",
"context",
".",
"Context",
")",
"error",
"{",
"// Avoid using the database connection to prepare unnecessary statements.",
"if",
"len",
"(",
"t",
".",
"additions",
")",
"==",
"0",
"{",
"return",
"nil"... | // add adds all switches pending addition to the database, clearing pending additions.
// No-op unless computeChanges was called first. Idempotent until computeChanges is called again. | [
"add",
"adds",
"all",
"switches",
"pending",
"addition",
"to",
"the",
"database",
"clearing",
"pending",
"additions",
".",
"No",
"-",
"op",
"unless",
"computeChanges",
"was",
"called",
"first",
".",
"Idempotent",
"until",
"computeChanges",
"is",
"called",
"again... | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/machine-db/appengine/model/switches.go#L130-L162 |
131,259 | luci/luci-go | machine-db/appengine/model/switches.go | remove | func (t *SwitchesTable) remove(c context.Context) error {
// Avoid using the database connection to prepare unnecessary statements.
if len(t.removals) == 0 {
return nil
}
db := database.Get(c)
stmt, err := db.PrepareContext(c, `
DELETE FROM switches
WHERE id = ?
`)
if err != nil {
return errors.Annotate... | go | func (t *SwitchesTable) remove(c context.Context) error {
// Avoid using the database connection to prepare unnecessary statements.
if len(t.removals) == 0 {
return nil
}
db := database.Get(c)
stmt, err := db.PrepareContext(c, `
DELETE FROM switches
WHERE id = ?
`)
if err != nil {
return errors.Annotate... | [
"func",
"(",
"t",
"*",
"SwitchesTable",
")",
"remove",
"(",
"c",
"context",
".",
"Context",
")",
"error",
"{",
"// Avoid using the database connection to prepare unnecessary statements.",
"if",
"len",
"(",
"t",
".",
"removals",
")",
"==",
"0",
"{",
"return",
"ni... | // remove removes all switches pending removal from the database, clearing pending removals.
// No-op unless computeChanges was called first. Idempotent until computeChanges is called again. | [
"remove",
"removes",
"all",
"switches",
"pending",
"removal",
"from",
"the",
"database",
"clearing",
"pending",
"removals",
".",
"No",
"-",
"op",
"unless",
"computeChanges",
"was",
"called",
"first",
".",
"Idempotent",
"until",
"computeChanges",
"is",
"called",
... | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/machine-db/appengine/model/switches.go#L166-L205 |
131,260 | luci/luci-go | machine-db/appengine/model/switches.go | update | func (t *SwitchesTable) update(c context.Context) error {
// Avoid using the database connection to prepare unnecessary statements.
if len(t.updates) == 0 {
return nil
}
db := database.Get(c)
stmt, err := db.PrepareContext(c, `
UPDATE switches
SET description = ?, ports = ?, state = ?, rack_id = ?
WHERE i... | go | func (t *SwitchesTable) update(c context.Context) error {
// Avoid using the database connection to prepare unnecessary statements.
if len(t.updates) == 0 {
return nil
}
db := database.Get(c)
stmt, err := db.PrepareContext(c, `
UPDATE switches
SET description = ?, ports = ?, state = ?, rack_id = ?
WHERE i... | [
"func",
"(",
"t",
"*",
"SwitchesTable",
")",
"update",
"(",
"c",
"context",
".",
"Context",
")",
"error",
"{",
"// Avoid using the database connection to prepare unnecessary statements.",
"if",
"len",
"(",
"t",
".",
"updates",
")",
"==",
"0",
"{",
"return",
"nil... | // update updates all switches pending update in the database, clearing pending updates.
// No-op unless computeChanges was called first. Idempotent until computeChanges is called again. | [
"update",
"updates",
"all",
"switches",
"pending",
"update",
"in",
"the",
"database",
"clearing",
"pending",
"updates",
".",
"No",
"-",
"op",
"unless",
"computeChanges",
"was",
"called",
"first",
".",
"Idempotent",
"until",
"computeChanges",
"is",
"called",
"aga... | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/machine-db/appengine/model/switches.go#L209-L249 |
131,261 | luci/luci-go | machine-db/appengine/model/switches.go | ids | func (t *SwitchesTable) ids(c context.Context) map[string]int64 {
switches := make(map[string]int64, len(t.current))
for _, s := range t.current {
switches[s.Name] = s.Id
}
return switches
} | go | func (t *SwitchesTable) ids(c context.Context) map[string]int64 {
switches := make(map[string]int64, len(t.current))
for _, s := range t.current {
switches[s.Name] = s.Id
}
return switches
} | [
"func",
"(",
"t",
"*",
"SwitchesTable",
")",
"ids",
"(",
"c",
"context",
".",
"Context",
")",
"map",
"[",
"string",
"]",
"int64",
"{",
"switches",
":=",
"make",
"(",
"map",
"[",
"string",
"]",
"int64",
",",
"len",
"(",
"t",
".",
"current",
")",
"... | // ids returns a map of switch names to IDs. | [
"ids",
"returns",
"a",
"map",
"of",
"switch",
"names",
"to",
"IDs",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/machine-db/appengine/model/switches.go#L252-L258 |
131,262 | luci/luci-go | machine-db/appengine/model/switches.go | EnsureSwitches | func EnsureSwitches(c context.Context, cfgs []*config.Datacenter, rackIds map[string]int64) error {
t := &SwitchesTable{}
t.racks = rackIds
if err := t.fetch(c); err != nil {
return errors.Annotate(err, "failed to fetch switches").Err()
}
if err := t.computeChanges(c, cfgs); err != nil {
return errors.Annotate... | go | func EnsureSwitches(c context.Context, cfgs []*config.Datacenter, rackIds map[string]int64) error {
t := &SwitchesTable{}
t.racks = rackIds
if err := t.fetch(c); err != nil {
return errors.Annotate(err, "failed to fetch switches").Err()
}
if err := t.computeChanges(c, cfgs); err != nil {
return errors.Annotate... | [
"func",
"EnsureSwitches",
"(",
"c",
"context",
".",
"Context",
",",
"cfgs",
"[",
"]",
"*",
"config",
".",
"Datacenter",
",",
"rackIds",
"map",
"[",
"string",
"]",
"int64",
")",
"error",
"{",
"t",
":=",
"&",
"SwitchesTable",
"{",
"}",
"\n",
"t",
".",
... | // EnsureSwitches ensures the database contains exactly the given switches. | [
"EnsureSwitches",
"ensures",
"the",
"database",
"contains",
"exactly",
"the",
"given",
"switches",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/machine-db/appengine/model/switches.go#L261-L280 |
131,263 | luci/luci-go | common/tsmon/distribution/distribution.go | New | func New(b *Bucketer) *Distribution {
if b == nil {
b = DefaultBucketer
}
return &Distribution{b: b, lastNonZeroBucket: -1}
} | go | func New(b *Bucketer) *Distribution {
if b == nil {
b = DefaultBucketer
}
return &Distribution{b: b, lastNonZeroBucket: -1}
} | [
"func",
"New",
"(",
"b",
"*",
"Bucketer",
")",
"*",
"Distribution",
"{",
"if",
"b",
"==",
"nil",
"{",
"b",
"=",
"DefaultBucketer",
"\n",
"}",
"\n",
"return",
"&",
"Distribution",
"{",
"b",
":",
"b",
",",
"lastNonZeroBucket",
":",
"-",
"1",
"}",
"\n... | // New creates a new distribution using the given bucketer. Passing a nil
// Bucketer will use DefaultBucketer. | [
"New",
"creates",
"a",
"new",
"distribution",
"using",
"the",
"given",
"bucketer",
".",
"Passing",
"a",
"nil",
"Bucketer",
"will",
"use",
"DefaultBucketer",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/common/tsmon/distribution/distribution.go#L32-L37 |
131,264 | luci/luci-go | common/tsmon/distribution/distribution.go | Add | func (d *Distribution) Add(sample float64) {
i := d.b.Bucket(sample)
if i >= len(d.buckets) {
d.buckets = append(d.buckets, make([]int64, i-len(d.buckets)+1)...)
}
d.buckets[i]++
d.sum += sample
d.count++
if i > d.lastNonZeroBucket {
d.lastNonZeroBucket = i
}
} | go | func (d *Distribution) Add(sample float64) {
i := d.b.Bucket(sample)
if i >= len(d.buckets) {
d.buckets = append(d.buckets, make([]int64, i-len(d.buckets)+1)...)
}
d.buckets[i]++
d.sum += sample
d.count++
if i > d.lastNonZeroBucket {
d.lastNonZeroBucket = i
}
} | [
"func",
"(",
"d",
"*",
"Distribution",
")",
"Add",
"(",
"sample",
"float64",
")",
"{",
"i",
":=",
"d",
".",
"b",
".",
"Bucket",
"(",
"sample",
")",
"\n",
"if",
"i",
">=",
"len",
"(",
"d",
".",
"buckets",
")",
"{",
"d",
".",
"buckets",
"=",
"a... | // Add adds the sample to the distribution and updates the statistics. | [
"Add",
"adds",
"the",
"sample",
"to",
"the",
"distribution",
"and",
"updates",
"the",
"statistics",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/common/tsmon/distribution/distribution.go#L40-L51 |
131,265 | luci/luci-go | common/logging/level.go | GetLevel | func GetLevel(c context.Context) Level {
if l, ok := c.Value(levelKey).(Level); ok {
return l
}
return DefaultLevel
} | go | func GetLevel(c context.Context) Level {
if l, ok := c.Value(levelKey).(Level); ok {
return l
}
return DefaultLevel
} | [
"func",
"GetLevel",
"(",
"c",
"context",
".",
"Context",
")",
"Level",
"{",
"if",
"l",
",",
"ok",
":=",
"c",
".",
"Value",
"(",
"levelKey",
")",
".",
"(",
"Level",
")",
";",
"ok",
"{",
"return",
"l",
"\n",
"}",
"\n",
"return",
"DefaultLevel",
"\n... | // GetLevel returns the Level for this context. It will return DefaultLevel if
// none is defined. | [
"GetLevel",
"returns",
"the",
"Level",
"for",
"this",
"context",
".",
"It",
"will",
"return",
"DefaultLevel",
"if",
"none",
"is",
"defined",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/common/logging/level.go#L84-L89 |
131,266 | luci/luci-go | logdog/api/logpb/utils.go | Validate | func (d *LogStreamDescriptor) Validate(prefix bool) error {
if d == nil {
return errors.New("descriptor is nil")
}
if prefix {
if err := types.StreamName(d.Prefix).Validate(); err != nil {
return fmt.Errorf("invalid prefix: %s", err)
}
}
if err := types.StreamName(d.Name).Validate(); err != nil {
retur... | go | func (d *LogStreamDescriptor) Validate(prefix bool) error {
if d == nil {
return errors.New("descriptor is nil")
}
if prefix {
if err := types.StreamName(d.Prefix).Validate(); err != nil {
return fmt.Errorf("invalid prefix: %s", err)
}
}
if err := types.StreamName(d.Name).Validate(); err != nil {
retur... | [
"func",
"(",
"d",
"*",
"LogStreamDescriptor",
")",
"Validate",
"(",
"prefix",
"bool",
")",
"error",
"{",
"if",
"d",
"==",
"nil",
"{",
"return",
"errors",
".",
"New",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n\n",
"if",
"prefix",
"{",
"if",
"err",
":=",
... | // Validate returns an error if the supplied LogStreamDescriptor is not complete
// and valid.
//
// If prefix is true, the Prefix field will be validated; otherwise, it will
// be ignored. This can be useful when attempting to validate a
// LogStreamDescriptor before the application-assigned Prefix is known. | [
"Validate",
"returns",
"an",
"error",
"if",
"the",
"supplied",
"LogStreamDescriptor",
"is",
"not",
"complete",
"and",
"valid",
".",
"If",
"prefix",
"is",
"true",
"the",
"Prefix",
"field",
"will",
"be",
"validated",
";",
"otherwise",
"it",
"will",
"be",
"igno... | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/logdog/api/logpb/utils.go#L36-L71 |
131,267 | luci/luci-go | logdog/api/logpb/utils.go | Equal | func (d *LogStreamDescriptor) Equal(o *LogStreamDescriptor) bool {
return reflect.DeepEqual(d, o)
} | go | func (d *LogStreamDescriptor) Equal(o *LogStreamDescriptor) bool {
return reflect.DeepEqual(d, o)
} | [
"func",
"(",
"d",
"*",
"LogStreamDescriptor",
")",
"Equal",
"(",
"o",
"*",
"LogStreamDescriptor",
")",
"bool",
"{",
"return",
"reflect",
".",
"DeepEqual",
"(",
"d",
",",
"o",
")",
"\n",
"}"
] | // Equal tests if two LogStreamDescriptor instances have the same data. | [
"Equal",
"tests",
"if",
"two",
"LogStreamDescriptor",
"instances",
"have",
"the",
"same",
"data",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/logdog/api/logpb/utils.go#L74-L76 |
131,268 | luci/luci-go | logdog/api/logpb/utils.go | Path | func (d *LogStreamDescriptor) Path() types.StreamPath {
return types.StreamName(d.Prefix).Join(types.StreamName(d.Name))
} | go | func (d *LogStreamDescriptor) Path() types.StreamPath {
return types.StreamName(d.Prefix).Join(types.StreamName(d.Name))
} | [
"func",
"(",
"d",
"*",
"LogStreamDescriptor",
")",
"Path",
"(",
")",
"types",
".",
"StreamPath",
"{",
"return",
"types",
".",
"StreamName",
"(",
"d",
".",
"Prefix",
")",
".",
"Join",
"(",
"types",
".",
"StreamName",
"(",
"d",
".",
"Name",
")",
")",
... | // Path returns a types.StreamPath constructed from the LogStreamDesciptor's
// Prefix and Name fields. | [
"Path",
"returns",
"a",
"types",
".",
"StreamPath",
"constructed",
"from",
"the",
"LogStreamDesciptor",
"s",
"Prefix",
"and",
"Name",
"fields",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/logdog/api/logpb/utils.go#L80-L82 |
131,269 | luci/luci-go | logdog/api/logpb/utils.go | Validate | func (e *LogEntry) Validate(d *LogStreamDescriptor) error {
if e == nil {
return errors.New("entry is nil")
}
// Check for content.
switch d.StreamType {
case StreamType_TEXT:
if t := e.GetText(); t == nil || len(t.Lines) == 0 {
return ErrNoContent
}
case StreamType_BINARY:
if b := e.GetBinary(); b =... | go | func (e *LogEntry) Validate(d *LogStreamDescriptor) error {
if e == nil {
return errors.New("entry is nil")
}
// Check for content.
switch d.StreamType {
case StreamType_TEXT:
if t := e.GetText(); t == nil || len(t.Lines) == 0 {
return ErrNoContent
}
case StreamType_BINARY:
if b := e.GetBinary(); b =... | [
"func",
"(",
"e",
"*",
"LogEntry",
")",
"Validate",
"(",
"d",
"*",
"LogStreamDescriptor",
")",
"error",
"{",
"if",
"e",
"==",
"nil",
"{",
"return",
"errors",
".",
"New",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n\n",
"// Check for content.",
"switch",
"d",
... | // Validate checks a supplied LogEntry against its LogStreamDescriptor for
// validity, returning an error if it is not valid.
//
// If the LogEntry is otherwise valid, but has no content, ErrNoContent will be
// returned. | [
"Validate",
"checks",
"a",
"supplied",
"LogEntry",
"against",
"its",
"LogStreamDescriptor",
"for",
"validity",
"returning",
"an",
"error",
"if",
"it",
"is",
"not",
"valid",
".",
"If",
"the",
"LogEntry",
"is",
"otherwise",
"valid",
"but",
"has",
"no",
"content"... | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/logdog/api/logpb/utils.go#L89-L112 |
131,270 | luci/luci-go | milo/buildsource/buildbucket/buckets.go | GetBuilders | func GetBuilders(c context.Context) (*swarmbucket.LegacySwarmbucketApiGetBuildersResponseMessage, error) {
host := common.GetSettings(c).GetBuildbucket().GetHost()
if host == "" {
return nil, errors.New("buildbucket host is missing in config")
}
return getBuilders(c, host)
} | go | func GetBuilders(c context.Context) (*swarmbucket.LegacySwarmbucketApiGetBuildersResponseMessage, error) {
host := common.GetSettings(c).GetBuildbucket().GetHost()
if host == "" {
return nil, errors.New("buildbucket host is missing in config")
}
return getBuilders(c, host)
} | [
"func",
"GetBuilders",
"(",
"c",
"context",
".",
"Context",
")",
"(",
"*",
"swarmbucket",
".",
"LegacySwarmbucketApiGetBuildersResponseMessage",
",",
"error",
")",
"{",
"host",
":=",
"common",
".",
"GetSettings",
"(",
"c",
")",
".",
"GetBuildbucket",
"(",
")",... | // GetBuilders returns all Swarmbucket builders, cached for current identity. | [
"GetBuilders",
"returns",
"all",
"Swarmbucket",
"builders",
"cached",
"for",
"current",
"identity",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/milo/buildsource/buildbucket/buckets.go#L35-L41 |
131,271 | luci/luci-go | server/auth/openid/settings.go | fetchCachedSettings | func fetchCachedSettings(c context.Context) (*Settings, error) {
cfg := &Settings{}
if err := settings.Get(c, SettingsKey, cfg); err != settings.ErrNoSettings {
return cfg, err
}
return cfg, nil
} | go | func fetchCachedSettings(c context.Context) (*Settings, error) {
cfg := &Settings{}
if err := settings.Get(c, SettingsKey, cfg); err != settings.ErrNoSettings {
return cfg, err
}
return cfg, nil
} | [
"func",
"fetchCachedSettings",
"(",
"c",
"context",
".",
"Context",
")",
"(",
"*",
"Settings",
",",
"error",
")",
"{",
"cfg",
":=",
"&",
"Settings",
"{",
"}",
"\n",
"if",
"err",
":=",
"settings",
".",
"Get",
"(",
"c",
",",
"SettingsKey",
",",
"cfg",
... | // fetchCachedSettings fetches OpenID configuration from the settings store. | [
"fetchCachedSettings",
"fetches",
"OpenID",
"configuration",
"from",
"the",
"settings",
"store",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/server/auth/openid/settings.go#L58-L64 |
131,272 | luci/luci-go | scheduler/appengine/apiservers/scheduler.go | GetJobs | func (s *SchedulerServer) GetJobs(ctx context.Context, in *scheduler.JobsRequest) (*scheduler.JobsReply, error) {
if in.GetCursor() != "" {
// Paging in GetJobs isn't implemented until we have enough jobs to care.
// Until then, not empty cursor implies no more jobs to return.
return &scheduler.JobsReply{Jobs: [... | go | func (s *SchedulerServer) GetJobs(ctx context.Context, in *scheduler.JobsRequest) (*scheduler.JobsReply, error) {
if in.GetCursor() != "" {
// Paging in GetJobs isn't implemented until we have enough jobs to care.
// Until then, not empty cursor implies no more jobs to return.
return &scheduler.JobsReply{Jobs: [... | [
"func",
"(",
"s",
"*",
"SchedulerServer",
")",
"GetJobs",
"(",
"ctx",
"context",
".",
"Context",
",",
"in",
"*",
"scheduler",
".",
"JobsRequest",
")",
"(",
"*",
"scheduler",
".",
"JobsReply",
",",
"error",
")",
"{",
"if",
"in",
".",
"GetCursor",
"(",
... | // GetJobs fetches all jobs satisfying JobsRequest and visibility ACLs. | [
"GetJobs",
"fetches",
"all",
"jobs",
"satisfying",
"JobsRequest",
"and",
"visibility",
"ACLs",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/scheduler/appengine/apiservers/scheduler.go#L50-L86 |
131,273 | luci/luci-go | logdog/appengine/coordinator/config/projects.go | ProjectConfigPath | func ProjectConfigPath(c context.Context) string {
return svcconfig.ProjectConfigPath(cfgclient.CurrentServiceName(c))
} | go | func ProjectConfigPath(c context.Context) string {
return svcconfig.ProjectConfigPath(cfgclient.CurrentServiceName(c))
} | [
"func",
"ProjectConfigPath",
"(",
"c",
"context",
".",
"Context",
")",
"string",
"{",
"return",
"svcconfig",
".",
"ProjectConfigPath",
"(",
"cfgclient",
".",
"CurrentServiceName",
"(",
"c",
")",
")",
"\n",
"}"
] | // ProjectConfigPath returns the path of the project-specific configuration.
// This path should be used with a project config set.
//
// A given project's configuration is named after the current App ID. | [
"ProjectConfigPath",
"returns",
"the",
"path",
"of",
"the",
"project",
"-",
"specific",
"configuration",
".",
"This",
"path",
"should",
"be",
"used",
"with",
"a",
"project",
"config",
"set",
".",
"A",
"given",
"project",
"s",
"configuration",
"is",
"named",
... | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/logdog/appengine/coordinator/config/projects.go#L33-L35 |
131,274 | luci/luci-go | logdog/appengine/coordinator/config/projects.go | ProjectNames | func ProjectNames(c context.Context, a cfgclient.Authority) ([]types.ProjectName, error) {
configPath := ProjectConfigPath(c)
var metas []*config.Meta
if err := cfgclient.Projects(c, a, configPath, nil, &metas); err != nil {
log.WithError(err).Errorf(c, "Failed to load project configs.")
return nil, err
}
//... | go | func ProjectNames(c context.Context, a cfgclient.Authority) ([]types.ProjectName, error) {
configPath := ProjectConfigPath(c)
var metas []*config.Meta
if err := cfgclient.Projects(c, a, configPath, nil, &metas); err != nil {
log.WithError(err).Errorf(c, "Failed to load project configs.")
return nil, err
}
//... | [
"func",
"ProjectNames",
"(",
"c",
"context",
".",
"Context",
",",
"a",
"cfgclient",
".",
"Authority",
")",
"(",
"[",
"]",
"types",
".",
"ProjectName",
",",
"error",
")",
"{",
"configPath",
":=",
"ProjectConfigPath",
"(",
"c",
")",
"\n\n",
"var",
"metas",... | // ProjectNames returns a sorted list of the names of all of the projects
// that the supplied authority can view. | [
"ProjectNames",
"returns",
"a",
"sorted",
"list",
"of",
"the",
"names",
"of",
"all",
"of",
"the",
"projects",
"that",
"the",
"supplied",
"authority",
"can",
"view",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/logdog/appengine/coordinator/config/projects.go#L70-L88 |
131,275 | luci/luci-go | logdog/appengine/coordinator/config/projects.go | ActiveProjects | func ActiveProjects(c context.Context) ([]types.ProjectName, error) {
return ProjectNames(c, cfgclient.AsService)
} | go | func ActiveProjects(c context.Context) ([]types.ProjectName, error) {
return ProjectNames(c, cfgclient.AsService)
} | [
"func",
"ActiveProjects",
"(",
"c",
"context",
".",
"Context",
")",
"(",
"[",
"]",
"types",
".",
"ProjectName",
",",
"error",
")",
"{",
"return",
"ProjectNames",
"(",
"c",
",",
"cfgclient",
".",
"AsService",
")",
"\n",
"}"
] | // ActiveProjects returns a full list of all config service projects with
// LogDog project configurations.
//
// The list will be alphabetically sorted. | [
"ActiveProjects",
"returns",
"a",
"full",
"list",
"of",
"all",
"config",
"service",
"projects",
"with",
"LogDog",
"project",
"configurations",
".",
"The",
"list",
"will",
"be",
"alphabetically",
"sorted",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/logdog/appengine/coordinator/config/projects.go#L94-L96 |
131,276 | luci/luci-go | logdog/appengine/coordinator/config/projects.go | ActiveUserProjects | func ActiveUserProjects(c context.Context) ([]types.ProjectName, error) {
return ProjectNames(c, cfgclient.AsUser)
} | go | func ActiveUserProjects(c context.Context) ([]types.ProjectName, error) {
return ProjectNames(c, cfgclient.AsUser)
} | [
"func",
"ActiveUserProjects",
"(",
"c",
"context",
".",
"Context",
")",
"(",
"[",
"]",
"types",
".",
"ProjectName",
",",
"error",
")",
"{",
"return",
"ProjectNames",
"(",
"c",
",",
"cfgclient",
".",
"AsUser",
")",
"\n",
"}"
] | // ActiveUserProjects returns a full list of all config service projects with
// LogDog project configurations that the current user can see.
//
// The list will be alphabetically sorted. | [
"ActiveUserProjects",
"returns",
"a",
"full",
"list",
"of",
"all",
"config",
"service",
"projects",
"with",
"LogDog",
"project",
"configurations",
"that",
"the",
"current",
"user",
"can",
"see",
".",
"The",
"list",
"will",
"be",
"alphabetically",
"sorted",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/logdog/appengine/coordinator/config/projects.go#L102-L104 |
131,277 | luci/luci-go | gce/vmtoken/vmtoken.go | Clear | func Clear(c context.Context) context.Context {
return context.WithValue(c, &pldKey, nil)
} | go | func Clear(c context.Context) context.Context {
return context.WithValue(c, &pldKey, nil)
} | [
"func",
"Clear",
"(",
"c",
"context",
".",
"Context",
")",
"context",
".",
"Context",
"{",
"return",
"context",
".",
"WithValue",
"(",
"c",
",",
"&",
"pldKey",
",",
"nil",
")",
"\n",
"}"
] | // Clear returns a new context without a GCE VM metadata token installed. | [
"Clear",
"returns",
"a",
"new",
"context",
"without",
"a",
"GCE",
"VM",
"metadata",
"token",
"installed",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/gce/vmtoken/vmtoken.go#L193-L195 |
131,278 | luci/luci-go | gce/vmtoken/vmtoken.go | Hostname | func Hostname(c context.Context) string {
p := getPayload(c)
if p == nil {
return ""
}
return p.Instance
} | go | func Hostname(c context.Context) string {
p := getPayload(c)
if p == nil {
return ""
}
return p.Instance
} | [
"func",
"Hostname",
"(",
"c",
"context",
".",
"Context",
")",
"string",
"{",
"p",
":=",
"getPayload",
"(",
"c",
")",
"\n",
"if",
"p",
"==",
"nil",
"{",
"return",
"\"",
"\"",
"\n",
"}",
"\n",
"return",
"p",
".",
"Instance",
"\n",
"}"
] | // Hostname returns the hostname of the VM stored in the current context. | [
"Hostname",
"returns",
"the",
"hostname",
"of",
"the",
"VM",
"stored",
"in",
"the",
"current",
"context",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/gce/vmtoken/vmtoken.go#L204-L210 |
131,279 | luci/luci-go | gce/vmtoken/vmtoken.go | CurrentIdentity | func CurrentIdentity(c context.Context) string {
p := getPayload(c)
if p == nil {
return "gce:anonymous"
}
// GCE hostnames must be unique per project, so <instance, project> suffices.
return fmt.Sprintf("gce:%s:%s", p.Instance, p.Project)
} | go | func CurrentIdentity(c context.Context) string {
p := getPayload(c)
if p == nil {
return "gce:anonymous"
}
// GCE hostnames must be unique per project, so <instance, project> suffices.
return fmt.Sprintf("gce:%s:%s", p.Instance, p.Project)
} | [
"func",
"CurrentIdentity",
"(",
"c",
"context",
".",
"Context",
")",
"string",
"{",
"p",
":=",
"getPayload",
"(",
"c",
")",
"\n",
"if",
"p",
"==",
"nil",
"{",
"return",
"\"",
"\"",
"\n",
"}",
"\n",
"// GCE hostnames must be unique per project, so <instance, pr... | // CurrentIdentity returns the identity of the VM stored in the current context. | [
"CurrentIdentity",
"returns",
"the",
"identity",
"of",
"the",
"VM",
"stored",
"in",
"the",
"current",
"context",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/gce/vmtoken/vmtoken.go#L213-L220 |
131,280 | luci/luci-go | gce/vmtoken/vmtoken.go | Matches | func Matches(c context.Context, host, zone, proj string) bool {
p := getPayload(c)
if p == nil {
return false
}
logging.Debugf(c, "expecting VM token from %q in %q in %q", host, zone, proj)
return p.Instance == host && p.Zone == zone && p.Project == proj
} | go | func Matches(c context.Context, host, zone, proj string) bool {
p := getPayload(c)
if p == nil {
return false
}
logging.Debugf(c, "expecting VM token from %q in %q in %q", host, zone, proj)
return p.Instance == host && p.Zone == zone && p.Project == proj
} | [
"func",
"Matches",
"(",
"c",
"context",
".",
"Context",
",",
"host",
",",
"zone",
",",
"proj",
"string",
")",
"bool",
"{",
"p",
":=",
"getPayload",
"(",
"c",
")",
"\n",
"if",
"p",
"==",
"nil",
"{",
"return",
"false",
"\n",
"}",
"\n",
"logging",
"... | // Matches returns whether the current context contains a GCE VM metadata
// token matching the given identity. | [
"Matches",
"returns",
"whether",
"the",
"current",
"context",
"contains",
"a",
"GCE",
"VM",
"metadata",
"token",
"matching",
"the",
"given",
"identity",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/gce/vmtoken/vmtoken.go#L224-L231 |
131,281 | luci/luci-go | gce/vmtoken/vmtoken.go | Middleware | func Middleware(c *router.Context, next router.Handler) {
if tok := c.Request.Header.Get(Header); tok != "" {
// TODO(smut): Support requests to other modules, versions.
aud := "https://" + info.DefaultVersionHostname(c.Context)
logging.Debugf(c.Context, "expecting VM token for: %s", aud)
switch p, err := Veri... | go | func Middleware(c *router.Context, next router.Handler) {
if tok := c.Request.Header.Get(Header); tok != "" {
// TODO(smut): Support requests to other modules, versions.
aud := "https://" + info.DefaultVersionHostname(c.Context)
logging.Debugf(c.Context, "expecting VM token for: %s", aud)
switch p, err := Veri... | [
"func",
"Middleware",
"(",
"c",
"*",
"router",
".",
"Context",
",",
"next",
"router",
".",
"Handler",
")",
"{",
"if",
"tok",
":=",
"c",
".",
"Request",
".",
"Header",
".",
"Get",
"(",
"Header",
")",
";",
"tok",
"!=",
"\"",
"\"",
"{",
"// TODO(smut)... | // Middleware embeds a Payload in the context if the request contains a GCE VM
// metadata token. | [
"Middleware",
"embeds",
"a",
"Payload",
"in",
"the",
"context",
"if",
"the",
"request",
"contains",
"a",
"GCE",
"VM",
"metadata",
"token",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/gce/vmtoken/vmtoken.go#L235-L259 |
131,282 | luci/luci-go | milo/frontend/view_builders.go | filterAuthorizedBuilders | func filterAuthorizedBuilders(c context.Context, builders []string) ([]string, error) {
buckets := stringset.New(0)
for _, b := range builders {
id := buildsource.BuilderID(b)
buildType, bucket, _, err := id.Split()
if err != nil {
logging.Warningf(c, "found malformed builder ID %q", id)
continue
}
if... | go | func filterAuthorizedBuilders(c context.Context, builders []string) ([]string, error) {
buckets := stringset.New(0)
for _, b := range builders {
id := buildsource.BuilderID(b)
buildType, bucket, _, err := id.Split()
if err != nil {
logging.Warningf(c, "found malformed builder ID %q", id)
continue
}
if... | [
"func",
"filterAuthorizedBuilders",
"(",
"c",
"context",
".",
"Context",
",",
"builders",
"[",
"]",
"string",
")",
"(",
"[",
"]",
"string",
",",
"error",
")",
"{",
"buckets",
":=",
"stringset",
".",
"New",
"(",
"0",
")",
"\n",
"for",
"_",
",",
"b",
... | // filterAuthorizedBuilders filters out builders that the user does not have access to. | [
"filterAuthorizedBuilders",
"filters",
"out",
"builders",
"that",
"the",
"user",
"does",
"not",
"have",
"access",
"to",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/milo/frontend/view_builders.go#L115-L144 |
131,283 | luci/luci-go | milo/frontend/view_builders.go | getBuilderHistories | func getBuilderHistories(c context.Context, builders []string, project string, limit int) ([]*builderHistory, error) {
// Populate the recent histories.
hists := make([]*builderHistory, len(builders))
err := parallel.WorkPool(16, func(ch chan<- func() error) {
for i, builder := range builders {
i := i
builde... | go | func getBuilderHistories(c context.Context, builders []string, project string, limit int) ([]*builderHistory, error) {
// Populate the recent histories.
hists := make([]*builderHistory, len(builders))
err := parallel.WorkPool(16, func(ch chan<- func() error) {
for i, builder := range builders {
i := i
builde... | [
"func",
"getBuilderHistories",
"(",
"c",
"context",
".",
"Context",
",",
"builders",
"[",
"]",
"string",
",",
"project",
"string",
",",
"limit",
"int",
")",
"(",
"[",
"]",
"*",
"builderHistory",
",",
"error",
")",
"{",
"// Populate the recent histories.",
"h... | // getBuilderHistories gets the recent histories for the builders in the given project. | [
"getBuilderHistories",
"gets",
"the",
"recent",
"histories",
"for",
"the",
"builders",
"in",
"the",
"given",
"project",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/milo/frontend/view_builders.go#L165-L209 |
131,284 | luci/luci-go | milo/frontend/view_builders.go | getBuildersForProject | func getBuildersForProject(c context.Context, project, console string) ([]string, error) {
var cons []*common.Console
// Get consoles for project and extract builders into set.
projKey := datastore.MakeKey(c, "Project", project)
if console == "" {
q := datastore.NewQuery("Console").Ancestor(projKey)
if err := ... | go | func getBuildersForProject(c context.Context, project, console string) ([]string, error) {
var cons []*common.Console
// Get consoles for project and extract builders into set.
projKey := datastore.MakeKey(c, "Project", project)
if console == "" {
q := datastore.NewQuery("Console").Ancestor(projKey)
if err := ... | [
"func",
"getBuildersForProject",
"(",
"c",
"context",
".",
"Context",
",",
"project",
",",
"console",
"string",
")",
"(",
"[",
"]",
"string",
",",
"error",
")",
"{",
"var",
"cons",
"[",
"]",
"*",
"common",
".",
"Console",
"\n\n",
"// Get consoles for proje... | // getBuildersForProject gets the sorted builder IDs associated with the given project. | [
"getBuildersForProject",
"gets",
"the",
"sorted",
"builder",
"IDs",
"associated",
"with",
"the",
"given",
"project",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/milo/frontend/view_builders.go#L212-L249 |
131,285 | luci/luci-go | tokenserver/appengine/impl/utils/sn.go | SerializeSN | func SerializeSN(sn *big.Int) ([]byte, error) {
blob, err := sn.GobEncode()
if err != nil {
return nil, fmt.Errorf("can't encode SN - %s", err)
}
return blob, nil
} | go | func SerializeSN(sn *big.Int) ([]byte, error) {
blob, err := sn.GobEncode()
if err != nil {
return nil, fmt.Errorf("can't encode SN - %s", err)
}
return blob, nil
} | [
"func",
"SerializeSN",
"(",
"sn",
"*",
"big",
".",
"Int",
")",
"(",
"[",
"]",
"byte",
",",
"error",
")",
"{",
"blob",
",",
"err",
":=",
"sn",
".",
"GobEncode",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"fmt",
".",
"... | // SerializeSN converts a certificate serial number to a byte blob. | [
"SerializeSN",
"converts",
"a",
"certificate",
"serial",
"number",
"to",
"a",
"byte",
"blob",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/tokenserver/appengine/impl/utils/sn.go#L23-L29 |
131,286 | luci/luci-go | scheduler/appengine/catalog/catalog.go | validateProjectConfig | func (cat *catalog) validateProjectConfig(ctx *validation.Context, configSet, path string, content []byte) error {
var cfg messages.ProjectConfig
err := proto.UnmarshalText(string(content), &cfg)
if err != nil {
ctx.Error(err)
return nil
}
// AclSets.
ctx.Enter("acl_sets")
knownACLSets := acl.ValidateACLSet... | go | func (cat *catalog) validateProjectConfig(ctx *validation.Context, configSet, path string, content []byte) error {
var cfg messages.ProjectConfig
err := proto.UnmarshalText(string(content), &cfg)
if err != nil {
ctx.Error(err)
return nil
}
// AclSets.
ctx.Enter("acl_sets")
knownACLSets := acl.ValidateACLSet... | [
"func",
"(",
"cat",
"*",
"catalog",
")",
"validateProjectConfig",
"(",
"ctx",
"*",
"validation",
".",
"Context",
",",
"configSet",
",",
"path",
"string",
",",
"content",
"[",
"]",
"byte",
")",
"error",
"{",
"var",
"cfg",
"messages",
".",
"ProjectConfig",
... | // validateProjectConfig validates the content of a project config file.
//
// Validation errors are returned via validation.Context. Returns an error if
// the validation itself fails for some reason. | [
"validateProjectConfig",
"validates",
"the",
"content",
"of",
"a",
"project",
"config",
"file",
".",
"Validation",
"errors",
"are",
"returned",
"via",
"validation",
".",
"Context",
".",
"Returns",
"an",
"error",
"if",
"the",
"validation",
"itself",
"fails",
"for... | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/scheduler/appengine/catalog/catalog.go#L366-L416 |
131,287 | luci/luci-go | scheduler/appengine/catalog/catalog.go | validateTriggerProto | func (cat *catalog) validateTriggerProto(ctx *validation.Context, t *messages.Trigger, jobIDs stringset.Set, failOnMissing bool) proto.Message {
if t.Id == "" {
ctx.Errorf("missing 'id' field'")
} else if !jobIDRe.MatchString(t.Id) {
ctx.Errorf("%q is not valid value for 'id' field", t.Id)
}
if t.Schedule != ""... | go | func (cat *catalog) validateTriggerProto(ctx *validation.Context, t *messages.Trigger, jobIDs stringset.Set, failOnMissing bool) proto.Message {
if t.Id == "" {
ctx.Errorf("missing 'id' field'")
} else if !jobIDRe.MatchString(t.Id) {
ctx.Errorf("%q is not valid value for 'id' field", t.Id)
}
if t.Schedule != ""... | [
"func",
"(",
"cat",
"*",
"catalog",
")",
"validateTriggerProto",
"(",
"ctx",
"*",
"validation",
".",
"Context",
",",
"t",
"*",
"messages",
".",
"Trigger",
",",
"jobIDs",
"stringset",
".",
"Set",
",",
"failOnMissing",
"bool",
")",
"proto",
".",
"Message",
... | // validateTriggerProto validates and filters messages.Trigger protobuf message.
//
// It also extracts a task definition from it.
//
// Takes a set of all defined job IDs, to verify the trigger triggers only
// declared jobs. If failOnMissing is true, referencing an undefined job is
// reported as a validation error. ... | [
"validateTriggerProto",
"validates",
"and",
"filters",
"messages",
".",
"Trigger",
"protobuf",
"message",
".",
"It",
"also",
"extracts",
"a",
"task",
"definition",
"from",
"it",
".",
"Takes",
"a",
"set",
"of",
"all",
"defined",
"job",
"IDs",
"to",
"verify",
... | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/scheduler/appengine/catalog/catalog.go#L449-L477 |
131,288 | luci/luci-go | scheduler/appengine/catalog/catalog.go | validateTriggeringPolicy | func (cat *catalog) validateTriggeringPolicy(ctx *validation.Context, p *messages.TriggeringPolicy) {
if p != nil {
ctx.Enter("triggering_policy")
policy.ValidateDefinition(ctx, p)
ctx.Exit()
}
} | go | func (cat *catalog) validateTriggeringPolicy(ctx *validation.Context, p *messages.TriggeringPolicy) {
if p != nil {
ctx.Enter("triggering_policy")
policy.ValidateDefinition(ctx, p)
ctx.Exit()
}
} | [
"func",
"(",
"cat",
"*",
"catalog",
")",
"validateTriggeringPolicy",
"(",
"ctx",
"*",
"validation",
".",
"Context",
",",
"p",
"*",
"messages",
".",
"TriggeringPolicy",
")",
"{",
"if",
"p",
"!=",
"nil",
"{",
"ctx",
".",
"Enter",
"(",
"\"",
"\"",
")",
... | // validateTriggeringPolicy validates TriggeringPolicy proto.
//
// Errors are returned via validation.Context. | [
"validateTriggeringPolicy",
"validates",
"TriggeringPolicy",
"proto",
".",
"Errors",
"are",
"returned",
"via",
"validation",
".",
"Context",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/scheduler/appengine/catalog/catalog.go#L529-L535 |
131,289 | luci/luci-go | scheduler/appengine/catalog/catalog.go | normalizeTriggeredJobIDs | func normalizeTriggeredJobIDs(projectID string, t *messages.Trigger) []string {
set := stringset.New(len(t.Triggers))
for _, j := range t.Triggers {
set.Add(projectID + "/" + j)
}
out := set.ToSlice()
sort.Strings(out)
return out
} | go | func normalizeTriggeredJobIDs(projectID string, t *messages.Trigger) []string {
set := stringset.New(len(t.Triggers))
for _, j := range t.Triggers {
set.Add(projectID + "/" + j)
}
out := set.ToSlice()
sort.Strings(out)
return out
} | [
"func",
"normalizeTriggeredJobIDs",
"(",
"projectID",
"string",
",",
"t",
"*",
"messages",
".",
"Trigger",
")",
"[",
"]",
"string",
"{",
"set",
":=",
"stringset",
".",
"New",
"(",
"len",
"(",
"t",
".",
"Triggers",
")",
")",
"\n",
"for",
"_",
",",
"j"... | // normalizeTriggeredJobIDs returns sorted list without duplicates. | [
"normalizeTriggeredJobIDs",
"returns",
"sorted",
"list",
"without",
"duplicates",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/scheduler/appengine/catalog/catalog.go#L590-L598 |
131,290 | luci/luci-go | scheduler/appengine/catalog/catalog.go | marshalTriggeringPolicy | func marshalTriggeringPolicy(p *messages.TriggeringPolicy) []byte {
if p == nil {
return nil
}
out, err := proto.Marshal(p)
if err != nil {
panic(fmt.Errorf("failed to marshal TriggeringPolicy - %s", err))
}
return out
} | go | func marshalTriggeringPolicy(p *messages.TriggeringPolicy) []byte {
if p == nil {
return nil
}
out, err := proto.Marshal(p)
if err != nil {
panic(fmt.Errorf("failed to marshal TriggeringPolicy - %s", err))
}
return out
} | [
"func",
"marshalTriggeringPolicy",
"(",
"p",
"*",
"messages",
".",
"TriggeringPolicy",
")",
"[",
"]",
"byte",
"{",
"if",
"p",
"==",
"nil",
"{",
"return",
"nil",
"\n",
"}",
"\n",
"out",
",",
"err",
":=",
"proto",
".",
"Marshal",
"(",
"p",
")",
"\n",
... | // marshalTriggeringPolicy serializes TriggeringPolicy proto. | [
"marshalTriggeringPolicy",
"serializes",
"TriggeringPolicy",
"proto",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/scheduler/appengine/catalog/catalog.go#L601-L610 |
131,291 | luci/luci-go | machine-db/client/cli/cli.go | createClient | func createClient(c context.Context, params *Parameters) crimson.CrimsonClient {
client, err := auth.NewAuthenticator(c, auth.InteractiveLogin, params.AuthOptions).Client()
if err != nil {
errors.Log(c, err)
panic("failed to get authenticated HTTP client")
}
return crimson.NewCrimsonPRPCClient(&prpc.Client{
C... | go | func createClient(c context.Context, params *Parameters) crimson.CrimsonClient {
client, err := auth.NewAuthenticator(c, auth.InteractiveLogin, params.AuthOptions).Client()
if err != nil {
errors.Log(c, err)
panic("failed to get authenticated HTTP client")
}
return crimson.NewCrimsonPRPCClient(&prpc.Client{
C... | [
"func",
"createClient",
"(",
"c",
"context",
".",
"Context",
",",
"params",
"*",
"Parameters",
")",
"crimson",
".",
"CrimsonClient",
"{",
"client",
",",
"err",
":=",
"auth",
".",
"NewAuthenticator",
"(",
"c",
",",
"auth",
".",
"InteractiveLogin",
",",
"par... | // createClient creates and returns a client which can make RPC requests to the Machine Database.
// Panics if the client cannot be created. | [
"createClient",
"creates",
"and",
"returns",
"a",
"client",
"which",
"can",
"make",
"RPC",
"requests",
"to",
"the",
"Machine",
"Database",
".",
"Panics",
"if",
"the",
"client",
"cannot",
"be",
"created",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/machine-db/client/cli/cli.go#L47-L57 |
131,292 | luci/luci-go | machine-db/client/cli/cli.go | getClient | func getClient(c context.Context) crimson.CrimsonClient {
return c.Value(&clientKey).(crimson.CrimsonClient)
} | go | func getClient(c context.Context) crimson.CrimsonClient {
return c.Value(&clientKey).(crimson.CrimsonClient)
} | [
"func",
"getClient",
"(",
"c",
"context",
".",
"Context",
")",
"crimson",
".",
"CrimsonClient",
"{",
"return",
"c",
".",
"Value",
"(",
"&",
"clientKey",
")",
".",
"(",
"crimson",
".",
"CrimsonClient",
")",
"\n",
"}"
] | // getClient retrieves the client pointer embedded in the current context.
// The client pointer can be embedded in the current context using withClient. | [
"getClient",
"retrieves",
"the",
"client",
"pointer",
"embedded",
"in",
"the",
"current",
"context",
".",
"The",
"client",
"pointer",
"can",
"be",
"embedded",
"in",
"the",
"current",
"context",
"using",
"withClient",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/machine-db/client/cli/cli.go#L61-L63 |
131,293 | luci/luci-go | machine-db/client/cli/cli.go | withClient | func withClient(c context.Context, client crimson.CrimsonClient) context.Context {
return context.WithValue(c, &clientKey, client)
} | go | func withClient(c context.Context, client crimson.CrimsonClient) context.Context {
return context.WithValue(c, &clientKey, client)
} | [
"func",
"withClient",
"(",
"c",
"context",
".",
"Context",
",",
"client",
"crimson",
".",
"CrimsonClient",
")",
"context",
".",
"Context",
"{",
"return",
"context",
".",
"WithValue",
"(",
"c",
",",
"&",
"clientKey",
",",
"client",
")",
"\n",
"}"
] | // withClient installs an RPC client pointer into the given context.
// It can be retrieved later on with getClient. | [
"withClient",
"installs",
"an",
"RPC",
"client",
"pointer",
"into",
"the",
"given",
"context",
".",
"It",
"can",
"be",
"retrieved",
"later",
"on",
"with",
"getClient",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/machine-db/client/cli/cli.go#L67-L69 |
131,294 | luci/luci-go | machine-db/client/cli/cli.go | Initialize | func (c *commandBase) Initialize(params *Parameters) {
c.p = params
c.f.Register(c.GetFlags(), params)
} | go | func (c *commandBase) Initialize(params *Parameters) {
c.p = params
c.f.Register(c.GetFlags(), params)
} | [
"func",
"(",
"c",
"*",
"commandBase",
")",
"Initialize",
"(",
"params",
"*",
"Parameters",
")",
"{",
"c",
".",
"p",
"=",
"params",
"\n",
"c",
".",
"f",
".",
"Register",
"(",
"c",
".",
"GetFlags",
"(",
")",
",",
"params",
")",
"\n",
"}"
] | // Initialize initializes the commandBase instance, registering common flags. | [
"Initialize",
"initializes",
"the",
"commandBase",
"instance",
"registering",
"common",
"flags",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/machine-db/client/cli/cli.go#L80-L83 |
131,295 | luci/luci-go | machine-db/client/cli/cli.go | ModifyContext | func (c *commandBase) ModifyContext(ctx context.Context) context.Context {
cfg := gologger.LoggerConfig{
Format: gologger.StdFormatWithColor,
Out: os.Stderr,
}
opts, err := c.f.authFlags.Options()
if err != nil {
errors.Log(ctx, err)
panic("failed to get authentication options")
}
c.p.AuthOptions = opt... | go | func (c *commandBase) ModifyContext(ctx context.Context) context.Context {
cfg := gologger.LoggerConfig{
Format: gologger.StdFormatWithColor,
Out: os.Stderr,
}
opts, err := c.f.authFlags.Options()
if err != nil {
errors.Log(ctx, err)
panic("failed to get authentication options")
}
c.p.AuthOptions = opt... | [
"func",
"(",
"c",
"*",
"commandBase",
")",
"ModifyContext",
"(",
"ctx",
"context",
".",
"Context",
")",
"context",
".",
"Context",
"{",
"cfg",
":=",
"gologger",
".",
"LoggerConfig",
"{",
"Format",
":",
"gologger",
".",
"StdFormatWithColor",
",",
"Out",
":"... | // ModifyContext returns a new context to be used with subcommands.
// Configures the context's logging and embeds the Machine Database RPC client.
// Implements cli.ContextModificator. | [
"ModifyContext",
"returns",
"a",
"new",
"context",
"to",
"be",
"used",
"with",
"subcommands",
".",
"Configures",
"the",
"context",
"s",
"logging",
"and",
"embeds",
"the",
"Machine",
"Database",
"RPC",
"client",
".",
"Implements",
"cli",
".",
"ContextModificator"... | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/machine-db/client/cli/cli.go#L88-L100 |
131,296 | luci/luci-go | machine-db/client/cli/cli.go | New | func New(params *Parameters) *cli.Application {
return &cli.Application{
Name: "crimson",
Title: "Machine Database client",
Commands: []*subcommands.Command{
subcommands.CmdHelp,
{}, // Create an empty command to separate groups of similar commands.
// Authentication.
authcli.SubcommandInfo(params.... | go | func New(params *Parameters) *cli.Application {
return &cli.Application{
Name: "crimson",
Title: "Machine Database client",
Commands: []*subcommands.Command{
subcommands.CmdHelp,
{}, // Create an empty command to separate groups of similar commands.
// Authentication.
authcli.SubcommandInfo(params.... | [
"func",
"New",
"(",
"params",
"*",
"Parameters",
")",
"*",
"cli",
".",
"Application",
"{",
"return",
"&",
"cli",
".",
"Application",
"{",
"Name",
":",
"\"",
"\"",
",",
"Title",
":",
"\"",
"\"",
",",
"Commands",
":",
"[",
"]",
"*",
"subcommands",
".... | // New returns the Machine Database command-line application. | [
"New",
"returns",
"the",
"Machine",
"Database",
"command",
"-",
"line",
"application",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/machine-db/client/cli/cli.go#L103-L173 |
131,297 | luci/luci-go | auth/auth.go | GetAccessToken | func (a *Authenticator) GetAccessToken(lifetime time.Duration) (*oauth2.Token, error) {
tok, err := a.currentToken()
if err != nil {
return nil, err
}
// Impose some arbitrary limit, since <= 0 lifetime won't work.
if lifetime < time.Second {
lifetime = time.Second
}
if tok == nil || internal.TokenExpiresInR... | go | func (a *Authenticator) GetAccessToken(lifetime time.Duration) (*oauth2.Token, error) {
tok, err := a.currentToken()
if err != nil {
return nil, err
}
// Impose some arbitrary limit, since <= 0 lifetime won't work.
if lifetime < time.Second {
lifetime = time.Second
}
if tok == nil || internal.TokenExpiresInR... | [
"func",
"(",
"a",
"*",
"Authenticator",
")",
"GetAccessToken",
"(",
"lifetime",
"time",
".",
"Duration",
")",
"(",
"*",
"oauth2",
".",
"Token",
",",
"error",
")",
"{",
"tok",
",",
"err",
":=",
"a",
".",
"currentToken",
"(",
")",
"\n",
"if",
"err",
... | // GetAccessToken returns a valid access token with specified minimum lifetime.
//
// Does not interact with the user. May return ErrLoginRequired. | [
"GetAccessToken",
"returns",
"a",
"valid",
"access",
"token",
"with",
"specified",
"minimum",
"lifetime",
".",
"Does",
"not",
"interact",
"with",
"the",
"user",
".",
"May",
"return",
"ErrLoginRequired",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/auth/auth.go#L582-L609 |
131,298 | luci/luci-go | auth/auth.go | GetEmail | func (a *Authenticator) GetEmail() (string, error) {
// Grab last known token and its associated email. Note that this call also
// initializes the guts of the authenticator, including a.authToken.
tok, err := a.currentToken()
switch {
case err != nil:
return "", err
case tok != nil && tok.Email == internal.NoE... | go | func (a *Authenticator) GetEmail() (string, error) {
// Grab last known token and its associated email. Note that this call also
// initializes the guts of the authenticator, including a.authToken.
tok, err := a.currentToken()
switch {
case err != nil:
return "", err
case tok != nil && tok.Email == internal.NoE... | [
"func",
"(",
"a",
"*",
"Authenticator",
")",
"GetEmail",
"(",
")",
"(",
"string",
",",
"error",
")",
"{",
"// Grab last known token and its associated email. Note that this call also",
"// initializes the guts of the authenticator, including a.authToken.",
"tok",
",",
"err",
... | // GetEmail returns an email associated with the credentials.
//
// In most cases this is a fast call that hits the cache. In some rare cases it
// may do an RPC to the Token Info endpoint to grab an email associated with the
// token.
//
// Returns ErrNoEmail if the email is not available. This may happen, for
// exam... | [
"GetEmail",
"returns",
"an",
"email",
"associated",
"with",
"the",
"credentials",
".",
"In",
"most",
"cases",
"this",
"is",
"a",
"fast",
"call",
"that",
"hits",
"the",
"cache",
".",
"In",
"some",
"rare",
"cases",
"it",
"may",
"do",
"an",
"RPC",
"to",
"... | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/auth/auth.go#L624-L668 |
131,299 | luci/luci-go | auth/auth.go | PurgeCredentialsCache | func (a *Authenticator) PurgeCredentialsCache() error {
a.lock.Lock()
defer a.lock.Unlock()
if err := a.ensureInitialized(); err != nil {
return err
}
return a.purgeCredentialsCacheLocked()
} | go | func (a *Authenticator) PurgeCredentialsCache() error {
a.lock.Lock()
defer a.lock.Unlock()
if err := a.ensureInitialized(); err != nil {
return err
}
return a.purgeCredentialsCacheLocked()
} | [
"func",
"(",
"a",
"*",
"Authenticator",
")",
"PurgeCredentialsCache",
"(",
")",
"error",
"{",
"a",
".",
"lock",
".",
"Lock",
"(",
")",
"\n",
"defer",
"a",
".",
"lock",
".",
"Unlock",
"(",
")",
"\n",
"if",
"err",
":=",
"a",
".",
"ensureInitialized",
... | // PurgeCredentialsCache removes cached tokens.
//
// Does not revoke them! | [
"PurgeCredentialsCache",
"removes",
"cached",
"tokens",
".",
"Does",
"not",
"revoke",
"them!"
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/auth/auth.go#L753-L760 |
Subsets and Splits
SQL Console for google/code_x_glue_ct_code_to_text
This query implements a thoughtful three-tier curation strategy to build a balanced safety dataset, categorizing code by destructive operations, safe I/O operations, and pure computational negatives with subsampling—revealing important patterns about how destructive intent manifests in Python code for model safety research.
SQL Console for google/code_x_glue_ct_code_to_text
This query performs meaningful classification of Python code samples into safety-relevant tiers based on destructive operations, I/O patterns, and pure computation, which could be valuable for building safety classifiers or curating training data, though the output itself is a filtered/ranked dataset rather than revealing novel statistical insights.