id
int32
0
167k
repo
stringlengths
5
54
path
stringlengths
4
155
func_name
stringlengths
1
118
original_string
stringlengths
52
85.5k
language
stringclasses
1 value
code
stringlengths
52
85.5k
code_tokens
list
docstring
stringlengths
6
2.61k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
85
252
9,500
luci/luci-go
machine-db/client/cli/physical_hosts.go
printPhysicalHosts
func printPhysicalHosts(tsv bool, hosts ...*crimson.PhysicalHost) { if len(hosts) > 0 { p := newStdoutPrinter(tsv) defer p.Flush() if !tsv { p.Row("Name", "VLAN", "IP Address", "Machine", "NIC", "MAC Address", "OS", "Max VM Slots", "Virtual Datacenter", "Description", "Deployment Ticket", "State") } for _...
go
func printPhysicalHosts(tsv bool, hosts ...*crimson.PhysicalHost) { if len(hosts) > 0 { p := newStdoutPrinter(tsv) defer p.Flush() if !tsv { p.Row("Name", "VLAN", "IP Address", "Machine", "NIC", "MAC Address", "OS", "Max VM Slots", "Virtual Datacenter", "Description", "Deployment Ticket", "State") } for _...
[ "func", "printPhysicalHosts", "(", "tsv", "bool", ",", "hosts", "...", "*", "crimson", ".", "PhysicalHost", ")", "{", "if", "len", "(", "hosts", ")", ">", "0", "{", "p", ":=", "newStdoutPrinter", "(", "tsv", ")", "\n", "defer", "p", ".", "Flush", "("...
// printPhysicalHosts prints physical host data to stdout in tab-separated columns.
[ "printPhysicalHosts", "prints", "physical", "host", "data", "to", "stdout", "in", "tab", "-", "separated", "columns", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/machine-db/client/cli/physical_hosts.go#L28-L39
9,501
luci/luci-go
machine-db/client/cli/physical_hosts.go
Run
func (c *AddPhysicalHostCmd) Run(app subcommands.Application, args []string, env subcommands.Env) int { ctx := cli.GetContext(app, c, env) // TODO(smut): Validate required fields client-side. req := &crimson.CreatePhysicalHostRequest{ Host: &c.host, } client := getClient(ctx) resp, err := client.CreatePhysicalH...
go
func (c *AddPhysicalHostCmd) Run(app subcommands.Application, args []string, env subcommands.Env) int { ctx := cli.GetContext(app, c, env) // TODO(smut): Validate required fields client-side. req := &crimson.CreatePhysicalHostRequest{ Host: &c.host, } client := getClient(ctx) resp, err := client.CreatePhysicalH...
[ "func", "(", "c", "*", "AddPhysicalHostCmd", ")", "Run", "(", "app", "subcommands", ".", "Application", ",", "args", "[", "]", "string", ",", "env", "subcommands", ".", "Env", ")", "int", "{", "ctx", ":=", "cli", ".", "GetContext", "(", "app", ",", "...
// Run runs the command to add a physical host.
[ "Run", "runs", "the", "command", "to", "add", "a", "physical", "host", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/machine-db/client/cli/physical_hosts.go#L48-L62
9,502
luci/luci-go
machine-db/client/cli/physical_hosts.go
editPhysicalHostCmd
func editPhysicalHostCmd(params *Parameters) *subcommands.Command { return &subcommands.Command{ UsageLine: "edit-host -name <name> [-machine <machine>] [-os <os>] [-state <state>] [-slots <vm slots>] [-vdc <virtual datacenter>] [-desc <description>] [-tick <deployment ticket>]", ShortDesc: "edits a physical host"...
go
func editPhysicalHostCmd(params *Parameters) *subcommands.Command { return &subcommands.Command{ UsageLine: "edit-host -name <name> [-machine <machine>] [-os <os>] [-state <state>] [-slots <vm slots>] [-vdc <virtual datacenter>] [-desc <description>] [-tick <deployment ticket>]", ShortDesc: "edits a physical host"...
[ "func", "editPhysicalHostCmd", "(", "params", "*", "Parameters", ")", "*", "subcommands", ".", "Command", "{", "return", "&", "subcommands", ".", "Command", "{", "UsageLine", ":", "\"", "\"", ",", "ShortDesc", ":", "\"", "\"", ",", "LongDesc", ":", "\"", ...
// editPhysicalHostCmd returns a command to edit a physical host.
[ "editPhysicalHostCmd", "returns", "a", "command", "to", "edit", "a", "physical", "host", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/machine-db/client/cli/physical_hosts.go#L121-L140
9,503
luci/luci-go
machine-db/client/cli/physical_hosts.go
Run
func (c *GetPhysicalHostsCmd) Run(app subcommands.Application, args []string, env subcommands.Env) int { ctx := cli.GetContext(app, c, env) client := getClient(ctx) resp, err := client.ListPhysicalHosts(ctx, &c.req) if err != nil { errors.Log(ctx, err) return 1 } printPhysicalHosts(c.f.tsv, resp.Hosts...) re...
go
func (c *GetPhysicalHostsCmd) Run(app subcommands.Application, args []string, env subcommands.Env) int { ctx := cli.GetContext(app, c, env) client := getClient(ctx) resp, err := client.ListPhysicalHosts(ctx, &c.req) if err != nil { errors.Log(ctx, err) return 1 } printPhysicalHosts(c.f.tsv, resp.Hosts...) re...
[ "func", "(", "c", "*", "GetPhysicalHostsCmd", ")", "Run", "(", "app", "subcommands", ".", "Application", ",", "args", "[", "]", "string", ",", "env", "subcommands", ".", "Env", ")", "int", "{", "ctx", ":=", "cli", ".", "GetContext", "(", "app", ",", ...
// Run runs the command to get physical hosts.
[ "Run", "runs", "the", "command", "to", "get", "physical", "hosts", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/machine-db/client/cli/physical_hosts.go#L149-L159
9,504
luci/luci-go
machine-db/client/cli/physical_hosts.go
getPhysicalHostsCmd
func getPhysicalHostsCmd(params *Parameters) *subcommands.Command { return &subcommands.Command{ UsageLine: "get-hosts [-name <name>]... [-vlan <id>]... [-machine <machine>]... [-nic <nic>]... [-mac <mac address>]... [-os <os>]... [-ip <ip address>]... [-state <state>]... [-vdc <virtual datacenter>]...", ShortDesc...
go
func getPhysicalHostsCmd(params *Parameters) *subcommands.Command { return &subcommands.Command{ UsageLine: "get-hosts [-name <name>]... [-vlan <id>]... [-machine <machine>]... [-nic <nic>]... [-mac <mac address>]... [-os <os>]... [-ip <ip address>]... [-state <state>]... [-vdc <virtual datacenter>]...", ShortDesc...
[ "func", "getPhysicalHostsCmd", "(", "params", "*", "Parameters", ")", "*", "subcommands", ".", "Command", "{", "return", "&", "subcommands", ".", "Command", "{", "UsageLine", ":", "\"", "\"", ",", "ShortDesc", ":", "\"", "\"", ",", "LongDesc", ":", "\"", ...
// getPhysicalHostsCmd returns a command to get physical hosts.
[ "getPhysicalHostsCmd", "returns", "a", "command", "to", "get", "physical", "hosts", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/machine-db/client/cli/physical_hosts.go#L162-L185
9,505
luci/luci-go
grpc/prpc/decoding.go
readMessage
func readMessage(r *http.Request, msg proto.Message) *protocolError { format, err := FormatFromContentType(r.Header.Get(headerContentType)) if err != nil { // Spec: http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.4.16 return errorf(http.StatusUnsupportedMediaType, "Content-Type header: %s", err) } ...
go
func readMessage(r *http.Request, msg proto.Message) *protocolError { format, err := FormatFromContentType(r.Header.Get(headerContentType)) if err != nil { // Spec: http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.4.16 return errorf(http.StatusUnsupportedMediaType, "Content-Type header: %s", err) } ...
[ "func", "readMessage", "(", "r", "*", "http", ".", "Request", ",", "msg", "proto", ".", "Message", ")", "*", "protocolError", "{", "format", ",", "err", ":=", "FormatFromContentType", "(", "r", ".", "Header", ".", "Get", "(", "headerContentType", ")", ")...
// readMessage decodes a protobuf message from an HTTP request. // Does not close the request body.
[ "readMessage", "decodes", "a", "protobuf", "message", "from", "an", "HTTP", "request", ".", "Does", "not", "close", "the", "request", "body", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/grpc/prpc/decoding.go#L46-L76
9,506
luci/luci-go
grpc/prpc/decoding.go
parseHeader
func parseHeader(c context.Context, header http.Header) (context.Context, error) { origC := c md, ok := metadata.FromIncomingContext(c) if ok { md = md.Copy() } else { md = metadata.MD{} } addedMeta := false for name, values := range header { if len(values) == 0 { continue } name = http.CanonicalH...
go
func parseHeader(c context.Context, header http.Header) (context.Context, error) { origC := c md, ok := metadata.FromIncomingContext(c) if ok { md = md.Copy() } else { md = metadata.MD{} } addedMeta := false for name, values := range header { if len(values) == 0 { continue } name = http.CanonicalH...
[ "func", "parseHeader", "(", "c", "context", ".", "Context", ",", "header", "http", ".", "Header", ")", "(", "context", ".", "Context", ",", "error", ")", "{", "origC", ":=", "c", "\n\n", "md", ",", "ok", ":=", "metadata", ".", "FromIncomingContext", "(...
// parseHeader parses HTTP headers and derives a new context. // Supports HeaderTimeout. // Ignores "Accept" and "Content-Type" headers. // // If there are unrecognized HTTP headers, with or without headerSuffixBinary, // they are added to a metadata.MD and a new context is derived. // If c already has metadata, the la...
[ "parseHeader", "parses", "HTTP", "headers", "and", "derives", "a", "new", "context", ".", "Supports", "HeaderTimeout", ".", "Ignores", "Accept", "and", "Content", "-", "Type", "headers", ".", "If", "there", "are", "unrecognized", "HTTP", "headers", "with", "or...
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/grpc/prpc/decoding.go#L87-L137
9,507
luci/luci-go
gce/api/config/v1/timeperiod.go
Normalize
func (t *TimePeriod) Normalize() error { if t.GetDuration() == "" { return nil } n, err := t.Time.(*TimePeriod_Duration).ToSeconds() if err != nil { return errors.Annotate(err, "invalid duration").Err() } t.Time = &TimePeriod_Seconds{ Seconds: n, } return nil }
go
func (t *TimePeriod) Normalize() error { if t.GetDuration() == "" { return nil } n, err := t.Time.(*TimePeriod_Duration).ToSeconds() if err != nil { return errors.Annotate(err, "invalid duration").Err() } t.Time = &TimePeriod_Seconds{ Seconds: n, } return nil }
[ "func", "(", "t", "*", "TimePeriod", ")", "Normalize", "(", ")", "error", "{", "if", "t", ".", "GetDuration", "(", ")", "==", "\"", "\"", "{", "return", "nil", "\n", "}", "\n", "n", ",", "err", ":=", "t", ".", "Time", ".", "(", "*", "TimePeriod...
// Normalize ensures this time period is in seconds. // Parses and converts duration to seconds if necessary.
[ "Normalize", "ensures", "this", "time", "period", "is", "in", "seconds", ".", "Parses", "and", "converts", "duration", "to", "seconds", "if", "necessary", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/gce/api/config/v1/timeperiod.go#L24-L36
9,508
luci/luci-go
gce/api/config/v1/timeperiod.go
ToSeconds
func (t *TimePeriod) ToSeconds() (int64, error) { if t == nil { return 0, nil } switch t := t.Time.(type) { case *TimePeriod_Duration: return t.ToSeconds() case *TimePeriod_Seconds: return t.Seconds, nil default: return 0, errors.Reason("unexpected type %T", t).Err() } }
go
func (t *TimePeriod) ToSeconds() (int64, error) { if t == nil { return 0, nil } switch t := t.Time.(type) { case *TimePeriod_Duration: return t.ToSeconds() case *TimePeriod_Seconds: return t.Seconds, nil default: return 0, errors.Reason("unexpected type %T", t).Err() } }
[ "func", "(", "t", "*", "TimePeriod", ")", "ToSeconds", "(", ")", "(", "int64", ",", "error", ")", "{", "if", "t", "==", "nil", "{", "return", "0", ",", "nil", "\n", "}", "\n", "switch", "t", ":=", "t", ".", "Time", ".", "(", "type", ")", "{",...
// ToSeconds returns this time period in seconds. Clamps to math.MaxInt64.
[ "ToSeconds", "returns", "this", "time", "period", "in", "seconds", ".", "Clamps", "to", "math", ".", "MaxInt64", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/gce/api/config/v1/timeperiod.go#L39-L51
9,509
luci/luci-go
gce/api/config/v1/timeperiod.go
Validate
func (t *TimePeriod) Validate(c *validation.Context) { switch { case t.GetDuration() != "": c.Enter("duration") t.Time.(*TimePeriod_Duration).Validate(c) c.Exit() case t.GetSeconds() < 0: c.Errorf("seconds must be non-negative") } }
go
func (t *TimePeriod) Validate(c *validation.Context) { switch { case t.GetDuration() != "": c.Enter("duration") t.Time.(*TimePeriod_Duration).Validate(c) c.Exit() case t.GetSeconds() < 0: c.Errorf("seconds must be non-negative") } }
[ "func", "(", "t", "*", "TimePeriod", ")", "Validate", "(", "c", "*", "validation", ".", "Context", ")", "{", "switch", "{", "case", "t", ".", "GetDuration", "(", ")", "!=", "\"", "\"", ":", "c", ".", "Enter", "(", "\"", "\"", ")", "\n", "t", "....
// Validate validates this time period.
[ "Validate", "validates", "this", "time", "period", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/gce/api/config/v1/timeperiod.go#L54-L63
9,510
luci/luci-go
gce/api/projects/v1/configs.go
Validate
func (cfgs *Configs) Validate(c *validation.Context) { prjs := stringset.New(len(cfgs.GetProject())) for i, cfg := range cfgs.GetProject() { c.Enter("project %d", i) cfg.Validate(c) if !prjs.Add(cfg.Project) { c.Errorf("project %q is not unique", cfg.Project) } c.Exit() } }
go
func (cfgs *Configs) Validate(c *validation.Context) { prjs := stringset.New(len(cfgs.GetProject())) for i, cfg := range cfgs.GetProject() { c.Enter("project %d", i) cfg.Validate(c) if !prjs.Add(cfg.Project) { c.Errorf("project %q is not unique", cfg.Project) } c.Exit() } }
[ "func", "(", "cfgs", "*", "Configs", ")", "Validate", "(", "c", "*", "validation", ".", "Context", ")", "{", "prjs", ":=", "stringset", ".", "New", "(", "len", "(", "cfgs", ".", "GetProject", "(", ")", ")", ")", "\n", "for", "i", ",", "cfg", ":="...
// Validate validates these configs.
[ "Validate", "validates", "these", "configs", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/gce/api/projects/v1/configs.go#L23-L33
9,511
luci/luci-go
milo/frontend/ui/console.go
HasCategory
func (c *Console) HasCategory() bool { if len(c.Table.children) != 1 { return true } root := c.Table.children[0] rootCat, ok := root.(*Category) if !ok { return false // This shouldn't happen. } for _, child := range rootCat.children { if _, ok := child.(*Category); ok { return true } } return false...
go
func (c *Console) HasCategory() bool { if len(c.Table.children) != 1 { return true } root := c.Table.children[0] rootCat, ok := root.(*Category) if !ok { return false // This shouldn't happen. } for _, child := range rootCat.children { if _, ok := child.(*Category); ok { return true } } return false...
[ "func", "(", "c", "*", "Console", ")", "HasCategory", "(", ")", "bool", "{", "if", "len", "(", "c", ".", "Table", ".", "children", ")", "!=", "1", "{", "return", "true", "\n", "}", "\n", "root", ":=", "c", ".", "Table", ".", "children", "[", "0...
// HasCategory returns true if there is at least a single category defined in the console.
[ "HasCategory", "returns", "true", "if", "there", "is", "at", "least", "a", "single", "category", "defined", "in", "the", "console", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/milo/frontend/ui/console.go#L75-L90
9,512
luci/luci-go
milo/frontend/ui/console.go
NewCategory
func NewCategory(name string) *Category { return &Category{ Name: name, childrenMap: make(map[string]ConsoleElement), children: make([]ConsoleElement, 0), cachedNumLeafNodes: -1, } }
go
func NewCategory(name string) *Category { return &Category{ Name: name, childrenMap: make(map[string]ConsoleElement), children: make([]ConsoleElement, 0), cachedNumLeafNodes: -1, } }
[ "func", "NewCategory", "(", "name", "string", ")", "*", "Category", "{", "return", "&", "Category", "{", "Name", ":", "name", ",", "childrenMap", ":", "make", "(", "map", "[", "string", "]", "ConsoleElement", ")", ",", "children", ":", "make", "(", "["...
// NewCategory allocates a new Category struct with no children.
[ "NewCategory", "allocates", "a", "new", "Category", "struct", "with", "no", "children", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/milo/frontend/ui/console.go#L229-L236
9,513
luci/luci-go
milo/frontend/ui/console.go
AddBuilder
func (c *Category) AddBuilder(categories []string, builder *BuilderRef) { current := c current.cachedNumLeafNodes = -1 for _, category := range categories { if child, ok := current.childrenMap[category]; ok { original := child.(*Category) original.cachedNumLeafNodes = -1 current = original } else { n...
go
func (c *Category) AddBuilder(categories []string, builder *BuilderRef) { current := c current.cachedNumLeafNodes = -1 for _, category := range categories { if child, ok := current.childrenMap[category]; ok { original := child.(*Category) original.cachedNumLeafNodes = -1 current = original } else { n...
[ "func", "(", "c", "*", "Category", ")", "AddBuilder", "(", "categories", "[", "]", "string", ",", "builder", "*", "BuilderRef", ")", "{", "current", ":=", "c", "\n", "current", ".", "cachedNumLeafNodes", "=", "-", "1", "\n", "for", "_", ",", "category"...
// AddBuilder inserts the builder into this Category tree. // // AddBuilder will create new subcategories as a chain of Category structs // as needed until there are no categories remaining. The builder is then // made a child of the deepest such Category.
[ "AddBuilder", "inserts", "the", "builder", "into", "this", "Category", "tree", ".", "AddBuilder", "will", "create", "new", "subcategories", "as", "a", "chain", "of", "Category", "structs", "as", "needed", "until", "there", "are", "no", "categories", "remaining",...
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/milo/frontend/ui/console.go#L243-L260
9,514
luci/luci-go
milo/frontend/ui/console.go
NumLeafNodes
func (c *Category) NumLeafNodes() int { if c.cachedNumLeafNodes != -1 { return c.cachedNumLeafNodes } leafNodes := 0 for _, child := range c.children { leafNodes += child.NumLeafNodes() } c.cachedNumLeafNodes = leafNodes return c.cachedNumLeafNodes }
go
func (c *Category) NumLeafNodes() int { if c.cachedNumLeafNodes != -1 { return c.cachedNumLeafNodes } leafNodes := 0 for _, child := range c.children { leafNodes += child.NumLeafNodes() } c.cachedNumLeafNodes = leafNodes return c.cachedNumLeafNodes }
[ "func", "(", "c", "*", "Category", ")", "NumLeafNodes", "(", ")", "int", "{", "if", "c", ".", "cachedNumLeafNodes", "!=", "-", "1", "{", "return", "c", ".", "cachedNumLeafNodes", "\n", "}", "\n\n", "leafNodes", ":=", "0", "\n", "for", "_", ",", "chil...
// NumLeafNodes calculates the number of leaf nodes in Category.
[ "NumLeafNodes", "calculates", "the", "number", "of", "leaf", "nodes", "in", "Category", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/milo/frontend/ui/console.go#L269-L280
9,515
luci/luci-go
milo/frontend/ui/console.go
RenderHTML
func (c Category) RenderHTML(buffer *bytes.Buffer, depth int, maxDepth int) { // Check to see if this category is a leaf. // A leaf category has no other categories as it's children. isLeafCategory := true for _, child := range c.children { if _, ok := child.(*Category); ok { isLeafCategory = false break ...
go
func (c Category) RenderHTML(buffer *bytes.Buffer, depth int, maxDepth int) { // Check to see if this category is a leaf. // A leaf category has no other categories as it's children. isLeafCategory := true for _, child := range c.children { if _, ok := child.(*Category); ok { isLeafCategory = false break ...
[ "func", "(", "c", "Category", ")", "RenderHTML", "(", "buffer", "*", "bytes", ".", "Buffer", ",", "depth", "int", ",", "maxDepth", "int", ")", "{", "// Check to see if this category is a leaf.", "// A leaf category has no other categories as it's children.", "isLeafCatego...
// RenderHTML renders the Category struct and its children as HTML into a buffer. // If maxDepth is negative, skip the labels to render the HTML as flat rather than nested.
[ "RenderHTML", "renders", "the", "Category", "struct", "and", "its", "children", "as", "HTML", "into", "a", "buffer", ".", "If", "maxDepth", "is", "negative", "skip", "the", "labels", "to", "render", "the", "HTML", "as", "flat", "rather", "than", "nested", ...
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/milo/frontend/ui/console.go#L492-L520
9,516
luci/luci-go
milo/api/buildbot/buildid.go
Validate
func (id BuildID) Validate() error { switch { case id.Master == "": return errors.New("master is unspecified", grpcutil.InvalidArgumentTag) case id.Builder == "": return errors.New("builder is unspecified", grpcutil.InvalidArgumentTag) case id.Number < 0: return errors.New("nunber must be >= 0", grpcutil.Inva...
go
func (id BuildID) Validate() error { switch { case id.Master == "": return errors.New("master is unspecified", grpcutil.InvalidArgumentTag) case id.Builder == "": return errors.New("builder is unspecified", grpcutil.InvalidArgumentTag) case id.Number < 0: return errors.New("nunber must be >= 0", grpcutil.Inva...
[ "func", "(", "id", "BuildID", ")", "Validate", "(", ")", "error", "{", "switch", "{", "case", "id", ".", "Master", "==", "\"", "\"", ":", "return", "errors", ".", "New", "(", "\"", "\"", ",", "grpcutil", ".", "InvalidArgumentTag", ")", "\n", "case", ...
// Validate returns an error if id is invalid.
[ "Validate", "returns", "an", "error", "if", "id", "is", "invalid", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/milo/api/buildbot/buildid.go#L32-L43
9,517
luci/luci-go
gce/api/config/v1/kinds.go
Map
func (kinds *Kinds) Map() map[string]*Kind { m := make(map[string]*Kind, len(kinds.GetKind())) for _, k := range kinds.GetKind() { m[k.Name] = k } return m }
go
func (kinds *Kinds) Map() map[string]*Kind { m := make(map[string]*Kind, len(kinds.GetKind())) for _, k := range kinds.GetKind() { m[k.Name] = k } return m }
[ "func", "(", "kinds", "*", "Kinds", ")", "Map", "(", ")", "map", "[", "string", "]", "*", "Kind", "{", "m", ":=", "make", "(", "map", "[", "string", "]", "*", "Kind", ",", "len", "(", "kinds", ".", "GetKind", "(", ")", ")", ")", "\n", "for", ...
// Map returns a map of name to VM kind. // For each name, only the last kind is included in the map. // Use Validate to ensure names are unique.
[ "Map", "returns", "a", "map", "of", "name", "to", "VM", "kind", ".", "For", "each", "name", "only", "the", "last", "kind", "is", "included", "in", "the", "map", ".", "Use", "Validate", "to", "ensure", "names", "are", "unique", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/gce/api/config/v1/kinds.go#L25-L31
9,518
luci/luci-go
gce/api/config/v1/kinds.go
Names
func (kinds *Kinds) Names() []string { names := make([]string, len(kinds.GetKind())) for i, k := range kinds.GetKind() { names[i] = k.Name } return names }
go
func (kinds *Kinds) Names() []string { names := make([]string, len(kinds.GetKind())) for i, k := range kinds.GetKind() { names[i] = k.Name } return names }
[ "func", "(", "kinds", "*", "Kinds", ")", "Names", "(", ")", "[", "]", "string", "{", "names", ":=", "make", "(", "[", "]", "string", ",", "len", "(", "kinds", ".", "GetKind", "(", ")", ")", ")", "\n", "for", "i", ",", "k", ":=", "range", "kin...
// Names returns the names of VM kinds.
[ "Names", "returns", "the", "names", "of", "VM", "kinds", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/gce/api/config/v1/kinds.go#L34-L40
9,519
luci/luci-go
gce/api/config/v1/kinds.go
Validate
func (kinds *Kinds) Validate(c *validation.Context) { names := stringset.New(len(kinds.GetKind())) for i, k := range kinds.GetKind() { c.Enter("kind %d", i) switch { case k.Name == "": c.Errorf("name is required") case !names.Add(k.Name): c.Errorf("duplicate name %q", k.Name) } c.Exit() } }
go
func (kinds *Kinds) Validate(c *validation.Context) { names := stringset.New(len(kinds.GetKind())) for i, k := range kinds.GetKind() { c.Enter("kind %d", i) switch { case k.Name == "": c.Errorf("name is required") case !names.Add(k.Name): c.Errorf("duplicate name %q", k.Name) } c.Exit() } }
[ "func", "(", "kinds", "*", "Kinds", ")", "Validate", "(", "c", "*", "validation", ".", "Context", ")", "{", "names", ":=", "stringset", ".", "New", "(", "len", "(", "kinds", ".", "GetKind", "(", ")", ")", ")", "\n", "for", "i", ",", "k", ":=", ...
// Validate validates VM kinds.
[ "Validate", "validates", "VM", "kinds", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/gce/api/config/v1/kinds.go#L43-L55
9,520
luci/luci-go
cipd/client/cipd/deployer/deployer.go
New
func New(root string) Deployer { var err error if root == "" { err = fmt.Errorf("site root path is not provided") } else { root, err = filepath.Abs(filepath.Clean(root)) } if err != nil { return errDeployer{err} } trashDir := filepath.Join(root, fs.SiteServiceDir, "trash") return &deployerImpl{fs.NewFileS...
go
func New(root string) Deployer { var err error if root == "" { err = fmt.Errorf("site root path is not provided") } else { root, err = filepath.Abs(filepath.Clean(root)) } if err != nil { return errDeployer{err} } trashDir := filepath.Join(root, fs.SiteServiceDir, "trash") return &deployerImpl{fs.NewFileS...
[ "func", "New", "(", "root", "string", ")", "Deployer", "{", "var", "err", "error", "\n", "if", "root", "==", "\"", "\"", "{", "err", "=", "fmt", ".", "Errorf", "(", "\"", "\"", ")", "\n", "}", "else", "{", "root", ",", "err", "=", "filepath", "...
// New return default Deployer implementation.
[ "New", "return", "default", "Deployer", "implementation", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/cipd/client/cipd/deployer/deployer.go#L191-L203
9,521
luci/luci-go
cipd/client/cipd/deployer/deployer.go
readDescription
func readDescription(r io.Reader) (desc *description, err error) { blob, err := ioutil.ReadAll(r) if err == nil { err = json.Unmarshal(blob, &desc) } return }
go
func readDescription(r io.Reader) (desc *description, err error) { blob, err := ioutil.ReadAll(r) if err == nil { err = json.Unmarshal(blob, &desc) } return }
[ "func", "readDescription", "(", "r", "io", ".", "Reader", ")", "(", "desc", "*", "description", ",", "err", "error", ")", "{", "blob", ",", "err", ":=", "ioutil", ".", "ReadAll", "(", "r", ")", "\n", "if", "err", "==", "nil", "{", "err", "=", "js...
// readDescription reads and decodes description JSON from io.Reader.
[ "readDescription", "reads", "and", "decodes", "description", "JSON", "from", "io", ".", "Reader", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/cipd/client/cipd/deployer/deployer.go#L248-L254
9,522
luci/luci-go
cipd/client/cipd/deployer/deployer.go
writeDescription
func writeDescription(d *description, w io.Writer) error { data, err := json.MarshalIndent(d, "", " ") if err != nil { return err } _, err = w.Write(data) return err }
go
func writeDescription(d *description, w io.Writer) error { data, err := json.MarshalIndent(d, "", " ") if err != nil { return err } _, err = w.Write(data) return err }
[ "func", "writeDescription", "(", "d", "*", "description", ",", "w", "io", ".", "Writer", ")", "error", "{", "data", ",", "err", ":=", "json", ".", "MarshalIndent", "(", "d", ",", "\"", "\"", ",", "\"", "\"", ")", "\n", "if", "err", "!=", "nil", "...
// writeDescription encodes and writes description JSON to io.Writer.
[ "writeDescription", "encodes", "and", "writes", "description", "JSON", "to", "io", ".", "Writer", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/cipd/client/cipd/deployer/deployer.go#L257-L264
9,523
luci/luci-go
cipd/client/cipd/deployer/deployer.go
removeFromSiteRoot
func (d *deployerImpl) removeFromSiteRoot(ctx context.Context, subdir string, files []pkg.FileInfo, keep *pathTree) { dirsToCleanup := stringset.New(0) for _, f := range files { rootRel := filepath.Join(subdir, filepath.FromSlash(f.Name)) if keep.has(rootRel) { continue } absPath, err := d.fs.RootRelToAbs...
go
func (d *deployerImpl) removeFromSiteRoot(ctx context.Context, subdir string, files []pkg.FileInfo, keep *pathTree) { dirsToCleanup := stringset.New(0) for _, f := range files { rootRel := filepath.Join(subdir, filepath.FromSlash(f.Name)) if keep.has(rootRel) { continue } absPath, err := d.fs.RootRelToAbs...
[ "func", "(", "d", "*", "deployerImpl", ")", "removeFromSiteRoot", "(", "ctx", "context", ".", "Context", ",", "subdir", "string", ",", "files", "[", "]", "pkg", ".", "FileInfo", ",", "keep", "*", "pathTree", ")", "{", "dirsToCleanup", ":=", "stringset", ...
// removeFromSiteRoot deletes files from the site root directory unless they // are present in the 'keep' set. // // Best effort. Logs errors and carries on.
[ "removeFromSiteRoot", "deletes", "files", "from", "the", "site", "root", "directory", "unless", "they", "are", "present", "in", "the", "keep", "set", ".", "Best", "effort", ".", "Logs", "errors", "and", "carries", "on", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/cipd/client/cipd/deployer/deployer.go#L1151-L1179
9,524
luci/luci-go
cipd/client/cipd/deployer/deployer.go
isPresentInSite
func (d *deployerImpl) isPresentInSite(ctx context.Context, subdir string, f pkg.FileInfo, followSymlinks bool) bool { absPath, err := d.fs.RootRelToAbs(filepath.Join(subdir, filepath.FromSlash(f.Name))) if err != nil { panic(err) // should not happen for files present in installed packages } stat := d.fs.Lstat ...
go
func (d *deployerImpl) isPresentInSite(ctx context.Context, subdir string, f pkg.FileInfo, followSymlinks bool) bool { absPath, err := d.fs.RootRelToAbs(filepath.Join(subdir, filepath.FromSlash(f.Name))) if err != nil { panic(err) // should not happen for files present in installed packages } stat := d.fs.Lstat ...
[ "func", "(", "d", "*", "deployerImpl", ")", "isPresentInSite", "(", "ctx", "context", ".", "Context", ",", "subdir", "string", ",", "f", "pkg", ".", "FileInfo", ",", "followSymlinks", "bool", ")", "bool", "{", "absPath", ",", "err", ":=", "d", ".", "fs...
// isPresentInSite checks whether the given file is installed in the site root. // // Optionally follows symlinks. // // If the file can't be checked for some reason, logs the error and returns // false.
[ "isPresentInSite", "checks", "whether", "the", "given", "file", "is", "installed", "in", "the", "site", "root", ".", "Optionally", "follows", "symlinks", ".", "If", "the", "file", "can", "t", "be", "checked", "for", "some", "reason", "logs", "the", "error", ...
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/cipd/client/cipd/deployer/deployer.go#L1187-L1210
9,525
luci/luci-go
cipd/client/cipd/deployer/deployer.go
checkIntegrity
func (d *deployerImpl) checkIntegrity(ctx context.Context, p *DeployedPackage, mode ParanoidMode) (redeploy, relink []string) { logging.Debugf(ctx, "Checking integrity of %q deployment in %q mode...", p.Pin.PackageName, mode) // TODO(vadimsh): Understand mode == CheckIntegrity. // Examine files that are supposed t...
go
func (d *deployerImpl) checkIntegrity(ctx context.Context, p *DeployedPackage, mode ParanoidMode) (redeploy, relink []string) { logging.Debugf(ctx, "Checking integrity of %q deployment in %q mode...", p.Pin.PackageName, mode) // TODO(vadimsh): Understand mode == CheckIntegrity. // Examine files that are supposed t...
[ "func", "(", "d", "*", "deployerImpl", ")", "checkIntegrity", "(", "ctx", "context", ".", "Context", ",", "p", "*", "DeployedPackage", ",", "mode", "ParanoidMode", ")", "(", "redeploy", ",", "relink", "[", "]", "string", ")", "{", "logging", ".", "Debugf...
// checkIntegrity verifies the given deployed package is correctly installed and // returns a list of files to relink and to redeploy if something is broken. // // See DeployedPackage struct for definition of "relink" and "redeploy".
[ "checkIntegrity", "verifies", "the", "given", "deployed", "package", "is", "correctly", "installed", "and", "returns", "a", "list", "of", "files", "to", "relink", "and", "to", "redeploy", "if", "something", "is", "broken", ".", "See", "DeployedPackage", "struct"...
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/cipd/client/cipd/deployer/deployer.go#L1239-L1291
9,526
luci/luci-go
cipd/client/cipd/deployer/deployer.go
newPathTree
func newPathTree(caseSensitive bool, capacity int) *pathTree { return &pathTree{ caseSensitive: caseSensitive, nodes: stringset.New(capacity / 5), // educated guess leafs: stringset.New(capacity), // exact } }
go
func newPathTree(caseSensitive bool, capacity int) *pathTree { return &pathTree{ caseSensitive: caseSensitive, nodes: stringset.New(capacity / 5), // educated guess leafs: stringset.New(capacity), // exact } }
[ "func", "newPathTree", "(", "caseSensitive", "bool", ",", "capacity", "int", ")", "*", "pathTree", "{", "return", "&", "pathTree", "{", "caseSensitive", ":", "caseSensitive", ",", "nodes", ":", "stringset", ".", "New", "(", "capacity", "/", "5", ")", ",", ...
// newPathTree initializes the path tree, allocating the given capacity.
[ "newPathTree", "initializes", "the", "path", "tree", "allocating", "the", "given", "capacity", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/cipd/client/cipd/deployer/deployer.go#L1318-L1324
9,527
luci/luci-go
cipd/client/cipd/deployer/deployer.go
add
func (p *pathTree) add(rel string) { if !p.caseSensitive { rel = strings.ToLower(rel) } p.leafs.Add(rel) parentDirs(rel, func(par string) bool { p.nodes.Add(par) return true }) }
go
func (p *pathTree) add(rel string) { if !p.caseSensitive { rel = strings.ToLower(rel) } p.leafs.Add(rel) parentDirs(rel, func(par string) bool { p.nodes.Add(par) return true }) }
[ "func", "(", "p", "*", "pathTree", ")", "add", "(", "rel", "string", ")", "{", "if", "!", "p", ".", "caseSensitive", "{", "rel", "=", "strings", ".", "ToLower", "(", "rel", ")", "\n", "}", "\n", "p", ".", "leafs", ".", "Add", "(", "rel", ")", ...
// add adds a native path 'rel', all its parents and all its children to the // path tree.
[ "add", "adds", "a", "native", "path", "rel", "all", "its", "parents", "and", "all", "its", "children", "to", "the", "path", "tree", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/cipd/client/cipd/deployer/deployer.go#L1328-L1337
9,528
luci/luci-go
cipd/client/cipd/deployer/deployer.go
has
func (p *pathTree) has(rel string) bool { if p == nil { return false } if !p.caseSensitive { rel = strings.ToLower(rel) } // It matches some added entry exactly? if p.leafs.Has(rel) { return true } // Was added as a parent of some entry? if p.nodes.Has(rel) { return true } // Maybe it has some add...
go
func (p *pathTree) has(rel string) bool { if p == nil { return false } if !p.caseSensitive { rel = strings.ToLower(rel) } // It matches some added entry exactly? if p.leafs.Has(rel) { return true } // Was added as a parent of some entry? if p.nodes.Has(rel) { return true } // Maybe it has some add...
[ "func", "(", "p", "*", "pathTree", ")", "has", "(", "rel", "string", ")", "bool", "{", "if", "p", "==", "nil", "{", "return", "false", "\n", "}", "\n\n", "if", "!", "p", ".", "caseSensitive", "{", "rel", "=", "strings", ".", "ToLower", "(", "rel"...
// has returns true if a native path 'rel' is in the tree. // // nil pathTree is considered empty.
[ "has", "returns", "true", "if", "a", "native", "path", "rel", "is", "in", "the", "tree", ".", "nil", "pathTree", "is", "considered", "empty", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/cipd/client/cipd/deployer/deployer.go#L1342-L1367
9,529
luci/luci-go
grpc/cmd/cproto/main.go
compile
func compile(c context.Context, gopath, importPaths, protoFiles []string, dir, descSetOut string) (outDir string, err error) { // make it absolute to find in $GOPATH and because protoc wants paths // to be under proto paths. if dir, err = filepath.Abs(dir); err != nil { return "", err } // By default place go f...
go
func compile(c context.Context, gopath, importPaths, protoFiles []string, dir, descSetOut string) (outDir string, err error) { // make it absolute to find in $GOPATH and because protoc wants paths // to be under proto paths. if dir, err = filepath.Abs(dir); err != nil { return "", err } // By default place go f...
[ "func", "compile", "(", "c", "context", ".", "Context", ",", "gopath", ",", "importPaths", ",", "protoFiles", "[", "]", "string", ",", "dir", ",", "descSetOut", "string", ")", "(", "outDir", "string", ",", "err", "error", ")", "{", "// make it absolute to ...
// compile runs protoc on protoFiles. protoFiles must be relative to dir.
[ "compile", "runs", "protoc", "on", "protoFiles", ".", "protoFiles", "must", "be", "relative", "to", "dir", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/grpc/cmd/cproto/main.go#L73-L162
9,530
luci/luci-go
grpc/cmd/cproto/main.go
findProtoFiles
func findProtoFiles(dir string) ([]string, error) { files, err := filepath.Glob(filepath.Join(dir, "*.proto")) if err != nil { return nil, err } for i, f := range files { files[i] = filepath.Base(f) } return files, err }
go
func findProtoFiles(dir string) ([]string, error) { files, err := filepath.Glob(filepath.Join(dir, "*.proto")) if err != nil { return nil, err } for i, f := range files { files[i] = filepath.Base(f) } return files, err }
[ "func", "findProtoFiles", "(", "dir", "string", ")", "(", "[", "]", "string", ",", "error", ")", "{", "files", ",", "err", ":=", "filepath", ".", "Glob", "(", "filepath", ".", "Join", "(", "dir", ",", "\"", "\"", ")", ")", "\n", "if", "err", "!="...
// findProtoFiles returns .proto files in dir. The returned file paths // are relative to dir.
[ "findProtoFiles", "returns", ".", "proto", "files", "in", "dir", ".", "The", "returned", "file", "paths", "are", "relative", "to", "dir", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/grpc/cmd/cproto/main.go#L296-L306
9,531
luci/luci-go
grpc/cmd/cproto/main.go
isInPackage
func isInPackage(fileName string, pkg string) (bool, error) { dir, err := filepath.Abs(filepath.Dir(fileName)) if err != nil { return false, err } dir = path.Clean(dir) pkg = path.Clean(pkg) if !strings.HasSuffix(dir, pkg) { return false, nil } src := strings.TrimSuffix(dir, pkg) src = path.Clean(src) go...
go
func isInPackage(fileName string, pkg string) (bool, error) { dir, err := filepath.Abs(filepath.Dir(fileName)) if err != nil { return false, err } dir = path.Clean(dir) pkg = path.Clean(pkg) if !strings.HasSuffix(dir, pkg) { return false, nil } src := strings.TrimSuffix(dir, pkg) src = path.Clean(src) go...
[ "func", "isInPackage", "(", "fileName", "string", ",", "pkg", "string", ")", "(", "bool", ",", "error", ")", "{", "dir", ",", "err", ":=", "filepath", ".", "Abs", "(", "filepath", ".", "Dir", "(", "fileName", ")", ")", "\n", "if", "err", "!=", "nil...
// isInPackage returns true if the filename is a part of the package.
[ "isInPackage", "returns", "true", "if", "the", "filename", "is", "a", "part", "of", "the", "package", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/grpc/cmd/cproto/main.go#L309-L329
9,532
luci/luci-go
buildbucket/protoutil/build.go
RunDuration
func RunDuration(b *pb.Build) (duration time.Duration, ok bool) { start, startErr := ptypes.Timestamp(b.StartTime) end, endErr := ptypes.Timestamp(b.EndTime) if startErr != nil || start.IsZero() || endErr != nil || end.IsZero() { return 0, false } return end.Sub(start), true }
go
func RunDuration(b *pb.Build) (duration time.Duration, ok bool) { start, startErr := ptypes.Timestamp(b.StartTime) end, endErr := ptypes.Timestamp(b.EndTime) if startErr != nil || start.IsZero() || endErr != nil || end.IsZero() { return 0, false } return end.Sub(start), true }
[ "func", "RunDuration", "(", "b", "*", "pb", ".", "Build", ")", "(", "duration", "time", ".", "Duration", ",", "ok", "bool", ")", "{", "start", ",", "startErr", ":=", "ptypes", ".", "Timestamp", "(", "b", ".", "StartTime", ")", "\n", "end", ",", "en...
// RunDuration returns duration between build start and end.
[ "RunDuration", "returns", "duration", "between", "build", "start", "and", "end", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/buildbucket/protoutil/build.go#L31-L39
9,533
luci/luci-go
buildbucket/protoutil/build.go
Tags
func Tags(b *pb.Build) strpair.Map { m := make(strpair.Map, len(b.Tags)) for _, t := range b.Tags { m.Add(t.Key, t.Value) } return m }
go
func Tags(b *pb.Build) strpair.Map { m := make(strpair.Map, len(b.Tags)) for _, t := range b.Tags { m.Add(t.Key, t.Value) } return m }
[ "func", "Tags", "(", "b", "*", "pb", ".", "Build", ")", "strpair", ".", "Map", "{", "m", ":=", "make", "(", "strpair", ".", "Map", ",", "len", "(", "b", ".", "Tags", ")", ")", "\n", "for", "_", ",", "t", ":=", "range", "b", ".", "Tags", "{"...
// Tags parses b.Tags as a strpair.Map.
[ "Tags", "parses", "b", ".", "Tags", "as", "a", "strpair", ".", "Map", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/buildbucket/protoutil/build.go#L53-L59
9,534
luci/luci-go
scheduler/appengine/task/gitiles/gitiles.go
isInteresting
func (p *pathFilter) isInteresting(diff []*git.Commit_TreeDiff) (skip bool) { isInterestingPath := func(path string) bool { switch { case path == "": return false case p.pathExclude != nil && p.pathExclude.MatchString(path): return false default: return p.pathInclude.MatchString(path) } } for _, ...
go
func (p *pathFilter) isInteresting(diff []*git.Commit_TreeDiff) (skip bool) { isInterestingPath := func(path string) bool { switch { case path == "": return false case p.pathExclude != nil && p.pathExclude.MatchString(path): return false default: return p.pathInclude.MatchString(path) } } for _, ...
[ "func", "(", "p", "*", "pathFilter", ")", "isInteresting", "(", "diff", "[", "]", "*", "git", ".", "Commit_TreeDiff", ")", "(", "skip", "bool", ")", "{", "isInterestingPath", ":=", "func", "(", "path", "string", ")", "bool", "{", "switch", "{", "case",...
// isInteresting decides whether commit is interesting according to pathFilter // based on which files were touched in commits.
[ "isInteresting", "decides", "whether", "commit", "is", "interesting", "according", "to", "pathFilter", "based", "on", "which", "files", "were", "touched", "in", "commits", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/scheduler/appengine/task/gitiles/gitiles.go#L556-L574
9,535
luci/luci-go
lucicfg/sequence.go
next
func (s *sequences) next(seq string) int { if s.s == nil { s.s = make(map[string]int, 1) } v := s.s[seq] + 1 s.s[seq] = v return v }
go
func (s *sequences) next(seq string) int { if s.s == nil { s.s = make(map[string]int, 1) } v := s.s[seq] + 1 s.s[seq] = v return v }
[ "func", "(", "s", "*", "sequences", ")", "next", "(", "seq", "string", ")", "int", "{", "if", "s", ".", "s", "==", "nil", "{", "s", ".", "s", "=", "make", "(", "map", "[", "string", "]", "int", ",", "1", ")", "\n", "}", "\n", "v", ":=", "...
// next returns the next number in the given sequence. // // Sequences start with 1.
[ "next", "returns", "the", "next", "number", "in", "the", "given", "sequence", ".", "Sequences", "start", "with", "1", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/lucicfg/sequence.go#L29-L36
9,536
luci/luci-go
cipd/client/cipd/pkg/installmode.go
PickInstallMode
func PickInstallMode(im InstallMode) (InstallMode, error) { switch { case runtime.GOOS == "windows": return InstallModeCopy, nil // Windows supports only 'copy' mode case im == "": return InstallModeSymlink, nil // default on other platforms } if err := ValidateInstallMode(im); err != nil { return "", err }...
go
func PickInstallMode(im InstallMode) (InstallMode, error) { switch { case runtime.GOOS == "windows": return InstallModeCopy, nil // Windows supports only 'copy' mode case im == "": return InstallModeSymlink, nil // default on other platforms } if err := ValidateInstallMode(im); err != nil { return "", err }...
[ "func", "PickInstallMode", "(", "im", "InstallMode", ")", "(", "InstallMode", ",", "error", ")", "{", "switch", "{", "case", "runtime", ".", "GOOS", "==", "\"", "\"", ":", "return", "InstallModeCopy", ",", "nil", "// Windows supports only 'copy' mode", "\n", "...
// PickInstallMode validates the install mode and picks the correct default // for the platform if no install mode is given.
[ "PickInstallMode", "validates", "the", "install", "mode", "and", "picks", "the", "correct", "default", "for", "the", "platform", "if", "no", "install", "mode", "is", "given", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/cipd/client/cipd/pkg/installmode.go#L68-L79
9,537
luci/luci-go
server/auth/oauth.go
Authenticate
func (m *GoogleOAuth2Method) Authenticate(c context.Context, r *http.Request) (user *User, err error) { cfg := getConfig(c) if cfg == nil || cfg.AnonymousTransport == nil { return nil, ErrNotConfigured } // Extract the access token from the Authorization header. header := r.Header.Get("Authorization") if heade...
go
func (m *GoogleOAuth2Method) Authenticate(c context.Context, r *http.Request) (user *User, err error) { cfg := getConfig(c) if cfg == nil || cfg.AnonymousTransport == nil { return nil, ErrNotConfigured } // Extract the access token from the Authorization header. header := r.Header.Get("Authorization") if heade...
[ "func", "(", "m", "*", "GoogleOAuth2Method", ")", "Authenticate", "(", "c", "context", ".", "Context", ",", "r", "*", "http", ".", "Request", ")", "(", "user", "*", "User", ",", "err", "error", ")", "{", "cfg", ":=", "getConfig", "(", "c", ")", "\n...
// Authenticate implements Method.
[ "Authenticate", "implements", "Method", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/server/auth/oauth.go#L79-L132
9,538
luci/luci-go
server/auth/oauth.go
GetUserCredentials
func (m *GoogleOAuth2Method) GetUserCredentials(c context.Context, r *http.Request) (*oauth2.Token, error) { accessToken, err := accessTokenFromHeader(r.Header.Get("Authorization")) if err != nil { return nil, err } return &oauth2.Token{ AccessToken: accessToken, TokenType: "Bearer", }, nil }
go
func (m *GoogleOAuth2Method) GetUserCredentials(c context.Context, r *http.Request) (*oauth2.Token, error) { accessToken, err := accessTokenFromHeader(r.Header.Get("Authorization")) if err != nil { return nil, err } return &oauth2.Token{ AccessToken: accessToken, TokenType: "Bearer", }, nil }
[ "func", "(", "m", "*", "GoogleOAuth2Method", ")", "GetUserCredentials", "(", "c", "context", ".", "Context", ",", "r", "*", "http", ".", "Request", ")", "(", "*", "oauth2", ".", "Token", ",", "error", ")", "{", "accessToken", ",", "err", ":=", "accessT...
// GetUserCredentials implements UserCredentialsGetter.
[ "GetUserCredentials", "implements", "UserCredentialsGetter", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/server/auth/oauth.go#L135-L144
9,539
luci/luci-go
milo/buildsource/swarming/build.go
addBuilderLink
func addBuilderLink(c context.Context, build *ui.MiloBuildLegacy, tags strpair.Map) { bucket := tags.Get("buildbucket_bucket") builder := tags.Get("builder") project := tags.Get("luci_project") if bucket != "" && builder != "" { builderParts := strings.Split(builder, "/") builder = builderParts[len(builderParts...
go
func addBuilderLink(c context.Context, build *ui.MiloBuildLegacy, tags strpair.Map) { bucket := tags.Get("buildbucket_bucket") builder := tags.Get("builder") project := tags.Get("luci_project") if bucket != "" && builder != "" { builderParts := strings.Split(builder, "/") builder = builderParts[len(builderParts...
[ "func", "addBuilderLink", "(", "c", "context", ".", "Context", ",", "build", "*", "ui", ".", "MiloBuildLegacy", ",", "tags", "strpair", ".", "Map", ")", "{", "bucket", ":=", "tags", ".", "Get", "(", "\"", "\"", ")", "\n", "builder", ":=", "tags", "."...
// addBuilderLink adds a link to the buildbucket builder view.
[ "addBuilderLink", "adds", "a", "link", "to", "the", "buildbucket", "builder", "view", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/milo/buildsource/swarming/build.go#L264-L275
9,540
luci/luci-go
milo/buildsource/swarming/build.go
AddBanner
func AddBanner(build *ui.MiloBuildLegacy, tags strpair.Map) { os := tags.Get("os") parts := strings.SplitN(os, "-", 2) var ver string if len(parts) == 2 { os = parts[0] ver = parts[1] } var base ui.LogoBase switch os { case "Ubuntu": base = ui.Ubuntu case "Windows": base = ui.Windows case "Mac": ba...
go
func AddBanner(build *ui.MiloBuildLegacy, tags strpair.Map) { os := tags.Get("os") parts := strings.SplitN(os, "-", 2) var ver string if len(parts) == 2 { os = parts[0] ver = parts[1] } var base ui.LogoBase switch os { case "Ubuntu": base = ui.Ubuntu case "Windows": base = ui.Windows case "Mac": ba...
[ "func", "AddBanner", "(", "build", "*", "ui", ".", "MiloBuildLegacy", ",", "tags", "strpair", ".", "Map", ")", "{", "os", ":=", "tags", ".", "Get", "(", "\"", "\"", ")", "\n", "parts", ":=", "strings", ".", "SplitN", "(", "os", ",", "\"", "\"", "...
// AddBanner adds an OS banner derived from "os" swarming tag, if present.
[ "AddBanner", "adds", "an", "OS", "banner", "derived", "from", "os", "swarming", "tag", "if", "present", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/milo/buildsource/swarming/build.go#L278-L307
9,541
luci/luci-go
milo/buildsource/swarming/build.go
addTaskToMiloStep
func addTaskToMiloStep(c context.Context, host string, sr *swarming.SwarmingRpcsTaskResult, step *miloProto.Step) error { step.Link = &miloProto.Link{ Label: "Task " + sr.TaskId, Value: &miloProto.Link_Url{ Url: TaskPageURL(host, sr.TaskId).String(), }, } switch sr.State { case TaskRunning: step.Status ...
go
func addTaskToMiloStep(c context.Context, host string, sr *swarming.SwarmingRpcsTaskResult, step *miloProto.Step) error { step.Link = &miloProto.Link{ Label: "Task " + sr.TaskId, Value: &miloProto.Link_Url{ Url: TaskPageURL(host, sr.TaskId).String(), }, } switch sr.State { case TaskRunning: step.Status ...
[ "func", "addTaskToMiloStep", "(", "c", "context", ".", "Context", ",", "host", "string", ",", "sr", "*", "swarming", ".", "SwarmingRpcsTaskResult", ",", "step", "*", "miloProto", ".", "Step", ")", "error", "{", "step", ".", "Link", "=", "&", "miloProto", ...
// addTaskToMiloStep augments a Milo Annotation Protobuf with state from the // Swarming task.
[ "addTaskToMiloStep", "augments", "a", "Milo", "Annotation", "Protobuf", "with", "state", "from", "the", "Swarming", "task", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/milo/buildsource/swarming/build.go#L311-L399
9,542
luci/luci-go
milo/buildsource/swarming/build.go
AddProjectInfo
func AddProjectInfo(build *ui.MiloBuildLegacy, tags strpair.Map) { if proj := tags.Get("luci_project"); proj != "" { if build.Trigger == nil { build.Trigger = &ui.Trigger{} } build.Trigger.Project = proj } }
go
func AddProjectInfo(build *ui.MiloBuildLegacy, tags strpair.Map) { if proj := tags.Get("luci_project"); proj != "" { if build.Trigger == nil { build.Trigger = &ui.Trigger{} } build.Trigger.Project = proj } }
[ "func", "AddProjectInfo", "(", "build", "*", "ui", ".", "MiloBuildLegacy", ",", "tags", "strpair", ".", "Map", ")", "{", "if", "proj", ":=", "tags", ".", "Get", "(", "\"", "\"", ")", ";", "proj", "!=", "\"", "\"", "{", "if", "build", ".", "Trigger"...
// addProjectInfo adds the luci_project swarming tag to the build.
[ "addProjectInfo", "adds", "the", "luci_project", "swarming", "tag", "to", "the", "build", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/milo/buildsource/swarming/build.go#L446-L453
9,543
luci/luci-go
milo/buildsource/swarming/build.go
addPendingTiming
func addPendingTiming(c context.Context, build *ui.MiloBuildLegacy, sr *swarming.SwarmingRpcsTaskResult) { created, err := time.Parse(SwarmingTimeLayout, sr.CreatedTs) if err != nil { return } build.Summary.PendingTime = ui.NewInterval(c, created, build.Summary.ExecutionTime.Started) }
go
func addPendingTiming(c context.Context, build *ui.MiloBuildLegacy, sr *swarming.SwarmingRpcsTaskResult) { created, err := time.Parse(SwarmingTimeLayout, sr.CreatedTs) if err != nil { return } build.Summary.PendingTime = ui.NewInterval(c, created, build.Summary.ExecutionTime.Started) }
[ "func", "addPendingTiming", "(", "c", "context", ".", "Context", ",", "build", "*", "ui", ".", "MiloBuildLegacy", ",", "sr", "*", "swarming", ".", "SwarmingRpcsTaskResult", ")", "{", "created", ",", "err", ":=", "time", ".", "Parse", "(", "SwarmingTimeLayout...
// addPendingTiming adds pending timing information to the build.
[ "addPendingTiming", "adds", "pending", "timing", "information", "to", "the", "build", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/milo/buildsource/swarming/build.go#L456-L462
9,544
luci/luci-go
milo/buildsource/swarming/build.go
streamsFromAnnotatedLog
func streamsFromAnnotatedLog(ctx context.Context, log string) (*rawpresentation.Streams, error) { c := &memoryClient{} p := annotee.New(ctx, annotee.Options{ Client: c, MetadataUpdateInterval: -1, // Neverrrrrr send incr updates. Offline: true, }) is := annotee.Stream{ Reader...
go
func streamsFromAnnotatedLog(ctx context.Context, log string) (*rawpresentation.Streams, error) { c := &memoryClient{} p := annotee.New(ctx, annotee.Options{ Client: c, MetadataUpdateInterval: -1, // Neverrrrrr send incr updates. Offline: true, }) is := annotee.Stream{ Reader...
[ "func", "streamsFromAnnotatedLog", "(", "ctx", "context", ".", "Context", ",", "log", "string", ")", "(", "*", "rawpresentation", ".", "Streams", ",", "error", ")", "{", "c", ":=", "&", "memoryClient", "{", "}", "\n", "p", ":=", "annotee", ".", "New", ...
// streamsFromAnnotatedLog takes in an annotated log and returns a fully // populated set of logdog streams
[ "streamsFromAnnotatedLog", "takes", "in", "an", "annotated", "log", "and", "returns", "a", "fully", "populated", "set", "of", "logdog", "streams" ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/milo/buildsource/swarming/build.go#L495-L516
9,545
luci/luci-go
milo/buildsource/swarming/build.go
failedToStart
func failedToStart(c context.Context, build *ui.MiloBuildLegacy, res *swarming.SwarmingRpcsTaskResult, host string) error { build.Summary.Status = model.InfraFailure started, err := time.Parse(SwarmingTimeLayout, res.StartedTs) if err != nil { return err } ended, err := time.Parse(SwarmingTimeLayout, res.Complet...
go
func failedToStart(c context.Context, build *ui.MiloBuildLegacy, res *swarming.SwarmingRpcsTaskResult, host string) error { build.Summary.Status = model.InfraFailure started, err := time.Parse(SwarmingTimeLayout, res.StartedTs) if err != nil { return err } ended, err := time.Parse(SwarmingTimeLayout, res.Complet...
[ "func", "failedToStart", "(", "c", "context", ".", "Context", ",", "build", "*", "ui", ".", "MiloBuildLegacy", ",", "res", "*", "swarming", ".", "SwarmingRpcsTaskResult", ",", "host", "string", ")", "error", "{", "build", ".", "Summary", ".", "Status", "="...
// failedToStart is called in the case where logdog-only mode is on but the // stream doesn't exist and the swarming job is complete. It modifies the build // to add information that would've otherwise been in the annotation stream.
[ "failedToStart", "is", "called", "in", "the", "case", "where", "logdog", "-", "only", "mode", "is", "on", "but", "the", "stream", "doesn", "t", "exist", "and", "the", "swarming", "job", "is", "complete", ".", "It", "modifies", "the", "build", "to", "add"...
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/milo/buildsource/swarming/build.go#L521-L537
9,546
luci/luci-go
milo/buildsource/swarming/build.go
swarmingFetchMaybeLogs
func swarmingFetchMaybeLogs(c context.Context, svc SwarmingService, taskID string) ( *swarmingFetchResult, *types.StreamAddr, error) { // Fetch the data from Swarming var logDogStreamAddr *types.StreamAddr fetchParams := swarmingFetchParams{ fetchLog: true, // Cancel if LogDog annotation stream parameters are...
go
func swarmingFetchMaybeLogs(c context.Context, svc SwarmingService, taskID string) ( *swarmingFetchResult, *types.StreamAddr, error) { // Fetch the data from Swarming var logDogStreamAddr *types.StreamAddr fetchParams := swarmingFetchParams{ fetchLog: true, // Cancel if LogDog annotation stream parameters are...
[ "func", "swarmingFetchMaybeLogs", "(", "c", "context", ".", "Context", ",", "svc", "SwarmingService", ",", "taskID", "string", ")", "(", "*", "swarmingFetchResult", ",", "*", "types", ".", "StreamAddr", ",", "error", ")", "{", "// Fetch the data from Swarming", ...
// swarmingFetchMaybeLogs fetches the swarming task result. It also fetches // the log iff the task is not a logdog enabled task.
[ "swarmingFetchMaybeLogs", "fetches", "the", "swarming", "task", "result", ".", "It", "also", "fetches", "the", "log", "iff", "the", "task", "is", "not", "a", "logdog", "enabled", "task", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/milo/buildsource/swarming/build.go#L541-L577
9,547
luci/luci-go
milo/buildsource/swarming/build.go
addFailureSummary
func addFailureSummary(b *ui.MiloBuildLegacy) { for _, comp := range b.Components { // Add interesting information into the main summary text. if comp.Status != model.Success { b.Summary.Text = append( b.Summary.Text, fmt.Sprintf("%s %s", comp.Status, comp.Label)) } } }
go
func addFailureSummary(b *ui.MiloBuildLegacy) { for _, comp := range b.Components { // Add interesting information into the main summary text. if comp.Status != model.Success { b.Summary.Text = append( b.Summary.Text, fmt.Sprintf("%s %s", comp.Status, comp.Label)) } } }
[ "func", "addFailureSummary", "(", "b", "*", "ui", ".", "MiloBuildLegacy", ")", "{", "for", "_", ",", "comp", ":=", "range", "b", ".", "Components", "{", "// Add interesting information into the main summary text.", "if", "comp", ".", "Status", "!=", "model", "."...
// addFailureSummary adds failure summary information to the main status, // derivied from individual steps.
[ "addFailureSummary", "adds", "failure", "summary", "information", "to", "the", "main", "status", "derivied", "from", "individual", "steps", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/milo/buildsource/swarming/build.go#L618-L626
9,548
luci/luci-go
milo/buildsource/swarming/build.go
SwarmingBuildImpl
func SwarmingBuildImpl(c context.Context, svc SwarmingService, taskID string) (*ui.MiloBuildLegacy, error) { // First, get the task result from swarming, and maybe the logs. fr, logDogStreamAddr, err := swarmingFetchMaybeLogs(c, svc, taskID) if err != nil { return nil, err } swarmingResult := fr.res // Legacy ...
go
func SwarmingBuildImpl(c context.Context, svc SwarmingService, taskID string) (*ui.MiloBuildLegacy, error) { // First, get the task result from swarming, and maybe the logs. fr, logDogStreamAddr, err := swarmingFetchMaybeLogs(c, svc, taskID) if err != nil { return nil, err } swarmingResult := fr.res // Legacy ...
[ "func", "SwarmingBuildImpl", "(", "c", "context", ".", "Context", ",", "svc", "SwarmingService", ",", "taskID", "string", ")", "(", "*", "ui", ".", "MiloBuildLegacy", ",", "error", ")", "{", "// First, get the task result from swarming, and maybe the logs.", "fr", "...
// SwarmingBuildImpl fetches data from Swarming and LogDog and produces a resp.MiloBuildLegacy // representation of a build state given a Swarming TaskID.
[ "SwarmingBuildImpl", "fetches", "data", "from", "Swarming", "and", "LogDog", "and", "produces", "a", "resp", ".", "MiloBuildLegacy", "representation", "of", "a", "build", "state", "given", "a", "Swarming", "TaskID", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/milo/buildsource/swarming/build.go#L630-L699
9,549
luci/luci-go
milo/buildsource/swarming/build.go
infoComponent
func infoComponent(st model.Status, label, text string) *ui.BuildComponent { return &ui.BuildComponent{ Type: ui.Summary, Label: ui.NewEmptyLink(label), Text: []string{text}, Status: st, } }
go
func infoComponent(st model.Status, label, text string) *ui.BuildComponent { return &ui.BuildComponent{ Type: ui.Summary, Label: ui.NewEmptyLink(label), Text: []string{text}, Status: st, } }
[ "func", "infoComponent", "(", "st", "model", ".", "Status", ",", "label", ",", "text", "string", ")", "*", "ui", ".", "BuildComponent", "{", "return", "&", "ui", ".", "BuildComponent", "{", "Type", ":", "ui", ".", "Summary", ",", "Label", ":", "ui", ...
// infoComponent is a helper function to return a resp build step with the // given status, label, and step text.
[ "infoComponent", "is", "a", "helper", "function", "to", "return", "a", "resp", "build", "step", "with", "the", "given", "status", "label", "and", "step", "text", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/milo/buildsource/swarming/build.go#L703-L710
9,550
luci/luci-go
milo/buildsource/swarming/build.go
TaskPageURL
func TaskPageURL(swarmingHostname, taskID string) *url.URL { val := url.Values{} val.Set("id", taskID) val.Set("show_raw", "1") val.Set("wide_logs", "true") return &url.URL{ Scheme: "https", Host: swarmingHostname, Path: "task", RawQuery: val.Encode(), } }
go
func TaskPageURL(swarmingHostname, taskID string) *url.URL { val := url.Values{} val.Set("id", taskID) val.Set("show_raw", "1") val.Set("wide_logs", "true") return &url.URL{ Scheme: "https", Host: swarmingHostname, Path: "task", RawQuery: val.Encode(), } }
[ "func", "TaskPageURL", "(", "swarmingHostname", ",", "taskID", "string", ")", "*", "url", ".", "URL", "{", "val", ":=", "url", ".", "Values", "{", "}", "\n", "val", ".", "Set", "(", "\"", "\"", ",", "taskID", ")", "\n", "val", ".", "Set", "(", "\...
// TaskPageURL returns a URL to a human-consumable page of a swarming task. // Supports host aliases.
[ "TaskPageURL", "returns", "a", "URL", "to", "a", "human", "-", "consumable", "page", "of", "a", "swarming", "task", ".", "Supports", "host", "aliases", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/milo/buildsource/swarming/build.go#L742-L753
9,551
luci/luci-go
milo/buildsource/swarming/build.go
getSwarmingHost
func getSwarmingHost(c context.Context, host string) (string, error) { settings := common.GetSettings(c) if settings.Swarming == nil { err := errors.New("swarming not in settings") logging.WithError(err).Errorf(c, "Go configure swarming in the settings page.") return "", err } if host == "" || host == settin...
go
func getSwarmingHost(c context.Context, host string) (string, error) { settings := common.GetSettings(c) if settings.Swarming == nil { err := errors.New("swarming not in settings") logging.WithError(err).Errorf(c, "Go configure swarming in the settings page.") return "", err } if host == "" || host == settin...
[ "func", "getSwarmingHost", "(", "c", "context", ".", "Context", ",", "host", "string", ")", "(", "string", ",", "error", ")", "{", "settings", ":=", "common", ".", "GetSettings", "(", "c", ")", "\n", "if", "settings", ".", "Swarming", "==", "nil", "{",...
// getSwarmingHost returns default hostname if host is empty. // If host is not empty and not allowed, returns an error.
[ "getSwarmingHost", "returns", "default", "hostname", "if", "host", "is", "empty", ".", "If", "host", "is", "not", "empty", "and", "not", "allowed", "returns", "an", "error", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/milo/buildsource/swarming/build.go#L816-L834
9,552
luci/luci-go
milo/buildsource/swarming/build.go
GetBuild
func GetBuild(c context.Context, host, taskId string) (*ui.MiloBuildLegacy, error) { if taskId == "" { return nil, errors.New("no swarming task id", grpcutil.InvalidArgumentTag) } sf, err := NewProdService(c, host) if err != nil { return nil, err } return SwarmingBuildImpl(c, sf, taskId) }
go
func GetBuild(c context.Context, host, taskId string) (*ui.MiloBuildLegacy, error) { if taskId == "" { return nil, errors.New("no swarming task id", grpcutil.InvalidArgumentTag) } sf, err := NewProdService(c, host) if err != nil { return nil, err } return SwarmingBuildImpl(c, sf, taskId) }
[ "func", "GetBuild", "(", "c", "context", ".", "Context", ",", "host", ",", "taskId", "string", ")", "(", "*", "ui", ".", "MiloBuildLegacy", ",", "error", ")", "{", "if", "taskId", "==", "\"", "\"", "{", "return", "nil", ",", "errors", ".", "New", "...
// GetBuild returns a milo build from a swarming task id.
[ "GetBuild", "returns", "a", "milo", "build", "from", "a", "swarming", "task", "id", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/milo/buildsource/swarming/build.go#L837-L848
9,553
luci/luci-go
milo/buildsource/swarming/build.go
GetLog
func GetLog(c context.Context, host, taskID, logname string) (text string, closed bool, err error) { switch { case taskID == "": err = errors.New("no swarming task id", grpcutil.InvalidArgumentTag) return case logname == "": err = errors.New("no log name", grpcutil.InvalidArgumentTag) return } sf, err := ...
go
func GetLog(c context.Context, host, taskID, logname string) (text string, closed bool, err error) { switch { case taskID == "": err = errors.New("no swarming task id", grpcutil.InvalidArgumentTag) return case logname == "": err = errors.New("no log name", grpcutil.InvalidArgumentTag) return } sf, err := ...
[ "func", "GetLog", "(", "c", "context", ".", "Context", ",", "host", ",", "taskID", ",", "logname", "string", ")", "(", "text", "string", ",", "closed", "bool", ",", "err", "error", ")", "{", "switch", "{", "case", "taskID", "==", "\"", "\"", ":", "...
// GetLog loads a step log.
[ "GetLog", "loads", "a", "step", "log", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/milo/buildsource/swarming/build.go#L851-L867
9,554
luci/luci-go
logdog/common/storage/cache.go
HashKey
func HashKey(parts ...string) string { hash := sha256.New() bio := bufio.NewWriter(hash) // Add a full NULL-delimited key sequence segment to our hash. for i, part := range parts { // Write the separator, except for the first key. if i > 0 { if _, err := bio.WriteRune('\x00'); err != nil { panic(err) ...
go
func HashKey(parts ...string) string { hash := sha256.New() bio := bufio.NewWriter(hash) // Add a full NULL-delimited key sequence segment to our hash. for i, part := range parts { // Write the separator, except for the first key. if i > 0 { if _, err := bio.WriteRune('\x00'); err != nil { panic(err) ...
[ "func", "HashKey", "(", "parts", "...", "string", ")", "string", "{", "hash", ":=", "sha256", ".", "New", "(", ")", "\n", "bio", ":=", "bufio", ".", "NewWriter", "(", "hash", ")", "\n\n", "// Add a full NULL-delimited key sequence segment to our hash.", "for", ...
// HashKey composes a hex-encoded SHA256 string from the supplied parts. The // local schema version and KeyType are included in the hash.
[ "HashKey", "composes", "a", "hex", "-", "encoded", "SHA256", "string", "from", "the", "supplied", "parts", ".", "The", "local", "schema", "version", "and", "KeyType", "are", "included", "in", "the", "hash", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/logdog/common/storage/cache.go#L65-L88
9,555
luci/luci-go
buildbucket/protoutil/tag.go
StringPairs
func StringPairs(m strpair.Map) []*pb.StringPair { ret := make([]*pb.StringPair, 0, len(m)) for k, vs := range m { for _, v := range vs { ret = append(ret, &pb.StringPair{Key: k, Value: v}) } } SortStringPairs(ret) return ret }
go
func StringPairs(m strpair.Map) []*pb.StringPair { ret := make([]*pb.StringPair, 0, len(m)) for k, vs := range m { for _, v := range vs { ret = append(ret, &pb.StringPair{Key: k, Value: v}) } } SortStringPairs(ret) return ret }
[ "func", "StringPairs", "(", "m", "strpair", ".", "Map", ")", "[", "]", "*", "pb", ".", "StringPair", "{", "ret", ":=", "make", "(", "[", "]", "*", "pb", ".", "StringPair", ",", "0", ",", "len", "(", "m", ")", ")", "\n", "for", "k", ",", "vs",...
// StringPairs converts a strpair.Map to a slice of StringPair messages.
[ "StringPairs", "converts", "a", "strpair", ".", "Map", "to", "a", "slice", "of", "StringPair", "messages", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/buildbucket/protoutil/tag.go#L31-L40
9,556
luci/luci-go
buildbucket/protoutil/tag.go
SortStringPairs
func SortStringPairs(pairs []*pb.StringPair) { sort.Slice(pairs, func(i, j int) bool { switch { case pairs[i].Key < pairs[j].Key: return true case pairs[i].Key > pairs[j].Key: return false default: return pairs[i].Value < pairs[j].Value } }) }
go
func SortStringPairs(pairs []*pb.StringPair) { sort.Slice(pairs, func(i, j int) bool { switch { case pairs[i].Key < pairs[j].Key: return true case pairs[i].Key > pairs[j].Key: return false default: return pairs[i].Value < pairs[j].Value } }) }
[ "func", "SortStringPairs", "(", "pairs", "[", "]", "*", "pb", ".", "StringPair", ")", "{", "sort", ".", "Slice", "(", "pairs", ",", "func", "(", "i", ",", "j", "int", ")", "bool", "{", "switch", "{", "case", "pairs", "[", "i", "]", ".", "Key", ...
// SortStringPairs sorts string pairs.
[ "SortStringPairs", "sorts", "string", "pairs", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/buildbucket/protoutil/tag.go#L43-L54
9,557
luci/luci-go
buildbucket/protoutil/tag.go
BuildSets
func BuildSets(b *pb.Build) []string { var result []string for _, tag := range b.Tags { if tag.Key == "buildset" { result = append(result, tag.Value) } } return result }
go
func BuildSets(b *pb.Build) []string { var result []string for _, tag := range b.Tags { if tag.Key == "buildset" { result = append(result, tag.Value) } } return result }
[ "func", "BuildSets", "(", "b", "*", "pb", ".", "Build", ")", "[", "]", "string", "{", "var", "result", "[", "]", "string", "\n", "for", "_", ",", "tag", ":=", "range", "b", ".", "Tags", "{", "if", "tag", ".", "Key", "==", "\"", "\"", "{", "re...
// BuildSets returns all of the buildsets of the build.
[ "BuildSets", "returns", "all", "of", "the", "buildsets", "of", "the", "build", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/buildbucket/protoutil/tag.go#L57-L65
9,558
luci/luci-go
cipd/client/cipd/fs/files.go
ExistingDestination
func ExistingDestination(dest string, fs FileSystem) Destination { if fs == nil { fs = NewFileSystem(filepath.Dir(dest), "") } return &fsDest{ fs: fs, dest: dest, atomic: true, // note: txnFSDest unsets this, see Begin openFiles: map[string]*os.File{}, } }
go
func ExistingDestination(dest string, fs FileSystem) Destination { if fs == nil { fs = NewFileSystem(filepath.Dir(dest), "") } return &fsDest{ fs: fs, dest: dest, atomic: true, // note: txnFSDest unsets this, see Begin openFiles: map[string]*os.File{}, } }
[ "func", "ExistingDestination", "(", "dest", "string", ",", "fs", "FileSystem", ")", "Destination", "{", "if", "fs", "==", "nil", "{", "fs", "=", "NewFileSystem", "(", "filepath", ".", "Dir", "(", "dest", ")", ",", "\"", "\"", ")", "\n", "}", "\n", "r...
// ExistingDestination returns an object that knows how to create files in an // existing directory in the file system. // // Will use a provided FileSystem object to operate on files if given, otherwise // uses a default one. If FileSystem is provided, dest must be in a subdirectory // of the given FileSystem root. //...
[ "ExistingDestination", "returns", "an", "object", "that", "knows", "how", "to", "create", "files", "in", "an", "existing", "directory", "in", "the", "file", "system", ".", "Will", "use", "a", "provided", "FileSystem", "object", "to", "operate", "on", "files", ...
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/cipd/client/cipd/fs/files.go#L388-L398
9,559
luci/luci-go
cipd/client/cipd/fs/files.go
numOpenFiles
func (d *fsDest) numOpenFiles() (n int) { d.lock.RLock() n = len(d.openFiles) d.lock.RUnlock() return }
go
func (d *fsDest) numOpenFiles() (n int) { d.lock.RLock() n = len(d.openFiles) d.lock.RUnlock() return }
[ "func", "(", "d", "*", "fsDest", ")", "numOpenFiles", "(", ")", "(", "n", "int", ")", "{", "d", ".", "lock", ".", "RLock", "(", ")", "\n", "n", "=", "len", "(", "d", ".", "openFiles", ")", "\n", "d", ".", "lock", ".", "RUnlock", "(", ")", "...
// numOpenFiles returns a number of currently open files. // // Used by txnFSDest to make sure all files are closed before finalizing the // transaction.
[ "numOpenFiles", "returns", "a", "number", "of", "currently", "open", "files", ".", "Used", "by", "txnFSDest", "to", "make", "sure", "all", "files", "are", "closed", "before", "finalizing", "the", "transaction", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/cipd/client/cipd/fs/files.go#L404-L409
9,560
luci/luci-go
cipd/client/cipd/fs/files.go
prepareFilePath
func (d *fsDest) prepareFilePath(ctx context.Context, name string) (string, error) { path := filepath.Clean(filepath.Join(d.dest, filepath.FromSlash(name))) if !IsSubpath(path, d.dest) { return "", fmt.Errorf("invalid relative file name: %s", name) } if _, err := d.fs.EnsureDirectory(ctx, filepath.Dir(path)); err...
go
func (d *fsDest) prepareFilePath(ctx context.Context, name string) (string, error) { path := filepath.Clean(filepath.Join(d.dest, filepath.FromSlash(name))) if !IsSubpath(path, d.dest) { return "", fmt.Errorf("invalid relative file name: %s", name) } if _, err := d.fs.EnsureDirectory(ctx, filepath.Dir(path)); err...
[ "func", "(", "d", "*", "fsDest", ")", "prepareFilePath", "(", "ctx", "context", ".", "Context", ",", "name", "string", ")", "(", "string", ",", "error", ")", "{", "path", ":=", "filepath", ".", "Clean", "(", "filepath", ".", "Join", "(", "d", ".", ...
// prepareFilePath performs steps common to CreateFile and CreateSymlink. // // It does some validation, expands "name" to an absolute path and creates // parent directories for a future file. Returns absolute path where the file // should be put.
[ "prepareFilePath", "performs", "steps", "common", "to", "CreateFile", "and", "CreateSymlink", ".", "It", "does", "some", "validation", "expands", "name", "to", "an", "absolute", "path", "and", "creates", "parent", "directories", "for", "a", "future", "file", "."...
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/cipd/client/cipd/fs/files.go#L416-L425
9,561
luci/luci-go
server/auth/client.go
GetPerRPCCredentials
func GetPerRPCCredentials(kind RPCAuthorityKind, opts ...RPCOption) (credentials.PerRPCCredentials, error) { options, err := makeRPCOptions(kind, opts) if err != nil { return nil, err } return perRPCCreds{options}, nil }
go
func GetPerRPCCredentials(kind RPCAuthorityKind, opts ...RPCOption) (credentials.PerRPCCredentials, error) { options, err := makeRPCOptions(kind, opts) if err != nil { return nil, err } return perRPCCreds{options}, nil }
[ "func", "GetPerRPCCredentials", "(", "kind", "RPCAuthorityKind", ",", "opts", "...", "RPCOption", ")", "(", "credentials", ".", "PerRPCCredentials", ",", "error", ")", "{", "options", ",", "err", ":=", "makeRPCOptions", "(", "kind", ",", "opts", ")", "\n", "...
// GetPerRPCCredentials returns gRPC's PerRPCCredentials implementation. // // It can be used to authenticate outbound gPRC RPC's.
[ "GetPerRPCCredentials", "returns", "gRPC", "s", "PerRPCCredentials", "implementation", ".", "It", "can", "be", "used", "to", "authenticate", "outbound", "gPRC", "RPC", "s", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/server/auth/client.go#L318-L324
9,562
luci/luci-go
server/auth/client.go
GetTokenSource
func GetTokenSource(c context.Context, kind RPCAuthorityKind, opts ...RPCOption) (oauth2.TokenSource, error) { if kind != AsSelf && kind != AsCredentialsForwarder && kind != AsActor { return nil, fmt.Errorf("auth: GetTokenSource can only be used with AsSelf, AsCredentialsForwarder or AsActor authorization kind") } ...
go
func GetTokenSource(c context.Context, kind RPCAuthorityKind, opts ...RPCOption) (oauth2.TokenSource, error) { if kind != AsSelf && kind != AsCredentialsForwarder && kind != AsActor { return nil, fmt.Errorf("auth: GetTokenSource can only be used with AsSelf, AsCredentialsForwarder or AsActor authorization kind") } ...
[ "func", "GetTokenSource", "(", "c", "context", ".", "Context", ",", "kind", "RPCAuthorityKind", ",", "opts", "...", "RPCOption", ")", "(", "oauth2", ".", "TokenSource", ",", "error", ")", "{", "if", "kind", "!=", "AsSelf", "&&", "kind", "!=", "AsCredential...
// GetTokenSource returns an oauth2.TokenSource bound to the supplied Context. // // Supports only AsSelf, AsCredentialsForwarder and AsActor authorization kinds, // since they are only ones that exclusively use OAuth2 tokens and no other // extra headers. // // While GetPerRPCCredentials is preferred, this can be used...
[ "GetTokenSource", "returns", "an", "oauth2", ".", "TokenSource", "bound", "to", "the", "supplied", "Context", ".", "Supports", "only", "AsSelf", "AsCredentialsForwarder", "and", "AsActor", "authorization", "kinds", "since", "they", "are", "only", "ones", "that", "...
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/server/auth/client.go#L363-L377
9,563
luci/luci-go
server/auth/client.go
tokenFingerprint
func tokenFingerprint(tok string) string { digest := sha256.Sum256([]byte(tok)) return hex.EncodeToString(digest[:16]) }
go
func tokenFingerprint(tok string) string { digest := sha256.Sum256([]byte(tok)) return hex.EncodeToString(digest[:16]) }
[ "func", "tokenFingerprint", "(", "tok", "string", ")", "string", "{", "digest", ":=", "sha256", ".", "Sum256", "(", "[", "]", "byte", "(", "tok", ")", ")", "\n", "return", "hex", ".", "EncodeToString", "(", "digest", "[", ":", "16", "]", ")", "\n", ...
// tokenFingerprint returns first 16 bytes of SHA256 of the token, as hex. // // Token fingerprints can be used to identify tokens without parsing them.
[ "tokenFingerprint", "returns", "first", "16", "bytes", "of", "SHA256", "of", "the", "token", "as", "hex", ".", "Token", "fingerprints", "can", "be", "used", "to", "identify", "tokens", "without", "parsing", "them", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/server/auth/client.go#L426-L429
9,564
luci/luci-go
server/auth/client.go
makeRPCOptions
func makeRPCOptions(kind RPCAuthorityKind, opts []RPCOption) (*rpcOptions, error) { options := &rpcOptions{kind: kind} for _, o := range opts { o.apply(options) } // Set default scopes. asSelfOrActorOrProject := options.kind == AsSelf || options.kind == AsActor || options.kind == AsProject if asSelfOrActorOrPr...
go
func makeRPCOptions(kind RPCAuthorityKind, opts []RPCOption) (*rpcOptions, error) { options := &rpcOptions{kind: kind} for _, o := range opts { o.apply(options) } // Set default scopes. asSelfOrActorOrProject := options.kind == AsSelf || options.kind == AsActor || options.kind == AsProject if asSelfOrActorOrPr...
[ "func", "makeRPCOptions", "(", "kind", "RPCAuthorityKind", ",", "opts", "[", "]", "RPCOption", ")", "(", "*", "rpcOptions", ",", "error", ")", "{", "options", ":=", "&", "rpcOptions", "{", "kind", ":", "kind", "}", "\n", "for", "_", ",", "o", ":=", "...
// makeRPCOptions applies all options and validates them.
[ "makeRPCOptions", "applies", "all", "options", "and", "validates", "them", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/server/auth/client.go#L463-L529
9,565
luci/luci-go
server/auth/client.go
noAuthHeaders
func noAuthHeaders(c context.Context, uri string, opts *rpcOptions) (*oauth2.Token, map[string]string, error) { return nil, nil, nil }
go
func noAuthHeaders(c context.Context, uri string, opts *rpcOptions) (*oauth2.Token, map[string]string, error) { return nil, nil, nil }
[ "func", "noAuthHeaders", "(", "c", "context", ".", "Context", ",", "uri", "string", ",", "opts", "*", "rpcOptions", ")", "(", "*", "oauth2", ".", "Token", ",", "map", "[", "string", "]", "string", ",", "error", ")", "{", "return", "nil", ",", "nil", ...
// noAuthHeaders is getRPCHeaders for NoAuth mode.
[ "noAuthHeaders", "is", "getRPCHeaders", "for", "NoAuth", "mode", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/server/auth/client.go#L532-L534
9,566
luci/luci-go
server/auth/client.go
asSelfHeaders
func asSelfHeaders(c context.Context, uri string, opts *rpcOptions) (*oauth2.Token, map[string]string, error) { cfg := getConfig(c) if cfg == nil || cfg.AccessTokenProvider == nil { return nil, nil, ErrNotConfigured } tok, err := cfg.AccessTokenProvider(c, opts.scopes) return tok, nil, err }
go
func asSelfHeaders(c context.Context, uri string, opts *rpcOptions) (*oauth2.Token, map[string]string, error) { cfg := getConfig(c) if cfg == nil || cfg.AccessTokenProvider == nil { return nil, nil, ErrNotConfigured } tok, err := cfg.AccessTokenProvider(c, opts.scopes) return tok, nil, err }
[ "func", "asSelfHeaders", "(", "c", "context", ".", "Context", ",", "uri", "string", ",", "opts", "*", "rpcOptions", ")", "(", "*", "oauth2", ".", "Token", ",", "map", "[", "string", "]", "string", ",", "error", ")", "{", "cfg", ":=", "getConfig", "("...
// asSelfHeaders returns a map of authentication headers to add to outbound // RPC requests done in AsSelf mode. // // This will be called by the transport layer on each request.
[ "asSelfHeaders", "returns", "a", "map", "of", "authentication", "headers", "to", "add", "to", "outbound", "RPC", "requests", "done", "in", "AsSelf", "mode", ".", "This", "will", "be", "called", "by", "the", "transport", "layer", "on", "each", "request", "." ...
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/server/auth/client.go#L540-L547
9,567
luci/luci-go
server/auth/client.go
asUserHeaders
func asUserHeaders(c context.Context, uri string, opts *rpcOptions) (*oauth2.Token, map[string]string, error) { cfg := getConfig(c) if cfg == nil || cfg.AccessTokenProvider == nil { return nil, nil, ErrNotConfigured } delegationToken := "" if opts.delegationToken != "" { delegationToken = opts.delegationToken...
go
func asUserHeaders(c context.Context, uri string, opts *rpcOptions) (*oauth2.Token, map[string]string, error) { cfg := getConfig(c) if cfg == nil || cfg.AccessTokenProvider == nil { return nil, nil, ErrNotConfigured } delegationToken := "" if opts.delegationToken != "" { delegationToken = opts.delegationToken...
[ "func", "asUserHeaders", "(", "c", "context", ".", "Context", ",", "uri", "string", ",", "opts", "*", "rpcOptions", ")", "(", "*", "oauth2", ".", "Token", ",", "map", "[", "string", "]", "string", ",", "error", ")", "{", "cfg", ":=", "getConfig", "("...
// asUserHeaders returns a map of authentication headers to add to outbound // RPC requests done in AsUser mode. // // This will be called by the transport layer on each request.
[ "asUserHeaders", "returns", "a", "map", "of", "authentication", "headers", "to", "add", "to", "outbound", "RPC", "requests", "done", "in", "AsUser", "mode", ".", "This", "will", "be", "called", "by", "the", "transport", "layer", "on", "each", "request", "." ...
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/server/auth/client.go#L553-L607
9,568
luci/luci-go
server/auth/client.go
asActorHeaders
func asActorHeaders(c context.Context, uri string, opts *rpcOptions) (*oauth2.Token, map[string]string, error) { mintTokenCall := MintAccessTokenForServiceAccount if opts.rpcMocks != nil && opts.rpcMocks.MintAccessTokenForServiceAccount != nil { mintTokenCall = opts.rpcMocks.MintAccessTokenForServiceAccount } oau...
go
func asActorHeaders(c context.Context, uri string, opts *rpcOptions) (*oauth2.Token, map[string]string, error) { mintTokenCall := MintAccessTokenForServiceAccount if opts.rpcMocks != nil && opts.rpcMocks.MintAccessTokenForServiceAccount != nil { mintTokenCall = opts.rpcMocks.MintAccessTokenForServiceAccount } oau...
[ "func", "asActorHeaders", "(", "c", "context", ".", "Context", ",", "uri", "string", ",", "opts", "*", "rpcOptions", ")", "(", "*", "oauth2", ".", "Token", ",", "map", "[", "string", "]", "string", ",", "error", ")", "{", "mintTokenCall", ":=", "MintAc...
// asActorHeaders returns a map of authentication headers to add to outbound // RPC requests done in AsActor mode. // // This will be called by the transport layer on each request.
[ "asActorHeaders", "returns", "a", "map", "of", "authentication", "headers", "to", "add", "to", "outbound", "RPC", "requests", "done", "in", "AsActor", "mode", ".", "This", "will", "be", "called", "by", "the", "transport", "layer", "on", "each", "request", "....
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/server/auth/client.go#L630-L641
9,569
luci/luci-go
server/auth/client.go
asProjectHeaders
func asProjectHeaders(c context.Context, uri string, opts *rpcOptions) (*oauth2.Token, map[string]string, error) { internal, err := isInternalURI(c, uri) if err != nil { return nil, nil, err } // For calls within a single LUCI deployment use the service's own OAuth2 // token and 'X-Luci-Project' header to conve...
go
func asProjectHeaders(c context.Context, uri string, opts *rpcOptions) (*oauth2.Token, map[string]string, error) { internal, err := isInternalURI(c, uri) if err != nil { return nil, nil, err } // For calls within a single LUCI deployment use the service's own OAuth2 // token and 'X-Luci-Project' header to conve...
[ "func", "asProjectHeaders", "(", "c", "context", ".", "Context", ",", "uri", "string", ",", "opts", "*", "rpcOptions", ")", "(", "*", "oauth2", ".", "Token", ",", "map", "[", "string", "]", "string", ",", "error", ")", "{", "internal", ",", "err", ":...
// asProjectHeaders returns a map of authentication headers to add to outbound // RPC requests done in AsProject mode. // // This will be called by the transport layer on each request.
[ "asProjectHeaders", "returns", "a", "map", "of", "authentication", "headers", "to", "add", "to", "outbound", "RPC", "requests", "done", "in", "AsProject", "mode", ".", "This", "will", "be", "called", "by", "the", "transport", "layer", "on", "each", "request", ...
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/server/auth/client.go#L647-L680
9,570
luci/luci-go
logdog/client/cmd/logdog_butler/subcommand_stream.go
Run
func (cmd *streamCommandRun) Run(app subcommands.Application, args []string, _ subcommands.Env) int { a := app.(*application) var ( streamFile *os.File defaultStreamName streamproto.StreamNameFlag ) if cmd.path == "-" { defaultStreamName = "stdin" streamFile = os.Stdin } else { streamName, err :=...
go
func (cmd *streamCommandRun) Run(app subcommands.Application, args []string, _ subcommands.Env) int { a := app.(*application) var ( streamFile *os.File defaultStreamName streamproto.StreamNameFlag ) if cmd.path == "-" { defaultStreamName = "stdin" streamFile = os.Stdin } else { streamName, err :=...
[ "func", "(", "cmd", "*", "streamCommandRun", ")", "Run", "(", "app", "subcommands", ".", "Application", ",", "args", "[", "]", "string", ",", "_", "subcommands", ".", "Env", ")", "int", "{", "a", ":=", "app", ".", "(", "*", "application", ")", "\n\n"...
// subcommands.Run
[ "subcommands", ".", "Run" ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/logdog/client/cmd/logdog_butler/subcommand_stream.go#L55-L117
9,571
luci/luci-go
buildbucket/luciexe/runner.go
Run
func (r *runner) Run(ctx context.Context, args *pb.RunnerArgs) (*pb.Build, error) { ctx, cancel := context.WithCancel(ctx) defer cancel() // Validate and normalize parameters. args = proto.Clone(args).(*pb.RunnerArgs) if err := normalizeArgs(args); err != nil { return nil, errors.Annotate(err, "invalid args").E...
go
func (r *runner) Run(ctx context.Context, args *pb.RunnerArgs) (*pb.Build, error) { ctx, cancel := context.WithCancel(ctx) defer cancel() // Validate and normalize parameters. args = proto.Clone(args).(*pb.RunnerArgs) if err := normalizeArgs(args); err != nil { return nil, errors.Annotate(err, "invalid args").E...
[ "func", "(", "r", "*", "runner", ")", "Run", "(", "ctx", "context", ".", "Context", ",", "args", "*", "pb", ".", "RunnerArgs", ")", "(", "*", "pb", ".", "Build", ",", "error", ")", "{", "ctx", ",", "cancel", ":=", "context", ".", "WithCancel", "(...
// Run runs a user executable.
[ "Run", "runs", "a", "user", "executable", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/buildbucket/luciexe/runner.go#L62-L154
9,572
luci/luci-go
buildbucket/luciexe/runner.go
setupWorkDir
func (r *runner) setupWorkDir(workDir string) error { switch _, err := os.Stat(workDir); { case err == nil: return errors.Reason("workdir %q already exists; it must not", workDir).Err() case os.IsNotExist(err): // good default: return err } return errors.Annotate(os.MkdirAll(workDir, 0700), "failed to c...
go
func (r *runner) setupWorkDir(workDir string) error { switch _, err := os.Stat(workDir); { case err == nil: return errors.Reason("workdir %q already exists; it must not", workDir).Err() case os.IsNotExist(err): // good default: return err } return errors.Annotate(os.MkdirAll(workDir, 0700), "failed to c...
[ "func", "(", "r", "*", "runner", ")", "setupWorkDir", "(", "workDir", "string", ")", "error", "{", "switch", "_", ",", "err", ":=", "os", ".", "Stat", "(", "workDir", ")", ";", "{", "case", "err", "==", "nil", ":", "return", "errors", ".", "Reason"...
// setupWorkDir creates a work dir. // If workdir already exists, returns an error.
[ "setupWorkDir", "creates", "a", "work", "dir", ".", "If", "workdir", "already", "exists", "returns", "an", "error", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/buildbucket/luciexe/runner.go#L158-L172
9,573
luci/luci-go
buildbucket/luciexe/runner.go
setupUserEnv
func (r *runner) setupUserEnv(ctx context.Context, args *pb.RunnerArgs, userAuth *authctx.Context, logdogServ *logdogServer, logdogNamespace string) (environ.Env, error) { ret := environ.System() userAuth.ExportIntoEnv(ret) if err := logdogServ.ExportIntoEnv(ret); err != nil { return environ.Env{}, err } ret.Set...
go
func (r *runner) setupUserEnv(ctx context.Context, args *pb.RunnerArgs, userAuth *authctx.Context, logdogServ *logdogServer, logdogNamespace string) (environ.Env, error) { ret := environ.System() userAuth.ExportIntoEnv(ret) if err := logdogServ.ExportIntoEnv(ret); err != nil { return environ.Env{}, err } ret.Set...
[ "func", "(", "r", "*", "runner", ")", "setupUserEnv", "(", "ctx", "context", ".", "Context", ",", "args", "*", "pb", ".", "RunnerArgs", ",", "userAuth", "*", "authctx", ".", "Context", ",", "logdogServ", "*", "logdogServer", ",", "logdogNamespace", "string...
// setupUserEnv prepares user subprocess environment.
[ "setupUserEnv", "prepares", "user", "subprocess", "environment", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/buildbucket/luciexe/runner.go#L243-L278
9,574
luci/luci-go
buildbucket/luciexe/runner.go
readBuildSecrets
func readBuildSecrets(ctx context.Context) (*pb.BuildSecrets, error) { swarming := lucictx.GetSwarming(ctx) if swarming == nil { return nil, nil } secrets := &pb.BuildSecrets{} if err := proto.Unmarshal(swarming.SecretBytes, secrets); err != nil { return nil, err } return secrets, nil }
go
func readBuildSecrets(ctx context.Context) (*pb.BuildSecrets, error) { swarming := lucictx.GetSwarming(ctx) if swarming == nil { return nil, nil } secrets := &pb.BuildSecrets{} if err := proto.Unmarshal(swarming.SecretBytes, secrets); err != nil { return nil, err } return secrets, nil }
[ "func", "readBuildSecrets", "(", "ctx", "context", ".", "Context", ")", "(", "*", "pb", ".", "BuildSecrets", ",", "error", ")", "{", "swarming", ":=", "lucictx", ".", "GetSwarming", "(", "ctx", ")", "\n", "if", "swarming", "==", "nil", "{", "return", "...
// readBuildSecrets reads BuildSecrets message from swarming secret bytes, // if any.
[ "readBuildSecrets", "reads", "BuildSecrets", "message", "from", "swarming", "secret", "bytes", "if", "any", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/buildbucket/luciexe/runner.go#L310-L321
9,575
luci/luci-go
buildbucket/luciexe/runner.go
indentedJSONPB
func indentedJSONPB(m proto.Message) ([]byte, error) { // Note: json.Indent indents more nicely than jsonpb.Marshaler. unindented := &bytes.Buffer{} if err := (&jsonpb.Marshaler{}).Marshal(unindented, m); err != nil { return nil, err } indented := &bytes.Buffer{} if err := json.Indent(indented, unindented.Byte...
go
func indentedJSONPB(m proto.Message) ([]byte, error) { // Note: json.Indent indents more nicely than jsonpb.Marshaler. unindented := &bytes.Buffer{} if err := (&jsonpb.Marshaler{}).Marshal(unindented, m); err != nil { return nil, err } indented := &bytes.Buffer{} if err := json.Indent(indented, unindented.Byte...
[ "func", "indentedJSONPB", "(", "m", "proto", ".", "Message", ")", "(", "[", "]", "byte", ",", "error", ")", "{", "// Note: json.Indent indents more nicely than jsonpb.Marshaler.", "unindented", ":=", "&", "bytes", ".", "Buffer", "{", "}", "\n", "if", "err", ":...
// indentedJSONPB returns m marshaled to indented JSON.
[ "indentedJSONPB", "returns", "m", "marshaled", "to", "indented", "JSON", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/buildbucket/luciexe/runner.go#L407-L419
9,576
luci/luci-go
buildbucket/luciexe/runner.go
globalLogTags
func globalLogTags(args *pb.RunnerArgs) map[string]string { ret := make(map[string]string, 4) ret[logDogViewerURLTag] = fmt.Sprintf("https://%s/build/%d", args.BuildbucketHost, args.Build.Id) // SWARMING_SERVER is the full URL: https://example.com // We want just the hostname. env := environ.System() if v, ok :=...
go
func globalLogTags(args *pb.RunnerArgs) map[string]string { ret := make(map[string]string, 4) ret[logDogViewerURLTag] = fmt.Sprintf("https://%s/build/%d", args.BuildbucketHost, args.Build.Id) // SWARMING_SERVER is the full URL: https://example.com // We want just the hostname. env := environ.System() if v, ok :=...
[ "func", "globalLogTags", "(", "args", "*", "pb", ".", "RunnerArgs", ")", "map", "[", "string", "]", "string", "{", "ret", ":=", "make", "(", "map", "[", "string", "]", "string", ",", "4", ")", "\n", "ret", "[", "logDogViewerURLTag", "]", "=", "fmt", ...
// globalLogTags returns tags to be added to all logdog streams by default.
[ "globalLogTags", "returns", "tags", "to", "be", "added", "to", "all", "logdog", "streams", "by", "default", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/buildbucket/luciexe/runner.go#L476-L495
9,577
luci/luci-go
common/api/buildbucket/buildbucket/v1/timestamp.go
ParseTimestamp
func ParseTimestamp(usec int64) time.Time { if usec == 0 { return time.Time{} } // TODO(nodir): will start to overflow in year ~2250+, fix it then. return time.Unix(0, usec*1000).UTC() }
go
func ParseTimestamp(usec int64) time.Time { if usec == 0 { return time.Time{} } // TODO(nodir): will start to overflow in year ~2250+, fix it then. return time.Unix(0, usec*1000).UTC() }
[ "func", "ParseTimestamp", "(", "usec", "int64", ")", "time", ".", "Time", "{", "if", "usec", "==", "0", "{", "return", "time", ".", "Time", "{", "}", "\n", "}", "\n", "// TODO(nodir): will start to overflow in year ~2250+, fix it then.", "return", "time", ".", ...
// ParseTimestamp parses a buildbucket timestamp.
[ "ParseTimestamp", "parses", "a", "buildbucket", "timestamp", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/common/api/buildbucket/buildbucket/v1/timestamp.go#L20-L26
9,578
luci/luci-go
auth/internal/iam.go
NewIAMTokenProvider
func NewIAMTokenProvider(ctx context.Context, actAs string, scopes []string, transport http.RoundTripper) (TokenProvider, error) { return &iamTokenProvider{ actAs: actAs, scopes: scopes, transport: transport, cacheKey: CacheKey{ Key: fmt.Sprintf("iam/%s", actAs), Scopes: scopes, }, }, nil }
go
func NewIAMTokenProvider(ctx context.Context, actAs string, scopes []string, transport http.RoundTripper) (TokenProvider, error) { return &iamTokenProvider{ actAs: actAs, scopes: scopes, transport: transport, cacheKey: CacheKey{ Key: fmt.Sprintf("iam/%s", actAs), Scopes: scopes, }, }, nil }
[ "func", "NewIAMTokenProvider", "(", "ctx", "context", ".", "Context", ",", "actAs", "string", ",", "scopes", "[", "]", "string", ",", "transport", "http", ".", "RoundTripper", ")", "(", "TokenProvider", ",", "error", ")", "{", "return", "&", "iamTokenProvide...
// NewIAMTokenProvider returns TokenProvider that uses SignBlob IAM API to // sign assertions on behalf of some service account.
[ "NewIAMTokenProvider", "returns", "TokenProvider", "that", "uses", "SignBlob", "IAM", "API", "to", "sign", "assertions", "on", "behalf", "of", "some", "service", "account", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/auth/internal/iam.go#L38-L48
9,579
luci/luci-go
grpc/svcmux/svcmux.go
GetServiceVersion
func GetServiceVersion(c context.Context, defaultVer string) string { if md, ok := metadata.FromIncomingContext(c); ok { values := md[VersionMetadataKey] if len(values) != 0 { return values[0] } } return defaultVer }
go
func GetServiceVersion(c context.Context, defaultVer string) string { if md, ok := metadata.FromIncomingContext(c); ok { values := md[VersionMetadataKey] if len(values) != 0 { return values[0] } } return defaultVer }
[ "func", "GetServiceVersion", "(", "c", "context", ".", "Context", ",", "defaultVer", "string", ")", "string", "{", "if", "md", ",", "ok", ":=", "metadata", ".", "FromIncomingContext", "(", "c", ")", ";", "ok", "{", "values", ":=", "md", "[", "VersionMeta...
// GetServiceVersion extracts requested service version from metadata in c.
[ "GetServiceVersion", "extracts", "requested", "service", "version", "from", "metadata", "in", "c", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/grpc/svcmux/svcmux.go#L33-L41
9,580
luci/luci-go
tokenserver/appengine/impl/certconfig/ca.go
ParseConfig
func (c *CA) ParseConfig() (*admin.CertificateAuthorityConfig, error) { msg := &admin.CertificateAuthorityConfig{} if err := proto.Unmarshal(c.Config, msg); err != nil { return nil, err } return msg, nil }
go
func (c *CA) ParseConfig() (*admin.CertificateAuthorityConfig, error) { msg := &admin.CertificateAuthorityConfig{} if err := proto.Unmarshal(c.Config, msg); err != nil { return nil, err } return msg, nil }
[ "func", "(", "c", "*", "CA", ")", "ParseConfig", "(", ")", "(", "*", "admin", ".", "CertificateAuthorityConfig", ",", "error", ")", "{", "msg", ":=", "&", "admin", ".", "CertificateAuthorityConfig", "{", "}", "\n", "if", "err", ":=", "proto", ".", "Unm...
// ParseConfig parses proto message stored in Config.
[ "ParseConfig", "parses", "proto", "message", "stored", "in", "Config", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/tokenserver/appengine/impl/certconfig/ca.go#L74-L80
9,581
luci/luci-go
tokenserver/appengine/impl/certconfig/ca.go
ListCAs
func ListCAs(c context.Context) ([]string, error) { keys := []*ds.Key{} q := ds.NewQuery("CA").Eq("Removed", false).KeysOnly(true) if err := ds.GetAll(c, q, &keys); err != nil { return nil, transient.Tag.Apply(err) } names := make([]string, len(keys)) for i, key := range keys { names[i] = key.StringID() } r...
go
func ListCAs(c context.Context) ([]string, error) { keys := []*ds.Key{} q := ds.NewQuery("CA").Eq("Removed", false).KeysOnly(true) if err := ds.GetAll(c, q, &keys); err != nil { return nil, transient.Tag.Apply(err) } names := make([]string, len(keys)) for i, key := range keys { names[i] = key.StringID() } r...
[ "func", "ListCAs", "(", "c", "context", ".", "Context", ")", "(", "[", "]", "string", ",", "error", ")", "{", "keys", ":=", "[", "]", "*", "ds", ".", "Key", "{", "}", "\n", "q", ":=", "ds", ".", "NewQuery", "(", "\"", "\"", ")", ".", "Eq", ...
// ListCAs returns names of all currently active CAs, in no particular order.
[ "ListCAs", "returns", "names", "of", "all", "currently", "active", "CAs", "in", "no", "particular", "order", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/tokenserver/appengine/impl/certconfig/ca.go#L83-L94
9,582
luci/luci-go
tokenserver/appengine/impl/certconfig/ca.go
StoreCAUniqueIDToCNMap
func StoreCAUniqueIDToCNMap(c context.Context, mapping map[int64]string) error { buf := bytes.Buffer{} enc := gob.NewEncoder(&buf) if err := enc.Encode(mapping); err != nil { return err } // Note that in practice 'mapping' is usually very small, so we are not // concerned about 1MB entity size limit. return tr...
go
func StoreCAUniqueIDToCNMap(c context.Context, mapping map[int64]string) error { buf := bytes.Buffer{} enc := gob.NewEncoder(&buf) if err := enc.Encode(mapping); err != nil { return err } // Note that in practice 'mapping' is usually very small, so we are not // concerned about 1MB entity size limit. return tr...
[ "func", "StoreCAUniqueIDToCNMap", "(", "c", "context", ".", "Context", ",", "mapping", "map", "[", "int64", "]", "string", ")", "error", "{", "buf", ":=", "bytes", ".", "Buffer", "{", "}", "\n", "enc", ":=", "gob", ".", "NewEncoder", "(", "&", "buf", ...
// StoreCAUniqueIDToCNMap overwrites CAUniqueIDToCNMap with new content.
[ "StoreCAUniqueIDToCNMap", "overwrites", "CAUniqueIDToCNMap", "with", "new", "content", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/tokenserver/appengine/impl/certconfig/ca.go#L108-L119
9,583
luci/luci-go
tokenserver/appengine/impl/certconfig/ca.go
LoadCAUniqueIDToCNMap
func LoadCAUniqueIDToCNMap(c context.Context) (map[int64]string, error) { ent := CAUniqueIDToCNMap{} switch err := ds.Get(c, &ent); { case err == ds.ErrNoSuchEntity: return nil, nil case err != nil: return nil, transient.Tag.Apply(err) } dec := gob.NewDecoder(bytes.NewReader(ent.GobEncodedMap)) out := map[in...
go
func LoadCAUniqueIDToCNMap(c context.Context) (map[int64]string, error) { ent := CAUniqueIDToCNMap{} switch err := ds.Get(c, &ent); { case err == ds.ErrNoSuchEntity: return nil, nil case err != nil: return nil, transient.Tag.Apply(err) } dec := gob.NewDecoder(bytes.NewReader(ent.GobEncodedMap)) out := map[in...
[ "func", "LoadCAUniqueIDToCNMap", "(", "c", "context", ".", "Context", ")", "(", "map", "[", "int64", "]", "string", ",", "error", ")", "{", "ent", ":=", "CAUniqueIDToCNMap", "{", "}", "\n", "switch", "err", ":=", "ds", ".", "Get", "(", "c", ",", "&",...
// LoadCAUniqueIDToCNMap loads CAUniqueIDToCNMap from the datastore.
[ "LoadCAUniqueIDToCNMap", "loads", "CAUniqueIDToCNMap", "from", "the", "datastore", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/tokenserver/appengine/impl/certconfig/ca.go#L122-L136
9,584
luci/luci-go
tokenserver/appengine/impl/certconfig/ca.go
GetCAByUniqueID
func GetCAByUniqueID(c context.Context, id int64) (string, error) { cached, err := mappingCache.Fetch(c, func(interface{}) (interface{}, time.Duration, error) { val, err := LoadCAUniqueIDToCNMap(c) return val, time.Minute, err }) if err != nil { return "", err } mapping := cached.(map[int64]string) return m...
go
func GetCAByUniqueID(c context.Context, id int64) (string, error) { cached, err := mappingCache.Fetch(c, func(interface{}) (interface{}, time.Duration, error) { val, err := LoadCAUniqueIDToCNMap(c) return val, time.Minute, err }) if err != nil { return "", err } mapping := cached.(map[int64]string) return m...
[ "func", "GetCAByUniqueID", "(", "c", "context", ".", "Context", ",", "id", "int64", ")", "(", "string", ",", "error", ")", "{", "cached", ",", "err", ":=", "mappingCache", ".", "Fetch", "(", "c", ",", "func", "(", "interface", "{", "}", ")", "(", "...
// GetCAByUniqueID returns CN name that corresponds to given unique ID. // // It uses cached CAUniqueIDToCNMap for lookups. Returns empty string if there's // no such CA.
[ "GetCAByUniqueID", "returns", "CN", "name", "that", "corresponds", "to", "given", "unique", "ID", ".", "It", "uses", "cached", "CAUniqueIDToCNMap", "for", "lookups", ".", "Returns", "empty", "string", "if", "there", "s", "no", "such", "CA", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/tokenserver/appengine/impl/certconfig/ca.go#L145-L155
9,585
libp2p/go-libp2p-nat
nat.go
DiscoverNAT
func DiscoverNAT(ctx context.Context) (*NAT, error) { var ( natInstance nat.NAT err error ) done := make(chan struct{}) go func() { defer close(done) // This will abort in 10 seconds anyways. natInstance, err = nat.DiscoverGateway() }() select { case <-done: case <-ctx.Done(): return nil, ...
go
func DiscoverNAT(ctx context.Context) (*NAT, error) { var ( natInstance nat.NAT err error ) done := make(chan struct{}) go func() { defer close(done) // This will abort in 10 seconds anyways. natInstance, err = nat.DiscoverGateway() }() select { case <-done: case <-ctx.Done(): return nil, ...
[ "func", "DiscoverNAT", "(", "ctx", "context", ".", "Context", ")", "(", "*", "NAT", ",", "error", ")", "{", "var", "(", "natInstance", "nat", ".", "NAT", "\n", "err", "error", "\n", ")", "\n\n", "done", ":=", "make", "(", "chan", "struct", "{", "}"...
// DiscoverNAT looks for a NAT device in the network and // returns an object that can manage port mappings.
[ "DiscoverNAT", "looks", "for", "a", "NAT", "device", "in", "the", "network", "and", "returns", "an", "object", "that", "can", "manage", "port", "mappings", "." ]
2736f3ac758bcdffdf068f7b28df7075a6707188
https://github.com/libp2p/go-libp2p-nat/blob/2736f3ac758bcdffdf068f7b28df7075a6707188/nat.go#L32-L64
9,586
libp2p/go-libp2p-nat
nat.go
Mappings
func (nat *NAT) Mappings() []Mapping { nat.mappingmu.Lock() maps2 := make([]Mapping, 0, len(nat.mappings)) for m := range nat.mappings { maps2 = append(maps2, m) } nat.mappingmu.Unlock() return maps2 }
go
func (nat *NAT) Mappings() []Mapping { nat.mappingmu.Lock() maps2 := make([]Mapping, 0, len(nat.mappings)) for m := range nat.mappings { maps2 = append(maps2, m) } nat.mappingmu.Unlock() return maps2 }
[ "func", "(", "nat", "*", "NAT", ")", "Mappings", "(", ")", "[", "]", "Mapping", "{", "nat", ".", "mappingmu", ".", "Lock", "(", ")", "\n", "maps2", ":=", "make", "(", "[", "]", "Mapping", ",", "0", ",", "len", "(", "nat", ".", "mappings", ")", ...
// Mappings returns a slice of all NAT mappings
[ "Mappings", "returns", "a", "slice", "of", "all", "NAT", "mappings" ]
2736f3ac758bcdffdf068f7b28df7075a6707188
https://github.com/libp2p/go-libp2p-nat/blob/2736f3ac758bcdffdf068f7b28df7075a6707188/nat.go#L99-L107
9,587
gernest/front
front.go
Handle
func (m *Matter) Handle(delim string, fn HandlerFunc) { m.handlers[delim] = fn }
go
func (m *Matter) Handle(delim string, fn HandlerFunc) { m.handlers[delim] = fn }
[ "func", "(", "m", "*", "Matter", ")", "Handle", "(", "delim", "string", ",", "fn", "HandlerFunc", ")", "{", "m", ".", "handlers", "[", "delim", "]", "=", "fn", "\n", "}" ]
//Handle registers a handler for the given frontmatter delimiter
[ "Handle", "registers", "a", "handler", "for", "the", "given", "frontmatter", "delimiter" ]
ed80ca338b8848e3bfc3fa13824c91ebbcad53db
https://github.com/gernest/front/blob/ed80ca338b8848e3bfc3fa13824c91ebbcad53db/front.go#L40-L42
9,588
gernest/front
front.go
Parse
func (m *Matter) Parse(input io.Reader) (front map[string]interface{}, body string, err error) { return m.parse(input) }
go
func (m *Matter) Parse(input io.Reader) (front map[string]interface{}, body string, err error) { return m.parse(input) }
[ "func", "(", "m", "*", "Matter", ")", "Parse", "(", "input", "io", ".", "Reader", ")", "(", "front", "map", "[", "string", "]", "interface", "{", "}", ",", "body", "string", ",", "err", "error", ")", "{", "return", "m", ".", "parse", "(", "input"...
// Parse parses the input and extract the frontmatter
[ "Parse", "parses", "the", "input", "and", "extract", "the", "frontmatter" ]
ed80ca338b8848e3bfc3fa13824c91ebbcad53db
https://github.com/gernest/front/blob/ed80ca338b8848e3bfc3fa13824c91ebbcad53db/front.go#L45-L47
9,589
gernest/front
front.go
split
func (m *Matter) split(data []byte, atEOF bool) (advance int, token []byte, err error) { if atEOF && len(data) == 0 { return 0, nil, nil } delim, err := sniffDelim(data) if err != nil { return 0, nil, err } if _, ok := m.handlers[delim]; !ok { return 0, nil, ErrUnknownDelim } if x := bytes.Index(data, []b...
go
func (m *Matter) split(data []byte, atEOF bool) (advance int, token []byte, err error) { if atEOF && len(data) == 0 { return 0, nil, nil } delim, err := sniffDelim(data) if err != nil { return 0, nil, err } if _, ok := m.handlers[delim]; !ok { return 0, nil, ErrUnknownDelim } if x := bytes.Index(data, []b...
[ "func", "(", "m", "*", "Matter", ")", "split", "(", "data", "[", "]", "byte", ",", "atEOF", "bool", ")", "(", "advance", "int", ",", "token", "[", "]", "byte", ",", "err", "error", ")", "{", "if", "atEOF", "&&", "len", "(", "data", ")", "==", ...
//split implements bufio.SplitFunc for spliting front matter from the body text.
[ "split", "implements", "bufio", ".", "SplitFunc", "for", "spliting", "front", "matter", "from", "the", "body", "text", "." ]
ed80ca338b8848e3bfc3fa13824c91ebbcad53db
https://github.com/gernest/front/blob/ed80ca338b8848e3bfc3fa13824c91ebbcad53db/front.go#L97-L119
9,590
gernest/front
front.go
JSONHandler
func JSONHandler(front string) (map[string]interface{}, error) { var rst interface{} err := json.Unmarshal([]byte(front), &rst) if err != nil { return nil, err } return rst.(map[string]interface{}), nil }
go
func JSONHandler(front string) (map[string]interface{}, error) { var rst interface{} err := json.Unmarshal([]byte(front), &rst) if err != nil { return nil, err } return rst.(map[string]interface{}), nil }
[ "func", "JSONHandler", "(", "front", "string", ")", "(", "map", "[", "string", "]", "interface", "{", "}", ",", "error", ")", "{", "var", "rst", "interface", "{", "}", "\n", "err", ":=", "json", ".", "Unmarshal", "(", "[", "]", "byte", "(", "front"...
//JSONHandler implements HandlerFunc interface. It extracts front matter data from the given // string argument by interpreting it as a json string.
[ "JSONHandler", "implements", "HandlerFunc", "interface", ".", "It", "extracts", "front", "matter", "data", "from", "the", "given", "string", "argument", "by", "interpreting", "it", "as", "a", "json", "string", "." ]
ed80ca338b8848e3bfc3fa13824c91ebbcad53db
https://github.com/gernest/front/blob/ed80ca338b8848e3bfc3fa13824c91ebbcad53db/front.go#L127-L134
9,591
mindprince/gonvml
bindings.go
errorString
func errorString(ret C.nvmlReturn_t) error { if ret == C.NVML_SUCCESS { return nil } // We need to special case this because if nvml library is not found // nvmlErrorString() method will not work. if ret == C.NVML_ERROR_LIBRARY_NOT_FOUND || C.nvmlHandle == nil { return errLibraryNotLoaded } err := C.GoString...
go
func errorString(ret C.nvmlReturn_t) error { if ret == C.NVML_SUCCESS { return nil } // We need to special case this because if nvml library is not found // nvmlErrorString() method will not work. if ret == C.NVML_ERROR_LIBRARY_NOT_FOUND || C.nvmlHandle == nil { return errLibraryNotLoaded } err := C.GoString...
[ "func", "errorString", "(", "ret", "C", ".", "nvmlReturn_t", ")", "error", "{", "if", "ret", "==", "C", ".", "NVML_SUCCESS", "{", "return", "nil", "\n", "}", "\n", "// We need to special case this because if nvml library is not found", "// nvmlErrorString() method will ...
// errorString takes a nvmlReturn_t and converts it into a golang error. // It uses a nvml method to convert to a user friendly error message.
[ "errorString", "takes", "a", "nvmlReturn_t", "and", "converts", "it", "into", "a", "golang", "error", ".", "It", "uses", "a", "nvml", "method", "to", "convert", "to", "a", "user", "friendly", "error", "message", "." ]
b364b296c7320f5d3dc084aa536a3dba33b68f90
https://github.com/mindprince/gonvml/blob/b364b296c7320f5d3dc084aa536a3dba33b68f90/bindings.go#L340-L351
9,592
mindprince/gonvml
bindings.go
SystemDriverVersion
func SystemDriverVersion() (string, error) { if C.nvmlHandle == nil { return "", errLibraryNotLoaded } var driver [szDriver]C.char r := C.nvmlSystemGetDriverVersion(&driver[0], szDriver) return C.GoString(&driver[0]), errorString(r) }
go
func SystemDriverVersion() (string, error) { if C.nvmlHandle == nil { return "", errLibraryNotLoaded } var driver [szDriver]C.char r := C.nvmlSystemGetDriverVersion(&driver[0], szDriver) return C.GoString(&driver[0]), errorString(r) }
[ "func", "SystemDriverVersion", "(", ")", "(", "string", ",", "error", ")", "{", "if", "C", ".", "nvmlHandle", "==", "nil", "{", "return", "\"", "\"", ",", "errLibraryNotLoaded", "\n", "}", "\n", "var", "driver", "[", "szDriver", "]", "C", ".", "char", ...
// SystemDriverVersion returns the the driver version on the system.
[ "SystemDriverVersion", "returns", "the", "the", "driver", "version", "on", "the", "system", "." ]
b364b296c7320f5d3dc084aa536a3dba33b68f90
https://github.com/mindprince/gonvml/blob/b364b296c7320f5d3dc084aa536a3dba33b68f90/bindings.go#L354-L361
9,593
mindprince/gonvml
bindings.go
DeviceCount
func DeviceCount() (uint, error) { if C.nvmlHandle == nil { return 0, errLibraryNotLoaded } var n C.uint r := C.nvmlDeviceGetCount(&n) return uint(n), errorString(r) }
go
func DeviceCount() (uint, error) { if C.nvmlHandle == nil { return 0, errLibraryNotLoaded } var n C.uint r := C.nvmlDeviceGetCount(&n) return uint(n), errorString(r) }
[ "func", "DeviceCount", "(", ")", "(", "uint", ",", "error", ")", "{", "if", "C", ".", "nvmlHandle", "==", "nil", "{", "return", "0", ",", "errLibraryNotLoaded", "\n", "}", "\n", "var", "n", "C", ".", "uint", "\n", "r", ":=", "C", ".", "nvmlDeviceGe...
// DeviceCount returns the number of nvidia devices on the system.
[ "DeviceCount", "returns", "the", "number", "of", "nvidia", "devices", "on", "the", "system", "." ]
b364b296c7320f5d3dc084aa536a3dba33b68f90
https://github.com/mindprince/gonvml/blob/b364b296c7320f5d3dc084aa536a3dba33b68f90/bindings.go#L364-L371
9,594
mindprince/gonvml
bindings.go
UUID
func (d Device) UUID() (string, error) { if C.nvmlHandle == nil { return "", errLibraryNotLoaded } var uuid [szUUID]C.char r := C.nvmlDeviceGetUUID(d.dev, &uuid[0], szUUID) return C.GoString(&uuid[0]), errorString(r) }
go
func (d Device) UUID() (string, error) { if C.nvmlHandle == nil { return "", errLibraryNotLoaded } var uuid [szUUID]C.char r := C.nvmlDeviceGetUUID(d.dev, &uuid[0], szUUID) return C.GoString(&uuid[0]), errorString(r) }
[ "func", "(", "d", "Device", ")", "UUID", "(", ")", "(", "string", ",", "error", ")", "{", "if", "C", ".", "nvmlHandle", "==", "nil", "{", "return", "\"", "\"", ",", "errLibraryNotLoaded", "\n", "}", "\n", "var", "uuid", "[", "szUUID", "]", "C", "...
// UUID returns the globally unique immutable UUID associated with this device.
[ "UUID", "returns", "the", "globally", "unique", "immutable", "UUID", "associated", "with", "this", "device", "." ]
b364b296c7320f5d3dc084aa536a3dba33b68f90
https://github.com/mindprince/gonvml/blob/b364b296c7320f5d3dc084aa536a3dba33b68f90/bindings.go#L404-L411
9,595
mindprince/gonvml
bindings.go
Name
func (d Device) Name() (string, error) { if C.nvmlHandle == nil { return "", errLibraryNotLoaded } var name [szName]C.char r := C.nvmlDeviceGetName(d.dev, &name[0], szName) return C.GoString(&name[0]), errorString(r) }
go
func (d Device) Name() (string, error) { if C.nvmlHandle == nil { return "", errLibraryNotLoaded } var name [szName]C.char r := C.nvmlDeviceGetName(d.dev, &name[0], szName) return C.GoString(&name[0]), errorString(r) }
[ "func", "(", "d", "Device", ")", "Name", "(", ")", "(", "string", ",", "error", ")", "{", "if", "C", ".", "nvmlHandle", "==", "nil", "{", "return", "\"", "\"", ",", "errLibraryNotLoaded", "\n", "}", "\n", "var", "name", "[", "szName", "]", "C", "...
// Name returns the product name of the device.
[ "Name", "returns", "the", "product", "name", "of", "the", "device", "." ]
b364b296c7320f5d3dc084aa536a3dba33b68f90
https://github.com/mindprince/gonvml/blob/b364b296c7320f5d3dc084aa536a3dba33b68f90/bindings.go#L414-L421
9,596
mindprince/gonvml
bindings.go
AveragePowerUsage
func (d Device) AveragePowerUsage(since time.Duration) (uint, error) { if C.nvmlHandle == nil { return 0, errLibraryNotLoaded } lastTs := C.ulonglong(time.Now().Add(-1*since).UnixNano() / 1000) var n C.uint r := C.nvmlDeviceGetAverageUsage(d.dev, C.NVML_TOTAL_POWER_SAMPLES, lastTs, &n) return uint(n), errorStri...
go
func (d Device) AveragePowerUsage(since time.Duration) (uint, error) { if C.nvmlHandle == nil { return 0, errLibraryNotLoaded } lastTs := C.ulonglong(time.Now().Add(-1*since).UnixNano() / 1000) var n C.uint r := C.nvmlDeviceGetAverageUsage(d.dev, C.NVML_TOTAL_POWER_SAMPLES, lastTs, &n) return uint(n), errorStri...
[ "func", "(", "d", "Device", ")", "AveragePowerUsage", "(", "since", "time", ".", "Duration", ")", "(", "uint", ",", "error", ")", "{", "if", "C", ".", "nvmlHandle", "==", "nil", "{", "return", "0", ",", "errLibraryNotLoaded", "\n", "}", "\n", "lastTs",...
// AveragePowerUsage returns the power usage for this GPU and its associated circuitry // in milliwatts averaged over the samples collected in the last `since` duration.
[ "AveragePowerUsage", "returns", "the", "power", "usage", "for", "this", "GPU", "and", "its", "associated", "circuitry", "in", "milliwatts", "averaged", "over", "the", "samples", "collected", "in", "the", "last", "since", "duration", "." ]
b364b296c7320f5d3dc084aa536a3dba33b68f90
https://github.com/mindprince/gonvml/blob/b364b296c7320f5d3dc084aa536a3dba33b68f90/bindings.go#L458-L466
9,597
mindprince/gonvml
bindings.go
Temperature
func (d Device) Temperature() (uint, error) { if C.nvmlHandle == nil { return 0, errLibraryNotLoaded } var n C.uint r := C.nvmlDeviceGetTemperature(d.dev, C.NVML_TEMPERATURE_GPU, &n) return uint(n), errorString(r) }
go
func (d Device) Temperature() (uint, error) { if C.nvmlHandle == nil { return 0, errLibraryNotLoaded } var n C.uint r := C.nvmlDeviceGetTemperature(d.dev, C.NVML_TEMPERATURE_GPU, &n) return uint(n), errorString(r) }
[ "func", "(", "d", "Device", ")", "Temperature", "(", ")", "(", "uint", ",", "error", ")", "{", "if", "C", ".", "nvmlHandle", "==", "nil", "{", "return", "0", ",", "errLibraryNotLoaded", "\n", "}", "\n", "var", "n", "C", ".", "uint", "\n", "r", ":...
// Temperature returns the temperature for this GPU in Celsius.
[ "Temperature", "returns", "the", "temperature", "for", "this", "GPU", "in", "Celsius", "." ]
b364b296c7320f5d3dc084aa536a3dba33b68f90
https://github.com/mindprince/gonvml/blob/b364b296c7320f5d3dc084aa536a3dba33b68f90/bindings.go#L482-L489
9,598
mindprince/gonvml
bindings.go
FanSpeed
func (d Device) FanSpeed() (uint, error) { if C.nvmlHandle == nil { return 0, errLibraryNotLoaded } var n C.uint r := C.nvmlDeviceGetFanSpeed(d.dev, &n) return uint(n), errorString(r) }
go
func (d Device) FanSpeed() (uint, error) { if C.nvmlHandle == nil { return 0, errLibraryNotLoaded } var n C.uint r := C.nvmlDeviceGetFanSpeed(d.dev, &n) return uint(n), errorString(r) }
[ "func", "(", "d", "Device", ")", "FanSpeed", "(", ")", "(", "uint", ",", "error", ")", "{", "if", "C", ".", "nvmlHandle", "==", "nil", "{", "return", "0", ",", "errLibraryNotLoaded", "\n", "}", "\n", "var", "n", "C", ".", "uint", "\n", "r", ":=",...
// FanSpeed returns the temperature for this GPU in the percentage of its full // speed, with 100 being the maximum.
[ "FanSpeed", "returns", "the", "temperature", "for", "this", "GPU", "in", "the", "percentage", "of", "its", "full", "speed", "with", "100", "being", "the", "maximum", "." ]
b364b296c7320f5d3dc084aa536a3dba33b68f90
https://github.com/mindprince/gonvml/blob/b364b296c7320f5d3dc084aa536a3dba33b68f90/bindings.go#L493-L500
9,599
mindprince/gonvml
bindings.go
EncoderUtilization
func (d Device) EncoderUtilization() (uint, uint, error) { if C.nvmlHandle == nil { return 0, 0, errLibraryNotLoaded } var n C.uint var sp C.uint r := C.nvmlDeviceGetEncoderUtilization(d.dev, &n, &sp) return uint(n), uint(sp), errorString(r) }
go
func (d Device) EncoderUtilization() (uint, uint, error) { if C.nvmlHandle == nil { return 0, 0, errLibraryNotLoaded } var n C.uint var sp C.uint r := C.nvmlDeviceGetEncoderUtilization(d.dev, &n, &sp) return uint(n), uint(sp), errorString(r) }
[ "func", "(", "d", "Device", ")", "EncoderUtilization", "(", ")", "(", "uint", ",", "uint", ",", "error", ")", "{", "if", "C", ".", "nvmlHandle", "==", "nil", "{", "return", "0", ",", "0", ",", "errLibraryNotLoaded", "\n", "}", "\n", "var", "n", "C"...
// EncoderUtilization returns the percent of time over the last sample period during which the GPU video encoder was being used. // The sampling period is variable and is returned in the second return argument in microseconds.
[ "EncoderUtilization", "returns", "the", "percent", "of", "time", "over", "the", "last", "sample", "period", "during", "which", "the", "GPU", "video", "encoder", "was", "being", "used", ".", "The", "sampling", "period", "is", "variable", "and", "is", "returned"...
b364b296c7320f5d3dc084aa536a3dba33b68f90
https://github.com/mindprince/gonvml/blob/b364b296c7320f5d3dc084aa536a3dba33b68f90/bindings.go#L504-L512