id int32 0 167k | repo stringlengths 5 54 | path stringlengths 4 155 | func_name stringlengths 1 118 | original_string stringlengths 52 85.5k | language stringclasses 1
value | code stringlengths 52 85.5k | code_tokens listlengths 21 1.41k | docstring stringlengths 6 2.61k | docstring_tokens listlengths 3 215 | sha stringlengths 40 40 | url stringlengths 85 252 |
|---|---|---|---|---|---|---|---|---|---|---|---|
129,800 | luci/luci-go | common/data/bit_field/bf.go | ToProperty | func (bf *BitField) ToProperty() (datastore.Property, error) {
bs, err := bf.MarshalBinary()
return datastore.MkPropertyNI(bs), err
} | go | func (bf *BitField) ToProperty() (datastore.Property, error) {
bs, err := bf.MarshalBinary()
return datastore.MkPropertyNI(bs), err
} | [
"func",
"(",
"bf",
"*",
"BitField",
")",
"ToProperty",
"(",
")",
"(",
"datastore",
".",
"Property",
",",
"error",
")",
"{",
"bs",
",",
"err",
":=",
"bf",
".",
"MarshalBinary",
"(",
")",
"\n",
"return",
"datastore",
".",
"MkPropertyNI",
"(",
"bs",
")"... | // ToProperty implements datastore.PropertyConverter | [
"ToProperty",
"implements",
"datastore",
".",
"PropertyConverter"
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/common/data/bit_field/bf.go#L85-L88 |
129,801 | luci/luci-go | common/data/bit_field/bf.go | Make | func Make(size uint32) BitField {
if size == 0 {
return BitField{}
}
return BitField{
data: make([]byte, (size+8-1)>>3),
size: size,
}
} | go | func Make(size uint32) BitField {
if size == 0 {
return BitField{}
}
return BitField{
data: make([]byte, (size+8-1)>>3),
size: size,
}
} | [
"func",
"Make",
"(",
"size",
"uint32",
")",
"BitField",
"{",
"if",
"size",
"==",
"0",
"{",
"return",
"BitField",
"{",
"}",
"\n",
"}",
"\n",
"return",
"BitField",
"{",
"data",
":",
"make",
"(",
"[",
"]",
"byte",
",",
"(",
"size",
"+",
"8",
"-",
... | // Make creates a new BitField. | [
"Make",
"creates",
"a",
"new",
"BitField",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/common/data/bit_field/bf.go#L106-L114 |
129,802 | luci/luci-go | common/data/bit_field/bf.go | All | func (bf BitField) All(val bool) bool {
targ := bf.size
if !val {
targ = 0
}
return bf.CountSet() == targ
} | go | func (bf BitField) All(val bool) bool {
targ := bf.size
if !val {
targ = 0
}
return bf.CountSet() == targ
} | [
"func",
"(",
"bf",
"BitField",
")",
"All",
"(",
"val",
"bool",
")",
"bool",
"{",
"targ",
":=",
"bf",
".",
"size",
"\n",
"if",
"!",
"val",
"{",
"targ",
"=",
"0",
"\n",
"}",
"\n",
"return",
"bf",
".",
"CountSet",
"(",
")",
"==",
"targ",
"\n",
"... | // All returns true iff all of the bits are equal to `val`. | [
"All",
"returns",
"true",
"iff",
"all",
"of",
"the",
"bits",
"are",
"equal",
"to",
"val",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/common/data/bit_field/bf.go#L140-L146 |
129,803 | luci/luci-go | common/data/bit_field/bf.go | CountSet | func (bf BitField) CountSet() (ret uint32) {
for _, b := range bf.data {
if b != 0 {
ret += uint32(bitCount[b])
}
}
return ret
} | go | func (bf BitField) CountSet() (ret uint32) {
for _, b := range bf.data {
if b != 0 {
ret += uint32(bitCount[b])
}
}
return ret
} | [
"func",
"(",
"bf",
"BitField",
")",
"CountSet",
"(",
")",
"(",
"ret",
"uint32",
")",
"{",
"for",
"_",
",",
"b",
":=",
"range",
"bf",
".",
"data",
"{",
"if",
"b",
"!=",
"0",
"{",
"ret",
"+=",
"uint32",
"(",
"bitCount",
"[",
"b",
"]",
")",
"\n"... | // CountSet returns the number of true bits. | [
"CountSet",
"returns",
"the",
"number",
"of",
"true",
"bits",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/common/data/bit_field/bf.go#L149-L156 |
129,804 | luci/luci-go | common/data/bit_field/bf.go | IsSet | func (bf BitField) IsSet(idx uint32) bool {
return idx < bf.size && ((bf.data[idx>>3] & (1 << (idx % 8))) != 0)
} | go | func (bf BitField) IsSet(idx uint32) bool {
return idx < bf.size && ((bf.data[idx>>3] & (1 << (idx % 8))) != 0)
} | [
"func",
"(",
"bf",
"BitField",
")",
"IsSet",
"(",
"idx",
"uint32",
")",
"bool",
"{",
"return",
"idx",
"<",
"bf",
".",
"size",
"&&",
"(",
"(",
"bf",
".",
"data",
"[",
"idx",
">>",
"3",
"]",
"&",
"(",
"1",
"<<",
"(",
"idx",
"%",
"8",
")",
")"... | // IsSet returns the value of a given bit. | [
"IsSet",
"returns",
"the",
"value",
"of",
"a",
"given",
"bit",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/common/data/bit_field/bf.go#L159-L161 |
129,805 | luci/luci-go | appengine/mapper/controller.go | tq | func (ctl *Controller) tq() *tq.Dispatcher {
ctl.m.RLock()
defer ctl.m.RUnlock()
if ctl.disp == nil {
panic("mapper.Controller wasn't installed into tq.Dispatcher yet")
}
return ctl.disp
} | go | func (ctl *Controller) tq() *tq.Dispatcher {
ctl.m.RLock()
defer ctl.m.RUnlock()
if ctl.disp == nil {
panic("mapper.Controller wasn't installed into tq.Dispatcher yet")
}
return ctl.disp
} | [
"func",
"(",
"ctl",
"*",
"Controller",
")",
"tq",
"(",
")",
"*",
"tq",
".",
"Dispatcher",
"{",
"ctl",
".",
"m",
".",
"RLock",
"(",
")",
"\n",
"defer",
"ctl",
".",
"m",
".",
"RUnlock",
"(",
")",
"\n",
"if",
"ctl",
".",
"disp",
"==",
"nil",
"{"... | // tq returns a dispatcher set in Install or panics if not set yet.
//
// Grabs the reader lock inside. | [
"tq",
"returns",
"a",
"dispatcher",
"set",
"in",
"Install",
"or",
"panics",
"if",
"not",
"set",
"yet",
".",
"Grabs",
"the",
"reader",
"lock",
"inside",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/appengine/mapper/controller.go#L148-L155 |
129,806 | luci/luci-go | appengine/mapper/controller.go | getFactory | func (ctl *Controller) getFactory(id ID) (Factory, error) {
ctl.m.RLock()
defer ctl.m.RUnlock()
if m, ok := ctl.mappers[id]; ok {
return m, nil
}
return nil, errors.Reason("no mapper factory with ID %q registered", id).Err()
} | go | func (ctl *Controller) getFactory(id ID) (Factory, error) {
ctl.m.RLock()
defer ctl.m.RUnlock()
if m, ok := ctl.mappers[id]; ok {
return m, nil
}
return nil, errors.Reason("no mapper factory with ID %q registered", id).Err()
} | [
"func",
"(",
"ctl",
"*",
"Controller",
")",
"getFactory",
"(",
"id",
"ID",
")",
"(",
"Factory",
",",
"error",
")",
"{",
"ctl",
".",
"m",
".",
"RLock",
"(",
")",
"\n",
"defer",
"ctl",
".",
"m",
".",
"RUnlock",
"(",
")",
"\n",
"if",
"m",
",",
"... | // getFactory returns a registered mapper factory or an error.
//
// Grabs the reader lock inside. Can return only fatal errors. | [
"getFactory",
"returns",
"a",
"registered",
"mapper",
"factory",
"or",
"an",
"error",
".",
"Grabs",
"the",
"reader",
"lock",
"inside",
".",
"Can",
"return",
"only",
"fatal",
"errors",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/appengine/mapper/controller.go#L183-L190 |
129,807 | luci/luci-go | appengine/mapper/controller.go | initMapper | func (ctl *Controller) initMapper(c context.Context, j *Job, shardIdx int) (Mapper, error) {
f, err := ctl.getFactory(j.Config.Mapper)
if err != nil {
return nil, errors.Annotate(err, "when initializing mapper").Err()
}
m, err := f(c, j, shardIdx)
if err != nil {
return nil, errors.Annotate(err, "error from ma... | go | func (ctl *Controller) initMapper(c context.Context, j *Job, shardIdx int) (Mapper, error) {
f, err := ctl.getFactory(j.Config.Mapper)
if err != nil {
return nil, errors.Annotate(err, "when initializing mapper").Err()
}
m, err := f(c, j, shardIdx)
if err != nil {
return nil, errors.Annotate(err, "error from ma... | [
"func",
"(",
"ctl",
"*",
"Controller",
")",
"initMapper",
"(",
"c",
"context",
".",
"Context",
",",
"j",
"*",
"Job",
",",
"shardIdx",
"int",
")",
"(",
"Mapper",
",",
"error",
")",
"{",
"f",
",",
"err",
":=",
"ctl",
".",
"getFactory",
"(",
"j",
".... | // initMapper instantiates a Mapper through a registered factory.
//
// May return fatal and transient errors. | [
"initMapper",
"instantiates",
"a",
"Mapper",
"through",
"a",
"registered",
"factory",
".",
"May",
"return",
"fatal",
"and",
"transient",
"errors",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/appengine/mapper/controller.go#L195-L205 |
129,808 | luci/luci-go | appengine/mapper/controller.go | GetJob | func (ctl *Controller) GetJob(c context.Context, id JobID) (*Job, error) {
// Even though we could have made getJob public, we want to force API users
// to use Controller as a single facade.
return getJob(c, id)
} | go | func (ctl *Controller) GetJob(c context.Context, id JobID) (*Job, error) {
// Even though we could have made getJob public, we want to force API users
// to use Controller as a single facade.
return getJob(c, id)
} | [
"func",
"(",
"ctl",
"*",
"Controller",
")",
"GetJob",
"(",
"c",
"context",
".",
"Context",
",",
"id",
"JobID",
")",
"(",
"*",
"Job",
",",
"error",
")",
"{",
"// Even though we could have made getJob public, we want to force API users",
"// to use Controller as a singl... | // GetJob fetches a previously launched job given its ID.
//
// Returns ErrNoSuchJob if not found. All other possible errors are transient
// and they are marked as such. | [
"GetJob",
"fetches",
"a",
"previously",
"launched",
"job",
"given",
"its",
"ID",
".",
"Returns",
"ErrNoSuchJob",
"if",
"not",
"found",
".",
"All",
"other",
"possible",
"errors",
"are",
"transient",
"and",
"they",
"are",
"marked",
"as",
"such",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/appengine/mapper/controller.go#L254-L258 |
129,809 | luci/luci-go | appengine/mapper/controller.go | AbortJob | func (ctl *Controller) AbortJob(c context.Context, id JobID) (job *Job, err error) {
err = runTxn(c, func(c context.Context) error {
var err error
switch job, err = getJob(c, id); {
case err != nil:
return err
case isFinalState(job.State) || job.State == State_ABORTING:
return nil // nothing to abort, al... | go | func (ctl *Controller) AbortJob(c context.Context, id JobID) (job *Job, err error) {
err = runTxn(c, func(c context.Context) error {
var err error
switch job, err = getJob(c, id); {
case err != nil:
return err
case isFinalState(job.State) || job.State == State_ABORTING:
return nil // nothing to abort, al... | [
"func",
"(",
"ctl",
"*",
"Controller",
")",
"AbortJob",
"(",
"c",
"context",
".",
"Context",
",",
"id",
"JobID",
")",
"(",
"job",
"*",
"Job",
",",
"err",
"error",
")",
"{",
"err",
"=",
"runTxn",
"(",
"c",
",",
"func",
"(",
"c",
"context",
".",
... | // AbortJob aborts a job and returns its most recent state.
//
// Silently does nothing if the job is finished or already aborted.
//
// Returns ErrNoSuchJob is there's no such job at all. All other possible errors
// are transient and they are marked as such. | [
"AbortJob",
"aborts",
"a",
"job",
"and",
"returns",
"its",
"most",
"recent",
"state",
".",
"Silently",
"does",
"nothing",
"if",
"the",
"job",
"is",
"finished",
"or",
"already",
"aborted",
".",
"Returns",
"ErrNoSuchJob",
"is",
"there",
"s",
"no",
"such",
"j... | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/appengine/mapper/controller.go#L266-L291 |
129,810 | luci/luci-go | appengine/mapper/controller.go | fanOutShardsHandler | func (ctl *Controller) fanOutShardsHandler(c context.Context, payload proto.Message) error {
msg := payload.(*tasks.FanOutShards)
// Make sure the job is still present. If it is aborted, we still need to
// launch the shards, so they notice they are being aborted. We could try
// to abort all shards right here and... | go | func (ctl *Controller) fanOutShardsHandler(c context.Context, payload proto.Message) error {
msg := payload.(*tasks.FanOutShards)
// Make sure the job is still present. If it is aborted, we still need to
// launch the shards, so they notice they are being aborted. We could try
// to abort all shards right here and... | [
"func",
"(",
"ctl",
"*",
"Controller",
")",
"fanOutShardsHandler",
"(",
"c",
"context",
".",
"Context",
",",
"payload",
"proto",
".",
"Message",
")",
"error",
"{",
"msg",
":=",
"payload",
".",
"(",
"*",
"tasks",
".",
"FanOutShards",
")",
"\n\n",
"// Make... | // fanOutShardsHandler fetches a list of shards from the job and launches
// named ProcessShard tasks, one per shard. | [
"fanOutShardsHandler",
"fetches",
"a",
"list",
"of",
"shards",
"from",
"the",
"job",
"and",
"launches",
"named",
"ProcessShard",
"tasks",
"one",
"per",
"shard",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/appengine/mapper/controller.go#L442-L470 |
129,811 | luci/luci-go | appengine/mapper/controller.go | requestJobStateUpdate | func (ctl *Controller) requestJobStateUpdate(c context.Context, jobID JobID, shardID int64) error {
return ctl.tq().AddTask(c, &tq.Task{
Title: fmt.Sprintf("notify:job-%d-shard-%d", jobID, shardID),
Payload: &tasks.RequestJobStateUpdate{
JobId: int64(jobID),
ShardId: shardID,
},
})
} | go | func (ctl *Controller) requestJobStateUpdate(c context.Context, jobID JobID, shardID int64) error {
return ctl.tq().AddTask(c, &tq.Task{
Title: fmt.Sprintf("notify:job-%d-shard-%d", jobID, shardID),
Payload: &tasks.RequestJobStateUpdate{
JobId: int64(jobID),
ShardId: shardID,
},
})
} | [
"func",
"(",
"ctl",
"*",
"Controller",
")",
"requestJobStateUpdate",
"(",
"c",
"context",
".",
"Context",
",",
"jobID",
"JobID",
",",
"shardID",
"int64",
")",
"error",
"{",
"return",
"ctl",
".",
"tq",
"(",
")",
".",
"AddTask",
"(",
"c",
",",
"&",
"tq... | // requestJobStateUpdate submits RequestJobStateUpdate task, which eventually
// causes updateJobStateHandler to execute. | [
"requestJobStateUpdate",
"submits",
"RequestJobStateUpdate",
"task",
"which",
"eventually",
"causes",
"updateJobStateHandler",
"to",
"execute",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/appengine/mapper/controller.go#L702-L710 |
129,812 | luci/luci-go | appengine/mapper/controller.go | updateJobStateHandler | func (ctl *Controller) updateJobStateHandler(c context.Context, payload proto.Message) error {
msg := payload.(*tasks.UpdateJobState)
// Get the job and all its shards in their most recent state.
job, err := getJobInState(c, JobID(msg.JobId), State_RUNNING, State_ABORTING)
if err != nil || job == nil {
return er... | go | func (ctl *Controller) updateJobStateHandler(c context.Context, payload proto.Message) error {
msg := payload.(*tasks.UpdateJobState)
// Get the job and all its shards in their most recent state.
job, err := getJobInState(c, JobID(msg.JobId), State_RUNNING, State_ABORTING)
if err != nil || job == nil {
return er... | [
"func",
"(",
"ctl",
"*",
"Controller",
")",
"updateJobStateHandler",
"(",
"c",
"context",
".",
"Context",
",",
"payload",
"proto",
".",
"Message",
")",
"error",
"{",
"msg",
":=",
"payload",
".",
"(",
"*",
"tasks",
".",
"UpdateJobState",
")",
"\n\n",
"// ... | // updateJobStateHandler is called some time later after one or more shards have
// changed state.
//
// It calculates overall job state based on the state of its shards. | [
"updateJobStateHandler",
"is",
"called",
"some",
"time",
"later",
"after",
"one",
"or",
"more",
"shards",
"have",
"changed",
"state",
".",
"It",
"calculates",
"overall",
"job",
"state",
"based",
"on",
"the",
"state",
"of",
"its",
"shards",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/appengine/mapper/controller.go#L739-L808 |
129,813 | luci/luci-go | starlark/starlarkproto/loader.go | injectEnumValues | func injectEnumValues(d starlark.StringDict, enum *descpb.EnumDescriptorProto) {
for _, val := range enum.Value {
d[val.GetName()] = starlark.MakeInt(int(val.GetNumber()))
}
} | go | func injectEnumValues(d starlark.StringDict, enum *descpb.EnumDescriptorProto) {
for _, val := range enum.Value {
d[val.GetName()] = starlark.MakeInt(int(val.GetNumber()))
}
} | [
"func",
"injectEnumValues",
"(",
"d",
"starlark",
".",
"StringDict",
",",
"enum",
"*",
"descpb",
".",
"EnumDescriptorProto",
")",
"{",
"for",
"_",
",",
"val",
":=",
"range",
"enum",
".",
"Value",
"{",
"d",
"[",
"val",
".",
"GetName",
"(",
")",
"]",
"... | // injectEnumValues takes enum constants defined in 'enum' and puts them
// directly into the given dict as integers. | [
"injectEnumValues",
"takes",
"enum",
"constants",
"defined",
"in",
"enum",
"and",
"puts",
"them",
"directly",
"into",
"the",
"given",
"dict",
"as",
"integers",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/starlark/starlarkproto/loader.go#L121-L125 |
129,814 | luci/luci-go | starlark/starlarkproto/loader.go | loadFileDesc | func loadFileDesc(name string) (*descpb.FileDescriptorProto, error) {
gzblob := proto.FileDescriptor(name)
if gzblob == nil {
return nil, fmt.Errorf("no such proto file registered")
}
r, err := gzip.NewReader(bytes.NewReader(gzblob))
if err != nil {
return nil, fmt.Errorf("failed to open gzip reader - %s", er... | go | func loadFileDesc(name string) (*descpb.FileDescriptorProto, error) {
gzblob := proto.FileDescriptor(name)
if gzblob == nil {
return nil, fmt.Errorf("no such proto file registered")
}
r, err := gzip.NewReader(bytes.NewReader(gzblob))
if err != nil {
return nil, fmt.Errorf("failed to open gzip reader - %s", er... | [
"func",
"loadFileDesc",
"(",
"name",
"string",
")",
"(",
"*",
"descpb",
".",
"FileDescriptorProto",
",",
"error",
")",
"{",
"gzblob",
":=",
"proto",
".",
"FileDescriptor",
"(",
"name",
")",
"\n",
"if",
"gzblob",
"==",
"nil",
"{",
"return",
"nil",
",",
... | // loadFileDesc loads a FileDescriptorProto for a given proto module, specified
// by its full path.
//
// The module should be registered in the process's protobuf descriptors set. | [
"loadFileDesc",
"loads",
"a",
"FileDescriptorProto",
"for",
"a",
"given",
"proto",
"module",
"specified",
"by",
"its",
"full",
"path",
".",
"The",
"module",
"should",
"be",
"registered",
"in",
"the",
"process",
"s",
"protobuf",
"descriptors",
"set",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/starlark/starlarkproto/loader.go#L131-L154 |
129,815 | luci/luci-go | cipd/appengine/impl/cas/signed_urls.go | signURL | func signURL(c context.Context, gsPath string, signer *signer, expiry time.Duration) (string, error) {
// See https://cloud.google.com/storage/docs/access-control/signed-urls.
//
// Basically, we sign a specially crafted multi-line string that encodes
// expected parameters of the request. During the actual request... | go | func signURL(c context.Context, gsPath string, signer *signer, expiry time.Duration) (string, error) {
// See https://cloud.google.com/storage/docs/access-control/signed-urls.
//
// Basically, we sign a specially crafted multi-line string that encodes
// expected parameters of the request. During the actual request... | [
"func",
"signURL",
"(",
"c",
"context",
".",
"Context",
",",
"gsPath",
"string",
",",
"signer",
"*",
"signer",
",",
"expiry",
"time",
".",
"Duration",
")",
"(",
"string",
",",
"error",
")",
"{",
"// See https://cloud.google.com/storage/docs/access-control/signed-u... | // signURL generates a signed GS URL using the signer. | [
"signURL",
"generates",
"a",
"signed",
"GS",
"URL",
"using",
"the",
"signer",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/cipd/appengine/impl/cas/signed_urls.go#L117-L150 |
129,816 | luci/luci-go | milo/api/config/util.go | AllBuilderIDs | func (c *Console) AllBuilderIDs() []string {
builders := make([]string, 0, len(c.Builders))
for _, b := range c.Builders {
builders = append(builders, b.Name...)
}
return builders
} | go | func (c *Console) AllBuilderIDs() []string {
builders := make([]string, 0, len(c.Builders))
for _, b := range c.Builders {
builders = append(builders, b.Name...)
}
return builders
} | [
"func",
"(",
"c",
"*",
"Console",
")",
"AllBuilderIDs",
"(",
")",
"[",
"]",
"string",
"{",
"builders",
":=",
"make",
"(",
"[",
"]",
"string",
",",
"0",
",",
"len",
"(",
"c",
".",
"Builders",
")",
")",
"\n",
"for",
"_",
",",
"b",
":=",
"range",
... | // AllBuilderIDs returns all BuilderIDs mentioned by this Console. | [
"AllBuilderIDs",
"returns",
"all",
"BuilderIDs",
"mentioned",
"by",
"this",
"Console",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/milo/api/config/util.go#L26-L32 |
129,817 | luci/luci-go | machine-db/appengine/model/oses.go | fetch | func (t *OSesTable) fetch(c context.Context) error {
db := database.Get(c)
rows, err := db.QueryContext(c, `
SELECT id, name, description
FROM oses
`)
if err != nil {
return errors.Annotate(err, "failed to select operating systems").Err()
}
defer rows.Close()
for rows.Next() {
os := &OS{}
if err := row... | go | func (t *OSesTable) fetch(c context.Context) error {
db := database.Get(c)
rows, err := db.QueryContext(c, `
SELECT id, name, description
FROM oses
`)
if err != nil {
return errors.Annotate(err, "failed to select operating systems").Err()
}
defer rows.Close()
for rows.Next() {
os := &OS{}
if err := row... | [
"func",
"(",
"t",
"*",
"OSesTable",
")",
"fetch",
"(",
"c",
"context",
".",
"Context",
")",
"error",
"{",
"db",
":=",
"database",
".",
"Get",
"(",
"c",
")",
"\n",
"rows",
",",
"err",
":=",
"db",
".",
"QueryContext",
"(",
"c",
",",
"`\n\t\tSELECT id... | // fetch fetches the operating systems from the database. | [
"fetch",
"fetches",
"the",
"operating",
"systems",
"from",
"the",
"database",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/machine-db/appengine/model/oses.go#L47-L65 |
129,818 | luci/luci-go | machine-db/appengine/model/oses.go | computeChanges | func (t *OSesTable) computeChanges(c context.Context, oses []*config.OS) {
cfgs := make(map[string]*OS, len(oses))
for _, cfg := range oses {
cfgs[cfg.Name] = &OS{
OS: config.OS{
Name: cfg.Name,
Description: cfg.Description,
},
}
}
for _, os := range t.current {
if cfg, ok := cfgs[os.Nam... | go | func (t *OSesTable) computeChanges(c context.Context, oses []*config.OS) {
cfgs := make(map[string]*OS, len(oses))
for _, cfg := range oses {
cfgs[cfg.Name] = &OS{
OS: config.OS{
Name: cfg.Name,
Description: cfg.Description,
},
}
}
for _, os := range t.current {
if cfg, ok := cfgs[os.Nam... | [
"func",
"(",
"t",
"*",
"OSesTable",
")",
"computeChanges",
"(",
"c",
"context",
".",
"Context",
",",
"oses",
"[",
"]",
"*",
"config",
".",
"OS",
")",
"{",
"cfgs",
":=",
"make",
"(",
"map",
"[",
"string",
"]",
"*",
"OS",
",",
"len",
"(",
"oses",
... | // computeChanges computes the changes that need to be made to the operating systems in the database. | [
"computeChanges",
"computes",
"the",
"changes",
"that",
"need",
"to",
"be",
"made",
"to",
"the",
"operating",
"systems",
"in",
"the",
"database",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/machine-db/appengine/model/oses.go#L73-L107 |
129,819 | luci/luci-go | machine-db/appengine/model/oses.go | remove | func (t *OSesTable) 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 oses
WHERE id = ?
`)
if err != nil {
return errors.Annotate(err, "f... | go | func (t *OSesTable) 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 oses
WHERE id = ?
`)
if err != nil {
return errors.Annotate(err, "f... | [
"func",
"(",
"t",
"*",
"OSesTable",
")",
"remove",
"(",
"c",
"context",
".",
"Context",
")",
"error",
"{",
"// Avoid using the database connection to prepare unnecessary statements.",
"if",
"len",
"(",
"t",
".",
"removals",
")",
"==",
"0",
"{",
"return",
"nil",
... | // remove removes all operating systems pending removal from the database, clearing pending removals.
// No-op unless computeChanges was called first. Idempotent until computeChanges is called again. | [
"remove",
"removes",
"all",
"operating",
"systems",
"pending",
"removal",
"from",
"the",
"database",
"clearing",
"pending",
"removals",
".",
"No",
"-",
"op",
"unless",
"computeChanges",
"was",
"called",
"first",
".",
"Idempotent",
"until",
"computeChanges",
"is",
... | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/machine-db/appengine/model/oses.go#L147-L186 |
129,820 | luci/luci-go | machine-db/appengine/model/oses.go | ids | func (t *OSesTable) ids(c context.Context) map[string]int64 {
oses := make(map[string]int64, len(t.current))
for _, os := range t.current {
oses[os.Name] = os.Id
}
return oses
} | go | func (t *OSesTable) ids(c context.Context) map[string]int64 {
oses := make(map[string]int64, len(t.current))
for _, os := range t.current {
oses[os.Name] = os.Id
}
return oses
} | [
"func",
"(",
"t",
"*",
"OSesTable",
")",
"ids",
"(",
"c",
"context",
".",
"Context",
")",
"map",
"[",
"string",
"]",
"int64",
"{",
"oses",
":=",
"make",
"(",
"map",
"[",
"string",
"]",
"int64",
",",
"len",
"(",
"t",
".",
"current",
")",
")",
"\... | // ids returns a map of operating system names to IDs. | [
"ids",
"returns",
"a",
"map",
"of",
"operating",
"system",
"names",
"to",
"IDs",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/machine-db/appengine/model/oses.go#L230-L236 |
129,821 | luci/luci-go | machine-db/appengine/model/oses.go | EnsureOSes | func EnsureOSes(c context.Context, cfgs []*config.OS) error {
t := &OSesTable{}
if err := t.fetch(c); err != nil {
return errors.Annotate(err, "failed to fetch operating systems").Err()
}
t.computeChanges(c, cfgs)
if err := t.add(c); err != nil {
return errors.Annotate(err, "failed to add operating systems").E... | go | func EnsureOSes(c context.Context, cfgs []*config.OS) error {
t := &OSesTable{}
if err := t.fetch(c); err != nil {
return errors.Annotate(err, "failed to fetch operating systems").Err()
}
t.computeChanges(c, cfgs)
if err := t.add(c); err != nil {
return errors.Annotate(err, "failed to add operating systems").E... | [
"func",
"EnsureOSes",
"(",
"c",
"context",
".",
"Context",
",",
"cfgs",
"[",
"]",
"*",
"config",
".",
"OS",
")",
"error",
"{",
"t",
":=",
"&",
"OSesTable",
"{",
"}",
"\n",
"if",
"err",
":=",
"t",
".",
"fetch",
"(",
"c",
")",
";",
"err",
"!=",
... | // EnsureOSes ensures the database contains exactly the given operating systems. | [
"EnsureOSes",
"ensures",
"the",
"database",
"contains",
"exactly",
"the",
"given",
"operating",
"systems",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/machine-db/appengine/model/oses.go#L239-L255 |
129,822 | luci/luci-go | cipd/common/hash.go | NewHash | func NewHash(algo api.HashAlgo) (hash.Hash, error) {
if err := ValidateHashAlgo(algo); err != nil {
return nil, err
}
return supportedAlgos[algo].hash(), nil
} | go | func NewHash(algo api.HashAlgo) (hash.Hash, error) {
if err := ValidateHashAlgo(algo); err != nil {
return nil, err
}
return supportedAlgos[algo].hash(), nil
} | [
"func",
"NewHash",
"(",
"algo",
"api",
".",
"HashAlgo",
")",
"(",
"hash",
".",
"Hash",
",",
"error",
")",
"{",
"if",
"err",
":=",
"ValidateHashAlgo",
"(",
"algo",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n",
"r... | // NewHash returns a hash implementation or an error if the algo is unknown. | [
"NewHash",
"returns",
"a",
"hash",
"implementation",
"or",
"an",
"error",
"if",
"the",
"algo",
"is",
"unknown",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/cipd/common/hash.go#L55-L60 |
129,823 | luci/luci-go | cipd/common/hash.go | MustNewHash | func MustNewHash(algo api.HashAlgo) hash.Hash {
h, err := NewHash(algo)
if err != nil {
panic(err)
}
return h
} | go | func MustNewHash(algo api.HashAlgo) hash.Hash {
h, err := NewHash(algo)
if err != nil {
panic(err)
}
return h
} | [
"func",
"MustNewHash",
"(",
"algo",
"api",
".",
"HashAlgo",
")",
"hash",
".",
"Hash",
"{",
"h",
",",
"err",
":=",
"NewHash",
"(",
"algo",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"panic",
"(",
"err",
")",
"\n",
"}",
"\n",
"return",
"h",
"\n",
... | // MustNewHash as like NewHash, but panics on errors.
//
// Appropriate for cases when the hash algo has already been validated. | [
"MustNewHash",
"as",
"like",
"NewHash",
"but",
"panics",
"on",
"errors",
".",
"Appropriate",
"for",
"cases",
"when",
"the",
"hash",
"algo",
"has",
"already",
"been",
"validated",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/cipd/common/hash.go#L65-L71 |
129,824 | luci/luci-go | gce/appengine/rpc/instances.go | Delete | func (*Instances) Delete(c context.Context, req *instances.DeleteRequest) (*empty.Empty, error) {
if req.GetId() == "" {
return nil, status.Errorf(codes.InvalidArgument, "ID is required")
}
vm := &model.VM{
ID: req.Id,
}
if err := datastore.RunInTransaction(c, func(c context.Context) error {
switch err := da... | go | func (*Instances) Delete(c context.Context, req *instances.DeleteRequest) (*empty.Empty, error) {
if req.GetId() == "" {
return nil, status.Errorf(codes.InvalidArgument, "ID is required")
}
vm := &model.VM{
ID: req.Id,
}
if err := datastore.RunInTransaction(c, func(c context.Context) error {
switch err := da... | [
"func",
"(",
"*",
"Instances",
")",
"Delete",
"(",
"c",
"context",
".",
"Context",
",",
"req",
"*",
"instances",
".",
"DeleteRequest",
")",
"(",
"*",
"empty",
".",
"Empty",
",",
"error",
")",
"{",
"if",
"req",
".",
"GetId",
"(",
")",
"==",
"\"",
... | // Delete handles a request to delete an instance asynchronously. | [
"Delete",
"handles",
"a",
"request",
"to",
"delete",
"an",
"instance",
"asynchronously",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/gce/appengine/rpc/instances.go#L42-L67 |
129,825 | luci/luci-go | gce/appengine/rpc/instances.go | Get | func (*Instances) Get(c context.Context, req *instances.GetRequest) (*instances.Instance, error) {
switch {
case req.GetId() == "" && req.GetHostname() == "":
return nil, status.Errorf(codes.InvalidArgument, "ID or hostname is required")
case req.Id != "" && req.Hostname != "":
return nil, status.Errorf(codes.In... | go | func (*Instances) Get(c context.Context, req *instances.GetRequest) (*instances.Instance, error) {
switch {
case req.GetId() == "" && req.GetHostname() == "":
return nil, status.Errorf(codes.InvalidArgument, "ID or hostname is required")
case req.Id != "" && req.Hostname != "":
return nil, status.Errorf(codes.In... | [
"func",
"(",
"*",
"Instances",
")",
"Get",
"(",
"c",
"context",
".",
"Context",
",",
"req",
"*",
"instances",
".",
"GetRequest",
")",
"(",
"*",
"instances",
".",
"Instance",
",",
"error",
")",
"{",
"switch",
"{",
"case",
"req",
".",
"GetId",
"(",
"... | // Get handles a request to get an existing instance. | [
"Get",
"handles",
"a",
"request",
"to",
"get",
"an",
"existing",
"instance",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/gce/appengine/rpc/instances.go#L148-L159 |
129,826 | luci/luci-go | gce/appengine/rpc/instances.go | List | func (*Instances) List(c context.Context, req *instances.ListRequest) (*instances.ListResponse, error) {
if req.GetPrefix() == "" {
return nil, status.Errorf(codes.InvalidArgument, "prefix is required")
}
rsp := &instances.ListResponse{}
// TODO(smut): Handle page tokens.
if req.GetPageToken() != "" {
return r... | go | func (*Instances) List(c context.Context, req *instances.ListRequest) (*instances.ListResponse, error) {
if req.GetPrefix() == "" {
return nil, status.Errorf(codes.InvalidArgument, "prefix is required")
}
rsp := &instances.ListResponse{}
// TODO(smut): Handle page tokens.
if req.GetPageToken() != "" {
return r... | [
"func",
"(",
"*",
"Instances",
")",
"List",
"(",
"c",
"context",
".",
"Context",
",",
"req",
"*",
"instances",
".",
"ListRequest",
")",
"(",
"*",
"instances",
".",
"ListResponse",
",",
"error",
")",
"{",
"if",
"req",
".",
"GetPrefix",
"(",
")",
"==",... | // List handles a request to list instances. | [
"List",
"handles",
"a",
"request",
"to",
"list",
"instances",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/gce/appengine/rpc/instances.go#L162-L179 |
129,827 | luci/luci-go | gce/appengine/rpc/instances.go | NewInstancesServer | func NewInstancesServer() instances.InstancesServer {
return &instances.DecoratedInstances{
Prelude: vmAccessPrelude,
Service: &Instances{},
Postlude: gRPCifyAndLogErr,
}
} | go | func NewInstancesServer() instances.InstancesServer {
return &instances.DecoratedInstances{
Prelude: vmAccessPrelude,
Service: &Instances{},
Postlude: gRPCifyAndLogErr,
}
} | [
"func",
"NewInstancesServer",
"(",
")",
"instances",
".",
"InstancesServer",
"{",
"return",
"&",
"instances",
".",
"DecoratedInstances",
"{",
"Prelude",
":",
"vmAccessPrelude",
",",
"Service",
":",
"&",
"Instances",
"{",
"}",
",",
"Postlude",
":",
"gRPCifyAndLog... | // NewInstancesServer returns a new instances server. | [
"NewInstancesServer",
"returns",
"a",
"new",
"instances",
"server",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/gce/appengine/rpc/instances.go#L182-L188 |
129,828 | luci/luci-go | milo/git/client.go | UseACLs | func UseACLs(c context.Context, acls *gitacls.ACLs) context.Context {
return Use(c, &implementation{acls: acls})
} | go | func UseACLs(c context.Context, acls *gitacls.ACLs) context.Context {
return Use(c, &implementation{acls: acls})
} | [
"func",
"UseACLs",
"(",
"c",
"context",
".",
"Context",
",",
"acls",
"*",
"gitacls",
".",
"ACLs",
")",
"context",
".",
"Context",
"{",
"return",
"Use",
"(",
"c",
",",
"&",
"implementation",
"{",
"acls",
":",
"acls",
"}",
")",
"\n",
"}"
] | // UseACLs returns context with production implementation installed. | [
"UseACLs",
"returns",
"context",
"with",
"production",
"implementation",
"installed",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/milo/git/client.go#L97-L99 |
129,829 | luci/luci-go | milo/git/client.go | Use | func Use(c context.Context, s Client) context.Context {
return context.WithValue(c, &contextKey, s)
} | go | func Use(c context.Context, s Client) context.Context {
return context.WithValue(c, &contextKey, s)
} | [
"func",
"Use",
"(",
"c",
"context",
".",
"Context",
",",
"s",
"Client",
")",
"context",
".",
"Context",
"{",
"return",
"context",
".",
"WithValue",
"(",
"c",
",",
"&",
"contextKey",
",",
"s",
")",
"\n",
"}"
] | // Use returns context with provided Client implementation.
//
// Useful in tests, see also gittest.MockClient | [
"Use",
"returns",
"context",
"with",
"provided",
"Client",
"implementation",
".",
"Useful",
"in",
"tests",
"see",
"also",
"gittest",
".",
"MockClient"
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/milo/git/client.go#L104-L106 |
129,830 | luci/luci-go | milo/git/client.go | Get | func Get(c context.Context) Client {
s, ok := c.Value(&contextKey).(Client)
if !ok {
panic(errors.New("git.Client not installed in context"))
}
return s
} | go | func Get(c context.Context) Client {
s, ok := c.Value(&contextKey).(Client)
if !ok {
panic(errors.New("git.Client not installed in context"))
}
return s
} | [
"func",
"Get",
"(",
"c",
"context",
".",
"Context",
")",
"Client",
"{",
"s",
",",
"ok",
":=",
"c",
".",
"Value",
"(",
"&",
"contextKey",
")",
".",
"(",
"Client",
")",
"\n",
"if",
"!",
"ok",
"{",
"panic",
"(",
"errors",
".",
"New",
"(",
"\"",
... | // Get returns Client set in supplied context.
//
// panics if not set. | [
"Get",
"returns",
"Client",
"set",
"in",
"supplied",
"context",
".",
"panics",
"if",
"not",
"set",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/milo/git/client.go#L111-L117 |
129,831 | luci/luci-go | milo/git/client.go | transport | func (p *implementation) transport(c context.Context) (transport http.RoundTripper, err error) {
luciProject, err := ProjectFromContext(c)
if err != nil {
return nil, err
}
opts := []auth.RPCOption{
auth.WithProject(luciProject),
auth.WithScopes(gitiles.OAuthScope),
}
return auth.GetRPCTransport(c, auth.AsP... | go | func (p *implementation) transport(c context.Context) (transport http.RoundTripper, err error) {
luciProject, err := ProjectFromContext(c)
if err != nil {
return nil, err
}
opts := []auth.RPCOption{
auth.WithProject(luciProject),
auth.WithScopes(gitiles.OAuthScope),
}
return auth.GetRPCTransport(c, auth.AsP... | [
"func",
"(",
"p",
"*",
"implementation",
")",
"transport",
"(",
"c",
"context",
".",
"Context",
")",
"(",
"transport",
"http",
".",
"RoundTripper",
",",
"err",
"error",
")",
"{",
"luciProject",
",",
"err",
":=",
"ProjectFromContext",
"(",
"c",
")",
"\n",... | // transport returns an authenticated RoundTripper for Gerrit or Gitiles RPCs. | [
"transport",
"returns",
"an",
"authenticated",
"RoundTripper",
"for",
"Gerrit",
"or",
"Gitiles",
"RPCs",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/milo/git/client.go#L135-L145 |
129,832 | luci/luci-go | common/tsmon/flush.go | Flush | func Flush(c context.Context) error {
return GetState(c).Flush(c, nil)
} | go | func Flush(c context.Context) error {
return GetState(c).Flush(c, nil)
} | [
"func",
"Flush",
"(",
"c",
"context",
".",
"Context",
")",
"error",
"{",
"return",
"GetState",
"(",
"c",
")",
".",
"Flush",
"(",
"c",
",",
"nil",
")",
"\n",
"}"
] | // Flush sends all the metrics that are registered in the application. | [
"Flush",
"sends",
"all",
"the",
"metrics",
"that",
"are",
"registered",
"in",
"the",
"application",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/common/tsmon/flush.go#L26-L28 |
129,833 | luci/luci-go | gce/appengine/config/config.go | withInterface | func withInterface(c context.Context, cfg config.Interface) context.Context {
return context.WithValue(c, &cfgKey, cfg)
} | go | func withInterface(c context.Context, cfg config.Interface) context.Context {
return context.WithValue(c, &cfgKey, cfg)
} | [
"func",
"withInterface",
"(",
"c",
"context",
".",
"Context",
",",
"cfg",
"config",
".",
"Interface",
")",
"context",
".",
"Context",
"{",
"return",
"context",
".",
"WithValue",
"(",
"c",
",",
"&",
"cfgKey",
",",
"cfg",
")",
"\n",
"}"
] | // withInterface returns a new context with the given config.Interface
// installed. | [
"withInterface",
"returns",
"a",
"new",
"context",
"with",
"the",
"given",
"config",
".",
"Interface",
"installed",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/gce/appengine/config/config.go#L62-L64 |
129,834 | luci/luci-go | gce/appengine/config/config.go | getInterface | func getInterface(c context.Context) config.Interface {
return c.Value(&cfgKey).(config.Interface)
} | go | func getInterface(c context.Context) config.Interface {
return c.Value(&cfgKey).(config.Interface)
} | [
"func",
"getInterface",
"(",
"c",
"context",
".",
"Context",
")",
"config",
".",
"Interface",
"{",
"return",
"c",
".",
"Value",
"(",
"&",
"cfgKey",
")",
".",
"(",
"config",
".",
"Interface",
")",
"\n",
"}"
] | // getInterface returns the config.Interface installed in the current context. | [
"getInterface",
"returns",
"the",
"config",
".",
"Interface",
"installed",
"in",
"the",
"current",
"context",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/gce/appengine/config/config.go#L67-L69 |
129,835 | luci/luci-go | gce/appengine/config/config.go | withProjServer | func withProjServer(c context.Context, srv projects.ProjectsServer) context.Context {
return context.WithValue(c, &prjKey, srv)
} | go | func withProjServer(c context.Context, srv projects.ProjectsServer) context.Context {
return context.WithValue(c, &prjKey, srv)
} | [
"func",
"withProjServer",
"(",
"c",
"context",
".",
"Context",
",",
"srv",
"projects",
".",
"ProjectsServer",
")",
"context",
".",
"Context",
"{",
"return",
"context",
".",
"WithValue",
"(",
"c",
",",
"&",
"prjKey",
",",
"srv",
")",
"\n",
"}"
] | // withProjServer returns a new context with the given projects.ProjectsServer
// installed. | [
"withProjServer",
"returns",
"a",
"new",
"context",
"with",
"the",
"given",
"projects",
".",
"ProjectsServer",
"installed",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/gce/appengine/config/config.go#L76-L78 |
129,836 | luci/luci-go | gce/appengine/config/config.go | getProjServer | func getProjServer(c context.Context) projects.ProjectsServer {
return c.Value(&prjKey).(projects.ProjectsServer)
} | go | func getProjServer(c context.Context) projects.ProjectsServer {
return c.Value(&prjKey).(projects.ProjectsServer)
} | [
"func",
"getProjServer",
"(",
"c",
"context",
".",
"Context",
")",
"projects",
".",
"ProjectsServer",
"{",
"return",
"c",
".",
"Value",
"(",
"&",
"prjKey",
")",
".",
"(",
"projects",
".",
"ProjectsServer",
")",
"\n",
"}"
] | // getProjServer returns the projects.ProjectsServer installed in the current
// context. | [
"getProjServer",
"returns",
"the",
"projects",
".",
"ProjectsServer",
"installed",
"in",
"the",
"current",
"context",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/gce/appengine/config/config.go#L82-L84 |
129,837 | luci/luci-go | gce/appengine/config/config.go | withVMsServer | func withVMsServer(c context.Context, srv gce.ConfigurationServer) context.Context {
return context.WithValue(c, &vmsKey, srv)
} | go | func withVMsServer(c context.Context, srv gce.ConfigurationServer) context.Context {
return context.WithValue(c, &vmsKey, srv)
} | [
"func",
"withVMsServer",
"(",
"c",
"context",
".",
"Context",
",",
"srv",
"gce",
".",
"ConfigurationServer",
")",
"context",
".",
"Context",
"{",
"return",
"context",
".",
"WithValue",
"(",
"c",
",",
"&",
"vmsKey",
",",
"srv",
")",
"\n",
"}"
] | // withVMsServer returns a new context with the given gce.ConfigurationServer
// installed. | [
"withVMsServer",
"returns",
"a",
"new",
"context",
"with",
"the",
"given",
"gce",
".",
"ConfigurationServer",
"installed",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/gce/appengine/config/config.go#L91-L93 |
129,838 | luci/luci-go | gce/appengine/config/config.go | getVMsServer | func getVMsServer(c context.Context) gce.ConfigurationServer {
return c.Value(&vmsKey).(gce.ConfigurationServer)
} | go | func getVMsServer(c context.Context) gce.ConfigurationServer {
return c.Value(&vmsKey).(gce.ConfigurationServer)
} | [
"func",
"getVMsServer",
"(",
"c",
"context",
".",
"Context",
")",
"gce",
".",
"ConfigurationServer",
"{",
"return",
"c",
".",
"Value",
"(",
"&",
"vmsKey",
")",
".",
"(",
"gce",
".",
"ConfigurationServer",
")",
"\n",
"}"
] | // getVMsServer returns the gce.ConfigurationServer installed in the current
// context. | [
"getVMsServer",
"returns",
"the",
"gce",
".",
"ConfigurationServer",
"installed",
"in",
"the",
"current",
"context",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/gce/appengine/config/config.go#L97-L99 |
129,839 | luci/luci-go | gce/appengine/config/config.go | newInterface | func newInterface(c context.Context) config.Interface {
s, err := gaeconfig.FetchCachedSettings(c)
if err != nil {
panic(err)
}
t, err := auth.GetRPCTransport(c, auth.AsSelf)
if err != nil {
panic(err)
}
return remote.New(s.ConfigServiceHost, false, func(c context.Context) (*http.Client, error) {
return &h... | go | func newInterface(c context.Context) config.Interface {
s, err := gaeconfig.FetchCachedSettings(c)
if err != nil {
panic(err)
}
t, err := auth.GetRPCTransport(c, auth.AsSelf)
if err != nil {
panic(err)
}
return remote.New(s.ConfigServiceHost, false, func(c context.Context) (*http.Client, error) {
return &h... | [
"func",
"newInterface",
"(",
"c",
"context",
".",
"Context",
")",
"config",
".",
"Interface",
"{",
"s",
",",
"err",
":=",
"gaeconfig",
".",
"FetchCachedSettings",
"(",
"c",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"panic",
"(",
"err",
")",
"\n",
"}"... | // newInterface returns a new config.Interface. Panics on error. | [
"newInterface",
"returns",
"a",
"new",
"config",
".",
"Interface",
".",
"Panics",
"on",
"error",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/gce/appengine/config/config.go#L102-L114 |
129,840 | luci/luci-go | gce/appengine/config/config.go | fetch | func fetch(c context.Context) (*Config, error) {
cli := getInterface(c)
set := cfgclient.CurrentServiceConfigSet(c)
// If VMs and kinds are both non-empty, then their revisions must match
// because VMs may depend on kinds. If VMs is empty but kinds is not,
// then kinds are declared but unused (which is fine). I... | go | func fetch(c context.Context) (*Config, error) {
cli := getInterface(c)
set := cfgclient.CurrentServiceConfigSet(c)
// If VMs and kinds are both non-empty, then their revisions must match
// because VMs may depend on kinds. If VMs is empty but kinds is not,
// then kinds are declared but unused (which is fine). I... | [
"func",
"fetch",
"(",
"c",
"context",
".",
"Context",
")",
"(",
"*",
"Config",
",",
"error",
")",
"{",
"cli",
":=",
"getInterface",
"(",
"c",
")",
"\n",
"set",
":=",
"cfgclient",
".",
"CurrentServiceConfigSet",
"(",
"c",
")",
"\n\n",
"// If VMs and kinds... | // fetch fetches configs from the config service. | [
"fetch",
"fetches",
"configs",
"from",
"the",
"config",
"service",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/gce/appengine/config/config.go#L117-L178 |
129,841 | luci/luci-go | gce/appengine/config/config.go | validate | func validate(c context.Context, cfg *Config) error {
v := &validation.Context{Context: c}
v.SetFile(kindsFile)
cfg.Kinds.Validate(v)
v.SetFile(projectsFile)
cfg.Projects.Validate(v)
v.SetFile(vmsFile)
cfg.VMs.Validate(v)
return v.Finalize()
} | go | func validate(c context.Context, cfg *Config) error {
v := &validation.Context{Context: c}
v.SetFile(kindsFile)
cfg.Kinds.Validate(v)
v.SetFile(projectsFile)
cfg.Projects.Validate(v)
v.SetFile(vmsFile)
cfg.VMs.Validate(v)
return v.Finalize()
} | [
"func",
"validate",
"(",
"c",
"context",
".",
"Context",
",",
"cfg",
"*",
"Config",
")",
"error",
"{",
"v",
":=",
"&",
"validation",
".",
"Context",
"{",
"Context",
":",
"c",
"}",
"\n",
"v",
".",
"SetFile",
"(",
"kindsFile",
")",
"\n",
"cfg",
".",
... | // validate validates configs. | [
"validate",
"validates",
"configs",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/gce/appengine/config/config.go#L181-L190 |
129,842 | luci/luci-go | gce/appengine/config/config.go | merge | func merge(c context.Context, cfg *Config) error {
kindsMap := cfg.Kinds.Map()
for _, v := range cfg.VMs.GetVms() {
if v.Kind != "" {
k, ok := kindsMap[v.Kind]
if !ok {
return errors.Reason("unknown kind %q", v.Kind).Err()
}
// Merge the config's attributes into a copy of the kind's.
// This ensu... | go | func merge(c context.Context, cfg *Config) error {
kindsMap := cfg.Kinds.Map()
for _, v := range cfg.VMs.GetVms() {
if v.Kind != "" {
k, ok := kindsMap[v.Kind]
if !ok {
return errors.Reason("unknown kind %q", v.Kind).Err()
}
// Merge the config's attributes into a copy of the kind's.
// This ensu... | [
"func",
"merge",
"(",
"c",
"context",
".",
"Context",
",",
"cfg",
"*",
"Config",
")",
"error",
"{",
"kindsMap",
":=",
"cfg",
".",
"Kinds",
".",
"Map",
"(",
")",
"\n",
"for",
"_",
",",
"v",
":=",
"range",
"cfg",
".",
"VMs",
".",
"GetVms",
"(",
"... | // merge merges validated configs.
// Each config's referenced Kind is used to fill out unset values in its attributes. | [
"merge",
"merges",
"validated",
"configs",
".",
"Each",
"config",
"s",
"referenced",
"Kind",
"is",
"used",
"to",
"fill",
"out",
"unset",
"values",
"in",
"its",
"attributes",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/gce/appengine/config/config.go#L194-L224 |
129,843 | luci/luci-go | gce/appengine/config/config.go | deref | func deref(c context.Context, cfg *Config) error {
// Cache fetched files.
fileMap := make(map[string]string)
cli := getInterface(c)
set := cfgclient.CurrentServiceConfigSet(c)
for _, v := range cfg.VMs.GetVms() {
for i, m := range v.GetAttributes().Metadata {
if m.GetFromFile() != "" {
parts := strings.S... | go | func deref(c context.Context, cfg *Config) error {
// Cache fetched files.
fileMap := make(map[string]string)
cli := getInterface(c)
set := cfgclient.CurrentServiceConfigSet(c)
for _, v := range cfg.VMs.GetVms() {
for i, m := range v.GetAttributes().Metadata {
if m.GetFromFile() != "" {
parts := strings.S... | [
"func",
"deref",
"(",
"c",
"context",
".",
"Context",
",",
"cfg",
"*",
"Config",
")",
"error",
"{",
"// Cache fetched files.",
"fileMap",
":=",
"make",
"(",
"map",
"[",
"string",
"]",
"string",
")",
"\n",
"cli",
":=",
"getInterface",
"(",
"c",
")",
"\n... | // deref dereferences VMs metadata by fetching referenced files. | [
"deref",
"dereferences",
"VMs",
"metadata",
"by",
"fetching",
"referenced",
"files",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/gce/appengine/config/config.go#L227-L261 |
129,844 | luci/luci-go | gce/appengine/config/config.go | normalize | func normalize(c context.Context, cfg *Config) error {
for _, p := range cfg.Projects.GetProject() {
p.Revision = cfg.revision
}
for _, v := range cfg.VMs.GetVms() {
for _, ch := range v.Amount.GetChange() {
if err := ch.Length.Normalize(); err != nil {
return errors.Annotate(err, "failed to normalize %q"... | go | func normalize(c context.Context, cfg *Config) error {
for _, p := range cfg.Projects.GetProject() {
p.Revision = cfg.revision
}
for _, v := range cfg.VMs.GetVms() {
for _, ch := range v.Amount.GetChange() {
if err := ch.Length.Normalize(); err != nil {
return errors.Annotate(err, "failed to normalize %q"... | [
"func",
"normalize",
"(",
"c",
"context",
".",
"Context",
",",
"cfg",
"*",
"Config",
")",
"error",
"{",
"for",
"_",
",",
"p",
":=",
"range",
"cfg",
".",
"Projects",
".",
"GetProject",
"(",
")",
"{",
"p",
".",
"Revision",
"=",
"cfg",
".",
"revision"... | // normalize normalizes VMs durations by converting them to seconds, and sets
// output-only properties. | [
"normalize",
"normalizes",
"VMs",
"durations",
"by",
"converting",
"them",
"to",
"seconds",
"and",
"sets",
"output",
"-",
"only",
"properties",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/gce/appengine/config/config.go#L265-L284 |
129,845 | luci/luci-go | gce/appengine/config/config.go | syncVMs | func syncVMs(c context.Context, vms []*gce.Config) error {
// Fetch existing configs.
srv := getVMsServer(c)
rsp, err := srv.List(c, &gce.ListRequest{})
if err != nil {
return errors.Annotate(err, "failed to fetch VMs configs").Err()
}
// Track the revision of each config.
revs := make(map[string]string, len(r... | go | func syncVMs(c context.Context, vms []*gce.Config) error {
// Fetch existing configs.
srv := getVMsServer(c)
rsp, err := srv.List(c, &gce.ListRequest{})
if err != nil {
return errors.Annotate(err, "failed to fetch VMs configs").Err()
}
// Track the revision of each config.
revs := make(map[string]string, len(r... | [
"func",
"syncVMs",
"(",
"c",
"context",
".",
"Context",
",",
"vms",
"[",
"]",
"*",
"gce",
".",
"Config",
")",
"error",
"{",
"// Fetch existing configs.",
"srv",
":=",
"getVMsServer",
"(",
"c",
")",
"\n",
"rsp",
",",
"err",
":=",
"srv",
".",
"List",
"... | // syncVMs synchronizes the given validated VM configs. | [
"syncVMs",
"synchronizes",
"the",
"given",
"validated",
"VM",
"configs",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/gce/appengine/config/config.go#L287-L326 |
129,846 | luci/luci-go | gce/appengine/config/config.go | syncPrjs | func syncPrjs(c context.Context, prjs []*projects.Config) error {
// Fetch existing configs.
srv := getProjServer(c)
rsp, err := srv.List(c, &projects.ListRequest{})
if err != nil {
return errors.Annotate(err, "failed to fetch project configs").Err()
}
// Track the revision of each config.
revs := make(map[str... | go | func syncPrjs(c context.Context, prjs []*projects.Config) error {
// Fetch existing configs.
srv := getProjServer(c)
rsp, err := srv.List(c, &projects.ListRequest{})
if err != nil {
return errors.Annotate(err, "failed to fetch project configs").Err()
}
// Track the revision of each config.
revs := make(map[str... | [
"func",
"syncPrjs",
"(",
"c",
"context",
".",
"Context",
",",
"prjs",
"[",
"]",
"*",
"projects",
".",
"Config",
")",
"error",
"{",
"// Fetch existing configs.",
"srv",
":=",
"getProjServer",
"(",
"c",
")",
"\n",
"rsp",
",",
"err",
":=",
"srv",
".",
"Li... | // syncPrjs synchronizes the given validated project configs. | [
"syncPrjs",
"synchronizes",
"the",
"given",
"validated",
"project",
"configs",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/gce/appengine/config/config.go#L329-L368 |
129,847 | luci/luci-go | gce/appengine/config/config.go | sync | func sync(c context.Context, cfg *Config) error {
if err := syncVMs(c, cfg.VMs.GetVms()); err != nil {
return errors.Annotate(err, "failed to sync VMs configs").Err()
}
if err := syncPrjs(c, cfg.Projects.GetProject()); err != nil {
return errors.Annotate(err, "failed to sync project configs").Err()
}
return ni... | go | func sync(c context.Context, cfg *Config) error {
if err := syncVMs(c, cfg.VMs.GetVms()); err != nil {
return errors.Annotate(err, "failed to sync VMs configs").Err()
}
if err := syncPrjs(c, cfg.Projects.GetProject()); err != nil {
return errors.Annotate(err, "failed to sync project configs").Err()
}
return ni... | [
"func",
"sync",
"(",
"c",
"context",
".",
"Context",
",",
"cfg",
"*",
"Config",
")",
"error",
"{",
"if",
"err",
":=",
"syncVMs",
"(",
"c",
",",
"cfg",
".",
"VMs",
".",
"GetVms",
"(",
")",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"errors",
"... | // sync synchronizes the given validated configs. | [
"sync",
"synchronizes",
"the",
"given",
"validated",
"configs",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/gce/appengine/config/config.go#L371-L379 |
129,848 | luci/luci-go | gce/appengine/config/config.go | Import | func Import(c context.Context) error {
cfg, err := fetch(c)
if err != nil {
return errors.Annotate(err, "failed to fetch configs").Err()
}
// Merge before validating. VMs may be invalid until referenced kinds are applied.
if err := merge(c, cfg); err != nil {
return errors.Annotate(err, "failed to merge kinds... | go | func Import(c context.Context) error {
cfg, err := fetch(c)
if err != nil {
return errors.Annotate(err, "failed to fetch configs").Err()
}
// Merge before validating. VMs may be invalid until referenced kinds are applied.
if err := merge(c, cfg); err != nil {
return errors.Annotate(err, "failed to merge kinds... | [
"func",
"Import",
"(",
"c",
"context",
".",
"Context",
")",
"error",
"{",
"cfg",
",",
"err",
":=",
"fetch",
"(",
"c",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"errors",
".",
"Annotate",
"(",
"err",
",",
"\"",
"\"",
")",
".",
"Err",
"... | // Import fetches and validates configs from the config service. | [
"Import",
"fetches",
"and",
"validates",
"configs",
"from",
"the",
"config",
"service",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/gce/appengine/config/config.go#L382-L410 |
129,849 | luci/luci-go | gce/appengine/config/config.go | importHandler | func importHandler(c *router.Context) {
c.Writer.Header().Set("Content-Type", "text/plain")
if err := Import(c.Context); err != nil {
errors.Log(c.Context, err)
c.Writer.WriteHeader(http.StatusInternalServerError)
return
}
c.Writer.WriteHeader(http.StatusOK)
} | go | func importHandler(c *router.Context) {
c.Writer.Header().Set("Content-Type", "text/plain")
if err := Import(c.Context); err != nil {
errors.Log(c.Context, err)
c.Writer.WriteHeader(http.StatusInternalServerError)
return
}
c.Writer.WriteHeader(http.StatusOK)
} | [
"func",
"importHandler",
"(",
"c",
"*",
"router",
".",
"Context",
")",
"{",
"c",
".",
"Writer",
".",
"Header",
"(",
")",
".",
"Set",
"(",
"\"",
"\"",
",",
"\"",
"\"",
")",
"\n\n",
"if",
"err",
":=",
"Import",
"(",
"c",
".",
"Context",
")",
";",... | // importHandler imports the config from the config service. | [
"importHandler",
"imports",
"the",
"config",
"from",
"the",
"config",
"service",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/gce/appengine/config/config.go#L413-L423 |
129,850 | luci/luci-go | cipd/client/cli/main.go | writeJSONOutput | func (c *cipdSubcommand) writeJSONOutput(result interface{}, err error) error {
// -json-output flag wasn't specified.
if c.jsonOutput == "" {
return err
}
// Prepare the body of the output file.
var body struct {
Error string `json:"error,omitempty"`
Result interface{} `json:"result,omitempty"`
}
i... | go | func (c *cipdSubcommand) writeJSONOutput(result interface{}, err error) error {
// -json-output flag wasn't specified.
if c.jsonOutput == "" {
return err
}
// Prepare the body of the output file.
var body struct {
Error string `json:"error,omitempty"`
Result interface{} `json:"result,omitempty"`
}
i... | [
"func",
"(",
"c",
"*",
"cipdSubcommand",
")",
"writeJSONOutput",
"(",
"result",
"interface",
"{",
"}",
",",
"err",
"error",
")",
"error",
"{",
"// -json-output flag wasn't specified.",
"if",
"c",
".",
"jsonOutput",
"==",
"\"",
"\"",
"{",
"return",
"err",
"\n... | // writeJSONOutput writes result to JSON output file. It returns original error
// if it is non-nil. | [
"writeJSONOutput",
"writes",
"result",
"to",
"JSON",
"output",
"file",
".",
"It",
"returns",
"original",
"error",
"if",
"it",
"is",
"non",
"-",
"nil",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/cipd/client/cli/main.go#L213-L249 |
129,851 | luci/luci-go | cipd/client/cli/main.go | doneWithPins | func (c *cipdSubcommand) doneWithPins(pins []pinInfo, err error) int {
return c.doneWithPinMap(map[string][]pinInfo{"": pins}, err)
} | go | func (c *cipdSubcommand) doneWithPins(pins []pinInfo, err error) int {
return c.doneWithPinMap(map[string][]pinInfo{"": pins}, err)
} | [
"func",
"(",
"c",
"*",
"cipdSubcommand",
")",
"doneWithPins",
"(",
"pins",
"[",
"]",
"pinInfo",
",",
"err",
"error",
")",
"int",
"{",
"return",
"c",
".",
"doneWithPinMap",
"(",
"map",
"[",
"string",
"]",
"[",
"]",
"pinInfo",
"{",
"\"",
"\"",
":",
"... | // doneWithPins is a handy shortcut that prints a pinInfo slice and
// deduces process exit code based on presence of errors there.
//
// This just calls through to doneWithPinMap. | [
"doneWithPins",
"is",
"a",
"handy",
"shortcut",
"that",
"prints",
"a",
"pinInfo",
"slice",
"and",
"deduces",
"process",
"exit",
"code",
"based",
"on",
"presence",
"of",
"errors",
"there",
".",
"This",
"just",
"calls",
"through",
"to",
"doneWithPinMap",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/cipd/client/cli/main.go#L267-L269 |
129,852 | luci/luci-go | cipd/client/cli/main.go | doneWithPinMap | func (c *cipdSubcommand) doneWithPinMap(pins map[string][]pinInfo, err error) int {
if len(pins) == 0 {
if err == nil { // this error will be printed in c.done(...)
fmt.Println("No packages.")
}
} else {
printPinsAndError(pins)
}
if ret := c.done(pins, err); ret != 0 {
return ret
}
for _, infos := rang... | go | func (c *cipdSubcommand) doneWithPinMap(pins map[string][]pinInfo, err error) int {
if len(pins) == 0 {
if err == nil { // this error will be printed in c.done(...)
fmt.Println("No packages.")
}
} else {
printPinsAndError(pins)
}
if ret := c.done(pins, err); ret != 0 {
return ret
}
for _, infos := rang... | [
"func",
"(",
"c",
"*",
"cipdSubcommand",
")",
"doneWithPinMap",
"(",
"pins",
"map",
"[",
"string",
"]",
"[",
"]",
"pinInfo",
",",
"err",
"error",
")",
"int",
"{",
"if",
"len",
"(",
"pins",
")",
"==",
"0",
"{",
"if",
"err",
"==",
"nil",
"{",
"// t... | // doneWithPinMap is a handy shortcut that prints the subdir->pinInfo map and
// deduces process exit code based on presence of errors there. | [
"doneWithPinMap",
"is",
"a",
"handy",
"shortcut",
"that",
"prints",
"the",
"subdir",
"-",
">",
"pinInfo",
"map",
"and",
"deduces",
"process",
"exit",
"code",
"based",
"on",
"presence",
"of",
"errors",
"there",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/cipd/client/cli/main.go#L273-L290 |
129,853 | luci/luci-go | cipd/client/cli/main.go | makeCLIError | func makeCLIError(msg string, args ...interface{}) error {
return commandLineError{fmt.Errorf(msg, args...)}
} | go | func makeCLIError(msg string, args ...interface{}) error {
return commandLineError{fmt.Errorf(msg, args...)}
} | [
"func",
"makeCLIError",
"(",
"msg",
"string",
",",
"args",
"...",
"interface",
"{",
"}",
")",
"error",
"{",
"return",
"commandLineError",
"{",
"fmt",
".",
"Errorf",
"(",
"msg",
",",
"args",
"...",
")",
"}",
"\n",
"}"
] | // makeCLIError returns new commandLineError. | [
"makeCLIError",
"returns",
"new",
"commandLineError",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/cipd/client/cli/main.go#L298-L300 |
129,854 | luci/luci-go | cipd/client/cli/main.go | prepareInput | func (opts *inputOptions) prepareInput() (builder.Options, error) {
empty := builder.Options{}
if opts.compressionLevel < 0 || opts.compressionLevel > 9 {
return empty, makeCLIError("invalid -compression-level: must be in [0-9] set")
}
// Handle -name and -in if defined. Do not allow -pkg-def in that case, sinc... | go | func (opts *inputOptions) prepareInput() (builder.Options, error) {
empty := builder.Options{}
if opts.compressionLevel < 0 || opts.compressionLevel > 9 {
return empty, makeCLIError("invalid -compression-level: must be in [0-9] set")
}
// Handle -name and -in if defined. Do not allow -pkg-def in that case, sinc... | [
"func",
"(",
"opts",
"*",
"inputOptions",
")",
"prepareInput",
"(",
")",
"(",
"builder",
".",
"Options",
",",
"error",
")",
"{",
"empty",
":=",
"builder",
".",
"Options",
"{",
"}",
"\n\n",
"if",
"opts",
".",
"compressionLevel",
"<",
"0",
"||",
"opts",
... | // prepareInput processes inputOptions by collecting all files to be added to
// a package and populating builder.Options. Caller is still responsible to fill
// out Output field of Options. | [
"prepareInput",
"processes",
"inputOptions",
"by",
"collecting",
"all",
"files",
"to",
"be",
"added",
"to",
"a",
"package",
"and",
"populating",
"builder",
".",
"Options",
".",
"Caller",
"is",
"still",
"responsible",
"to",
"fill",
"out",
"Output",
"field",
"of... | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/cipd/client/cli/main.go#L462-L545 |
129,855 | luci/luci-go | cipd/client/cli/main.go | String | func (ha *hashAlgoFlag) String() string {
return strings.ToLower(api.HashAlgo(*ha).String())
} | go | func (ha *hashAlgoFlag) String() string {
return strings.ToLower(api.HashAlgo(*ha).String())
} | [
"func",
"(",
"ha",
"*",
"hashAlgoFlag",
")",
"String",
"(",
")",
"string",
"{",
"return",
"strings",
".",
"ToLower",
"(",
"api",
".",
"HashAlgo",
"(",
"*",
"ha",
")",
".",
"String",
"(",
")",
")",
"\n",
"}"
] | // String is called by 'flag' package when displaying default value of a flag. | [
"String",
"is",
"called",
"by",
"flag",
"package",
"when",
"displaying",
"default",
"value",
"of",
"a",
"flag",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/cipd/client/cli/main.go#L647-L649 |
129,856 | luci/luci-go | cipd/client/cli/main.go | loadEnsureFile | func (opts *ensureFileOptions) loadEnsureFile(ctx context.Context, clientOpts *clientOptions, verifying verifyingEnsureFile, parseVers versionFileOpt) (*ensure.File, error) {
parsedFile, err := ensure.LoadEnsureFile(opts.ensureFile)
if err != nil {
return nil, err
}
// Prefer the ServiceURL from the file (if set... | go | func (opts *ensureFileOptions) loadEnsureFile(ctx context.Context, clientOpts *clientOptions, verifying verifyingEnsureFile, parseVers versionFileOpt) (*ensure.File, error) {
parsedFile, err := ensure.LoadEnsureFile(opts.ensureFile)
if err != nil {
return nil, err
}
// Prefer the ServiceURL from the file (if set... | [
"func",
"(",
"opts",
"*",
"ensureFileOptions",
")",
"loadEnsureFile",
"(",
"ctx",
"context",
".",
"Context",
",",
"clientOpts",
"*",
"clientOptions",
",",
"verifying",
"verifyingEnsureFile",
",",
"parseVers",
"versionFileOpt",
")",
"(",
"*",
"ensure",
".",
"File... | // loadEnsureFile parses the ensure file and mutates clientOpts to point to a
// service URL specified in the ensure file. | [
"loadEnsureFile",
"parses",
"the",
"ensure",
"file",
"and",
"mutates",
"clientOpts",
"to",
"point",
"to",
"a",
"service",
"URL",
"specified",
"in",
"the",
"ensure",
"file",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/cipd/client/cli/main.go#L737-L769 |
129,857 | luci/luci-go | cipd/client/cli/main.go | loadClientVersion | func loadClientVersion(path string) (string, error) {
blob, err := ioutil.ReadFile(path)
if err != nil {
return "", err
}
version := strings.TrimSpace(string(blob))
if err := common.ValidateInstanceVersion(version); err != nil {
return "", err
}
return version, nil
} | go | func loadClientVersion(path string) (string, error) {
blob, err := ioutil.ReadFile(path)
if err != nil {
return "", err
}
version := strings.TrimSpace(string(blob))
if err := common.ValidateInstanceVersion(version); err != nil {
return "", err
}
return version, nil
} | [
"func",
"loadClientVersion",
"(",
"path",
"string",
")",
"(",
"string",
",",
"error",
")",
"{",
"blob",
",",
"err",
":=",
"ioutil",
".",
"ReadFile",
"(",
"path",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"\"",
"\"",
",",
"err",
"\n",
"}",... | // loadClientVersion reads a version string from a file. | [
"loadClientVersion",
"reads",
"a",
"version",
"string",
"from",
"a",
"file",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/cipd/client/cli/main.go#L2731-L2741 |
129,858 | luci/luci-go | cipd/client/cli/main.go | assembleClientDigests | func assembleClientDigests(ctx context.Context, c cipd.Client, version string) (*digests.ClientDigestsFile, []pinInfo, error) {
if !strings.HasSuffix(cipd.ClientPackage, "/${platform}") {
panic(fmt.Sprintf("client package template (%q) is expected to end with '${platform}'", cipd.ClientPackage))
}
out := &digests... | go | func assembleClientDigests(ctx context.Context, c cipd.Client, version string) (*digests.ClientDigestsFile, []pinInfo, error) {
if !strings.HasSuffix(cipd.ClientPackage, "/${platform}") {
panic(fmt.Sprintf("client package template (%q) is expected to end with '${platform}'", cipd.ClientPackage))
}
out := &digests... | [
"func",
"assembleClientDigests",
"(",
"ctx",
"context",
".",
"Context",
",",
"c",
"cipd",
".",
"Client",
",",
"version",
"string",
")",
"(",
"*",
"digests",
".",
"ClientDigestsFile",
",",
"[",
"]",
"pinInfo",
",",
"error",
")",
"{",
"if",
"!",
"strings",... | // assembleClientDigests produces the digests file by making backend RPCs. | [
"assembleClientDigests",
"produces",
"the",
"digests",
"file",
"by",
"making",
"backend",
"RPCs",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/cipd/client/cli/main.go#L2760-L2799 |
129,859 | luci/luci-go | cipd/client/cli/main.go | Main | func Main(params Parameters, args []string) int {
return subcommands.Run(GetApplication(params), fixflagpos.FixSubcommands(args))
} | go | func Main(params Parameters, args []string) int {
return subcommands.Run(GetApplication(params), fixflagpos.FixSubcommands(args))
} | [
"func",
"Main",
"(",
"params",
"Parameters",
",",
"args",
"[",
"]",
"string",
")",
"int",
"{",
"return",
"subcommands",
".",
"Run",
"(",
"GetApplication",
"(",
"params",
")",
",",
"fixflagpos",
".",
"FixSubcommands",
"(",
"args",
")",
")",
"\n",
"}"
] | // Main runs the CIPD CLI.
// | [
"Main",
"runs",
"the",
"CIPD",
"CLI",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/cipd/client/cli/main.go#L2989-L2991 |
129,860 | luci/luci-go | common/isolated/utils.go | Sum | func Sum(h hash.Hash) HexDigest {
return HexDigest(hex.EncodeToString(h.Sum(nil)))
} | go | func Sum(h hash.Hash) HexDigest {
return HexDigest(hex.EncodeToString(h.Sum(nil)))
} | [
"func",
"Sum",
"(",
"h",
"hash",
".",
"Hash",
")",
"HexDigest",
"{",
"return",
"HexDigest",
"(",
"hex",
".",
"EncodeToString",
"(",
"h",
".",
"Sum",
"(",
"nil",
")",
")",
")",
"\n",
"}"
] | // Sum is a shortcut to get a HexDigest from a hash.Hash. | [
"Sum",
"is",
"a",
"shortcut",
"to",
"get",
"a",
"HexDigest",
"from",
"a",
"hash",
".",
"Hash",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/common/isolated/utils.go#L28-L30 |
129,861 | luci/luci-go | common/isolated/utils.go | Hash | func Hash(h crypto.Hash, src io.Reader) (HexDigest, error) {
a := h.New()
_, err := io.Copy(a, src)
if err != nil {
return HexDigest(""), err
}
return Sum(a), nil
} | go | func Hash(h crypto.Hash, src io.Reader) (HexDigest, error) {
a := h.New()
_, err := io.Copy(a, src)
if err != nil {
return HexDigest(""), err
}
return Sum(a), nil
} | [
"func",
"Hash",
"(",
"h",
"crypto",
".",
"Hash",
",",
"src",
"io",
".",
"Reader",
")",
"(",
"HexDigest",
",",
"error",
")",
"{",
"a",
":=",
"h",
".",
"New",
"(",
")",
"\n",
"_",
",",
"err",
":=",
"io",
".",
"Copy",
"(",
"a",
",",
"src",
")"... | // Hash hashes a reader and returns a HexDigest from it. | [
"Hash",
"hashes",
"a",
"reader",
"and",
"returns",
"a",
"HexDigest",
"from",
"it",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/common/isolated/utils.go#L33-L40 |
129,862 | luci/luci-go | common/isolated/utils.go | HashBytes | func HashBytes(h crypto.Hash, content []byte) HexDigest {
a := h.New()
_, _ = a.Write(content)
return Sum(a)
} | go | func HashBytes(h crypto.Hash, content []byte) HexDigest {
a := h.New()
_, _ = a.Write(content)
return Sum(a)
} | [
"func",
"HashBytes",
"(",
"h",
"crypto",
".",
"Hash",
",",
"content",
"[",
"]",
"byte",
")",
"HexDigest",
"{",
"a",
":=",
"h",
".",
"New",
"(",
")",
"\n",
"_",
",",
"_",
"=",
"a",
".",
"Write",
"(",
"content",
")",
"\n",
"return",
"Sum",
"(",
... | // HashBytes hashes content and returns a HexDigest from it. | [
"HashBytes",
"hashes",
"content",
"and",
"returns",
"a",
"HexDigest",
"from",
"it",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/common/isolated/utils.go#L43-L47 |
129,863 | luci/luci-go | common/isolated/utils.go | HashFile | func HashFile(h crypto.Hash, path string) (isolateservice.HandlersEndpointsV1Digest, error) {
f, err := os.Open(path)
if err != nil {
return isolateservice.HandlersEndpointsV1Digest{}, err
}
defer f.Close()
a := h.New()
size, err := io.Copy(a, f)
if err != nil {
return isolateservice.HandlersEndpointsV1Diges... | go | func HashFile(h crypto.Hash, path string) (isolateservice.HandlersEndpointsV1Digest, error) {
f, err := os.Open(path)
if err != nil {
return isolateservice.HandlersEndpointsV1Digest{}, err
}
defer f.Close()
a := h.New()
size, err := io.Copy(a, f)
if err != nil {
return isolateservice.HandlersEndpointsV1Diges... | [
"func",
"HashFile",
"(",
"h",
"crypto",
".",
"Hash",
",",
"path",
"string",
")",
"(",
"isolateservice",
".",
"HandlersEndpointsV1Digest",
",",
"error",
")",
"{",
"f",
",",
"err",
":=",
"os",
".",
"Open",
"(",
"path",
")",
"\n",
"if",
"err",
"!=",
"ni... | // HashFile hashes a file and returns a HandlersEndpointsV1Digest out of it. | [
"HashFile",
"hashes",
"a",
"file",
"and",
"returns",
"a",
"HandlersEndpointsV1Digest",
"out",
"of",
"it",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/common/isolated/utils.go#L50-L62 |
129,864 | luci/luci-go | common/tsmon/field/utils.go | Hash | func Hash(fieldVals []interface{}) uint64 {
if len(fieldVals) == 0 {
// Avoid allocating the hasher if there are no fieldVals
return 0
}
h := fnv.New64a()
for _, v := range fieldVals {
switch v := v.(type) {
case string:
h.Write([]byte(v))
case int64:
b := [8]byte{}
for i := 0; i < 8; i++ {
... | go | func Hash(fieldVals []interface{}) uint64 {
if len(fieldVals) == 0 {
// Avoid allocating the hasher if there are no fieldVals
return 0
}
h := fnv.New64a()
for _, v := range fieldVals {
switch v := v.(type) {
case string:
h.Write([]byte(v))
case int64:
b := [8]byte{}
for i := 0; i < 8; i++ {
... | [
"func",
"Hash",
"(",
"fieldVals",
"[",
"]",
"interface",
"{",
"}",
")",
"uint64",
"{",
"if",
"len",
"(",
"fieldVals",
")",
"==",
"0",
"{",
"// Avoid allocating the hasher if there are no fieldVals",
"return",
"0",
"\n",
"}",
"\n",
"h",
":=",
"fnv",
".",
"N... | // Hash returns a uint64 hash of fieldVals. | [
"Hash",
"returns",
"a",
"uint64",
"hash",
"of",
"fieldVals",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/common/tsmon/field/utils.go#L60-L87 |
129,865 | luci/luci-go | logdog/appengine/coordinator/settings.go | validatePercent | func validatePercent(v string) error {
if v == "" {
return nil
}
i, err := strconv.Atoi(v)
if err != nil {
return fmt.Errorf("invalid integer %q - %s", v, err)
}
if i < 0 || i > 100 {
return fmt.Errorf("%d is out of range (0-100)", i)
}
return nil
} | go | func validatePercent(v string) error {
if v == "" {
return nil
}
i, err := strconv.Atoi(v)
if err != nil {
return fmt.Errorf("invalid integer %q - %s", v, err)
}
if i < 0 || i > 100 {
return fmt.Errorf("%d is out of range (0-100)", i)
}
return nil
} | [
"func",
"validatePercent",
"(",
"v",
"string",
")",
"error",
"{",
"if",
"v",
"==",
"\"",
"\"",
"{",
"return",
"nil",
"\n",
"}",
"\n",
"i",
",",
"err",
":=",
"strconv",
".",
"Atoi",
"(",
"v",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"... | // validatePercent validates a string is empty or an integer between 0-100. | [
"validatePercent",
"validates",
"a",
"string",
"is",
"empty",
"or",
"an",
"integer",
"between",
"0",
"-",
"100",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/logdog/appengine/coordinator/settings.go#L202-L214 |
129,866 | luci/luci-go | logdog/appengine/coordinator/settings.go | validateInt | func validateInt(v string) error {
if v == "" {
return nil
}
_, err := strconv.Atoi(v)
return err
} | go | func validateInt(v string) error {
if v == "" {
return nil
}
_, err := strconv.Atoi(v)
return err
} | [
"func",
"validateInt",
"(",
"v",
"string",
")",
"error",
"{",
"if",
"v",
"==",
"\"",
"\"",
"{",
"return",
"nil",
"\n",
"}",
"\n",
"_",
",",
"err",
":=",
"strconv",
".",
"Atoi",
"(",
"v",
")",
"\n",
"return",
"err",
"\n",
"}"
] | // validateInt validates that a string is empty or an integer. | [
"validateInt",
"validates",
"that",
"a",
"string",
"is",
"empty",
"or",
"an",
"integer",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/logdog/appengine/coordinator/settings.go#L217-L223 |
129,867 | luci/luci-go | logdog/appengine/coordinator/settings.go | GetSettings | func GetSettings(c context.Context) *Settings {
set := Settings{}
switch err := settings.Get(c, baseName, &set); err {
case nil:
break
case settings.ErrNoSettings:
// Defaults.
set = defaultSettings
default:
panic(fmt.Errorf("could not fetch Archivist settings - %s", err))
}
return &set
} | go | func GetSettings(c context.Context) *Settings {
set := Settings{}
switch err := settings.Get(c, baseName, &set); err {
case nil:
break
case settings.ErrNoSettings:
// Defaults.
set = defaultSettings
default:
panic(fmt.Errorf("could not fetch Archivist settings - %s", err))
}
return &set
} | [
"func",
"GetSettings",
"(",
"c",
"context",
".",
"Context",
")",
"*",
"Settings",
"{",
"set",
":=",
"Settings",
"{",
"}",
"\n",
"switch",
"err",
":=",
"settings",
".",
"Get",
"(",
"c",
",",
"baseName",
",",
"&",
"set",
")",
";",
"err",
"{",
"case",... | // GetSettings returns the current settings.
//
// It first tries to load it from settings. If no settings is installed, or if
// there is no configuration in settings, defaultSettings is returned. | [
"GetSettings",
"returns",
"the",
"current",
"settings",
".",
"It",
"first",
"tries",
"to",
"load",
"it",
"from",
"settings",
".",
"If",
"no",
"settings",
"is",
"installed",
"or",
"if",
"there",
"is",
"no",
"configuration",
"in",
"settings",
"defaultSettings",
... | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/logdog/appengine/coordinator/settings.go#L244-L256 |
129,868 | luci/luci-go | vpython/api/vpython/util.go | Clone | func (e *Environment) Clone() *Environment {
if e == nil {
return &Environment{}
}
return proto.Clone(e).(*Environment)
} | go | func (e *Environment) Clone() *Environment {
if e == nil {
return &Environment{}
}
return proto.Clone(e).(*Environment)
} | [
"func",
"(",
"e",
"*",
"Environment",
")",
"Clone",
"(",
")",
"*",
"Environment",
"{",
"if",
"e",
"==",
"nil",
"{",
"return",
"&",
"Environment",
"{",
"}",
"\n",
"}",
"\n",
"return",
"proto",
".",
"Clone",
"(",
"e",
")",
".",
"(",
"*",
"Environme... | // Clone returns a deep clone of the supplied Environment.
//
// If e is nil, a non-nil empty Environment will be returned. | [
"Clone",
"returns",
"a",
"deep",
"clone",
"of",
"the",
"supplied",
"Environment",
".",
"If",
"e",
"is",
"nil",
"a",
"non",
"-",
"nil",
"empty",
"Environment",
"will",
"be",
"returned",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/vpython/api/vpython/util.go#L33-L38 |
129,869 | luci/luci-go | vpython/api/vpython/util.go | IsZero | func (t *PEP425Tag) IsZero() bool {
return t == nil || (t.Python == "" && t.Abi == "" && t.Platform == "")
} | go | func (t *PEP425Tag) IsZero() bool {
return t == nil || (t.Python == "" && t.Abi == "" && t.Platform == "")
} | [
"func",
"(",
"t",
"*",
"PEP425Tag",
")",
"IsZero",
"(",
")",
"bool",
"{",
"return",
"t",
"==",
"nil",
"||",
"(",
"t",
".",
"Python",
"==",
"\"",
"\"",
"&&",
"t",
".",
"Abi",
"==",
"\"",
"\"",
"&&",
"t",
".",
"Platform",
"==",
"\"",
"\"",
")",... | // IsZero returns true if this tag is a zero value. | [
"IsZero",
"returns",
"true",
"if",
"this",
"tag",
"is",
"a",
"zero",
"value",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/vpython/api/vpython/util.go#L41-L43 |
129,870 | luci/luci-go | vpython/api/vpython/util.go | TagString | func (t *PEP425Tag) TagString() string {
return strings.Join([]string{t.Python, t.Abi, t.Platform}, "-")
} | go | func (t *PEP425Tag) TagString() string {
return strings.Join([]string{t.Python, t.Abi, t.Platform}, "-")
} | [
"func",
"(",
"t",
"*",
"PEP425Tag",
")",
"TagString",
"(",
")",
"string",
"{",
"return",
"strings",
".",
"Join",
"(",
"[",
"]",
"string",
"{",
"t",
".",
"Python",
",",
"t",
".",
"Abi",
",",
"t",
".",
"Platform",
"}",
",",
"\"",
"\"",
")",
"\n",... | // TagString returns an underscore-separated string containing t's fields. | [
"TagString",
"returns",
"an",
"underscore",
"-",
"separated",
"string",
"containing",
"t",
"s",
"fields",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/vpython/api/vpython/util.go#L46-L48 |
129,871 | luci/luci-go | vpython/api/vpython/util.go | Count | func (t *PEP425Tag) Count() (v int) {
if t.HasABI() {
v++
}
if t.AnyPlatform() {
v++
}
return
} | go | func (t *PEP425Tag) Count() (v int) {
if t.HasABI() {
v++
}
if t.AnyPlatform() {
v++
}
return
} | [
"func",
"(",
"t",
"*",
"PEP425Tag",
")",
"Count",
"(",
")",
"(",
"v",
"int",
")",
"{",
"if",
"t",
".",
"HasABI",
"(",
")",
"{",
"v",
"++",
"\n",
"}",
"\n",
"if",
"t",
".",
"AnyPlatform",
"(",
")",
"{",
"v",
"++",
"\n",
"}",
"\n",
"return",
... | // Count returns the number of populated fields in this tag. | [
"Count",
"returns",
"the",
"number",
"of",
"populated",
"fields",
"in",
"this",
"tag",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/vpython/api/vpython/util.go#L57-L65 |
129,872 | luci/luci-go | vpython/api/vpython/util.go | Clone | func (s *Spec) Clone() *Spec {
if s == nil {
return &Spec{}
}
return proto.Clone(s).(*Spec)
} | go | func (s *Spec) Clone() *Spec {
if s == nil {
return &Spec{}
}
return proto.Clone(s).(*Spec)
} | [
"func",
"(",
"s",
"*",
"Spec",
")",
"Clone",
"(",
")",
"*",
"Spec",
"{",
"if",
"s",
"==",
"nil",
"{",
"return",
"&",
"Spec",
"{",
"}",
"\n",
"}",
"\n",
"return",
"proto",
".",
"Clone",
"(",
"s",
")",
".",
"(",
"*",
"Spec",
")",
"\n",
"}"
] | // Clone returns a deep clone of the supplied Spec.
//
// If e is nil, a non-nil empty Spec will be returned. | [
"Clone",
"returns",
"a",
"deep",
"clone",
"of",
"the",
"supplied",
"Spec",
".",
"If",
"e",
"is",
"nil",
"a",
"non",
"-",
"nil",
"empty",
"Spec",
"will",
"be",
"returned",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/vpython/api/vpython/util.go#L70-L75 |
129,873 | luci/luci-go | dm/api/service/v1/queries.go | AttemptRangeQuery | func AttemptRangeQuery(quest string, low, high uint32) *GraphQuery {
return &GraphQuery{
AttemptRange: []*GraphQuery_AttemptRange{{Quest: quest, Low: low, High: high}}}
} | go | func AttemptRangeQuery(quest string, low, high uint32) *GraphQuery {
return &GraphQuery{
AttemptRange: []*GraphQuery_AttemptRange{{Quest: quest, Low: low, High: high}}}
} | [
"func",
"AttemptRangeQuery",
"(",
"quest",
"string",
",",
"low",
",",
"high",
"uint32",
")",
"*",
"GraphQuery",
"{",
"return",
"&",
"GraphQuery",
"{",
"AttemptRange",
":",
"[",
"]",
"*",
"GraphQuery_AttemptRange",
"{",
"{",
"Quest",
":",
"quest",
",",
"Low... | // AttemptRangeQuery returns a new GraphQuery for the given AttemptRange
// specification. | [
"AttemptRangeQuery",
"returns",
"a",
"new",
"GraphQuery",
"for",
"the",
"given",
"AttemptRange",
"specification",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/dm/api/service/v1/queries.go#L30-L33 |
129,874 | luci/luci-go | logdog/client/annotee/link_generator.go | GetLink | func (g *CoordinatorLinkGenerator) GetLink(names ...types.StreamName) string {
paths := make([]types.StreamPath, len(names))
for i, name := range names {
paths[i] = g.Prefix.AsPathPrefix(name)
}
return viewer.GetURL(g.Host, g.Project, paths...)
} | go | func (g *CoordinatorLinkGenerator) GetLink(names ...types.StreamName) string {
paths := make([]types.StreamPath, len(names))
for i, name := range names {
paths[i] = g.Prefix.AsPathPrefix(name)
}
return viewer.GetURL(g.Host, g.Project, paths...)
} | [
"func",
"(",
"g",
"*",
"CoordinatorLinkGenerator",
")",
"GetLink",
"(",
"names",
"...",
"types",
".",
"StreamName",
")",
"string",
"{",
"paths",
":=",
"make",
"(",
"[",
"]",
"types",
".",
"StreamPath",
",",
"len",
"(",
"names",
")",
")",
"\n",
"for",
... | // GetLink implements LinkGenerator. | [
"GetLink",
"implements",
"LinkGenerator",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/logdog/client/annotee/link_generator.go#L44-L50 |
129,875 | luci/luci-go | server/router/handler.go | RunMiddleware | func RunMiddleware(c *Context, mc MiddlewareChain, h Handler) {
runChains(c, mc, MiddlewareChain{}, h)
} | go | func RunMiddleware(c *Context, mc MiddlewareChain, h Handler) {
runChains(c, mc, MiddlewareChain{}, h)
} | [
"func",
"RunMiddleware",
"(",
"c",
"*",
"Context",
",",
"mc",
"MiddlewareChain",
",",
"h",
"Handler",
")",
"{",
"runChains",
"(",
"c",
",",
"mc",
",",
"MiddlewareChain",
"{",
"}",
",",
"h",
")",
"\n",
"}"
] | // RunMiddleware executes the middleware chain and handlers with the given
// initial context. Useful to execute a chain of functions in tests. | [
"RunMiddleware",
"executes",
"the",
"middleware",
"chain",
"and",
"handlers",
"with",
"the",
"given",
"initial",
"context",
".",
"Useful",
"to",
"execute",
"a",
"chain",
"of",
"functions",
"in",
"tests",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/server/router/handler.go#L43-L45 |
129,876 | luci/luci-go | server/router/handler.go | NewMiddlewareChain | func NewMiddlewareChain(mw ...Middleware) (mc MiddlewareChain) {
if len(mw) > 0 {
mc = mc.Extend(mw...)
}
return
} | go | func NewMiddlewareChain(mw ...Middleware) (mc MiddlewareChain) {
if len(mw) > 0 {
mc = mc.Extend(mw...)
}
return
} | [
"func",
"NewMiddlewareChain",
"(",
"mw",
"...",
"Middleware",
")",
"(",
"mc",
"MiddlewareChain",
")",
"{",
"if",
"len",
"(",
"mw",
")",
">",
"0",
"{",
"mc",
"=",
"mc",
".",
"Extend",
"(",
"mw",
"...",
")",
"\n",
"}",
"\n",
"return",
"\n",
"}"
] | // NewMiddlewareChain creates a new MiddlewareChain with the supplied Middleware
// entries. | [
"NewMiddlewareChain",
"creates",
"a",
"new",
"MiddlewareChain",
"with",
"the",
"supplied",
"Middleware",
"entries",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/server/router/handler.go#L49-L54 |
129,877 | luci/luci-go | server/router/handler.go | Extend | func (mc MiddlewareChain) Extend(mw ...Middleware) MiddlewareChain {
if len(mw) == 0 {
return mc
}
ext := make([]Middleware, 0, len(mc.middleware)+len(mw))
return MiddlewareChain{append(append(ext, mc.middleware...), mw...)}
} | go | func (mc MiddlewareChain) Extend(mw ...Middleware) MiddlewareChain {
if len(mw) == 0 {
return mc
}
ext := make([]Middleware, 0, len(mc.middleware)+len(mw))
return MiddlewareChain{append(append(ext, mc.middleware...), mw...)}
} | [
"func",
"(",
"mc",
"MiddlewareChain",
")",
"Extend",
"(",
"mw",
"...",
"Middleware",
")",
"MiddlewareChain",
"{",
"if",
"len",
"(",
"mw",
")",
"==",
"0",
"{",
"return",
"mc",
"\n",
"}",
"\n\n",
"ext",
":=",
"make",
"(",
"[",
"]",
"Middleware",
",",
... | // Extend returns a new MiddlewareChain with the supplied Middleware appended to
// the end. | [
"Extend",
"returns",
"a",
"new",
"MiddlewareChain",
"with",
"the",
"supplied",
"Middleware",
"appended",
"to",
"the",
"end",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/server/router/handler.go#L58-L65 |
129,878 | luci/luci-go | server/router/handler.go | ExtendFrom | func (mc MiddlewareChain) ExtendFrom(other MiddlewareChain) MiddlewareChain {
return mc.Extend(other.middleware...)
} | go | func (mc MiddlewareChain) ExtendFrom(other MiddlewareChain) MiddlewareChain {
return mc.Extend(other.middleware...)
} | [
"func",
"(",
"mc",
"MiddlewareChain",
")",
"ExtendFrom",
"(",
"other",
"MiddlewareChain",
")",
"MiddlewareChain",
"{",
"return",
"mc",
".",
"Extend",
"(",
"other",
".",
"middleware",
"...",
")",
"\n",
"}"
] | // ExtendFrom returns a new MiddlewareChain with the supplied MiddlewareChain
// appended to the end. | [
"ExtendFrom",
"returns",
"a",
"new",
"MiddlewareChain",
"with",
"the",
"supplied",
"MiddlewareChain",
"appended",
"to",
"the",
"end",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/server/router/handler.go#L69-L71 |
129,879 | luci/luci-go | server/router/handler.go | run | func run(c *Context, m, n []Middleware, h Handler) {
switch {
case len(m) > 0:
if m[0] != nil {
m[0](c, func(ctx *Context) { run(ctx, m[1:], n, h) })
} else {
run(c, m[1:], n, h)
}
case len(n) > 0:
if n[0] != nil {
n[0](c, func(ctx *Context) { run(ctx, nil, n[1:], h) })
} else {
run(c, nil, n[1... | go | func run(c *Context, m, n []Middleware, h Handler) {
switch {
case len(m) > 0:
if m[0] != nil {
m[0](c, func(ctx *Context) { run(ctx, m[1:], n, h) })
} else {
run(c, m[1:], n, h)
}
case len(n) > 0:
if n[0] != nil {
n[0](c, func(ctx *Context) { run(ctx, nil, n[1:], h) })
} else {
run(c, nil, n[1... | [
"func",
"run",
"(",
"c",
"*",
"Context",
",",
"m",
",",
"n",
"[",
"]",
"Middleware",
",",
"h",
"Handler",
")",
"{",
"switch",
"{",
"case",
"len",
"(",
"m",
")",
">",
"0",
":",
"if",
"m",
"[",
"0",
"]",
"!=",
"nil",
"{",
"m",
"[",
"0",
"]"... | // run executes the middleware chains m and n and the handler h using
// c as the initial context. If a middleware or handler is nil, run
// simply advances to the next middleware or handler. | [
"run",
"executes",
"the",
"middleware",
"chains",
"m",
"and",
"n",
"and",
"the",
"handler",
"h",
"using",
"c",
"as",
"the",
"initial",
"context",
".",
"If",
"a",
"middleware",
"or",
"handler",
"is",
"nil",
"run",
"simply",
"advances",
"to",
"the",
"next"... | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/server/router/handler.go#L80-L97 |
129,880 | luci/luci-go | dm/appengine/distributor/jobsim/run.go | getRandom | func getRandom(c context.Context, want int) ([]byte, error) {
ret := make([]byte, want)
_, err := cryptorand.Read(c, ret)
if err != nil {
logging.WithError(err).Errorf(c, "could not generate random data")
return nil, err
}
return ret, nil
} | go | func getRandom(c context.Context, want int) ([]byte, error) {
ret := make([]byte, want)
_, err := cryptorand.Read(c, ret)
if err != nil {
logging.WithError(err).Errorf(c, "could not generate random data")
return nil, err
}
return ret, nil
} | [
"func",
"getRandom",
"(",
"c",
"context",
".",
"Context",
",",
"want",
"int",
")",
"(",
"[",
"]",
"byte",
",",
"error",
")",
"{",
"ret",
":=",
"make",
"(",
"[",
"]",
"byte",
",",
"want",
")",
"\n",
"_",
",",
"err",
":=",
"cryptorand",
".",
"Rea... | // getRandom returns a random byte sequence of `want` length, or an error if
// that number of random bytes could not be generated.
//
// This uses cryptorand to generate cryptographically secure random numbers. | [
"getRandom",
"returns",
"a",
"random",
"byte",
"sequence",
"of",
"want",
"length",
"or",
"an",
"error",
"if",
"that",
"number",
"of",
"random",
"bytes",
"could",
"not",
"be",
"generated",
".",
"This",
"uses",
"cryptorand",
"to",
"generate",
"cryptographically"... | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/dm/appengine/distributor/jobsim/run.go#L96-L104 |
129,881 | luci/luci-go | dm/appengine/distributor/jobsim/run.go | doReturnStage | func (r *runner) doReturnStage(stg *jobsim.ReturnStage) error {
retval := int64(0)
if stg != nil {
retval += stg.Retval
}
if r.state != nil {
retval += r.state.Sum
}
_, err := r.dmc.FinishAttempt(r.c, &dm.FinishAttemptReq{
Auth: r.auth,
Data: executionResult(true, retval, google.TimeFromProto(stg.GetExpi... | go | func (r *runner) doReturnStage(stg *jobsim.ReturnStage) error {
retval := int64(0)
if stg != nil {
retval += stg.Retval
}
if r.state != nil {
retval += r.state.Sum
}
_, err := r.dmc.FinishAttempt(r.c, &dm.FinishAttemptReq{
Auth: r.auth,
Data: executionResult(true, retval, google.TimeFromProto(stg.GetExpi... | [
"func",
"(",
"r",
"*",
"runner",
")",
"doReturnStage",
"(",
"stg",
"*",
"jobsim",
".",
"ReturnStage",
")",
"error",
"{",
"retval",
":=",
"int64",
"(",
"0",
")",
"\n",
"if",
"stg",
"!=",
"nil",
"{",
"retval",
"+=",
"stg",
".",
"Retval",
"\n",
"}",
... | // doReturnStage implements the FinishAttempt portion of the DM Attempt
// lifecycle. This sets the final result for the Attempt, and will prevent any
// further executions of this Attempt. This is analogous to the recipe returning
// a final result. | [
"doReturnStage",
"implements",
"the",
"FinishAttempt",
"portion",
"of",
"the",
"DM",
"Attempt",
"lifecycle",
".",
"This",
"sets",
"the",
"final",
"result",
"for",
"the",
"Attempt",
"and",
"will",
"prevent",
"any",
"further",
"executions",
"of",
"this",
"Attempt"... | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/dm/appengine/distributor/jobsim/run.go#L143-L160 |
129,882 | luci/luci-go | common/data/strpair/pair.go | ParseMap | func ParseMap(raw []string) Map {
m := make(Map, len(raw))
for _, t := range raw {
m.Add(Parse(t))
}
return m
} | go | func ParseMap(raw []string) Map {
m := make(Map, len(raw))
for _, t := range raw {
m.Add(Parse(t))
}
return m
} | [
"func",
"ParseMap",
"(",
"raw",
"[",
"]",
"string",
")",
"Map",
"{",
"m",
":=",
"make",
"(",
"Map",
",",
"len",
"(",
"raw",
")",
")",
"\n",
"for",
"_",
",",
"t",
":=",
"range",
"raw",
"{",
"m",
".",
"Add",
"(",
"Parse",
"(",
"t",
")",
")",
... | // ParseMap parses a list of colon-delimited key-value pair strings. | [
"ParseMap",
"parses",
"a",
"list",
"of",
"colon",
"-",
"delimited",
"key",
"-",
"value",
"pair",
"strings",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/common/data/strpair/pair.go#L86-L92 |
129,883 | luci/luci-go | common/data/strpair/pair.go | Format | func (m Map) Format() []string {
res := make([]string, 0, len(m))
for k, values := range m {
for _, v := range values {
res = append(res, Format(k, v))
}
}
sort.Strings(res)
return res
} | go | func (m Map) Format() []string {
res := make([]string, 0, len(m))
for k, values := range m {
for _, v := range values {
res = append(res, Format(k, v))
}
}
sort.Strings(res)
return res
} | [
"func",
"(",
"m",
"Map",
")",
"Format",
"(",
")",
"[",
"]",
"string",
"{",
"res",
":=",
"make",
"(",
"[",
"]",
"string",
",",
"0",
",",
"len",
"(",
"m",
")",
")",
"\n",
"for",
"k",
",",
"values",
":=",
"range",
"m",
"{",
"for",
"_",
",",
... | // Format converts m to a sorted list of strings. | [
"Format",
"converts",
"m",
"to",
"a",
"sorted",
"list",
"of",
"strings",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/common/data/strpair/pair.go#L95-L104 |
129,884 | luci/luci-go | common/data/strpair/pair.go | Copy | func (m Map) Copy() Map {
cpy := make(Map, len(m))
for k, vs := range m {
cpy[k] = append([]string(nil), vs...)
}
return cpy
} | go | func (m Map) Copy() Map {
cpy := make(Map, len(m))
for k, vs := range m {
cpy[k] = append([]string(nil), vs...)
}
return cpy
} | [
"func",
"(",
"m",
"Map",
")",
"Copy",
"(",
")",
"Map",
"{",
"cpy",
":=",
"make",
"(",
"Map",
",",
"len",
"(",
"m",
")",
")",
"\n",
"for",
"k",
",",
"vs",
":=",
"range",
"m",
"{",
"cpy",
"[",
"k",
"]",
"=",
"append",
"(",
"[",
"]",
"string... | // Copy returns a deep copy of m. | [
"Copy",
"returns",
"a",
"deep",
"copy",
"of",
"m",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/common/data/strpair/pair.go#L107-L113 |
129,885 | luci/luci-go | common/data/strpair/pair.go | Contains | func (m Map) Contains(key, value string) bool {
for _, v := range m[key] {
if v == value {
return true
}
}
return false
} | go | func (m Map) Contains(key, value string) bool {
for _, v := range m[key] {
if v == value {
return true
}
}
return false
} | [
"func",
"(",
"m",
"Map",
")",
"Contains",
"(",
"key",
",",
"value",
"string",
")",
"bool",
"{",
"for",
"_",
",",
"v",
":=",
"range",
"m",
"[",
"key",
"]",
"{",
"if",
"v",
"==",
"value",
"{",
"return",
"true",
"\n",
"}",
"\n",
"}",
"\n",
"retu... | // Contains returns true if m contains the key-value pair. | [
"Contains",
"returns",
"true",
"if",
"m",
"contains",
"the",
"key",
"-",
"value",
"pair",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/common/data/strpair/pair.go#L116-L123 |
129,886 | luci/luci-go | milo/buildsource/swarming/buildLog.go | swarmingBuildLogImpl | func swarmingBuildLogImpl(c context.Context, svc SwarmingService, taskID, logname string) (string, bool, error) {
server := svc.GetHost()
cached, err := mc.GetKey(c, path.Join("swarmingLog", server, taskID, logname))
switch {
case err == mc.ErrCacheMiss:
case err != nil:
logging.WithError(err).Errorf(c, "failed... | go | func swarmingBuildLogImpl(c context.Context, svc SwarmingService, taskID, logname string) (string, bool, error) {
server := svc.GetHost()
cached, err := mc.GetKey(c, path.Join("swarmingLog", server, taskID, logname))
switch {
case err == mc.ErrCacheMiss:
case err != nil:
logging.WithError(err).Errorf(c, "failed... | [
"func",
"swarmingBuildLogImpl",
"(",
"c",
"context",
".",
"Context",
",",
"svc",
"SwarmingService",
",",
"taskID",
",",
"logname",
"string",
")",
"(",
"string",
",",
"bool",
",",
"error",
")",
"{",
"server",
":=",
"svc",
".",
"GetHost",
"(",
")",
"\n",
... | // swarmingBuildLogImpl is the implementation for getting a log name from
// a swarming build via annotee. It returns the full text of the specific log,
// and whether or not it has been closed. | [
"swarmingBuildLogImpl",
"is",
"the",
"implementation",
"for",
"getting",
"a",
"log",
"name",
"from",
"a",
"swarming",
"build",
"via",
"annotee",
".",
"It",
"returns",
"the",
"full",
"text",
"of",
"the",
"specific",
"log",
"and",
"whether",
"or",
"not",
"it",... | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/milo/buildsource/swarming/buildLog.go#L30-L74 |
129,887 | luci/luci-go | tokenserver/appengine/impl/serviceaccounts/grant.go | SignGrant | func SignGrant(c context.Context, signer signing.Signer, tok *tokenserver.OAuthTokenGrantBody) (string, error) {
s := tokensigning.Signer{
Signer: signer,
SigningContext: tokenSigningContext,
Wrap: func(w *tokensigning.Unwrapped) proto.Message {
return &tokenserver.OAuthTokenGrantEnvelope{
TokenBo... | go | func SignGrant(c context.Context, signer signing.Signer, tok *tokenserver.OAuthTokenGrantBody) (string, error) {
s := tokensigning.Signer{
Signer: signer,
SigningContext: tokenSigningContext,
Wrap: func(w *tokensigning.Unwrapped) proto.Message {
return &tokenserver.OAuthTokenGrantEnvelope{
TokenBo... | [
"func",
"SignGrant",
"(",
"c",
"context",
".",
"Context",
",",
"signer",
"signing",
".",
"Signer",
",",
"tok",
"*",
"tokenserver",
".",
"OAuthTokenGrantBody",
")",
"(",
"string",
",",
"error",
")",
"{",
"s",
":=",
"tokensigning",
".",
"Signer",
"{",
"Sig... | // SignGrant signs and serializes the OAuth grant.
//
// It doesn't do any validation. Assumes the prepared body is valid.
//
// Produces base64 URL-safe token or a transient error. | [
"SignGrant",
"signs",
"and",
"serializes",
"the",
"OAuth",
"grant",
".",
"It",
"doesn",
"t",
"do",
"any",
"validation",
".",
"Assumes",
"the",
"prepared",
"body",
"is",
"valid",
".",
"Produces",
"base64",
"URL",
"-",
"safe",
"token",
"or",
"a",
"transient"... | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/tokenserver/appengine/impl/serviceaccounts/grant.go#L41-L54 |
129,888 | luci/luci-go | config/impl/filesystem/fs.go | setRevision | func (c *scannedConfigs) setRevision(revision string) {
newRevPathMap := make(map[lookupKey]*config.Config, len(c.contentRevPathMap))
for k, v := range c.contentRevPathMap {
k.revision = revision
v.Revision = revision
newRevPathMap[k] = v
}
c.contentRevPathMap = newRevPathMap
newRevProject := make(map[looku... | go | func (c *scannedConfigs) setRevision(revision string) {
newRevPathMap := make(map[lookupKey]*config.Config, len(c.contentRevPathMap))
for k, v := range c.contentRevPathMap {
k.revision = revision
v.Revision = revision
newRevPathMap[k] = v
}
c.contentRevPathMap = newRevPathMap
newRevProject := make(map[looku... | [
"func",
"(",
"c",
"*",
"scannedConfigs",
")",
"setRevision",
"(",
"revision",
"string",
")",
"{",
"newRevPathMap",
":=",
"make",
"(",
"map",
"[",
"lookupKey",
"]",
"*",
"config",
".",
"Config",
",",
"len",
"(",
"c",
".",
"contentRevPathMap",
")",
")",
... | // setRevision updates 'revision' fields of all objects owned by scannedConfigs. | [
"setRevision",
"updates",
"revision",
"fields",
"of",
"all",
"objects",
"owned",
"by",
"scannedConfigs",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/config/impl/filesystem/fs.go#L122-L137 |
129,889 | luci/luci-go | config/impl/filesystem/fs.go | deriveRevision | func deriveRevision(c *scannedConfigs) string {
keys := make([]string, 0, len(c.contentHashMap))
for k := range c.contentHashMap {
keys = append(keys, k)
}
sort.Strings(keys)
hsh := sha256.New()
for _, k := range keys {
fmt.Fprintf(hsh, "%s\n%s\n", k, c.contentHashMap[k])
}
digest := hsh.Sum(nil)
return he... | go | func deriveRevision(c *scannedConfigs) string {
keys := make([]string, 0, len(c.contentHashMap))
for k := range c.contentHashMap {
keys = append(keys, k)
}
sort.Strings(keys)
hsh := sha256.New()
for _, k := range keys {
fmt.Fprintf(hsh, "%s\n%s\n", k, c.contentHashMap[k])
}
digest := hsh.Sum(nil)
return he... | [
"func",
"deriveRevision",
"(",
"c",
"*",
"scannedConfigs",
")",
"string",
"{",
"keys",
":=",
"make",
"(",
"[",
"]",
"string",
",",
"0",
",",
"len",
"(",
"c",
".",
"contentHashMap",
")",
")",
"\n",
"for",
"k",
":=",
"range",
"c",
".",
"contentHashMap"... | // deriveRevision generates a revision string from data in contentHashMap. | [
"deriveRevision",
"generates",
"a",
"revision",
"string",
"from",
"data",
"in",
"contentHashMap",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/config/impl/filesystem/fs.go#L140-L152 |
129,890 | luci/luci-go | common/bq/eventupload.go | Save | func (r *Row) Save() (map[string]bigquery.Value, string, error) {
m, err := mapFromMessage(r.Message, nil)
return m, r.InsertID, err
} | go | func (r *Row) Save() (map[string]bigquery.Value, string, error) {
m, err := mapFromMessage(r.Message, nil)
return m, r.InsertID, err
} | [
"func",
"(",
"r",
"*",
"Row",
")",
"Save",
"(",
")",
"(",
"map",
"[",
"string",
"]",
"bigquery",
".",
"Value",
",",
"string",
",",
"error",
")",
"{",
"m",
",",
"err",
":=",
"mapFromMessage",
"(",
"r",
".",
"Message",
",",
"nil",
")",
"\n",
"ret... | // Save is used by bigquery.Uploader.Put when inserting values into a table. | [
"Save",
"is",
"used",
"by",
"bigquery",
".",
"Uploader",
".",
"Put",
"when",
"inserting",
"values",
"into",
"a",
"table",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/common/bq/eventupload.go#L102-L105 |
129,891 | luci/luci-go | common/bq/eventupload.go | getFieldInfos | func getFieldInfos(t reflect.Type) ([]fieldInfo, error) {
bqFieldsLock.RLock()
f := bqFields[t]
bqFieldsLock.RUnlock()
if f != nil {
return f, nil
}
bqFieldsLock.Lock()
defer bqFieldsLock.Unlock()
return getFieldInfosLocked(t)
} | go | func getFieldInfos(t reflect.Type) ([]fieldInfo, error) {
bqFieldsLock.RLock()
f := bqFields[t]
bqFieldsLock.RUnlock()
if f != nil {
return f, nil
}
bqFieldsLock.Lock()
defer bqFieldsLock.Unlock()
return getFieldInfosLocked(t)
} | [
"func",
"getFieldInfos",
"(",
"t",
"reflect",
".",
"Type",
")",
"(",
"[",
"]",
"fieldInfo",
",",
"error",
")",
"{",
"bqFieldsLock",
".",
"RLock",
"(",
")",
"\n",
"f",
":=",
"bqFields",
"[",
"t",
"]",
"\n",
"bqFieldsLock",
".",
"RUnlock",
"(",
")",
... | // getFieldInfos returns field metadata for a given proto go type.
// Caches results. | [
"getFieldInfos",
"returns",
"field",
"metadata",
"for",
"a",
"given",
"proto",
"go",
"type",
".",
"Caches",
"results",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/common/bq/eventupload.go#L193-L204 |
129,892 | luci/luci-go | common/bq/eventupload.go | NewUploader | func NewUploader(ctx context.Context, c *bigquery.Client, datasetID, tableID string) *Uploader {
return &Uploader{
DatasetID: datasetID,
TableID: tableID,
Uploader: c.Dataset(datasetID).Table(tableID).Uploader(),
}
} | go | func NewUploader(ctx context.Context, c *bigquery.Client, datasetID, tableID string) *Uploader {
return &Uploader{
DatasetID: datasetID,
TableID: tableID,
Uploader: c.Dataset(datasetID).Table(tableID).Uploader(),
}
} | [
"func",
"NewUploader",
"(",
"ctx",
"context",
".",
"Context",
",",
"c",
"*",
"bigquery",
".",
"Client",
",",
"datasetID",
",",
"tableID",
"string",
")",
"*",
"Uploader",
"{",
"return",
"&",
"Uploader",
"{",
"DatasetID",
":",
"datasetID",
",",
"TableID",
... | // NewUploader constructs a new Uploader struct.
//
// DatasetID and TableID are provided to the BigQuery client to
// gain access to a particular table.
//
// You may want to change the default configuration of the bigquery.Uploader.
// Check the documentation for more details.
//
// Set UploadsMetricName on the resul... | [
"NewUploader",
"constructs",
"a",
"new",
"Uploader",
"struct",
".",
"DatasetID",
"and",
"TableID",
"are",
"provided",
"to",
"the",
"BigQuery",
"client",
"to",
"gain",
"access",
"to",
"a",
"particular",
"table",
".",
"You",
"may",
"want",
"to",
"change",
"the... | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/common/bq/eventupload.go#L337-L343 |
129,893 | luci/luci-go | common/bq/eventupload.go | Put | func (u *Uploader) Put(ctx context.Context, messages ...proto.Message) error {
if _, ok := ctx.Deadline(); !ok {
var c context.CancelFunc
ctx, c = context.WithTimeout(ctx, time.Minute)
defer c()
}
rows := make([]*Row, len(messages))
for i, m := range messages {
rows[i] = &Row{
Message: m,
InsertID: I... | go | func (u *Uploader) Put(ctx context.Context, messages ...proto.Message) error {
if _, ok := ctx.Deadline(); !ok {
var c context.CancelFunc
ctx, c = context.WithTimeout(ctx, time.Minute)
defer c()
}
rows := make([]*Row, len(messages))
for i, m := range messages {
rows[i] = &Row{
Message: m,
InsertID: I... | [
"func",
"(",
"u",
"*",
"Uploader",
")",
"Put",
"(",
"ctx",
"context",
".",
"Context",
",",
"messages",
"...",
"proto",
".",
"Message",
")",
"error",
"{",
"if",
"_",
",",
"ok",
":=",
"ctx",
".",
"Deadline",
"(",
")",
";",
"!",
"ok",
"{",
"var",
... | // Put uploads one or more rows to the BigQuery service. Put takes care of
// adding InsertIDs, used by BigQuery to deduplicate rows.
//
// If any rows do now match one of the expected types, Put will not attempt to
// upload any rows and returns an InvalidTypeError.
//
// Put returns a PutMultiError if one or more row... | [
"Put",
"uploads",
"one",
"or",
"more",
"rows",
"to",
"the",
"BigQuery",
"service",
".",
"Put",
"takes",
"care",
"of",
"adding",
"InsertIDs",
"used",
"by",
"BigQuery",
"to",
"deduplicate",
"rows",
".",
"If",
"any",
"rows",
"do",
"now",
"match",
"one",
"of... | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/common/bq/eventupload.go#L388-L425 |
129,894 | luci/luci-go | server/caching/global.go | WithGlobalCache | func WithGlobalCache(c context.Context, provider BlobCacheProvider) context.Context {
return context.WithValue(c, &globalCacheKey, provider)
} | go | func WithGlobalCache(c context.Context, provider BlobCacheProvider) context.Context {
return context.WithValue(c, &globalCacheKey, provider)
} | [
"func",
"WithGlobalCache",
"(",
"c",
"context",
".",
"Context",
",",
"provider",
"BlobCacheProvider",
")",
"context",
".",
"Context",
"{",
"return",
"context",
".",
"WithValue",
"(",
"c",
",",
"&",
"globalCacheKey",
",",
"provider",
")",
"\n",
"}"
] | // WithGlobalCache installs a global cache implementation into the supplied
// context. | [
"WithGlobalCache",
"installs",
"a",
"global",
"cache",
"implementation",
"into",
"the",
"supplied",
"context",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/server/caching/global.go#L61-L63 |
129,895 | luci/luci-go | appengine/gaeauth/client/client.go | GetAccessToken | func GetAccessToken(c context.Context, scopes []string) (*oauth2.Token, error) {
scopes, cacheKey := normalizeScopes(scopes)
// Try to find the token in the local memory first. If it expires soon,
// refresh it earlier with some probability. That avoids a situation when
// parallel requests that use access tokens ... | go | func GetAccessToken(c context.Context, scopes []string) (*oauth2.Token, error) {
scopes, cacheKey := normalizeScopes(scopes)
// Try to find the token in the local memory first. If it expires soon,
// refresh it earlier with some probability. That avoids a situation when
// parallel requests that use access tokens ... | [
"func",
"GetAccessToken",
"(",
"c",
"context",
".",
"Context",
",",
"scopes",
"[",
"]",
"string",
")",
"(",
"*",
"oauth2",
".",
"Token",
",",
"error",
")",
"{",
"scopes",
",",
"cacheKey",
":=",
"normalizeScopes",
"(",
"scopes",
")",
"\n\n",
"// Try to fi... | // GetAccessToken returns an OAuth access token representing app's service
// account.
//
// If scopes is empty, uses auth.OAuthScopeEmail scope.
//
// Implements a caching layer on top of GAE's GetAccessToken RPC. May return
// transient errors. | [
"GetAccessToken",
"returns",
"an",
"OAuth",
"access",
"token",
"representing",
"app",
"s",
"service",
"account",
".",
"If",
"scopes",
"is",
"empty",
"uses",
"auth",
".",
"OAuthScopeEmail",
"scope",
".",
"Implements",
"a",
"caching",
"layer",
"on",
"top",
"of",... | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/appengine/gaeauth/client/client.go#L46-L85 |
129,896 | luci/luci-go | appengine/gaeauth/client/client.go | NewTokenSource | func NewTokenSource(ctx context.Context, scopes []string) oauth2.TokenSource {
return &tokenSource{ctx, scopes}
} | go | func NewTokenSource(ctx context.Context, scopes []string) oauth2.TokenSource {
return &tokenSource{ctx, scopes}
} | [
"func",
"NewTokenSource",
"(",
"ctx",
"context",
".",
"Context",
",",
"scopes",
"[",
"]",
"string",
")",
"oauth2",
".",
"TokenSource",
"{",
"return",
"&",
"tokenSource",
"{",
"ctx",
",",
"scopes",
"}",
"\n",
"}"
] | // NewTokenSource makes oauth2.TokenSource implemented on top of GetAccessToken.
//
// It is bound to the given context. | [
"NewTokenSource",
"makes",
"oauth2",
".",
"TokenSource",
"implemented",
"on",
"top",
"of",
"GetAccessToken",
".",
"It",
"is",
"bound",
"to",
"the",
"given",
"context",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/appengine/gaeauth/client/client.go#L90-L92 |
129,897 | luci/luci-go | common/clock/tags.go | Tag | func Tag(c context.Context, v string) context.Context {
return context.WithValue(c, &clockTagKey, append(Tags(c), v))
} | go | func Tag(c context.Context, v string) context.Context {
return context.WithValue(c, &clockTagKey, append(Tags(c), v))
} | [
"func",
"Tag",
"(",
"c",
"context",
".",
"Context",
",",
"v",
"string",
")",
"context",
".",
"Context",
"{",
"return",
"context",
".",
"WithValue",
"(",
"c",
",",
"&",
"clockTagKey",
",",
"append",
"(",
"Tags",
"(",
"c",
")",
",",
"v",
")",
")",
... | // Tag returns a derivative Context with the supplied Tag appended to it.
//
// Tag chains can be used by timers to identify themselves. | [
"Tag",
"returns",
"a",
"derivative",
"Context",
"with",
"the",
"supplied",
"Tag",
"appended",
"to",
"it",
".",
"Tag",
"chains",
"can",
"be",
"used",
"by",
"timers",
"to",
"identify",
"themselves",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/common/clock/tags.go#L24-L26 |
129,898 | luci/luci-go | common/clock/tags.go | Tags | func Tags(c context.Context) []string {
if tags, ok := c.Value(&clockTagKey).([]string); ok && len(tags) > 0 {
tclone := make([]string, len(tags))
copy(tclone, tags)
return tclone
}
return nil
} | go | func Tags(c context.Context) []string {
if tags, ok := c.Value(&clockTagKey).([]string); ok && len(tags) > 0 {
tclone := make([]string, len(tags))
copy(tclone, tags)
return tclone
}
return nil
} | [
"func",
"Tags",
"(",
"c",
"context",
".",
"Context",
")",
"[",
"]",
"string",
"{",
"if",
"tags",
",",
"ok",
":=",
"c",
".",
"Value",
"(",
"&",
"clockTagKey",
")",
".",
"(",
"[",
"]",
"string",
")",
";",
"ok",
"&&",
"len",
"(",
"tags",
")",
">... | // Tags returns a copy of the set of tags in the current Context. | [
"Tags",
"returns",
"a",
"copy",
"of",
"the",
"set",
"of",
"tags",
"in",
"the",
"current",
"Context",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/common/clock/tags.go#L29-L36 |
129,899 | luci/luci-go | machine-db/appengine/model/rack_kvms.go | fetch | func (t *RackKVMsTable) fetch(c context.Context) error {
db := database.Get(c)
rows, err := db.QueryContext(c, `
SELECT id, name, kvm_id
FROM racks
`)
if err != nil {
return errors.Annotate(err, "failed to select racks").Err()
}
defer rows.Close()
for rows.Next() {
rack := &RackKVM{}
if err := rows.Sca... | go | func (t *RackKVMsTable) fetch(c context.Context) error {
db := database.Get(c)
rows, err := db.QueryContext(c, `
SELECT id, name, kvm_id
FROM racks
`)
if err != nil {
return errors.Annotate(err, "failed to select racks").Err()
}
defer rows.Close()
for rows.Next() {
rack := &RackKVM{}
if err := rows.Sca... | [
"func",
"(",
"t",
"*",
"RackKVMsTable",
")",
"fetch",
"(",
"c",
"context",
".",
"Context",
")",
"error",
"{",
"db",
":=",
"database",
".",
"Get",
"(",
"c",
")",
"\n",
"rows",
",",
"err",
":=",
"db",
".",
"QueryContext",
"(",
"c",
",",
"`\n\t\tSELEC... | // fetch fetches the rack kvm_ids from the database. | [
"fetch",
"fetches",
"the",
"rack",
"kvm_ids",
"from",
"the",
"database",
"."
] | f6cef429871eee3be7c6903af88d3ee884eaf683 | https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/machine-db/appengine/model/rack_kvms.go#L47-L65 |
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.