id
int32
0
167k
repo
stringlengths
5
54
path
stringlengths
4
155
func_name
stringlengths
1
118
original_string
stringlengths
52
85.5k
language
stringclasses
1 value
code
stringlengths
52
85.5k
code_tokens
listlengths
21
1.41k
docstring
stringlengths
6
2.61k
docstring_tokens
listlengths
3
215
sha
stringlengths
40
40
url
stringlengths
85
252
131,100
luci/luci-go
machine-db/appengine/rpc/dracs.go
CreateDRAC
func (*Service) CreateDRAC(c context.Context, req *crimson.CreateDRACRequest) (*crimson.DRAC, error) { return createDRAC(c, req.Drac) }
go
func (*Service) CreateDRAC(c context.Context, req *crimson.CreateDRACRequest) (*crimson.DRAC, error) { return createDRAC(c, req.Drac) }
[ "func", "(", "*", "Service", ")", "CreateDRAC", "(", "c", "context", ".", "Context", ",", "req", "*", "crimson", ".", "CreateDRACRequest", ")", "(", "*", "crimson", ".", "DRAC", ",", "error", ")", "{", "return", "createDRAC", "(", "c", ",", "req", "....
// CreateDRAC handles a request to create a new DRAC.
[ "CreateDRAC", "handles", "a", "request", "to", "create", "a", "new", "DRAC", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/machine-db/appengine/rpc/dracs.go#L38-L40
131,101
luci/luci-go
machine-db/appengine/rpc/dracs.go
ListDRACs
func (*Service) ListDRACs(c context.Context, req *crimson.ListDRACsRequest) (*crimson.ListDRACsResponse, error) { dracs, err := listDRACs(c, database.Get(c), req) if err != nil { return nil, err } return &crimson.ListDRACsResponse{ Dracs: dracs, }, nil }
go
func (*Service) ListDRACs(c context.Context, req *crimson.ListDRACsRequest) (*crimson.ListDRACsResponse, error) { dracs, err := listDRACs(c, database.Get(c), req) if err != nil { return nil, err } return &crimson.ListDRACsResponse{ Dracs: dracs, }, nil }
[ "func", "(", "*", "Service", ")", "ListDRACs", "(", "c", "context", ".", "Context", ",", "req", "*", "crimson", ".", "ListDRACsRequest", ")", "(", "*", "crimson", ".", "ListDRACsResponse", ",", "error", ")", "{", "dracs", ",", "err", ":=", "listDRACs", ...
// ListDRACs handles a request to list DRACs.
[ "ListDRACs", "handles", "a", "request", "to", "list", "DRACs", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/machine-db/appengine/rpc/dracs.go#L43-L51
131,102
luci/luci-go
machine-db/appengine/rpc/dracs.go
UpdateDRAC
func (*Service) UpdateDRAC(c context.Context, req *crimson.UpdateDRACRequest) (*crimson.DRAC, error) { return updateDRAC(c, req.Drac, req.UpdateMask) }
go
func (*Service) UpdateDRAC(c context.Context, req *crimson.UpdateDRACRequest) (*crimson.DRAC, error) { return updateDRAC(c, req.Drac, req.UpdateMask) }
[ "func", "(", "*", "Service", ")", "UpdateDRAC", "(", "c", "context", ".", "Context", ",", "req", "*", "crimson", ".", "UpdateDRACRequest", ")", "(", "*", "crimson", ".", "DRAC", ",", "error", ")", "{", "return", "updateDRAC", "(", "c", ",", "req", "....
// UpdateDRAC handles a request to update an existing DRAC.
[ "UpdateDRAC", "handles", "a", "request", "to", "update", "an", "existing", "DRAC", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/machine-db/appengine/rpc/dracs.go#L54-L56
131,103
luci/luci-go
machine-db/appengine/rpc/dracs.go
createDRAC
func createDRAC(c context.Context, d *crimson.DRAC) (*crimson.DRAC, error) { if err := validateDRACForCreation(d); err != nil { return nil, err } ip, _ := common.ParseIPv4(d.Ipv4) mac, _ := common.ParseMAC48(d.MacAddress) tx, err := database.Begin(c) if err != nil { return nil, errors.Annotate(err, "failed to...
go
func createDRAC(c context.Context, d *crimson.DRAC) (*crimson.DRAC, error) { if err := validateDRACForCreation(d); err != nil { return nil, err } ip, _ := common.ParseIPv4(d.Ipv4) mac, _ := common.ParseMAC48(d.MacAddress) tx, err := database.Begin(c) if err != nil { return nil, errors.Annotate(err, "failed to...
[ "func", "createDRAC", "(", "c", "context", ".", "Context", ",", "d", "*", "crimson", ".", "DRAC", ")", "(", "*", "crimson", ".", "DRAC", ",", "error", ")", "{", "if", "err", ":=", "validateDRACForCreation", "(", "d", ")", ";", "err", "!=", "nil", "...
// createDRAC creates a new DRAC in the database.
[ "createDRAC", "creates", "a", "new", "DRAC", "in", "the", "database", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/machine-db/appengine/rpc/dracs.go#L59-L111
131,104
luci/luci-go
machine-db/appengine/rpc/dracs.go
listDRACs
func listDRACs(c context.Context, q database.QueryerContext, req *crimson.ListDRACsRequest) ([]*crimson.DRAC, error) { ipv4s, err := parseIPv4s(req.Ipv4S) if err != nil { return nil, err } mac48s, err := parseMAC48s(req.MacAddresses) if err != nil { return nil, err } stmt := squirrel.Select("h.name", "h.vla...
go
func listDRACs(c context.Context, q database.QueryerContext, req *crimson.ListDRACsRequest) ([]*crimson.DRAC, error) { ipv4s, err := parseIPv4s(req.Ipv4S) if err != nil { return nil, err } mac48s, err := parseMAC48s(req.MacAddresses) if err != nil { return nil, err } stmt := squirrel.Select("h.name", "h.vla...
[ "func", "listDRACs", "(", "c", "context", ".", "Context", ",", "q", "database", ".", "QueryerContext", ",", "req", "*", "crimson", ".", "ListDRACsRequest", ")", "(", "[", "]", "*", "crimson", ".", "DRAC", ",", "error", ")", "{", "ipv4s", ",", "err", ...
// listDRACs returns a slice of DRACs in the database.
[ "listDRACs", "returns", "a", "slice", "of", "DRACs", "in", "the", "database", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/machine-db/appengine/rpc/dracs.go#L114-L159
131,105
luci/luci-go
machine-db/appengine/rpc/dracs.go
validateDRACForCreation
func validateDRACForCreation(d *crimson.DRAC) error { switch { case d == nil: return status.Error(codes.InvalidArgument, "DRAC specification is required") case d.Name == "": return status.Error(codes.InvalidArgument, "hostname is required and must be non-empty") case d.Machine == "": return status.Error(codes...
go
func validateDRACForCreation(d *crimson.DRAC) error { switch { case d == nil: return status.Error(codes.InvalidArgument, "DRAC specification is required") case d.Name == "": return status.Error(codes.InvalidArgument, "hostname is required and must be non-empty") case d.Machine == "": return status.Error(codes...
[ "func", "validateDRACForCreation", "(", "d", "*", "crimson", ".", "DRAC", ")", "error", "{", "switch", "{", "case", "d", "==", "nil", ":", "return", "status", ".", "Error", "(", "codes", ".", "InvalidArgument", ",", "\"", "\"", ")", "\n", "case", "d", ...
// validateDRACForCreation validates a DRAC for creation.
[ "validateDRACForCreation", "validates", "a", "DRAC", "for", "creation", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/machine-db/appengine/rpc/dracs.go#L232-L257
131,106
luci/luci-go
machine-db/appengine/rpc/dracs.go
validateDRACForUpdate
func validateDRACForUpdate(d *crimson.DRAC, mask *field_mask.FieldMask) error { switch err := validateUpdateMask(mask); { case d == nil: return status.Error(codes.InvalidArgument, "DRAC specification is required") case d.Name == "": return status.Error(codes.InvalidArgument, "DRAC name is required and must be no...
go
func validateDRACForUpdate(d *crimson.DRAC, mask *field_mask.FieldMask) error { switch err := validateUpdateMask(mask); { case d == nil: return status.Error(codes.InvalidArgument, "DRAC specification is required") case d.Name == "": return status.Error(codes.InvalidArgument, "DRAC name is required and must be no...
[ "func", "validateDRACForUpdate", "(", "d", "*", "crimson", ".", "DRAC", ",", "mask", "*", "field_mask", ".", "FieldMask", ")", "error", "{", "switch", "err", ":=", "validateUpdateMask", "(", "mask", ")", ";", "{", "case", "d", "==", "nil", ":", "return",...
// validateDRACForUpdate validates a DRAC for update.
[ "validateDRACForUpdate", "validates", "a", "DRAC", "for", "update", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/machine-db/appengine/rpc/dracs.go#L260-L301
131,107
luci/luci-go
grpc/prpc/accept.go
qParamSplit
func qParamSplit(v string) (mediaType string, qValue string, acceptParams string) { rest := v for { semicolon := strings.IndexRune(rest, ';') if semicolon < 0 { mediaType = v return } semicolonAbs := len(v) - len(rest) + semicolon // mark rest = rest[semicolon:] rest = rest[1:] // consume ; rest ...
go
func qParamSplit(v string) (mediaType string, qValue string, acceptParams string) { rest := v for { semicolon := strings.IndexRune(rest, ';') if semicolon < 0 { mediaType = v return } semicolonAbs := len(v) - len(rest) + semicolon // mark rest = rest[semicolon:] rest = rest[1:] // consume ; rest ...
[ "func", "qParamSplit", "(", "v", "string", ")", "(", "mediaType", "string", ",", "qValue", "string", ",", "acceptParams", "string", ")", "{", "rest", ":=", "v", "\n", "for", "{", "semicolon", ":=", "strings", ".", "IndexRune", "(", "rest", ",", "';'", ...
// qParamSplit splits media type and accept params by "q" parameter.
[ "qParamSplit", "splits", "media", "type", "and", "accept", "params", "by", "q", "parameter", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/grpc/prpc/accept.go#L79-L123
131,108
luci/luci-go
milo/buildsource/buildbot/pubsub.go
unmarshal
func unmarshal( c context.Context, msg []byte) ([]*buildbot.Build, *buildbot.Master, error) { bm := buildMasterMsg{} if len(msg) == 0 { return bm.Builds, bm.Master, nil } reader, err := zlib.NewReader(bytes.NewReader(msg)) if err != nil { logging.WithError(err).Errorf(c, "gzip decompression error") return n...
go
func unmarshal( c context.Context, msg []byte) ([]*buildbot.Build, *buildbot.Master, error) { bm := buildMasterMsg{} if len(msg) == 0 { return bm.Builds, bm.Master, nil } reader, err := zlib.NewReader(bytes.NewReader(msg)) if err != nil { logging.WithError(err).Errorf(c, "gzip decompression error") return n...
[ "func", "unmarshal", "(", "c", "context", ".", "Context", ",", "msg", "[", "]", "byte", ")", "(", "[", "]", "*", "buildbot", ".", "Build", ",", "*", "buildbot", ".", "Master", ",", "error", ")", "{", "bm", ":=", "buildMasterMsg", "{", "}", "\n", ...
// unmarshal a gzipped byte stream into a list of buildbot builds and masters.
[ "unmarshal", "a", "gzipped", "byte", "stream", "into", "a", "list", "of", "buildbot", "builds", "and", "masters", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/milo/buildsource/buildbot/pubsub.go#L72-L105
131,109
luci/luci-go
milo/buildsource/buildbot/pubsub.go
getOSInfo
func getOSInfo(c context.Context, b *buildbot.Build, m *buildstore.Master) ( family, version string) { // Fetch the master info from datastore if not provided. if m.Name == "" { logging.Infof(c, "Fetching info for master %s", b.Master) freshMaster, err := buildstore.GetMaster(c, b.Master, false) if err != nil ...
go
func getOSInfo(c context.Context, b *buildbot.Build, m *buildstore.Master) ( family, version string) { // Fetch the master info from datastore if not provided. if m.Name == "" { logging.Infof(c, "Fetching info for master %s", b.Master) freshMaster, err := buildstore.GetMaster(c, b.Master, false) if err != nil ...
[ "func", "getOSInfo", "(", "c", "context", ".", "Context", ",", "b", "*", "buildbot", ".", "Build", ",", "m", "*", "buildstore", ".", "Master", ")", "(", "family", ",", "version", "string", ")", "{", "// Fetch the master info from datastore if not provided.", "...
// getOSInfo fetches the os family and version of the slave the build was // running on from the master json on a best-effort basis.
[ "getOSInfo", "fetches", "the", "os", "family", "and", "version", "of", "the", "slave", "the", "build", "was", "running", "on", "from", "the", "master", "json", "on", "a", "best", "-", "effort", "basis", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/milo/buildsource/buildbot/pubsub.go#L109-L145
131,110
luci/luci-go
milo/buildsource/buildbot/pubsub.go
StatsHandler
func StatsHandler(c context.Context) error { masters, err := buildstore.AllMasters(c, false) if err != nil { return errors.Annotate(err, "failed to fetch masters").Err() } now := clock.Now(c) for _, m := range masters { allMasterTimer.Set(c, now.Sub(m.Modified).Seconds(), m.Name) } return nil }
go
func StatsHandler(c context.Context) error { masters, err := buildstore.AllMasters(c, false) if err != nil { return errors.Annotate(err, "failed to fetch masters").Err() } now := clock.Now(c) for _, m := range masters { allMasterTimer.Set(c, now.Sub(m.Modified).Seconds(), m.Name) } return nil }
[ "func", "StatsHandler", "(", "c", "context", ".", "Context", ")", "error", "{", "masters", ",", "err", ":=", "buildstore", ".", "AllMasters", "(", "c", ",", "false", ")", "\n", "if", "err", "!=", "nil", "{", "return", "errors", ".", "Annotate", "(", ...
// StatsHandler is a cron endpoint that sends stats periodically.
[ "StatsHandler", "is", "a", "cron", "endpoint", "that", "sends", "stats", "periodically", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/milo/buildsource/buildbot/pubsub.go#L182-L192
131,111
luci/luci-go
client/isolate/format.go
ToIsolated
func (r ReadOnlyValue) ToIsolated() (out *isolated.ReadOnlyValue) { switch r { case NotSet: case Writeable: out = new(isolated.ReadOnlyValue) *out = isolated.Writeable case FilesReadOnly: out = new(isolated.ReadOnlyValue) *out = isolated.FilesReadOnly case DirsReadOnly: out = new(isolated.ReadOnlyValue) ...
go
func (r ReadOnlyValue) ToIsolated() (out *isolated.ReadOnlyValue) { switch r { case NotSet: case Writeable: out = new(isolated.ReadOnlyValue) *out = isolated.Writeable case FilesReadOnly: out = new(isolated.ReadOnlyValue) *out = isolated.FilesReadOnly case DirsReadOnly: out = new(isolated.ReadOnlyValue) ...
[ "func", "(", "r", "ReadOnlyValue", ")", "ToIsolated", "(", ")", "(", "out", "*", "isolated", ".", "ReadOnlyValue", ")", "{", "switch", "r", "{", "case", "NotSet", ":", "case", "Writeable", ":", "out", "=", "new", "(", "isolated", ".", "ReadOnlyValue", ...
// ToIsolated can be used to convert ReadOnlyValue enum values to corresponding // isolated.ReadOnlyValue enum values. It returns nil on errors.
[ "ToIsolated", "can", "be", "used", "to", "convert", "ReadOnlyValue", "enum", "values", "to", "corresponding", "isolated", ".", "ReadOnlyValue", "enum", "values", ".", "It", "returns", "nil", "on", "errors", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/client/isolate/format.go#L57-L73
131,112
luci/luci-go
client/isolate/format.go
GetConfig
func (c *Configs) GetConfig(configName configName) (*ConfigSettings, error) { // Order byConfig according to configNames ordering function. out := &ConfigSettings{} for _, pair := range c.getSortedConfigPairs() { ok := true for i, confKey := range configName { if pair.key[i].isBound() && pair.key[i].compare(c...
go
func (c *Configs) GetConfig(configName configName) (*ConfigSettings, error) { // Order byConfig according to configNames ordering function. out := &ConfigSettings{} for _, pair := range c.getSortedConfigPairs() { ok := true for i, confKey := range configName { if pair.key[i].isBound() && pair.key[i].compare(c...
[ "func", "(", "c", "*", "Configs", ")", "GetConfig", "(", "configName", "configName", ")", "(", "*", "ConfigSettings", ",", "error", ")", "{", "// Order byConfig according to configNames ordering function.", "out", ":=", "&", "ConfigSettings", "{", "}", "\n", "for"...
// GetConfig returns all configs that matches this config as a single ConfigSettings. // // Returns nil if none apply.
[ "GetConfig", "returns", "all", "configs", "that", "matches", "this", "config", "as", "a", "single", "ConfigSettings", ".", "Returns", "nil", "if", "none", "apply", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/client/isolate/format.go#L261-L280
131,113
luci/luci-go
client/isolate/format.go
setConfig
func (c *Configs) setConfig(confName configName, value *ConfigSettings) { assert(len(confName) == len(c.ConfigVariables)) assert(value != nil) key := confName.key() pair, ok := c.byConfig[key] assert(!ok, "setConfig must not override existing keys (%s => %v)", key, pair.value) c.byConfig[key] = configPair{confNam...
go
func (c *Configs) setConfig(confName configName, value *ConfigSettings) { assert(len(confName) == len(c.ConfigVariables)) assert(value != nil) key := confName.key() pair, ok := c.byConfig[key] assert(!ok, "setConfig must not override existing keys (%s => %v)", key, pair.value) c.byConfig[key] = configPair{confNam...
[ "func", "(", "c", "*", "Configs", ")", "setConfig", "(", "confName", "configName", ",", "value", "*", "ConfigSettings", ")", "{", "assert", "(", "len", "(", "confName", ")", "==", "len", "(", "c", ".", "ConfigVariables", ")", ")", "\n", "assert", "(", ...
// setConfig sets the ConfigSettings for this key. // // The key is a tuple of bounded or unbounded variables. The global variable // is the key where all values are unbounded.
[ "setConfig", "sets", "the", "ConfigSettings", "for", "this", "key", ".", "The", "key", "is", "a", "tuple", "of", "bounded", "or", "unbounded", "variables", ".", "The", "global", "variable", "is", "the", "key", "where", "all", "values", "are", "unbounded", ...
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/client/isolate/format.go#L286-L293
131,114
luci/luci-go
client/isolate/format.go
union
func (c *Configs) union(rhs *Configs) (*Configs, error) { // Merge the keys of ConfigVariables for each Configs instances. All the new // variables will become unbounded. This requires realigning the keys. configVariables := uniqueMergeSortedStrings( c.ConfigVariables, rhs.ConfigVariables) out := newConfigs(confi...
go
func (c *Configs) union(rhs *Configs) (*Configs, error) { // Merge the keys of ConfigVariables for each Configs instances. All the new // variables will become unbounded. This requires realigning the keys. configVariables := uniqueMergeSortedStrings( c.ConfigVariables, rhs.ConfigVariables) out := newConfigs(confi...
[ "func", "(", "c", "*", "Configs", ")", "union", "(", "rhs", "*", "Configs", ")", "(", "*", "Configs", ",", "error", ")", "{", "// Merge the keys of ConfigVariables for each Configs instances. All the new", "// variables will become unbounded. This requires realigning the keys...
// union returns a new Configs instance, the union of variables from self and rhs. // // It keeps ConfigVariables sorted in the output.
[ "union", "returns", "a", "new", "Configs", "instance", "the", "union", "of", "variables", "from", "self", "and", "rhs", ".", "It", "keeps", "ConfigVariables", "sorted", "in", "the", "output", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/client/isolate/format.go#L298-L329
131,115
luci/luci-go
client/isolate/format.go
expandConfigVariables
func (c *Configs) expandConfigVariables(newConfigVars []string) []configPair { // Get mapping from old config vars list to new one. mapping := make([]int, len(newConfigVars)) i := 0 for n, nk := range newConfigVars { if i == len(c.ConfigVariables) || c.ConfigVariables[i] > nk { mapping[n] = -1 } else if c.Co...
go
func (c *Configs) expandConfigVariables(newConfigVars []string) []configPair { // Get mapping from old config vars list to new one. mapping := make([]int, len(newConfigVars)) i := 0 for n, nk := range newConfigVars { if i == len(c.ConfigVariables) || c.ConfigVariables[i] > nk { mapping[n] = -1 } else if c.Co...
[ "func", "(", "c", "*", "Configs", ")", "expandConfigVariables", "(", "newConfigVars", "[", "]", "string", ")", "[", "]", "configPair", "{", "// Get mapping from old config vars list to new one.", "mapping", ":=", "make", "(", "[", "]", "int", ",", "len", "(", ...
// expandConfigVariables returns new configPair list for newConfigVars.
[ "expandConfigVariables", "returns", "new", "configPair", "list", "for", "newConfigVars", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/client/isolate/format.go#L332-L364
131,116
luci/luci-go
client/isolate/format.go
convertIsolateToJSON5
func convertIsolateToJSON5(content []byte) io.Reader { out := &bytes.Buffer{} for _, l := range strings.Split(string(content), "\n") { l = strings.TrimSpace(l) if len(l) == 0 || l[0] == '#' { continue } l = strings.Replace(l, "\"", "\\\"", -1) l = strings.Replace(l, "'", "\"", -1) _, _ = io.WriteString...
go
func convertIsolateToJSON5(content []byte) io.Reader { out := &bytes.Buffer{} for _, l := range strings.Split(string(content), "\n") { l = strings.TrimSpace(l) if len(l) == 0 || l[0] == '#' { continue } l = strings.Replace(l, "\"", "\\\"", -1) l = strings.Replace(l, "'", "\"", -1) _, _ = io.WriteString...
[ "func", "convertIsolateToJSON5", "(", "content", "[", "]", "byte", ")", "io", ".", "Reader", "{", "out", ":=", "&", "bytes", ".", "Buffer", "{", "}", "\n", "for", "_", ",", "l", ":=", "range", "strings", ".", "Split", "(", "string", "(", "content", ...
// convertIsolateToJSON5 cleans up isolate content to be json5.
[ "convertIsolateToJSON5", "cleans", "up", "isolate", "content", "to", "be", "json5", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/client/isolate/format.go#L691-L703
131,117
luci/luci-go
client/isolate/format.go
processIsolate
func processIsolate(content []byte) (*processedIsolate, error) { isolate, err := parseIsolate(content) if err != nil { return nil, err } if err := isolate.Variables.verify(); err != nil { return nil, err } out := &processedIsolate{ isolate.Includes, make([]*processedCondition, len(isolate.Conditions)), ...
go
func processIsolate(content []byte) (*processedIsolate, error) { isolate, err := parseIsolate(content) if err != nil { return nil, err } if err := isolate.Variables.verify(); err != nil { return nil, err } out := &processedIsolate{ isolate.Includes, make([]*processedCondition, len(isolate.Conditions)), ...
[ "func", "processIsolate", "(", "content", "[", "]", "byte", ")", "(", "*", "processedIsolate", ",", "error", ")", "{", "isolate", ",", "err", ":=", "parseIsolate", "(", "content", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", ...
// processIsolate loads isolate, then verifies and returns it as // a processedIsolate for faster further processing.
[ "processIsolate", "loads", "isolate", "then", "verifies", "and", "returns", "it", "as", "a", "processedIsolate", "for", "faster", "further", "processing", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/client/isolate/format.go#L723-L744
131,118
luci/luci-go
client/isolate/format.go
processCondition
func processCondition(c condition, varsAndValues variablesValuesSet) (*processedCondition, error) { goCond, err := pythonToGoCondition(c.Condition) if err != nil { return nil, err } out := &processedCondition{condition: c.Condition, variables: c.Variables} if out.expr, err = parser.ParseExpr(goCond); err != nil ...
go
func processCondition(c condition, varsAndValues variablesValuesSet) (*processedCondition, error) { goCond, err := pythonToGoCondition(c.Condition) if err != nil { return nil, err } out := &processedCondition{condition: c.Condition, variables: c.Variables} if out.expr, err = parser.ParseExpr(goCond); err != nil ...
[ "func", "processCondition", "(", "c", "condition", ",", "varsAndValues", "variablesValuesSet", ")", "(", "*", "processedCondition", ",", "error", ")", "{", "goCond", ",", "err", ":=", "pythonToGoCondition", "(", "c", ".", "Condition", ")", "\n", "if", "err", ...
// processCondition ensures condition is in correct format, and converts it // to processedCondition for further evaluation.
[ "processCondition", "ensures", "condition", "is", "in", "correct", "format", "and", "converts", "it", "to", "processedCondition", "for", "further", "evaluation", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/client/isolate/format.go#L771-L784
131,119
luci/luci-go
client/isolate/format.go
pythonToGoCondition
func pythonToGoCondition(pyCond string) (string, error) { // Isolate supported grammar is: // expr ::= expr ( "or" | "and" ) expr // | identifier "==" ( string | int ) // and parentheses. // We convert this to equivalent Go expression by: // * replacing all 'string' to "string" // * replacing `and` and `or` t...
go
func pythonToGoCondition(pyCond string) (string, error) { // Isolate supported grammar is: // expr ::= expr ( "or" | "and" ) expr // | identifier "==" ( string | int ) // and parentheses. // We convert this to equivalent Go expression by: // * replacing all 'string' to "string" // * replacing `and` and `or` t...
[ "func", "pythonToGoCondition", "(", "pyCond", "string", ")", "(", "string", ",", "error", ")", "{", "// Isolate supported grammar is:", "//\texpr ::= expr ( \"or\" | \"and\" ) expr", "//\t\t\t| identifier \"==\" ( string | int )", "// and parentheses.", "// We convert this to equival...
// pythonToGoCondition converts Python code into valid Go code.
[ "pythonToGoCondition", "converts", "Python", "code", "into", "valid", "Go", "code", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/client/isolate/format.go#L948-L973
131,120
luci/luci-go
dm/api/service/v1/ensure_graph_data_normalize.go
Normalize
func (t *TemplateInstantiation) Normalize() error { if t.Project == "" { return errors.New("empty project") } return t.Specifier.Normalize() }
go
func (t *TemplateInstantiation) Normalize() error { if t.Project == "" { return errors.New("empty project") } return t.Specifier.Normalize() }
[ "func", "(", "t", "*", "TemplateInstantiation", ")", "Normalize", "(", ")", "error", "{", "if", "t", ".", "Project", "==", "\"", "\"", "{", "return", "errors", ".", "New", "(", "\"", "\"", ")", "\n", "}", "\n", "return", "t", ".", "Specifier", ".",...
// Normalize returns an error iff the TemplateInstantiation is invalid.
[ "Normalize", "returns", "an", "error", "iff", "the", "TemplateInstantiation", "is", "invalid", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/dm/api/service/v1/ensure_graph_data_normalize.go#L24-L29
131,121
luci/luci-go
dm/api/service/v1/ensure_graph_data_normalize.go
Normalize
func (r *EnsureGraphDataReq) Normalize() error { if r.ForExecution != nil { if err := r.ForExecution.Normalize(); err != nil { return err } } if err := r.RawAttempts.Normalize(); err != nil { return err } hasAttempts := false if r.RawAttempts != nil { for _, nums := range r.RawAttempts.To { if len...
go
func (r *EnsureGraphDataReq) Normalize() error { if r.ForExecution != nil { if err := r.ForExecution.Normalize(); err != nil { return err } } if err := r.RawAttempts.Normalize(); err != nil { return err } hasAttempts := false if r.RawAttempts != nil { for _, nums := range r.RawAttempts.To { if len...
[ "func", "(", "r", "*", "EnsureGraphDataReq", ")", "Normalize", "(", ")", "error", "{", "if", "r", ".", "ForExecution", "!=", "nil", "{", "if", "err", ":=", "r", ".", "ForExecution", ".", "Normalize", "(", ")", ";", "err", "!=", "nil", "{", "return", ...
// Normalize returns an error iff the request is invalid.
[ "Normalize", "returns", "an", "error", "iff", "the", "request", "is", "invalid", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/dm/api/service/v1/ensure_graph_data_normalize.go#L44-L113
131,122
luci/luci-go
client/internal/common/flags.go
StartTracing
func (d *Flags) StartTracing() (io.Closer, error) { if d.TracePath == "" { return &tracingState{}, nil } f, err := os.Create(d.TracePath) if err != nil { return &tracingState{}, err } if err = tracer.Start(f, 0); err != nil { _ = f.Close() return &tracingState{}, err } return &tracingState{f}, nil }
go
func (d *Flags) StartTracing() (io.Closer, error) { if d.TracePath == "" { return &tracingState{}, nil } f, err := os.Create(d.TracePath) if err != nil { return &tracingState{}, err } if err = tracer.Start(f, 0); err != nil { _ = f.Close() return &tracingState{}, err } return &tracingState{f}, nil }
[ "func", "(", "d", "*", "Flags", ")", "StartTracing", "(", ")", "(", "io", ".", "Closer", ",", "error", ")", "{", "if", "d", ".", "TracePath", "==", "\"", "\"", "{", "return", "&", "tracingState", "{", "}", ",", "nil", "\n", "}", "\n", "f", ",",...
// StartTracing enables tracing and returns a closer that must be called on // process termination.
[ "StartTracing", "enables", "tracing", "and", "returns", "a", "closer", "that", "must", "be", "called", "on", "process", "termination", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/client/internal/common/flags.go#L67-L80
131,123
luci/luci-go
server/templates/bundle.go
MergeArgs
func MergeArgs(args ...Args) Args { total := 0 for _, a := range args { total += len(a) } if total == 0 { return nil } res := make(Args, total) for _, a := range args { for k, v := range a { res[k] = v } } return res }
go
func MergeArgs(args ...Args) Args { total := 0 for _, a := range args { total += len(a) } if total == 0 { return nil } res := make(Args, total) for _, a := range args { for k, v := range a { res[k] = v } } return res }
[ "func", "MergeArgs", "(", "args", "...", "Args", ")", "Args", "{", "total", ":=", "0", "\n", "for", "_", ",", "a", ":=", "range", "args", "{", "total", "+=", "len", "(", "a", ")", "\n", "}", "\n", "if", "total", "==", "0", "{", "return", "nil",...
// MergeArgs combines multiple Args instances into one. Returns nil if all // passed args are empty.
[ "MergeArgs", "combines", "multiple", "Args", "instances", "into", "one", ".", "Returns", "nil", "if", "all", "passed", "args", "are", "empty", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/server/templates/bundle.go#L37-L52
131,124
luci/luci-go
server/templates/bundle.go
EnsureLoaded
func (b *Bundle) EnsureLoaded(c context.Context) error { // Always reload in debug mode. Load only once in non-debug mode. if dm := b.DebugMode; dm != nil && dm(c) { b.templates, b.err = b.Loader(c, b.FuncMap) } else { b.once.Do(func() { b.templates, b.err = b.Loader(c, b.FuncMap) }) } return b.err }
go
func (b *Bundle) EnsureLoaded(c context.Context) error { // Always reload in debug mode. Load only once in non-debug mode. if dm := b.DebugMode; dm != nil && dm(c) { b.templates, b.err = b.Loader(c, b.FuncMap) } else { b.once.Do(func() { b.templates, b.err = b.Loader(c, b.FuncMap) }) } return b.err }
[ "func", "(", "b", "*", "Bundle", ")", "EnsureLoaded", "(", "c", "context", ".", "Context", ")", "error", "{", "// Always reload in debug mode. Load only once in non-debug mode.", "if", "dm", ":=", "b", ".", "DebugMode", ";", "dm", "!=", "nil", "&&", "dm", "(",...
// EnsureLoaded loads all the templates if they haven't been loaded yet.
[ "EnsureLoaded", "loads", "all", "the", "templates", "if", "they", "haven", "t", "been", "loaded", "yet", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/server/templates/bundle.go#L112-L122
131,125
luci/luci-go
server/auth/signing/certs.go
FetchCertificatesForServiceAccount
func FetchCertificatesForServiceAccount(c context.Context, email string) (*PublicCertificates, error) { // Do only basic validation and offload full validation to the google backend. if !strings.HasSuffix(email, ".gserviceaccount.com") { return nil, fmt.Errorf("signature: not a google service account %q", email) }...
go
func FetchCertificatesForServiceAccount(c context.Context, email string) (*PublicCertificates, error) { // Do only basic validation and offload full validation to the google backend. if !strings.HasSuffix(email, ".gserviceaccount.com") { return nil, fmt.Errorf("signature: not a google service account %q", email) }...
[ "func", "FetchCertificatesForServiceAccount", "(", "c", "context", ".", "Context", ",", "email", "string", ")", "(", "*", "PublicCertificates", ",", "error", ")", "{", "// Do only basic validation and offload full validation to the google backend.", "if", "!", "strings", ...
// FetchCertificatesForServiceAccount fetches certificates of some Google // service account. // // Works only with Google service accounts (@*.gserviceaccount.com). Uses the // process cache to cache them for CertsCacheExpiration minutes. // // Usage (roughly): // // certs, err := signing.FetchCertificatesForService...
[ "FetchCertificatesForServiceAccount", "fetches", "certificates", "of", "some", "Google", "service", "account", ".", "Works", "only", "with", "Google", "service", "accounts", "(" ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/server/auth/signing/certs.go#L140-L157
131,126
luci/luci-go
server/auth/signing/certs.go
fetchCertsJSON
func fetchCertsJSON(c context.Context, url string) (*PublicCertificates, error) { keysAndCerts := map[string]string{} req := internal.Request{ Method: "GET", URL: url, Out: &keysAndCerts, } if err := req.Do(c); err != nil { return nil, err } // Sort by key for reproducibility of return values. key...
go
func fetchCertsJSON(c context.Context, url string) (*PublicCertificates, error) { keysAndCerts := map[string]string{} req := internal.Request{ Method: "GET", URL: url, Out: &keysAndCerts, } if err := req.Do(c); err != nil { return nil, err } // Sort by key for reproducibility of return values. key...
[ "func", "fetchCertsJSON", "(", "c", "context", ".", "Context", ",", "url", "string", ")", "(", "*", "PublicCertificates", ",", "error", ")", "{", "keysAndCerts", ":=", "map", "[", "string", "]", "string", "{", "}", "\n", "req", ":=", "internal", ".", "...
// fetchCertsJSON loads certificates from a JSON dict "key id => x509 PEM cert". // // This is the format served by Google certificate endpoints.
[ "fetchCertsJSON", "loads", "certificates", "from", "a", "JSON", "dict", "key", "id", "=", ">", "x509", "PEM", "cert", ".", "This", "is", "the", "format", "served", "by", "Google", "certificate", "endpoints", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/server/auth/signing/certs.go#L183-L210
131,127
luci/luci-go
server/auth/signing/certs.go
CertificateForKey
func (pc *PublicCertificates) CertificateForKey(key string) (*x509.Certificate, error) { // Use fast reader lock first. pc.lock.RLock() cert, ok := pc.cache[key] pc.lock.RUnlock() if ok { return cert, nil } // Grab the write lock and recheck the cache. pc.lock.Lock() defer pc.lock.Unlock() if cert, ok := p...
go
func (pc *PublicCertificates) CertificateForKey(key string) (*x509.Certificate, error) { // Use fast reader lock first. pc.lock.RLock() cert, ok := pc.cache[key] pc.lock.RUnlock() if ok { return cert, nil } // Grab the write lock and recheck the cache. pc.lock.Lock() defer pc.lock.Unlock() if cert, ok := p...
[ "func", "(", "pc", "*", "PublicCertificates", ")", "CertificateForKey", "(", "key", "string", ")", "(", "*", "x509", ".", "Certificate", ",", "error", ")", "{", "// Use fast reader lock first.", "pc", ".", "lock", ".", "RLock", "(", ")", "\n", "cert", ",",...
// CertificateForKey finds the certificate for given key and deserializes it.
[ "CertificateForKey", "finds", "the", "certificate", "for", "given", "key", "and", "deserializes", "it", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/server/auth/signing/certs.go#L213-L248
131,128
luci/luci-go
server/auth/signing/certs.go
CheckSignature
func (pc *PublicCertificates) CheckSignature(key string, signed, signature []byte) error { cert, err := pc.CertificateForKey(key) if err != nil { return err } return cert.CheckSignature(x509.SHA256WithRSA, signed, signature) }
go
func (pc *PublicCertificates) CheckSignature(key string, signed, signature []byte) error { cert, err := pc.CertificateForKey(key) if err != nil { return err } return cert.CheckSignature(x509.SHA256WithRSA, signed, signature) }
[ "func", "(", "pc", "*", "PublicCertificates", ")", "CheckSignature", "(", "key", "string", ",", "signed", ",", "signature", "[", "]", "byte", ")", "error", "{", "cert", ",", "err", ":=", "pc", ".", "CertificateForKey", "(", "key", ")", "\n", "if", "err...
// CheckSignature returns nil if `signed` was indeed signed by given key.
[ "CheckSignature", "returns", "nil", "if", "signed", "was", "indeed", "signed", "by", "given", "key", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/server/auth/signing/certs.go#L251-L257
131,129
luci/luci-go
appengine/gaeauth/server/internal/authdbimpl/handlers.go
InstallHandlers
func InstallHandlers(r *router.Router, base router.MiddlewareChain) { if appengine.IsDevAppServer() { r.GET(pubSubPullURLPath, base, pubSubPull) } r.POST(pubSubPushURLPath, base, pubSubPush) }
go
func InstallHandlers(r *router.Router, base router.MiddlewareChain) { if appengine.IsDevAppServer() { r.GET(pubSubPullURLPath, base, pubSubPull) } r.POST(pubSubPushURLPath, base, pubSubPush) }
[ "func", "InstallHandlers", "(", "r", "*", "router", ".", "Router", ",", "base", "router", ".", "MiddlewareChain", ")", "{", "if", "appengine", ".", "IsDevAppServer", "(", ")", "{", "r", ".", "GET", "(", "pubSubPullURLPath", ",", "base", ",", "pubSubPull", ...
// InstallHandlers installs PubSub related HTTP handlers.
[ "InstallHandlers", "installs", "PubSub", "related", "HTTP", "handlers", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/appengine/gaeauth/server/internal/authdbimpl/handlers.go#L41-L46
131,130
luci/luci-go
appengine/gaeauth/server/internal/authdbimpl/handlers.go
setupPubSub
func setupPubSub(c context.Context, baseURL, authServiceURL string) error { pushURL := "" if !info.IsDevAppServer(c) { pushURL = baseURL + pubSubPushURLPath // push in prod, pull on dev server } service := getAuthService(c, authServiceURL) return service.EnsureSubscription(c, subscriptionName(c, authServiceURL),...
go
func setupPubSub(c context.Context, baseURL, authServiceURL string) error { pushURL := "" if !info.IsDevAppServer(c) { pushURL = baseURL + pubSubPushURLPath // push in prod, pull on dev server } service := getAuthService(c, authServiceURL) return service.EnsureSubscription(c, subscriptionName(c, authServiceURL),...
[ "func", "setupPubSub", "(", "c", "context", ".", "Context", ",", "baseURL", ",", "authServiceURL", "string", ")", "error", "{", "pushURL", ":=", "\"", "\"", "\n", "if", "!", "info", ".", "IsDevAppServer", "(", "c", ")", "{", "pushURL", "=", "baseURL", ...
// setupPubSub creates a subscription to AuthDB service notification stream.
[ "setupPubSub", "creates", "a", "subscription", "to", "AuthDB", "service", "notification", "stream", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/appengine/gaeauth/server/internal/authdbimpl/handlers.go#L49-L56
131,131
luci/luci-go
appengine/gaeauth/server/internal/authdbimpl/handlers.go
killPubSub
func killPubSub(c context.Context, authServiceURL string) error { service := getAuthService(c, authServiceURL) return service.DeleteSubscription(c, subscriptionName(c, authServiceURL)) }
go
func killPubSub(c context.Context, authServiceURL string) error { service := getAuthService(c, authServiceURL) return service.DeleteSubscription(c, subscriptionName(c, authServiceURL)) }
[ "func", "killPubSub", "(", "c", "context", ".", "Context", ",", "authServiceURL", "string", ")", "error", "{", "service", ":=", "getAuthService", "(", "c", ",", "authServiceURL", ")", "\n", "return", "service", ".", "DeleteSubscription", "(", "c", ",", "subs...
// killPubSub removes PubSub subscription created with setupPubSub.
[ "killPubSub", "removes", "PubSub", "subscription", "created", "with", "setupPubSub", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/appengine/gaeauth/server/internal/authdbimpl/handlers.go#L59-L62
131,132
luci/luci-go
appengine/gaeauth/server/internal/authdbimpl/handlers.go
subscriptionName
func subscriptionName(c context.Context, authServiceURL string) string { subIDPrefix := "gae-v1" if info.IsDevAppServer(c) { subIDPrefix = "dev-app-server-v1" } serviceURL, err := url.Parse(authServiceURL) if err != nil { panic(err) } return fmt.Sprintf("projects/%s/subscriptions/%s+%s", info.AppID(c), subID...
go
func subscriptionName(c context.Context, authServiceURL string) string { subIDPrefix := "gae-v1" if info.IsDevAppServer(c) { subIDPrefix = "dev-app-server-v1" } serviceURL, err := url.Parse(authServiceURL) if err != nil { panic(err) } return fmt.Sprintf("projects/%s/subscriptions/%s+%s", info.AppID(c), subID...
[ "func", "subscriptionName", "(", "c", "context", ".", "Context", ",", "authServiceURL", "string", ")", "string", "{", "subIDPrefix", ":=", "\"", "\"", "\n", "if", "info", ".", "IsDevAppServer", "(", "c", ")", "{", "subIDPrefix", "=", "\"", "\"", "\n", "}...
// subscriptionName returns full PubSub subscription name for AuthDB // change notifications stream from given auth service.
[ "subscriptionName", "returns", "full", "PubSub", "subscription", "name", "for", "AuthDB", "change", "notifications", "stream", "from", "given", "auth", "service", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/appengine/gaeauth/server/internal/authdbimpl/handlers.go#L66-L76
131,133
luci/luci-go
appengine/gaeauth/server/internal/authdbimpl/handlers.go
pubSubPull
func pubSubPull(c *router.Context) { if !appengine.IsDevAppServer() { replyError(c.Context, c.Writer, errors.New("not a dev server")) return } processPubSubRequest(c.Context, c.Writer, c.Request, func(c context.Context, srv authService, serviceURL string) (*service.Notification, error) { return srv.PullPubSub(...
go
func pubSubPull(c *router.Context) { if !appengine.IsDevAppServer() { replyError(c.Context, c.Writer, errors.New("not a dev server")) return } processPubSubRequest(c.Context, c.Writer, c.Request, func(c context.Context, srv authService, serviceURL string) (*service.Notification, error) { return srv.PullPubSub(...
[ "func", "pubSubPull", "(", "c", "*", "router", ".", "Context", ")", "{", "if", "!", "appengine", ".", "IsDevAppServer", "(", ")", "{", "replyError", "(", "c", ".", "Context", ",", "c", ".", "Writer", ",", "errors", ".", "New", "(", "\"", "\"", ")",...
// pubSubPull is HTTP handler that pulls PubSub messages from AuthDB change // notification topic. // // Used only on dev server for manual testing. Prod services use push-based // delivery.
[ "pubSubPull", "is", "HTTP", "handler", "that", "pulls", "PubSub", "messages", "from", "AuthDB", "change", "notification", "topic", ".", "Used", "only", "on", "dev", "server", "for", "manual", "testing", ".", "Prod", "services", "use", "push", "-", "based", "...
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/appengine/gaeauth/server/internal/authdbimpl/handlers.go#L83-L91
131,134
luci/luci-go
appengine/gaeauth/server/internal/authdbimpl/handlers.go
pubSubPush
func pubSubPush(c *router.Context) { processPubSubRequest(c.Context, c.Writer, c.Request, func(ctx context.Context, srv authService, serviceURL string) (*service.Notification, error) { body, err := ioutil.ReadAll(c.Request.Body) if err != nil { return nil, err } return srv.ProcessPubSubPush(ctx, body) }) }
go
func pubSubPush(c *router.Context) { processPubSubRequest(c.Context, c.Writer, c.Request, func(ctx context.Context, srv authService, serviceURL string) (*service.Notification, error) { body, err := ioutil.ReadAll(c.Request.Body) if err != nil { return nil, err } return srv.ProcessPubSubPush(ctx, body) }) }
[ "func", "pubSubPush", "(", "c", "*", "router", ".", "Context", ")", "{", "processPubSubRequest", "(", "c", ".", "Context", ",", "c", ".", "Writer", ",", "c", ".", "Request", ",", "func", "(", "ctx", "context", ".", "Context", ",", "srv", "authService",...
// pubSubPush is HTTP handler that processes incoming PubSub push notifications. // // It uses the signature inside PubSub message body for authentication. Skips // messages not signed by currently configured auth service.
[ "pubSubPush", "is", "HTTP", "handler", "that", "processes", "incoming", "PubSub", "push", "notifications", ".", "It", "uses", "the", "signature", "inside", "PubSub", "message", "body", "for", "authentication", ".", "Skips", "messages", "not", "signed", "by", "cu...
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/appengine/gaeauth/server/internal/authdbimpl/handlers.go#L97-L105
131,135
luci/luci-go
appengine/gaeauth/server/internal/authdbimpl/handlers.go
processPubSubRequest
func processPubSubRequest(c context.Context, rw http.ResponseWriter, r *http.Request, callback notifcationGetter) { c = defaultNS(c) info, err := GetLatestSnapshotInfo(c) if err != nil { replyError(c, rw, err) return } if info == nil { // Return HTTP 200 to avoid a redelivery. replyOK(c, rw, "Auth Service ...
go
func processPubSubRequest(c context.Context, rw http.ResponseWriter, r *http.Request, callback notifcationGetter) { c = defaultNS(c) info, err := GetLatestSnapshotInfo(c) if err != nil { replyError(c, rw, err) return } if info == nil { // Return HTTP 200 to avoid a redelivery. replyOK(c, rw, "Auth Service ...
[ "func", "processPubSubRequest", "(", "c", "context", ".", "Context", ",", "rw", "http", ".", "ResponseWriter", ",", "r", "*", "http", ".", "Request", ",", "callback", "notifcationGetter", ")", "{", "c", "=", "defaultNS", "(", "c", ")", "\n", "info", ",",...
// processPubSubRequest is common wrapper for pubSubPull and pubSubPush. // // It implements most logic of notification handling. Calls supplied callback // to actually get service.Notification, since this part is different from Pull // and Push subscriptions.
[ "processPubSubRequest", "is", "common", "wrapper", "for", "pubSubPull", "and", "pubSubPush", ".", "It", "implements", "most", "logic", "of", "notification", "handling", ".", "Calls", "supplied", "callback", "to", "actually", "get", "service", ".", "Notification", ...
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/appengine/gaeauth/server/internal/authdbimpl/handlers.go#L114-L158
131,136
luci/luci-go
appengine/gaeauth/server/internal/authdbimpl/handlers.go
replyError
func replyError(c context.Context, rw http.ResponseWriter, err error) { logging.Errorf(c, "Error while processing PubSub notification - %s", err) if transient.Tag.In(err) { http.Error(rw, err.Error(), http.StatusInternalServerError) } else { http.Error(rw, err.Error(), http.StatusBadRequest) } }
go
func replyError(c context.Context, rw http.ResponseWriter, err error) { logging.Errorf(c, "Error while processing PubSub notification - %s", err) if transient.Tag.In(err) { http.Error(rw, err.Error(), http.StatusInternalServerError) } else { http.Error(rw, err.Error(), http.StatusBadRequest) } }
[ "func", "replyError", "(", "c", "context", ".", "Context", ",", "rw", "http", ".", "ResponseWriter", ",", "err", "error", ")", "{", "logging", ".", "Errorf", "(", "c", ",", "\"", "\"", ",", "err", ")", "\n", "if", "transient", ".", "Tag", ".", "In"...
// replyError sends HTTP 500 on transient errors, HTTP 400 on fatal ones.
[ "replyError", "sends", "HTTP", "500", "on", "transient", "errors", "HTTP", "400", "on", "fatal", "ones", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/appengine/gaeauth/server/internal/authdbimpl/handlers.go#L161-L168
131,137
luci/luci-go
appengine/gaeauth/server/internal/authdbimpl/handlers.go
replyOK
func replyOK(c context.Context, rw http.ResponseWriter, msg string, args ...interface{}) { logging.Infof(c, msg, args...) rw.Write([]byte(fmt.Sprintf(msg, args...))) }
go
func replyOK(c context.Context, rw http.ResponseWriter, msg string, args ...interface{}) { logging.Infof(c, msg, args...) rw.Write([]byte(fmt.Sprintf(msg, args...))) }
[ "func", "replyOK", "(", "c", "context", ".", "Context", ",", "rw", "http", ".", "ResponseWriter", ",", "msg", "string", ",", "args", "...", "interface", "{", "}", ")", "{", "logging", ".", "Infof", "(", "c", ",", "msg", ",", "args", "...", ")", "\n...
// replyOK sends HTTP 200.
[ "replyOK", "sends", "HTTP", "200", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/appengine/gaeauth/server/internal/authdbimpl/handlers.go#L171-L174
131,138
luci/luci-go
tokenserver/appengine/impl/utils/shards/shards.go
Serialize
func (s Shard) Serialize() []byte { sorted := make([]string, 0, len(s)) for blob := range s { sorted = append(sorted, blob) } sort.Strings(sorted) out := bytes.Buffer{} enc := gob.NewEncoder(&out) err := enc.Encode(sorted) if err != nil { panic("impossible error when encoding []string") } return out.Bytes...
go
func (s Shard) Serialize() []byte { sorted := make([]string, 0, len(s)) for blob := range s { sorted = append(sorted, blob) } sort.Strings(sorted) out := bytes.Buffer{} enc := gob.NewEncoder(&out) err := enc.Encode(sorted) if err != nil { panic("impossible error when encoding []string") } return out.Bytes...
[ "func", "(", "s", "Shard", ")", "Serialize", "(", ")", "[", "]", "byte", "{", "sorted", ":=", "make", "(", "[", "]", "string", ",", "0", ",", "len", "(", "s", ")", ")", "\n", "for", "blob", ":=", "range", "s", "{", "sorted", "=", "append", "(...
// Serialize serializes the shard to a byte buffer.
[ "Serialize", "serializes", "the", "shard", "to", "a", "byte", "buffer", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/tokenserver/appengine/impl/utils/shards/shards.go#L46-L59
131,139
luci/luci-go
tokenserver/appengine/impl/utils/shards/shards.go
Insert
func (s Set) Insert(blob []byte) { shard := &s[ShardIndex(blob, len(s))] if *shard == nil { *shard = make(Shard) } (*shard)[string(blob)] = struct{}{} }
go
func (s Set) Insert(blob []byte) { shard := &s[ShardIndex(blob, len(s))] if *shard == nil { *shard = make(Shard) } (*shard)[string(blob)] = struct{}{} }
[ "func", "(", "s", "Set", ")", "Insert", "(", "blob", "[", "]", "byte", ")", "{", "shard", ":=", "&", "s", "[", "ShardIndex", "(", "blob", ",", "len", "(", "s", ")", ")", "]", "\n", "if", "*", "shard", "==", "nil", "{", "*", "shard", "=", "m...
// Insert adds a blob into the sharded set.
[ "Insert", "adds", "a", "blob", "into", "the", "sharded", "set", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/tokenserver/appengine/impl/utils/shards/shards.go#L68-L74
131,140
luci/luci-go
tokenserver/appengine/impl/utils/shards/shards.go
ShardIndex
func ShardIndex(member []byte, shardCount int) int { hash := fnv.New32() hash.Write(member) return int(hash.Sum32() % uint32(shardCount)) }
go
func ShardIndex(member []byte, shardCount int) int { hash := fnv.New32() hash.Write(member) return int(hash.Sum32() % uint32(shardCount)) }
[ "func", "ShardIndex", "(", "member", "[", "]", "byte", ",", "shardCount", "int", ")", "int", "{", "hash", ":=", "fnv", ".", "New32", "(", ")", "\n", "hash", ".", "Write", "(", "member", ")", "\n", "return", "int", "(", "hash", ".", "Sum32", "(", ...
// ShardIndex returns an index of a shard to use when storing given blob.
[ "ShardIndex", "returns", "an", "index", "of", "a", "shard", "to", "use", "when", "storing", "given", "blob", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/tokenserver/appengine/impl/utils/shards/shards.go#L77-L81
131,141
luci/luci-go
server/auth/delegation/checker.go
deserializeToken
func deserializeToken(token string) (*messages.DelegationToken, error) { blob, err := base64.RawURLEncoding.DecodeString(token) if err != nil { return nil, err } if len(blob) > maxTokenSize { return nil, fmt.Errorf("the delegation token is too big (%d bytes)", len(blob)) } tok := &messages.DelegationToken{} ...
go
func deserializeToken(token string) (*messages.DelegationToken, error) { blob, err := base64.RawURLEncoding.DecodeString(token) if err != nil { return nil, err } if len(blob) > maxTokenSize { return nil, fmt.Errorf("the delegation token is too big (%d bytes)", len(blob)) } tok := &messages.DelegationToken{} ...
[ "func", "deserializeToken", "(", "token", "string", ")", "(", "*", "messages", ".", "DelegationToken", ",", "error", ")", "{", "blob", ",", "err", ":=", "base64", ".", "RawURLEncoding", ".", "DecodeString", "(", "token", ")", "\n", "if", "err", "!=", "ni...
// deserializeToken deserializes DelegationToken proto message.
[ "deserializeToken", "deserializes", "DelegationToken", "proto", "message", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/server/auth/delegation/checker.go#L123-L136
131,142
luci/luci-go
server/auth/delegation/checker.go
unsealToken
func unsealToken(c context.Context, tok *messages.DelegationToken, certsProvider CertificatesProvider) (*messages.Subtoken, error) { // Grab the public keys of the service that signed the token, if we trust it. signerID, err := identity.MakeIdentity(tok.SignerId) if err != nil { return nil, fmt.Errorf("bad signer_...
go
func unsealToken(c context.Context, tok *messages.DelegationToken, certsProvider CertificatesProvider) (*messages.Subtoken, error) { // Grab the public keys of the service that signed the token, if we trust it. signerID, err := identity.MakeIdentity(tok.SignerId) if err != nil { return nil, fmt.Errorf("bad signer_...
[ "func", "unsealToken", "(", "c", "context", ".", "Context", ",", "tok", "*", "messages", ".", "DelegationToken", ",", "certsProvider", "CertificatesProvider", ")", "(", "*", "messages", ".", "Subtoken", ",", "error", ")", "{", "// Grab the public keys of the servi...
// unsealToken verifies token's signature and deserializes the subtoken. // // May return transient errors.
[ "unsealToken", "verifies", "token", "s", "signature", "and", "deserializes", "the", "subtoken", ".", "May", "return", "transient", "errors", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/server/auth/delegation/checker.go#L141-L168
131,143
luci/luci-go
server/auth/delegation/checker.go
checkSubtoken
func checkSubtoken(c context.Context, subtoken *messages.Subtoken, params *CheckTokenParams) (identity.Identity, error) { if subtoken.Kind != messages.Subtoken_BEARER_DELEGATION_TOKEN { logging.Warningf(c, "auth: Invalid delegation token kind - %s", subtoken.Kind) return "", ErrForbiddenDelegationToken } // Do ...
go
func checkSubtoken(c context.Context, subtoken *messages.Subtoken, params *CheckTokenParams) (identity.Identity, error) { if subtoken.Kind != messages.Subtoken_BEARER_DELEGATION_TOKEN { logging.Warningf(c, "auth: Invalid delegation token kind - %s", subtoken.Kind) return "", ErrForbiddenDelegationToken } // Do ...
[ "func", "checkSubtoken", "(", "c", "context", ".", "Context", ",", "subtoken", "*", "messages", ".", "Subtoken", ",", "params", "*", "CheckTokenParams", ")", "(", "identity", ".", "Identity", ",", "error", ")", "{", "if", "subtoken", ".", "Kind", "!=", "...
// checkSubtoken validates the delegation subtoken. // // It extracts and returns original delegated_identity.
[ "checkSubtoken", "validates", "the", "delegation", "subtoken", ".", "It", "extracts", "and", "returns", "original", "delegated_identity", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/server/auth/delegation/checker.go#L173-L208
131,144
luci/luci-go
server/auth/delegation/checker.go
checkSubtokenExpiration
func checkSubtokenExpiration(t *messages.Subtoken, now int64) error { if t.CreationTime <= 0 { return fmt.Errorf("invalid 'creation_time' field: %d", t.CreationTime) } dur := int64(t.ValidityDuration) if dur <= 0 { return fmt.Errorf("invalid validity_duration: %d", dur) } if t.CreationTime >= now+allowedClock...
go
func checkSubtokenExpiration(t *messages.Subtoken, now int64) error { if t.CreationTime <= 0 { return fmt.Errorf("invalid 'creation_time' field: %d", t.CreationTime) } dur := int64(t.ValidityDuration) if dur <= 0 { return fmt.Errorf("invalid validity_duration: %d", dur) } if t.CreationTime >= now+allowedClock...
[ "func", "checkSubtokenExpiration", "(", "t", "*", "messages", ".", "Subtoken", ",", "now", "int64", ")", "error", "{", "if", "t", ".", "CreationTime", "<=", "0", "{", "return", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "t", ".", "CreationTime", ")", ...
// checkSubtokenExpiration checks 'CreationTime' and 'ValidityDuration' fields.
[ "checkSubtokenExpiration", "checks", "CreationTime", "and", "ValidityDuration", "fields", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/server/auth/delegation/checker.go#L211-L226
131,145
luci/luci-go
server/auth/delegation/checker.go
checkSubtokenServices
func checkSubtokenServices(t *messages.Subtoken, serviceID identity.Identity) error { // Empty services field is not allowed. if len(t.Services) == 0 { return fmt.Errorf("the token's services list is empty") } // Else, make sure we are in the 'services' list or it contains '*'. for _, allowed := range t.Services...
go
func checkSubtokenServices(t *messages.Subtoken, serviceID identity.Identity) error { // Empty services field is not allowed. if len(t.Services) == 0 { return fmt.Errorf("the token's services list is empty") } // Else, make sure we are in the 'services' list or it contains '*'. for _, allowed := range t.Services...
[ "func", "checkSubtokenServices", "(", "t", "*", "messages", ".", "Subtoken", ",", "serviceID", "identity", ".", "Identity", ")", "error", "{", "// Empty services field is not allowed.", "if", "len", "(", "t", ".", "Services", ")", "==", "0", "{", "return", "fm...
// checkSubtokenServices makes sure the token is usable by the current service.
[ "checkSubtokenServices", "makes", "sure", "the", "token", "is", "usable", "by", "the", "current", "service", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/server/auth/delegation/checker.go#L229-L241
131,146
luci/luci-go
server/auth/delegation/checker.go
checkSubtokenAudience
func checkSubtokenAudience(c context.Context, t *messages.Subtoken, ident identity.Identity, checker GroupsChecker) error { // Empty audience field is not allowed. if len(t.Audience) == 0 { return fmt.Errorf("the token's audience list is empty") } // Try to find a direct hit first, to avoid calling expensive grou...
go
func checkSubtokenAudience(c context.Context, t *messages.Subtoken, ident identity.Identity, checker GroupsChecker) error { // Empty audience field is not allowed. if len(t.Audience) == 0 { return fmt.Errorf("the token's audience list is empty") } // Try to find a direct hit first, to avoid calling expensive grou...
[ "func", "checkSubtokenAudience", "(", "c", "context", ".", "Context", ",", "t", "*", "messages", ".", "Subtoken", ",", "ident", "identity", ".", "Identity", ",", "checker", "GroupsChecker", ")", "error", "{", "// Empty audience field is not allowed.", "if", "len",...
// checkSubtokenAudience makes sure the token is intended for use by given // identity. // // May return transient errors.
[ "checkSubtokenAudience", "makes", "sure", "the", "token", "is", "intended", "for", "use", "by", "given", "identity", ".", "May", "return", "transient", "errors", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/server/auth/delegation/checker.go#L247-L271
131,147
luci/luci-go
vpython/spec/env.go
LoadEnvironment
func LoadEnvironment(path string, environment *vpython.Environment) error { content, err := ioutil.ReadFile(path) if err != nil { return errors.Annotate(err, "failed to load file from: %s", path).Err() } return ParseEnvironment(string(content), environment) }
go
func LoadEnvironment(path string, environment *vpython.Environment) error { content, err := ioutil.ReadFile(path) if err != nil { return errors.Annotate(err, "failed to load file from: %s", path).Err() } return ParseEnvironment(string(content), environment) }
[ "func", "LoadEnvironment", "(", "path", "string", ",", "environment", "*", "vpython", ".", "Environment", ")", "error", "{", "content", ",", "err", ":=", "ioutil", ".", "ReadFile", "(", "path", ")", "\n", "if", "err", "!=", "nil", "{", "return", "errors"...
// LoadEnvironment loads an environment file text protobuf from the supplied // path.
[ "LoadEnvironment", "loads", "an", "environment", "file", "text", "protobuf", "from", "the", "supplied", "path", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/vpython/spec/env.go#L30-L37
131,148
luci/luci-go
vpython/spec/env.go
ParseEnvironment
func ParseEnvironment(content string, environment *vpython.Environment) error { if err := proto.UnmarshalText(content, environment); err != nil { return errors.Annotate(err, "failed to unmarshal vpython.Environment").Err() } return nil }
go
func ParseEnvironment(content string, environment *vpython.Environment) error { if err := proto.UnmarshalText(content, environment); err != nil { return errors.Annotate(err, "failed to unmarshal vpython.Environment").Err() } return nil }
[ "func", "ParseEnvironment", "(", "content", "string", ",", "environment", "*", "vpython", ".", "Environment", ")", "error", "{", "if", "err", ":=", "proto", ".", "UnmarshalText", "(", "content", ",", "environment", ")", ";", "err", "!=", "nil", "{", "retur...
// ParseEnvironment loads a environment protobuf message from a content string.
[ "ParseEnvironment", "loads", "a", "environment", "protobuf", "message", "from", "a", "content", "string", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/vpython/spec/env.go#L40-L45
131,149
luci/luci-go
vpython/spec/env.go
NormalizeEnvironment
func NormalizeEnvironment(env *vpython.Environment) error { if env.Spec == nil { env.Spec = &vpython.Spec{} } if err := NormalizeSpec(env.Spec, env.Pep425Tag); err != nil { return err } if env.Runtime == nil { env.Runtime = &vpython.Runtime{} } sort.Sort(pep425TagSlice(env.Pep425Tag)) return nil }
go
func NormalizeEnvironment(env *vpython.Environment) error { if env.Spec == nil { env.Spec = &vpython.Spec{} } if err := NormalizeSpec(env.Spec, env.Pep425Tag); err != nil { return err } if env.Runtime == nil { env.Runtime = &vpython.Runtime{} } sort.Sort(pep425TagSlice(env.Pep425Tag)) return nil }
[ "func", "NormalizeEnvironment", "(", "env", "*", "vpython", ".", "Environment", ")", "error", "{", "if", "env", ".", "Spec", "==", "nil", "{", "env", ".", "Spec", "=", "&", "vpython", ".", "Spec", "{", "}", "\n", "}", "\n", "if", "err", ":=", "Norm...
// NormalizeEnvironment normalizes the supplied Environment such that two // messages with identical meaning will have identical representation.
[ "NormalizeEnvironment", "normalizes", "the", "supplied", "Environment", "such", "that", "two", "messages", "with", "identical", "meaning", "will", "have", "identical", "representation", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/vpython/spec/env.go#L49-L63
131,150
luci/luci-go
server/settings/settings.go
get
func (b *Bundle) get(key string, value interface{}) error { raw, ok := b.Values[key] if !ok || raw == nil || len(*raw) == 0 { return ErrNoSettings } typ := reflect.TypeOf(value) // Fast path for already-in-cache values. b.lock.RLock() cached, ok := b.unpacked[key] b.lock.RUnlock() // Slow path. if !ok { ...
go
func (b *Bundle) get(key string, value interface{}) error { raw, ok := b.Values[key] if !ok || raw == nil || len(*raw) == 0 { return ErrNoSettings } typ := reflect.TypeOf(value) // Fast path for already-in-cache values. b.lock.RLock() cached, ok := b.unpacked[key] b.lock.RUnlock() // Slow path. if !ok { ...
[ "func", "(", "b", "*", "Bundle", ")", "get", "(", "key", "string", ",", "value", "interface", "{", "}", ")", "error", "{", "raw", ",", "ok", ":=", "b", ".", "Values", "[", "key", "]", "\n", "if", "!", "ok", "||", "raw", "==", "nil", "||", "le...
// get deserializes value for given key.
[ "get", "deserializes", "value", "for", "given", "key", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/server/settings/settings.go#L55-L101
131,151
luci/luci-go
server/settings/settings.go
GetUncached
func (s *Settings) GetUncached(c context.Context, key string, value interface{}) error { bundle, _, err := s.storage.FetchAllSettings(c) if err != nil { return err } return bundle.get(key, value) }
go
func (s *Settings) GetUncached(c context.Context, key string, value interface{}) error { bundle, _, err := s.storage.FetchAllSettings(c) if err != nil { return err } return bundle.get(key, value) }
[ "func", "(", "s", "*", "Settings", ")", "GetUncached", "(", "c", "context", ".", "Context", ",", "key", "string", ",", "value", "interface", "{", "}", ")", "error", "{", "bundle", ",", "_", ",", "err", ":=", "s", ".", "storage", ".", "FetchAllSetting...
// GetUncached is like Get, by always fetches settings from the storage. // // Do not use GetUncached in performance critical parts, it is much heavier than // Get.
[ "GetUncached", "is", "like", "Get", "by", "always", "fetches", "settings", "from", "the", "storage", ".", "Do", "not", "use", "GetUncached", "in", "performance", "critical", "parts", "it", "is", "much", "heavier", "than", "Get", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/server/settings/settings.go#L184-L190
131,152
luci/luci-go
server/settings/settings.go
SetIfChanged
func (s *Settings) SetIfChanged(c context.Context, key string, value interface{}, who, why string) error { // 'value' must be a pointer to a struct. Construct a zero value of this // kind of struct. typ := reflect.TypeOf(value) if typ.Kind() != reflect.Ptr || typ.Elem().Kind() != reflect.Struct { return ErrBadTyp...
go
func (s *Settings) SetIfChanged(c context.Context, key string, value interface{}, who, why string) error { // 'value' must be a pointer to a struct. Construct a zero value of this // kind of struct. typ := reflect.TypeOf(value) if typ.Kind() != reflect.Ptr || typ.Elem().Kind() != reflect.Struct { return ErrBadTyp...
[ "func", "(", "s", "*", "Settings", ")", "SetIfChanged", "(", "c", "context", ".", "Context", ",", "key", "string", ",", "value", "interface", "{", "}", ",", "who", ",", "why", "string", ")", "error", "{", "// 'value' must be a pointer to a struct. Construct a ...
// SetIfChanged is like Set, but fetches an existing value and compares it to // a new one before changing it. // // Avoids generating new revisions of settings if no changes are actually // made. Also logs who is making the change.
[ "SetIfChanged", "is", "like", "Set", "but", "fetches", "an", "existing", "value", "and", "compares", "it", "to", "a", "new", "one", "before", "changing", "it", ".", "Avoids", "generating", "new", "revisions", "of", "settings", "if", "no", "changes", "are", ...
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/server/settings/settings.go#L209-L233
131,153
luci/luci-go
milo/frontend/ui/build.go
ShortName
func (s *Step) ShortName() string { parts := strings.Split(s.Name, "|") if len(parts) == 0 { return "ERROR: EMPTY NAME" } return parts[len(parts)-1] }
go
func (s *Step) ShortName() string { parts := strings.Split(s.Name, "|") if len(parts) == 0 { return "ERROR: EMPTY NAME" } return parts[len(parts)-1] }
[ "func", "(", "s", "*", "Step", ")", "ShortName", "(", ")", "string", "{", "parts", ":=", "strings", ".", "Split", "(", "s", ".", "Name", ",", "\"", "\"", ")", "\n", "if", "len", "(", "parts", ")", "==", "0", "{", "return", "\"", "\"", "\n", "...
// ShortName returns the leaf name of a potentially nested step. // Eg. With a name of GrandParent|Parent|Child, this returns "Child"
[ "ShortName", "returns", "the", "leaf", "name", "of", "a", "potentially", "nested", "step", ".", "Eg", ".", "With", "a", "name", "of", "GrandParent|Parent|Child", "this", "returns", "Child" ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/milo/frontend/ui/build.go#L53-L59
131,154
luci/luci-go
milo/frontend/ui/build.go
BuildbucketLink
func (bp *BuildPage) BuildbucketLink() *Link { if bp.BuildbucketHost == "" { return nil } u := url.URL{ Scheme: "https", Host: bp.BuildbucketHost, Path: "/rpcexplorer/services/buildbucket.v2.Builds/GetBuild", RawQuery: url.Values{ "request": []string{fmt.Sprintf(`{"id":"%d"}`, bp.Id)}, }.Encode(),...
go
func (bp *BuildPage) BuildbucketLink() *Link { if bp.BuildbucketHost == "" { return nil } u := url.URL{ Scheme: "https", Host: bp.BuildbucketHost, Path: "/rpcexplorer/services/buildbucket.v2.Builds/GetBuild", RawQuery: url.Values{ "request": []string{fmt.Sprintf(`{"id":"%d"}`, bp.Id)}, }.Encode(),...
[ "func", "(", "bp", "*", "BuildPage", ")", "BuildbucketLink", "(", ")", "*", "Link", "{", "if", "bp", ".", "BuildbucketHost", "==", "\"", "\"", "{", "return", "nil", "\n", "}", "\n", "u", ":=", "url", ".", "URL", "{", "Scheme", ":", "\"", "\"", ",...
// BuildbucketLink returns a link to the buildbucket version of the page.
[ "BuildbucketLink", "returns", "a", "link", "to", "the", "buildbucket", "version", "of", "the", "page", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/milo/frontend/ui/build.go#L143-L159
131,155
luci/luci-go
milo/frontend/ui/build.go
HumanStatus
func (b *Build) HumanStatus() string { switch b.Status { case buildbucketpb.Status_SCHEDULED: return "Pending" case buildbucketpb.Status_STARTED: return "Running" case buildbucketpb.Status_SUCCESS: return "Success" case buildbucketpb.Status_FAILURE: return "Failure" case buildbucketpb.Status_INFRA_FAILURE...
go
func (b *Build) HumanStatus() string { switch b.Status { case buildbucketpb.Status_SCHEDULED: return "Pending" case buildbucketpb.Status_STARTED: return "Running" case buildbucketpb.Status_SUCCESS: return "Success" case buildbucketpb.Status_FAILURE: return "Failure" case buildbucketpb.Status_INFRA_FAILURE...
[ "func", "(", "b", "*", "Build", ")", "HumanStatus", "(", ")", "string", "{", "switch", "b", ".", "Status", "{", "case", "buildbucketpb", ".", "Status_SCHEDULED", ":", "return", "\"", "\"", "\n", "case", "buildbucketpb", ".", "Status_STARTED", ":", "return"...
// Status returns a human friendly string for the status.
[ "Status", "returns", "a", "human", "friendly", "string", "for", "the", "status", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/milo/frontend/ui/build.go#L205-L222
131,156
luci/luci-go
milo/frontend/ui/build.go
properties
func properties(props *structpb.Struct) []property { if props == nil { return nil } // Render the fields to JSON. m := jsonpb.Marshaler{} buf := bytes.NewBuffer(nil) if err := m.Marshal(buf, props); err != nil { panic(err) // This shouldn't happen. } d := json.NewDecoder(buf) jsonProps := map[string]json.R...
go
func properties(props *structpb.Struct) []property { if props == nil { return nil } // Render the fields to JSON. m := jsonpb.Marshaler{} buf := bytes.NewBuffer(nil) if err := m.Marshal(buf, props); err != nil { panic(err) // This shouldn't happen. } d := json.NewDecoder(buf) jsonProps := map[string]json.R...
[ "func", "properties", "(", "props", "*", "structpb", ".", "Struct", ")", "[", "]", "property", "{", "if", "props", "==", "nil", "{", "return", "nil", "\n", "}", "\n", "// Render the fields to JSON.", "m", ":=", "jsonpb", ".", "Marshaler", "{", "}", "\n",...
// properties returns the values in the proto struct fields as // a json rendered slice of pairs, sorted by key.
[ "properties", "returns", "the", "values", "in", "the", "proto", "struct", "fields", "as", "a", "json", "rendered", "slice", "of", "pairs", "sorted", "by", "key", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/milo/frontend/ui/build.go#L234-L268
131,157
luci/luci-go
milo/frontend/ui/build.go
BuilderLink
func (b *Build) BuilderLink() *Link { if b.Builder == nil { panic("Invalid build") } builder := b.Builder return NewLink( builder.Builder, fmt.Sprintf("/p/%s/builders/%s/%s", builder.Project, builder.Bucket, builder.Builder), fmt.Sprintf("Builder %s in bucket %s", builder.Builder, builder.Bucket)) }
go
func (b *Build) BuilderLink() *Link { if b.Builder == nil { panic("Invalid build") } builder := b.Builder return NewLink( builder.Builder, fmt.Sprintf("/p/%s/builders/%s/%s", builder.Project, builder.Bucket, builder.Builder), fmt.Sprintf("Builder %s in bucket %s", builder.Builder, builder.Bucket)) }
[ "func", "(", "b", "*", "Build", ")", "BuilderLink", "(", ")", "*", "Link", "{", "if", "b", ".", "Builder", "==", "nil", "{", "panic", "(", "\"", "\"", ")", "\n", "}", "\n", "builder", ":=", "b", ".", "Builder", "\n", "return", "NewLink", "(", "...
// BuilderLink returns a link to the builder in b.
[ "BuilderLink", "returns", "a", "link", "to", "the", "builder", "in", "b", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/milo/frontend/ui/build.go#L279-L288
131,158
luci/luci-go
milo/frontend/ui/build.go
Link
func (b *Build) Link() *Link { if b.Builder == nil { panic("invalid build") } num := b.Id if b.Number != 0 { num = int64(b.Number) } builder := b.Builder return NewLink( fmt.Sprintf("%d", num), fmt.Sprintf("/p/%s/builders/%s/%s/%d", builder.Project, builder.Bucket, builder.Builder, num), fmt.Sprintf("B...
go
func (b *Build) Link() *Link { if b.Builder == nil { panic("invalid build") } num := b.Id if b.Number != 0 { num = int64(b.Number) } builder := b.Builder return NewLink( fmt.Sprintf("%d", num), fmt.Sprintf("/p/%s/builders/%s/%s/%d", builder.Project, builder.Bucket, builder.Builder, num), fmt.Sprintf("B...
[ "func", "(", "b", "*", "Build", ")", "Link", "(", ")", "*", "Link", "{", "if", "b", ".", "Builder", "==", "nil", "{", "panic", "(", "\"", "\"", ")", "\n", "}", "\n", "num", ":=", "b", ".", "Id", "\n", "if", "b", ".", "Number", "!=", "0", ...
// Link is a self link to the build.
[ "Link", "is", "a", "self", "link", "to", "the", "build", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/milo/frontend/ui/build.go#L291-L304
131,159
luci/luci-go
milo/frontend/ui/build.go
RevisionHTML
func (c *Commit) RevisionHTML() template.HTML { switch { case c == nil: return "" case c.Revision != nil: return c.Revision.HTML() case c.RequestRevision != nil: return c.RequestRevision.HTML() default: return "" } }
go
func (c *Commit) RevisionHTML() template.HTML { switch { case c == nil: return "" case c.Revision != nil: return c.Revision.HTML() case c.RequestRevision != nil: return c.RequestRevision.HTML() default: return "" } }
[ "func", "(", "c", "*", "Commit", ")", "RevisionHTML", "(", ")", "template", ".", "HTML", "{", "switch", "{", "case", "c", "==", "nil", ":", "return", "\"", "\"", "\n", "case", "c", ".", "Revision", "!=", "nil", ":", "return", "c", ".", "Revision", ...
// RevisionHTML returns a single rendered link for the revision, prioritizing // Revision over RequestRevision.
[ "RevisionHTML", "returns", "a", "single", "rendered", "link", "for", "the", "revision", "prioritizing", "Revision", "over", "RequestRevision", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/milo/frontend/ui/build.go#L389-L400
131,160
luci/luci-go
milo/frontend/ui/build.go
Timeline
func (bp *BuildPage) Timeline() string { // Return the cached version, if it exists already. if bp.timelineData != "" { return bp.timelineData } // stepData is extra data to deliver with the groups and items (see below) for the // Javascript vis Timeline component. Note that the step data is encoded in markdown...
go
func (bp *BuildPage) Timeline() string { // Return the cached version, if it exists already. if bp.timelineData != "" { return bp.timelineData } // stepData is extra data to deliver with the groups and items (see below) for the // Javascript vis Timeline component. Note that the step data is encoded in markdown...
[ "func", "(", "bp", "*", "BuildPage", ")", "Timeline", "(", ")", "string", "{", "// Return the cached version, if it exists already.", "if", "bp", ".", "timelineData", "!=", "\"", "\"", "{", "return", "bp", ".", "timelineData", "\n", "}", "\n\n", "// stepData is ...
// Timeline returns a JSON parsable string that can be fed into a viz timeline component.
[ "Timeline", "returns", "a", "JSON", "parsable", "string", "that", "can", "be", "fed", "into", "a", "viz", "timeline", "component", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/milo/frontend/ui/build.go#L420-L502
131,161
luci/luci-go
milo/frontend/ui/build.go
HTML
func (l *Link) HTML() template.HTML { if l == nil { return "" } buf := bytes.Buffer{} if err := linkifyTemplate.Execute(&buf, l); err != nil { panic(err) } return template.HTML(buf.Bytes()) }
go
func (l *Link) HTML() template.HTML { if l == nil { return "" } buf := bytes.Buffer{} if err := linkifyTemplate.Execute(&buf, l); err != nil { panic(err) } return template.HTML(buf.Bytes()) }
[ "func", "(", "l", "*", "Link", ")", "HTML", "(", ")", "template", ".", "HTML", "{", "if", "l", "==", "nil", "{", "return", "\"", "\"", "\n", "}", "\n", "buf", ":=", "bytes", ".", "Buffer", "{", "}", "\n", "if", "err", ":=", "linkifyTemplate", "...
// HTML renders this Link as HTML.
[ "HTML", "renders", "this", "Link", "as", "HTML", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/milo/frontend/ui/build.go#L533-L542
131,162
luci/luci-go
milo/frontend/ui/build.go
HTML
func (l LinkSet) HTML() template.HTML { if len(l) == 0 { return "" } buf := bytes.Buffer{} if err := linkifySetTemplate.Execute(&buf, l); err != nil { panic(err) } return template.HTML(buf.Bytes()) }
go
func (l LinkSet) HTML() template.HTML { if len(l) == 0 { return "" } buf := bytes.Buffer{} if err := linkifySetTemplate.Execute(&buf, l); err != nil { panic(err) } return template.HTML(buf.Bytes()) }
[ "func", "(", "l", "LinkSet", ")", "HTML", "(", ")", "template", ".", "HTML", "{", "if", "len", "(", "l", ")", "==", "0", "{", "return", "\"", "\"", "\n", "}", "\n", "buf", ":=", "bytes", ".", "Buffer", "{", "}", "\n", "if", "err", ":=", "link...
// HTML renders this LinkSet as HTML.
[ "HTML", "renders", "this", "LinkSet", "as", "HTML", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/milo/frontend/ui/build.go#L553-L562
131,163
luci/luci-go
milo/frontend/ui/build.go
NewLink
func NewLink(label, url, ariaLabel string) *Link { return &Link{Link: model.Link{Label: label, URL: url}, AriaLabel: ariaLabel} }
go
func NewLink(label, url, ariaLabel string) *Link { return &Link{Link: model.Link{Label: label, URL: url}, AriaLabel: ariaLabel} }
[ "func", "NewLink", "(", "label", ",", "url", ",", "ariaLabel", "string", ")", "*", "Link", "{", "return", "&", "Link", "{", "Link", ":", "model", ".", "Link", "{", "Label", ":", "label", ",", "URL", ":", "url", "}", ",", "AriaLabel", ":", "ariaLabe...
// NewLink does just about what you'd expect.
[ "NewLink", "does", "just", "about", "what", "you", "d", "expect", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/milo/frontend/ui/build.go#L584-L586
131,164
luci/luci-go
milo/frontend/ui/build.go
NewPatchLink
func NewPatchLink(cl *buildbucketpb.GerritChange) *Link { return NewLink( fmt.Sprintf("Gerrit CL %d (ps#%d)", cl.Change, cl.Patchset), protoutil.GerritChangeURL(cl), fmt.Sprintf("gerrit changelist number %d patchset %d", cl.Change, cl.Patchset)) }
go
func NewPatchLink(cl *buildbucketpb.GerritChange) *Link { return NewLink( fmt.Sprintf("Gerrit CL %d (ps#%d)", cl.Change, cl.Patchset), protoutil.GerritChangeURL(cl), fmt.Sprintf("gerrit changelist number %d patchset %d", cl.Change, cl.Patchset)) }
[ "func", "NewPatchLink", "(", "cl", "*", "buildbucketpb", ".", "GerritChange", ")", "*", "Link", "{", "return", "NewLink", "(", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "cl", ".", "Change", ",", "cl", ".", "Patchset", ")", ",", "protoutil", ".", "...
// NewPatchLink generates a URL to a Gerrit CL.
[ "NewPatchLink", "generates", "a", "URL", "to", "a", "Gerrit", "CL", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/milo/frontend/ui/build.go#L589-L594
131,165
luci/luci-go
milo/frontend/ui/build.go
NewEmptyLink
func NewEmptyLink(label string) *Link { return &Link{Link: model.Link{Label: label}} }
go
func NewEmptyLink(label string) *Link { return &Link{Link: model.Link{Label: label}} }
[ "func", "NewEmptyLink", "(", "label", "string", ")", "*", "Link", "{", "return", "&", "Link", "{", "Link", ":", "model", ".", "Link", "{", "Label", ":", "label", "}", "}", "\n", "}" ]
// NewEmptyLink creates a Link struct acting as a pure text label.
[ "NewEmptyLink", "creates", "a", "Link", "struct", "acting", "as", "a", "pure", "text", "label", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/milo/frontend/ui/build.go#L597-L599
131,166
luci/luci-go
server/auth/handlers.go
certsHandler
func certsHandler(c *router.Context) { s := GetSigner(c.Context) if s == nil { httpReplyError(c, http.StatusNotFound, "No Signer instance available") return } certs, err := s.Certificates(c.Context) if err != nil { httpReplyError(c, http.StatusInternalServerError, fmt.Sprintf("Can't fetch certificates - %s",...
go
func certsHandler(c *router.Context) { s := GetSigner(c.Context) if s == nil { httpReplyError(c, http.StatusNotFound, "No Signer instance available") return } certs, err := s.Certificates(c.Context) if err != nil { httpReplyError(c, http.StatusInternalServerError, fmt.Sprintf("Can't fetch certificates - %s",...
[ "func", "certsHandler", "(", "c", "*", "router", ".", "Context", ")", "{", "s", ":=", "GetSigner", "(", "c", ".", "Context", ")", "\n", "if", "s", "==", "nil", "{", "httpReplyError", "(", "c", ",", "http", ".", "StatusNotFound", ",", "\"", "\"", ")...
// certsHandler servers public certificates of the signer in the context.
[ "certsHandler", "servers", "public", "certificates", "of", "the", "signer", "in", "the", "context", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/server/auth/handlers.go#L38-L50
131,167
luci/luci-go
server/auth/handlers.go
infoHandler
func infoHandler(c *router.Context) { s := GetSigner(c.Context) if s == nil { httpReplyError(c, http.StatusNotFound, "No Signer instance available") return } info, err := s.ServiceInfo(c.Context) if err != nil { httpReplyError(c, http.StatusInternalServerError, fmt.Sprintf("Can't grab service info - %s", err...
go
func infoHandler(c *router.Context) { s := GetSigner(c.Context) if s == nil { httpReplyError(c, http.StatusNotFound, "No Signer instance available") return } info, err := s.ServiceInfo(c.Context) if err != nil { httpReplyError(c, http.StatusInternalServerError, fmt.Sprintf("Can't grab service info - %s", err...
[ "func", "infoHandler", "(", "c", "*", "router", ".", "Context", ")", "{", "s", ":=", "GetSigner", "(", "c", ".", "Context", ")", "\n", "if", "s", "==", "nil", "{", "httpReplyError", "(", "c", ",", "http", ".", "StatusNotFound", ",", "\"", "\"", ")"...
// infoHandler returns information about the current service identity.
[ "infoHandler", "returns", "information", "about", "the", "current", "service", "identity", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/server/auth/handlers.go#L53-L65
131,168
luci/luci-go
machine-db/client/cli/vlans.go
printVLANs
func printVLANs(tsv bool, vlans ...*crimson.VLAN) { if len(vlans) > 0 { p := newStdoutPrinter(tsv) defer p.Flush() if !tsv { p.Row("ID", "Alias", "Description", "State", "CIDR Block") } for _, v := range vlans { p.Row(v.Id, v.Alias, v.Description, v.State, v.CidrBlock) } } }
go
func printVLANs(tsv bool, vlans ...*crimson.VLAN) { if len(vlans) > 0 { p := newStdoutPrinter(tsv) defer p.Flush() if !tsv { p.Row("ID", "Alias", "Description", "State", "CIDR Block") } for _, v := range vlans { p.Row(v.Id, v.Alias, v.Description, v.State, v.CidrBlock) } } }
[ "func", "printVLANs", "(", "tsv", "bool", ",", "vlans", "...", "*", "crimson", ".", "VLAN", ")", "{", "if", "len", "(", "vlans", ")", ">", "0", "{", "p", ":=", "newStdoutPrinter", "(", "tsv", ")", "\n", "defer", "p", ".", "Flush", "(", ")", "\n",...
// printVLANs prints VLAN data to stdout in tab-separated columns.
[ "printVLANs", "prints", "VLAN", "data", "to", "stdout", "in", "tab", "-", "separated", "columns", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/machine-db/client/cli/vlans.go#L28-L39
131,169
luci/luci-go
machine-db/client/cli/vlans.go
Run
func (c *GetVLANsCmd) Run(app subcommands.Application, args []string, env subcommands.Env) int { ctx := cli.GetContext(app, c, env) client := getClient(ctx) resp, err := client.ListVLANs(ctx, &c.req) if err != nil { errors.Log(ctx, err) return 1 } printVLANs(c.f.tsv, resp.Vlans...) return 0 }
go
func (c *GetVLANsCmd) Run(app subcommands.Application, args []string, env subcommands.Env) int { ctx := cli.GetContext(app, c, env) client := getClient(ctx) resp, err := client.ListVLANs(ctx, &c.req) if err != nil { errors.Log(ctx, err) return 1 } printVLANs(c.f.tsv, resp.Vlans...) return 0 }
[ "func", "(", "c", "*", "GetVLANsCmd", ")", "Run", "(", "app", "subcommands", ".", "Application", ",", "args", "[", "]", "string", ",", "env", "subcommands", ".", "Env", ")", "int", "{", "ctx", ":=", "cli", ".", "GetContext", "(", "app", ",", "c", "...
// Run runs the command to get VLANs.
[ "Run", "runs", "the", "command", "to", "get", "VLANs", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/machine-db/client/cli/vlans.go#L48-L58
131,170
luci/luci-go
machine-db/client/cli/vlans.go
getVLANsCmd
func getVLANsCmd(params *Parameters) *subcommands.Command { return &subcommands.Command{ UsageLine: "get-vlans [-id <id>]... [-alias <alias>]...", ShortDesc: "retrieves VLANs", LongDesc: "Retrieves VLANs matching the given IDs or aliases, or all VLANs if IDs and aliases are omitted.\n\nExample to get all VLANs:...
go
func getVLANsCmd(params *Parameters) *subcommands.Command { return &subcommands.Command{ UsageLine: "get-vlans [-id <id>]... [-alias <alias>]...", ShortDesc: "retrieves VLANs", LongDesc: "Retrieves VLANs matching the given IDs or aliases, or all VLANs if IDs and aliases are omitted.\n\nExample to get all VLANs:...
[ "func", "getVLANsCmd", "(", "params", "*", "Parameters", ")", "*", "subcommands", ".", "Command", "{", "return", "&", "subcommands", ".", "Command", "{", "UsageLine", ":", "\"", "\"", ",", "ShortDesc", ":", "\"", "\"", ",", "LongDesc", ":", "\"", "\\n", ...
// getVLANsCmd returns a command to get VLANs.
[ "getVLANsCmd", "returns", "a", "command", "to", "get", "VLANs", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/machine-db/client/cli/vlans.go#L61-L74
131,171
luci/luci-go
common/data/recordio/reader.go
NewReader
func NewReader(r io.Reader, maxSize int64) Reader { br, ok := r.(io.ByteReader) if !ok { br = &simpleByteReader{Reader: r} } return &reader{ Reader: r, ByteReader: br, maxSize: maxSize, } }
go
func NewReader(r io.Reader, maxSize int64) Reader { br, ok := r.(io.ByteReader) if !ok { br = &simpleByteReader{Reader: r} } return &reader{ Reader: r, ByteReader: br, maxSize: maxSize, } }
[ "func", "NewReader", "(", "r", "io", ".", "Reader", ",", "maxSize", "int64", ")", "Reader", "{", "br", ",", "ok", ":=", "r", ".", "(", "io", ".", "ByteReader", ")", "\n", "if", "!", "ok", "{", "br", "=", "&", "simpleByteReader", "{", "Reader", ":...
// NewReader creates a new Reader which reads frame data from the // supplied Reader instance. // // If the Reader instance is also an io.ByteReader, its ReadByte method will // be used directly.
[ "NewReader", "creates", "a", "new", "Reader", "which", "reads", "frame", "data", "from", "the", "supplied", "Reader", "instance", ".", "If", "the", "Reader", "instance", "is", "also", "an", "io", ".", "ByteReader", "its", "ReadByte", "method", "will", "be", ...
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/common/data/recordio/reader.go#L59-L69
131,172
luci/luci-go
common/data/recordio/reader.go
Split
func Split(data []byte) (records [][]byte, err error) { br := bytes.NewReader(data) for br.Len() > 0 { var size uint64 size, err = binary.ReadUvarint(br) if err != nil { return } if size > uint64(br.Len()) { err = ErrFrameTooLarge return } // Pull out the record from the original byte stream ...
go
func Split(data []byte) (records [][]byte, err error) { br := bytes.NewReader(data) for br.Len() > 0 { var size uint64 size, err = binary.ReadUvarint(br) if err != nil { return } if size > uint64(br.Len()) { err = ErrFrameTooLarge return } // Pull out the record from the original byte stream ...
[ "func", "Split", "(", "data", "[", "]", "byte", ")", "(", "records", "[", "]", "[", "]", "byte", ",", "err", "error", ")", "{", "br", ":=", "bytes", ".", "NewReader", "(", "data", ")", "\n\n", "for", "br", ".", "Len", "(", ")", ">", "0", "{",...
// Split splits the supplied buffer into its component records. // // This method implements zero-copy segmentation, so the individual records are // slices of the original data set.
[ "Split", "splits", "the", "supplied", "buffer", "into", "its", "component", "records", ".", "This", "method", "implements", "zero", "-", "copy", "segmentation", "so", "the", "individual", "records", "are", "slices", "of", "the", "original", "data", "set", "." ...
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/common/data/recordio/reader.go#L121-L147
131,173
luci/luci-go
auth/authctx/git.go
Write
func (gc *gitConfig) Write(path string) error { f, err := os.Create(path) if err != nil { return err } defer f.Close() if err = gitConfigTempl.Execute(f, gc); err != nil { return err } return f.Close() // failure to close the file is an overall failure }
go
func (gc *gitConfig) Write(path string) error { f, err := os.Create(path) if err != nil { return err } defer f.Close() if err = gitConfigTempl.Execute(f, gc); err != nil { return err } return f.Close() // failure to close the file is an overall failure }
[ "func", "(", "gc", "*", "gitConfig", ")", "Write", "(", "path", "string", ")", "error", "{", "f", ",", "err", ":=", "os", ".", "Create", "(", "path", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "defer", "f", ".",...
// Write actually writes the config to 'path'.
[ "Write", "actually", "writes", "the", "config", "to", "path", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/auth/authctx/git.go#L122-L132
131,174
luci/luci-go
common/flag/nestedflagset/lexer.go
nextToken
func (l *lexerContext) nextToken() token { buf := new(bytes.Buffer) index := 0 escaped := false quoted := false MainLoop: for _, c := range l.value[l.index:] { index += utf8.RuneLen(c) if escaped { escaped = false buf.WriteRune(c) continue } switch c { case '\\': escaped = true case '"...
go
func (l *lexerContext) nextToken() token { buf := new(bytes.Buffer) index := 0 escaped := false quoted := false MainLoop: for _, c := range l.value[l.index:] { index += utf8.RuneLen(c) if escaped { escaped = false buf.WriteRune(c) continue } switch c { case '\\': escaped = true case '"...
[ "func", "(", "l", "*", "lexerContext", ")", "nextToken", "(", ")", "token", "{", "buf", ":=", "new", "(", "bytes", ".", "Buffer", ")", "\n\n", "index", ":=", "0", "\n", "escaped", ":=", "false", "\n", "quoted", ":=", "false", "\n\n", "MainLoop", ":",...
// nextToken parses and returns the next token in the string.
[ "nextToken", "parses", "and", "returns", "the", "next", "token", "in", "the", "string", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/common/flag/nestedflagset/lexer.go#L30-L68
131,175
luci/luci-go
common/flag/nestedflagset/lexer.go
lexer
func lexer(value string, delim rune) *lexerContext { return &lexerContext{ value: value, index: 0, delim: delim, } }
go
func lexer(value string, delim rune) *lexerContext { return &lexerContext{ value: value, index: 0, delim: delim, } }
[ "func", "lexer", "(", "value", "string", ",", "delim", "rune", ")", "*", "lexerContext", "{", "return", "&", "lexerContext", "{", "value", ":", "value", ",", "index", ":", "0", ",", "delim", ":", "delim", ",", "}", "\n", "}" ]
// Lexer creates a new lexer lexerContext.
[ "Lexer", "creates", "a", "new", "lexer", "lexerContext", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/common/flag/nestedflagset/lexer.go#L71-L77
131,176
luci/luci-go
common/flag/nestedflagset/lexer.go
split
func (l *lexerContext) split() []token { result := make([]token, 0, 16) for !l.finished() { result = append(result, l.nextToken()) } return result }
go
func (l *lexerContext) split() []token { result := make([]token, 0, 16) for !l.finished() { result = append(result, l.nextToken()) } return result }
[ "func", "(", "l", "*", "lexerContext", ")", "split", "(", ")", "[", "]", "token", "{", "result", ":=", "make", "(", "[", "]", "token", ",", "0", ",", "16", ")", "\n", "for", "!", "l", ".", "finished", "(", ")", "{", "result", "=", "append", "...
// split splits the Lexer's string into a slice of Tokens.
[ "split", "splits", "the", "Lexer", "s", "string", "into", "a", "slice", "of", "Tokens", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/common/flag/nestedflagset/lexer.go#L85-L91
131,177
luci/luci-go
gce/api/config/v1/vm.go
SetZone
func (v *VM) SetZone(zone string) { for _, disk := range v.GetDisk() { disk.Type = strings.Replace(disk.Type, "{{.Zone}}", zone, -1) } v.MachineType = strings.Replace(v.GetMachineType(), "{{.Zone}}", zone, -1) v.Zone = zone }
go
func (v *VM) SetZone(zone string) { for _, disk := range v.GetDisk() { disk.Type = strings.Replace(disk.Type, "{{.Zone}}", zone, -1) } v.MachineType = strings.Replace(v.GetMachineType(), "{{.Zone}}", zone, -1) v.Zone = zone }
[ "func", "(", "v", "*", "VM", ")", "SetZone", "(", "zone", "string", ")", "{", "for", "_", ",", "disk", ":=", "range", "v", ".", "GetDisk", "(", ")", "{", "disk", ".", "Type", "=", "strings", ".", "Replace", "(", "disk", ".", "Type", ",", "\"", ...
// SetZone sets the given zone throughout this VM.
[ "SetZone", "sets", "the", "given", "zone", "throughout", "this", "VM", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/gce/api/config/v1/vm.go#L43-L49
131,178
luci/luci-go
gce/api/config/v1/vm.go
Validate
func (v *VM) Validate(c *validation.Context) { if len(v.GetDisk()) == 0 { c.Errorf("at least one disk is required") } if v.GetMachineType() == "" { c.Errorf("machine type is required") } for i, meta := range v.GetMetadata() { c.Enter("metadata %d", i) // Implicitly rejects FromFile. // FromFile must be c...
go
func (v *VM) Validate(c *validation.Context) { if len(v.GetDisk()) == 0 { c.Errorf("at least one disk is required") } if v.GetMachineType() == "" { c.Errorf("machine type is required") } for i, meta := range v.GetMetadata() { c.Enter("metadata %d", i) // Implicitly rejects FromFile. // FromFile must be c...
[ "func", "(", "v", "*", "VM", ")", "Validate", "(", "c", "*", "validation", ".", "Context", ")", "{", "if", "len", "(", "v", ".", "GetDisk", "(", ")", ")", "==", "0", "{", "c", ".", "Errorf", "(", "\"", "\"", ")", "\n", "}", "\n", "if", "v",...
// Validate validates this VM description. // Metadata FromFile must already be converted to FromText.
[ "Validate", "validates", "this", "VM", "description", ".", "Metadata", "FromFile", "must", "already", "be", "converted", "to", "FromText", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/gce/api/config/v1/vm.go#L53-L78
131,179
luci/luci-go
common/isolated/isolated.go
BasicFile
func BasicFile(d HexDigest, mode int, size int64) File { return File{ Digest: d, Mode: &mode, Size: &size, } }
go
func BasicFile(d HexDigest, mode int, size int64) File { return File{ Digest: d, Mode: &mode, Size: &size, } }
[ "func", "BasicFile", "(", "d", "HexDigest", ",", "mode", "int", ",", "size", "int64", ")", "File", "{", "return", "File", "{", "Digest", ":", "d", ",", "Mode", ":", "&", "mode", ",", "Size", ":", "&", "size", ",", "}", "\n", "}" ]
// BasicFile returns a File populated for a basic file.
[ "BasicFile", "returns", "a", "File", "populated", "for", "a", "basic", "file", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/common/isolated/isolated.go#L68-L74
131,180
luci/luci-go
common/isolated/isolated.go
TarFile
func TarFile(d HexDigest, size int64) File { return File{ Digest: d, Size: &size, Type: TarArchive, } }
go
func TarFile(d HexDigest, size int64) File { return File{ Digest: d, Size: &size, Type: TarArchive, } }
[ "func", "TarFile", "(", "d", "HexDigest", ",", "size", "int64", ")", "File", "{", "return", "File", "{", "Digest", ":", "d", ",", "Size", ":", "&", "size", ",", "Type", ":", "TarArchive", ",", "}", "\n", "}" ]
// TarFile returns a file populated for a tar archive file.
[ "TarFile", "returns", "a", "file", "populated", "for", "a", "tar", "archive", "file", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/common/isolated/isolated.go#L84-L90
131,181
luci/luci-go
common/isolated/isolated.go
New
func New(h crypto.Hash) *Isolated { a := "" switch h { case crypto.SHA1: a = "sha-1" case crypto.SHA256: a = "sha-256" case crypto.SHA512: a = "sha-512" } return &Isolated{ Algo: a, Version: IsolatedFormatVersion, Files: map[string]File{}, } }
go
func New(h crypto.Hash) *Isolated { a := "" switch h { case crypto.SHA1: a = "sha-1" case crypto.SHA256: a = "sha-256" case crypto.SHA512: a = "sha-512" } return &Isolated{ Algo: a, Version: IsolatedFormatVersion, Files: map[string]File{}, } }
[ "func", "New", "(", "h", "crypto", ".", "Hash", ")", "*", "Isolated", "{", "a", ":=", "\"", "\"", "\n", "switch", "h", "{", "case", "crypto", ".", "SHA1", ":", "a", "=", "\"", "\"", "\n", "case", "crypto", ".", "SHA256", ":", "a", "=", "\"", ...
// New returns a new Isolated with the default Algo and Version.
[ "New", "returns", "a", "new", "Isolated", "with", "the", "default", "Algo", "and", "Version", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/common/isolated/isolated.go#L104-L119
131,182
luci/luci-go
cipd/client/cipd/storage.go
getNextOffset
func (s *storageImpl) getNextOffset(ctx context.Context, url string, length int64) (offset int64, err error) { r, err := http.NewRequest("PUT", url, nil) if err != nil { return } r.Header.Set("Content-Range", fmt.Sprintf("bytes */%d", length)) r.Header.Set("Content-Length", "0") r.Header.Set("User-Agent", s.use...
go
func (s *storageImpl) getNextOffset(ctx context.Context, url string, length int64) (offset int64, err error) { r, err := http.NewRequest("PUT", url, nil) if err != nil { return } r.Header.Set("Content-Range", fmt.Sprintf("bytes */%d", length)) r.Header.Set("Content-Length", "0") r.Header.Set("User-Agent", s.use...
[ "func", "(", "s", "*", "storageImpl", ")", "getNextOffset", "(", "ctx", "context", ".", "Context", ",", "url", "string", ",", "length", "int64", ")", "(", "offset", "int64", ",", "err", "error", ")", "{", "r", ",", "err", ":=", "http", ".", "NewReque...
// getNextOffset queries the storage for size of persisted data.
[ "getNextOffset", "queries", "the", "storage", "for", "size", "of", "persisted", "data", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/cipd/client/cipd/storage.go#L197-L233
131,183
luci/luci-go
config/server/cfgclient/backend/backend.go
WithBackend
func WithBackend(c context.Context, b B) context.Context { return WithFactory(c, func(context.Context) B { return b }) }
go
func WithBackend(c context.Context, b B) context.Context { return WithFactory(c, func(context.Context) B { return b }) }
[ "func", "WithBackend", "(", "c", "context", ".", "Context", ",", "b", "B", ")", "context", ".", "Context", "{", "return", "WithFactory", "(", "c", ",", "func", "(", "context", ".", "Context", ")", "B", "{", "return", "b", "}", ")", "\n", "}" ]
// WithBackend returns a derivative Context with the supplied Backend installed.
[ "WithBackend", "returns", "a", "derivative", "Context", "with", "the", "supplied", "Backend", "installed", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/config/server/cfgclient/backend/backend.go#L59-L61
131,184
luci/luci-go
config/server/cfgclient/backend/backend.go
WithFactory
func WithFactory(c context.Context, f Factory) context.Context { return context.WithValue(c, &configBackendKey, f) }
go
func WithFactory(c context.Context, f Factory) context.Context { return context.WithValue(c, &configBackendKey, f) }
[ "func", "WithFactory", "(", "c", "context", ".", "Context", ",", "f", "Factory", ")", "context", ".", "Context", "{", "return", "context", ".", "WithValue", "(", "c", ",", "&", "configBackendKey", ",", "f", ")", "\n", "}" ]
// WithFactory returns a derivative Context with the supplied BackendFactory // installed.
[ "WithFactory", "returns", "a", "derivative", "Context", "with", "the", "supplied", "BackendFactory", "installed", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/config/server/cfgclient/backend/backend.go#L65-L67
131,185
luci/luci-go
config/server/cfgclient/backend/backend.go
Get
func Get(c context.Context) B { if f, ok := c.Value(&configBackendKey).(Factory); ok { return f(c) } panic("no Backend factory is installed in the Context") }
go
func Get(c context.Context) B { if f, ok := c.Value(&configBackendKey).(Factory); ok { return f(c) } panic("no Backend factory is installed in the Context") }
[ "func", "Get", "(", "c", "context", ".", "Context", ")", "B", "{", "if", "f", ",", "ok", ":=", "c", ".", "Value", "(", "&", "configBackendKey", ")", ".", "(", "Factory", ")", ";", "ok", "{", "return", "f", "(", "c", ")", "\n", "}", "\n", "pan...
// Get returns the Backend that is installed into the Context. // // If no Backend is installed in the Context, Get will panic.
[ "Get", "returns", "the", "Backend", "that", "is", "installed", "into", "the", "Context", ".", "If", "no", "Backend", "is", "installed", "in", "the", "Context", "Get", "will", "panic", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/config/server/cfgclient/backend/backend.go#L72-L77
131,186
luci/luci-go
logdog/common/archive/archive.go
Archive
func Archive(m Manifest) error { // Wrap our log source in a safeLogEntrySource to protect our index order. m.Source = &safeLogEntrySource{ Manifest: &m, Source: m.Source, } // If no constraints are applied, index every LogEntry. if m.StreamIndexRange <= 0 && m.PrefixIndexRange <= 0 && m.ByteRange <= 0 { ...
go
func Archive(m Manifest) error { // Wrap our log source in a safeLogEntrySource to protect our index order. m.Source = &safeLogEntrySource{ Manifest: &m, Source: m.Source, } // If no constraints are applied, index every LogEntry. if m.StreamIndexRange <= 0 && m.PrefixIndexRange <= 0 && m.ByteRange <= 0 { ...
[ "func", "Archive", "(", "m", "Manifest", ")", "error", "{", "// Wrap our log source in a safeLogEntrySource to protect our index order.", "m", ".", "Source", "=", "&", "safeLogEntrySource", "{", "Manifest", ":", "&", "m", ",", "Source", ":", "m", ".", "Source", ",...
// Archive performs the log archival described in the supplied Manifest.
[ "Archive", "performs", "the", "log", "archival", "described", "in", "the", "supplied", "Manifest", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/logdog/common/archive/archive.go#L76-L165
131,187
luci/luci-go
cipd/appengine/impl/repo/processing/reader.go
NewPackageReader
func NewPackageReader(r io.ReaderAt, size int64) (*PackageReader, error) { zr, err := zip.NewReader(r, size) if err != nil { // Note: we rely here (and in other places where we return errors) on // zip.Reader NOT wrapping errors from 'r', so they inherit transient tags // in case of transient Google Storage err...
go
func NewPackageReader(r io.ReaderAt, size int64) (*PackageReader, error) { zr, err := zip.NewReader(r, size) if err != nil { // Note: we rely here (and in other places where we return errors) on // zip.Reader NOT wrapping errors from 'r', so they inherit transient tags // in case of transient Google Storage err...
[ "func", "NewPackageReader", "(", "r", "io", ".", "ReaderAt", ",", "size", "int64", ")", "(", "*", "PackageReader", ",", "error", ")", "{", "zr", ",", "err", ":=", "zip", ".", "NewReader", "(", "r", ",", "size", ")", "\n", "if", "err", "!=", "nil", ...
// NewPackageReader opens the package by reading its directory.
[ "NewPackageReader", "opens", "the", "package", "by", "reading", "its", "directory", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/cipd/appengine/impl/repo/processing/reader.go#L36-L45
131,188
luci/luci-go
cipd/appengine/impl/repo/processing/reader.go
Open
func (p *PackageReader) Open(path string) (io.ReadCloser, int64, error) { for _, f := range p.zr.File { if f.Name == path { if f.UncompressedSize64 > math.MaxInt64 { return nil, 0, errors.Reason("the file %q is unbelievably huge (%d bytes)", path, f.UncompressedSize64).Err() } rc, err := f.Open() if ...
go
func (p *PackageReader) Open(path string) (io.ReadCloser, int64, error) { for _, f := range p.zr.File { if f.Name == path { if f.UncompressedSize64 > math.MaxInt64 { return nil, 0, errors.Reason("the file %q is unbelievably huge (%d bytes)", path, f.UncompressedSize64).Err() } rc, err := f.Open() if ...
[ "func", "(", "p", "*", "PackageReader", ")", "Open", "(", "path", "string", ")", "(", "io", ".", "ReadCloser", ",", "int64", ",", "error", ")", "{", "for", "_", ",", "f", ":=", "range", "p", ".", "zr", ".", "File", "{", "if", "f", ".", "Name", ...
// Open opens some file inside the package for reading. // // Returns the ReadCloser and the uncompressed file size.
[ "Open", "opens", "some", "file", "inside", "the", "package", "for", "reading", ".", "Returns", "the", "ReadCloser", "and", "the", "uncompressed", "file", "size", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/cipd/appengine/impl/repo/processing/reader.go#L50-L64
131,189
luci/luci-go
common/system/filesystem/filesystem.go
MakeDirs
func MakeDirs(path string) error { if err := os.MkdirAll(path, 0755); err != nil { return errors.Annotate(err, "").Err() } return nil }
go
func MakeDirs(path string) error { if err := os.MkdirAll(path, 0755); err != nil { return errors.Annotate(err, "").Err() } return nil }
[ "func", "MakeDirs", "(", "path", "string", ")", "error", "{", "if", "err", ":=", "os", ".", "MkdirAll", "(", "path", ",", "0755", ")", ";", "err", "!=", "nil", "{", "return", "errors", ".", "Annotate", "(", "err", ",", "\"", "\"", ")", ".", "Err"...
// MakeDirs is a convenience wrapper around os.MkdirAll that applies a 0755 // mask to all created directories.
[ "MakeDirs", "is", "a", "convenience", "wrapper", "around", "os", ".", "MkdirAll", "that", "applies", "a", "0755", "mask", "to", "all", "created", "directories", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/common/system/filesystem/filesystem.go#L33-L38
131,190
luci/luci-go
common/system/filesystem/filesystem.go
AbsPath
func AbsPath(base *string) error { v, err := filepath.Abs(*base) if err != nil { return errors.Annotate(err, "unable to resolve absolute path"). InternalReason("base(%q)", *base).Err() } *base = v return nil }
go
func AbsPath(base *string) error { v, err := filepath.Abs(*base) if err != nil { return errors.Annotate(err, "unable to resolve absolute path"). InternalReason("base(%q)", *base).Err() } *base = v return nil }
[ "func", "AbsPath", "(", "base", "*", "string", ")", "error", "{", "v", ",", "err", ":=", "filepath", ".", "Abs", "(", "*", "base", ")", "\n", "if", "err", "!=", "nil", "{", "return", "errors", ".", "Annotate", "(", "err", ",", "\"", "\"", ")", ...
// AbsPath is a convenience wrapper around filepath.Abs that accepts a string // pointer, base, and updates it on successful resolution.
[ "AbsPath", "is", "a", "convenience", "wrapper", "around", "filepath", ".", "Abs", "that", "accepts", "a", "string", "pointer", "base", "and", "updates", "it", "on", "successful", "resolution", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/common/system/filesystem/filesystem.go#L42-L50
131,191
luci/luci-go
common/system/filesystem/filesystem.go
Touch
func Touch(path string, when time.Time, mode os.FileMode) error { // Try and create a file at the target path. fd, err := os.OpenFile(path, (os.O_CREATE | os.O_RDWR), mode) if err == nil { if err := fd.Close(); err != nil { return errors.Annotate(err, "failed to close new file").Err() } if when.IsZero() { ...
go
func Touch(path string, when time.Time, mode os.FileMode) error { // Try and create a file at the target path. fd, err := os.OpenFile(path, (os.O_CREATE | os.O_RDWR), mode) if err == nil { if err := fd.Close(); err != nil { return errors.Annotate(err, "failed to close new file").Err() } if when.IsZero() { ...
[ "func", "Touch", "(", "path", "string", ",", "when", "time", ".", "Time", ",", "mode", "os", ".", "FileMode", ")", "error", "{", "// Try and create a file at the target path.", "fd", ",", "err", ":=", "os", ".", "OpenFile", "(", "path", ",", "(", "os", "...
// Touch creates a new, empty file at the specified path. // // If when is zero-value, time.Now will be used.
[ "Touch", "creates", "a", "new", "empty", "file", "at", "the", "specified", "path", ".", "If", "when", "is", "zero", "-", "value", "time", ".", "Now", "will", "be", "used", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/common/system/filesystem/filesystem.go#L55-L81
131,192
luci/luci-go
common/system/filesystem/filesystem.go
MakeReadOnly
func MakeReadOnly(path string, filter func(string) bool) error { return recursiveChmod(path, filter, func(mode os.FileMode) os.FileMode { return mode & (^os.FileMode(0222)) }) }
go
func MakeReadOnly(path string, filter func(string) bool) error { return recursiveChmod(path, filter, func(mode os.FileMode) os.FileMode { return mode & (^os.FileMode(0222)) }) }
[ "func", "MakeReadOnly", "(", "path", "string", ",", "filter", "func", "(", "string", ")", "bool", ")", "error", "{", "return", "recursiveChmod", "(", "path", ",", "filter", ",", "func", "(", "mode", "os", ".", "FileMode", ")", "os", ".", "FileMode", "{...
// MakeReadOnly recursively iterates through all of the files and directories // starting at path and marks them read-only.
[ "MakeReadOnly", "recursively", "iterates", "through", "all", "of", "the", "files", "and", "directories", "starting", "at", "path", "and", "marks", "them", "read", "-", "only", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/common/system/filesystem/filesystem.go#L177-L181
131,193
luci/luci-go
common/system/filesystem/filesystem.go
MakePathUserWritable
func MakePathUserWritable(path string, fi os.FileInfo) error { if fi == nil { var err error if fi, err = os.Stat(path); err != nil { return errors.Annotate(err, "failed to Stat path").InternalReason("path(%q)", path).Err() } } // Make user-writable, if it's not already. mode := fi.Mode() if (mode & 0200)...
go
func MakePathUserWritable(path string, fi os.FileInfo) error { if fi == nil { var err error if fi, err = os.Stat(path); err != nil { return errors.Annotate(err, "failed to Stat path").InternalReason("path(%q)", path).Err() } } // Make user-writable, if it's not already. mode := fi.Mode() if (mode & 0200)...
[ "func", "MakePathUserWritable", "(", "path", "string", ",", "fi", "os", ".", "FileInfo", ")", "error", "{", "if", "fi", "==", "nil", "{", "var", "err", "error", "\n", "if", "fi", ",", "err", "=", "os", ".", "Stat", "(", "path", ")", ";", "err", "...
// MakePathUserWritable updates the filesystem metadata on a single file or // directory to make it user-writable. // // fi is optional. If nil, os.Stat will be called on path. Otherwise, fi will // be regarded as the results of calling os.Stat on path. This is provided as // an optimization, since some filesystem oper...
[ "MakePathUserWritable", "updates", "the", "filesystem", "metadata", "on", "a", "single", "file", "or", "directory", "to", "make", "it", "user", "-", "writable", ".", "fi", "is", "optional", ".", "If", "nil", "os", ".", "Stat", "will", "be", "called", "on",...
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/common/system/filesystem/filesystem.go#L190-L207
131,194
luci/luci-go
logdog/appengine/cmd/coordinator/default/cron.go
add
func (r *queryResult) add(s *queryResult) { r.lock.Lock() defer r.lock.Unlock() r.notArchived += s.notArchived r.archiveTasked += s.archiveTasked r.archivedPartial += s.archivedPartial r.archivedComplete += s.archivedComplete }
go
func (r *queryResult) add(s *queryResult) { r.lock.Lock() defer r.lock.Unlock() r.notArchived += s.notArchived r.archiveTasked += s.archiveTasked r.archivedPartial += s.archivedPartial r.archivedComplete += s.archivedComplete }
[ "func", "(", "r", "*", "queryResult", ")", "add", "(", "s", "*", "queryResult", ")", "{", "r", ".", "lock", ".", "Lock", "(", ")", "\n", "defer", "r", ".", "lock", ".", "Unlock", "(", ")", "\n", "r", ".", "notArchived", "+=", "s", ".", "notArch...
// add adds the contents of s into r. This is goroutine safe.
[ "add", "adds", "the", "contents", "of", "s", "into", "r", ".", "This", "is", "goroutine", "safe", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/logdog/appengine/cmd/coordinator/default/cron.go#L112-L119
131,195
luci/luci-go
logdog/appengine/cmd/coordinator/default/cron.go
doShardedQueryStat
func doShardedQueryStat(c context.Context, ns string, stat queryStat) error { results := &queryResult{} if err := parallel.FanOutIn(func(ch chan<- func() error) { for i := int64(0); i < totalShards; i++ { i := i ch <- func() error { result, err := doQueryStat(c, ns, stat, i) if err != nil { retur...
go
func doShardedQueryStat(c context.Context, ns string, stat queryStat) error { results := &queryResult{} if err := parallel.FanOutIn(func(ch chan<- func() error) { for i := int64(0); i < totalShards; i++ { i := i ch <- func() error { result, err := doQueryStat(c, ns, stat, i) if err != nil { retur...
[ "func", "doShardedQueryStat", "(", "c", "context", ".", "Context", ",", "ns", "string", ",", "stat", "queryStat", ")", "error", "{", "results", ":=", "&", "queryResult", "{", "}", "\n", "if", "err", ":=", "parallel", ".", "FanOutIn", "(", "func", "(", ...
// doShardedQueryStat launches a batch of queries, at different shard indices.
[ "doShardedQueryStat", "launches", "a", "batch", "of", "queries", "at", "different", "shard", "indices", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/logdog/appengine/cmd/coordinator/default/cron.go#L126-L152
131,196
luci/luci-go
logdog/appengine/cmd/coordinator/default/cron.go
doQueryStat
func doQueryStat(c context.Context, ns string, stat queryStat, index int64) (*queryResult, error) { // We shard a large query into smaller time blocks. shardSize := time.Duration((int64(stat.end) - int64(stat.start)) / totalShards) startOffset := time.Duration(int64(shardSize) * index) now := clock.Now(c) start :=...
go
func doQueryStat(c context.Context, ns string, stat queryStat, index int64) (*queryResult, error) { // We shard a large query into smaller time blocks. shardSize := time.Duration((int64(stat.end) - int64(stat.start)) / totalShards) startOffset := time.Duration(int64(shardSize) * index) now := clock.Now(c) start :=...
[ "func", "doQueryStat", "(", "c", "context", ".", "Context", ",", "ns", "string", ",", "stat", "queryStat", ",", "index", "int64", ")", "(", "*", "queryResult", ",", "error", ")", "{", "// We shard a large query into smaller time blocks.", "shardSize", ":=", "tim...
// doQueryStat runs a single query containing a time range, with a certain index.
[ "doQueryStat", "runs", "a", "single", "query", "containing", "a", "time", "range", "with", "a", "certain", "index", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/logdog/appengine/cmd/coordinator/default/cron.go#L155-L199
131,197
luci/luci-go
logdog/appengine/cmd/coordinator/default/cron.go
cronStatsNSHandler
func cronStatsNSHandler(ctx *router.Context) { s := ctx.Params.ByName("stat") qs, ok := metrics[s] if !ok { ctx.Writer.WriteHeader(http.StatusNotFound) return } ns := ctx.Params.ByName("namespace") c := info.MustNamespace(ctx.Context, ns) err := doShardedQueryStat(c, ns, qs) if err != nil { errors.Log(c, ...
go
func cronStatsNSHandler(ctx *router.Context) { s := ctx.Params.ByName("stat") qs, ok := metrics[s] if !ok { ctx.Writer.WriteHeader(http.StatusNotFound) return } ns := ctx.Params.ByName("namespace") c := info.MustNamespace(ctx.Context, ns) err := doShardedQueryStat(c, ns, qs) if err != nil { errors.Log(c, ...
[ "func", "cronStatsNSHandler", "(", "ctx", "*", "router", ".", "Context", ")", "{", "s", ":=", "ctx", ".", "Params", ".", "ByName", "(", "\"", "\"", ")", "\n", "qs", ",", "ok", ":=", "metrics", "[", "s", "]", "\n", "if", "!", "ok", "{", "ctx", "...
// cronStatsNSHandler gathers metrics about a metric and namespace within logdog.
[ "cronStatsNSHandler", "gathers", "metrics", "about", "a", "metric", "and", "namespace", "within", "logdog", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/logdog/appengine/cmd/coordinator/default/cron.go#L202-L216
131,198
luci/luci-go
machine-db/appengine/rpc/physical_hosts.go
CreatePhysicalHost
func (*Service) CreatePhysicalHost(c context.Context, req *crimson.CreatePhysicalHostRequest) (*crimson.PhysicalHost, error) { return createPhysicalHost(c, req.Host) }
go
func (*Service) CreatePhysicalHost(c context.Context, req *crimson.CreatePhysicalHostRequest) (*crimson.PhysicalHost, error) { return createPhysicalHost(c, req.Host) }
[ "func", "(", "*", "Service", ")", "CreatePhysicalHost", "(", "c", "context", ".", "Context", ",", "req", "*", "crimson", ".", "CreatePhysicalHostRequest", ")", "(", "*", "crimson", ".", "PhysicalHost", ",", "error", ")", "{", "return", "createPhysicalHost", ...
// CreatePhysicalHost handles a request to create a new physical host.
[ "CreatePhysicalHost", "handles", "a", "request", "to", "create", "a", "new", "physical", "host", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/machine-db/appengine/rpc/physical_hosts.go#L39-L41
131,199
luci/luci-go
machine-db/appengine/rpc/physical_hosts.go
ListPhysicalHosts
func (*Service) ListPhysicalHosts(c context.Context, req *crimson.ListPhysicalHostsRequest) (*crimson.ListPhysicalHostsResponse, error) { hosts, err := listPhysicalHosts(c, database.Get(c), req) if err != nil { return nil, err } return &crimson.ListPhysicalHostsResponse{ Hosts: hosts, }, nil }
go
func (*Service) ListPhysicalHosts(c context.Context, req *crimson.ListPhysicalHostsRequest) (*crimson.ListPhysicalHostsResponse, error) { hosts, err := listPhysicalHosts(c, database.Get(c), req) if err != nil { return nil, err } return &crimson.ListPhysicalHostsResponse{ Hosts: hosts, }, nil }
[ "func", "(", "*", "Service", ")", "ListPhysicalHosts", "(", "c", "context", ".", "Context", ",", "req", "*", "crimson", ".", "ListPhysicalHostsRequest", ")", "(", "*", "crimson", ".", "ListPhysicalHostsResponse", ",", "error", ")", "{", "hosts", ",", "err", ...
// ListPhysicalHosts handles a request to list physical hosts.
[ "ListPhysicalHosts", "handles", "a", "request", "to", "list", "physical", "hosts", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/machine-db/appengine/rpc/physical_hosts.go#L44-L52