id
int32
0
167k
repo
stringlengths
5
54
path
stringlengths
4
155
func_name
stringlengths
1
118
original_string
stringlengths
52
85.5k
language
stringclasses
1 value
code
stringlengths
52
85.5k
code_tokens
listlengths
21
1.41k
docstring
stringlengths
6
2.61k
docstring_tokens
listlengths
3
215
sha
stringlengths
40
40
url
stringlengths
85
252
129,600
luci/luci-go
milo/common/acl.go
GetAccessClient
func GetAccessClient(c context.Context) *AccessClient { if client, ok := c.Value(&accessClientKey).(*AccessClient); !ok { panic("access client not found in context") } else { return client } }
go
func GetAccessClient(c context.Context) *AccessClient { if client, ok := c.Value(&accessClientKey).(*AccessClient); !ok { panic("access client not found in context") } else { return client } }
[ "func", "GetAccessClient", "(", "c", "context", ".", "Context", ")", "*", "AccessClient", "{", "if", "client", ",", "ok", ":=", "c", ".", "Value", "(", "&", "accessClientKey", ")", ".", "(", "*", "AccessClient", ")", ";", "!", "ok", "{", "panic", "("...
// GetAccessClient retrieves an AccessClient from the given context.
[ "GetAccessClient", "retrieves", "an", "AccessClient", "from", "the", "given", "context", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/milo/common/acl.go#L100-L106
129,601
luci/luci-go
tokenserver/appengine/frontend/main.go
adminPrelude
func adminPrelude(serviceName string) func(context.Context, string, proto.Message) (context.Context, error) { return func(c context.Context, method string, _ proto.Message) (context.Context, error) { logging.Infof(c, "%s: %q is calling %q", serviceName, auth.CurrentIdentity(c), method) switch admin, err := auth.Is...
go
func adminPrelude(serviceName string) func(context.Context, string, proto.Message) (context.Context, error) { return func(c context.Context, method string, _ proto.Message) (context.Context, error) { logging.Infof(c, "%s: %q is calling %q", serviceName, auth.CurrentIdentity(c), method) switch admin, err := auth.Is...
[ "func", "adminPrelude", "(", "serviceName", "string", ")", "func", "(", "context", ".", "Context", ",", "string", ",", "proto", ".", "Message", ")", "(", "context", ".", "Context", ",", "error", ")", "{", "return", "func", "(", "c", "context", ".", "Co...
// adminPrelude returns a prelude that authorizes only administrators.
[ "adminPrelude", "returns", "a", "prelude", "that", "authorizes", "only", "administrators", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/tokenserver/appengine/frontend/main.go#L47-L58
129,602
luci/luci-go
common/data/text/templateproto/normalize.go
Normalize
func (t *File_Template) Normalize() error { if t.Body == "" { return errors.New("body is empty") } defaultParams := make(map[string]*Value, len(t.Param)) for k, param := range t.Param { if k == "" { return fmt.Errorf("param %q: invalid name", k) } if !ParamRegex.MatchString(k) { return fmt.Errorf("pa...
go
func (t *File_Template) Normalize() error { if t.Body == "" { return errors.New("body is empty") } defaultParams := make(map[string]*Value, len(t.Param)) for k, param := range t.Param { if k == "" { return fmt.Errorf("param %q: invalid name", k) } if !ParamRegex.MatchString(k) { return fmt.Errorf("pa...
[ "func", "(", "t", "*", "File_Template", ")", "Normalize", "(", ")", "error", "{", "if", "t", ".", "Body", "==", "\"", "\"", "{", "return", "errors", ".", "New", "(", "\"", "\"", ")", "\n", "}", "\n\n", "defaultParams", ":=", "make", "(", "map", "...
// Normalize will normalize the Template message, returning an error if it is // invalid.
[ "Normalize", "will", "normalize", "the", "Template", "message", "returning", "an", "error", "if", "it", "is", "invalid", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/common/data/text/templateproto/normalize.go#L50-L86
129,603
luci/luci-go
common/data/text/templateproto/normalize.go
Normalize
func (p *File_Template_Parameter) Normalize() error { if p == nil { return errors.New("is nil") } if err := p.Schema.Normalize(); err != nil { return fmt.Errorf("schema: %s", err) } if p.Default != nil { if err := p.Default.Normalize(); err != nil { return fmt.Errorf("default value: %s", err) } if err...
go
func (p *File_Template_Parameter) Normalize() error { if p == nil { return errors.New("is nil") } if err := p.Schema.Normalize(); err != nil { return fmt.Errorf("schema: %s", err) } if p.Default != nil { if err := p.Default.Normalize(); err != nil { return fmt.Errorf("default value: %s", err) } if err...
[ "func", "(", "p", "*", "File_Template_Parameter", ")", "Normalize", "(", ")", "error", "{", "if", "p", "==", "nil", "{", "return", "errors", ".", "New", "(", "\"", "\"", ")", "\n", "}", "\n", "if", "err", ":=", "p", ".", "Schema", ".", "Normalize",...
// Normalize will normalize the Parameter, returning an error if it is invalid.
[ "Normalize", "will", "normalize", "the", "Parameter", "returning", "an", "error", "if", "it", "is", "invalid", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/common/data/text/templateproto/normalize.go#L89-L105
129,604
luci/luci-go
common/data/text/templateproto/normalize.go
Accepts
func (p *File_Template_Parameter) Accepts(v *Value) error { if v.IsNull() { if !p.Nullable { return errors.New("not nullable") } } else if err := p.Schema.Accepts(v); err != nil { return err } else if err := v.Check(p.Schema); err != nil { return err } return nil }
go
func (p *File_Template_Parameter) Accepts(v *Value) error { if v.IsNull() { if !p.Nullable { return errors.New("not nullable") } } else if err := p.Schema.Accepts(v); err != nil { return err } else if err := v.Check(p.Schema); err != nil { return err } return nil }
[ "func", "(", "p", "*", "File_Template_Parameter", ")", "Accepts", "(", "v", "*", "Value", ")", "error", "{", "if", "v", ".", "IsNull", "(", ")", "{", "if", "!", "p", ".", "Nullable", "{", "return", "errors", ".", "New", "(", "\"", "\"", ")", "\n"...
// Accepts returns nil if this Parameter can accept the Value.
[ "Accepts", "returns", "nil", "if", "this", "Parameter", "can", "accept", "the", "Value", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/common/data/text/templateproto/normalize.go#L108-L119
129,605
luci/luci-go
common/data/text/templateproto/normalize.go
Normalize
func (s *Schema) Normalize() error { if s == nil { return errors.New("is nil") } if s.Schema == nil { return errors.New("has no type") } if enum := s.GetEnum(); enum != nil { return enum.Normalize() } return nil }
go
func (s *Schema) Normalize() error { if s == nil { return errors.New("is nil") } if s.Schema == nil { return errors.New("has no type") } if enum := s.GetEnum(); enum != nil { return enum.Normalize() } return nil }
[ "func", "(", "s", "*", "Schema", ")", "Normalize", "(", ")", "error", "{", "if", "s", "==", "nil", "{", "return", "errors", ".", "New", "(", "\"", "\"", ")", "\n", "}", "\n", "if", "s", ".", "Schema", "==", "nil", "{", "return", "errors", ".", ...
// Normalize will normalize the Schema, returning an error if it is invalid.
[ "Normalize", "will", "normalize", "the", "Schema", "returning", "an", "error", "if", "it", "is", "invalid", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/common/data/text/templateproto/normalize.go#L122-L133
129,606
luci/luci-go
common/data/text/templateproto/normalize.go
Normalize
func (s *Schema_Set) Normalize() error { if len(s.Entry) == 0 { return errors.New("set requires entries") } set := stringset.New(len(s.Entry)) for _, entry := range s.Entry { if entry.Token == "" { return errors.New("blank token") } if !set.Add(entry.Token) { return fmt.Errorf("duplicate token %q", en...
go
func (s *Schema_Set) Normalize() error { if len(s.Entry) == 0 { return errors.New("set requires entries") } set := stringset.New(len(s.Entry)) for _, entry := range s.Entry { if entry.Token == "" { return errors.New("blank token") } if !set.Add(entry.Token) { return fmt.Errorf("duplicate token %q", en...
[ "func", "(", "s", "*", "Schema_Set", ")", "Normalize", "(", ")", "error", "{", "if", "len", "(", "s", ".", "Entry", ")", "==", "0", "{", "return", "errors", ".", "New", "(", "\"", "\"", ")", "\n", "}", "\n", "set", ":=", "stringset", ".", "New"...
// Normalize will normalize the Schema_Set, returning an error if it is // invalid.
[ "Normalize", "will", "normalize", "the", "Schema_Set", "returning", "an", "error", "if", "it", "is", "invalid", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/common/data/text/templateproto/normalize.go#L137-L151
129,607
luci/luci-go
common/data/text/templateproto/normalize.go
Has
func (s *Schema_Set) Has(token string) bool { for _, tok := range s.Entry { if tok.Token == token { return true } } return false }
go
func (s *Schema_Set) Has(token string) bool { for _, tok := range s.Entry { if tok.Token == token { return true } } return false }
[ "func", "(", "s", "*", "Schema_Set", ")", "Has", "(", "token", "string", ")", "bool", "{", "for", "_", ",", "tok", ":=", "range", "s", ".", "Entry", "{", "if", "tok", ".", "Token", "==", "token", "{", "return", "true", "\n", "}", "\n", "}", "\n...
// Has returns true iff the given token is a valid value for this enumeration.
[ "Has", "returns", "true", "iff", "the", "given", "token", "is", "a", "valid", "value", "for", "this", "enumeration", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/common/data/text/templateproto/normalize.go#L154-L161
129,608
luci/luci-go
common/data/text/templateproto/normalize.go
IsNull
func (v *Value) IsNull() bool { _, ret := v.Value.(*Value_Null) return ret }
go
func (v *Value) IsNull() bool { _, ret := v.Value.(*Value_Null) return ret }
[ "func", "(", "v", "*", "Value", ")", "IsNull", "(", ")", "bool", "{", "_", ",", "ret", ":=", "v", ".", "Value", ".", "(", "*", "Value_Null", ")", "\n", "return", "ret", "\n", "}" ]
// IsNull returns true if this Value is the null value.
[ "IsNull", "returns", "true", "if", "this", "Value", "is", "the", "null", "value", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/common/data/text/templateproto/normalize.go#L164-L167
129,609
luci/luci-go
common/data/text/templateproto/normalize.go
Check
func (v *Value) Check(s *Schema) error { check, needsCheck := v.Value.(interface { Check(*Schema) error }) if !needsCheck { return nil } return check.Check(s) }
go
func (v *Value) Check(s *Schema) error { check, needsCheck := v.Value.(interface { Check(*Schema) error }) if !needsCheck { return nil } return check.Check(s) }
[ "func", "(", "v", "*", "Value", ")", "Check", "(", "s", "*", "Schema", ")", "error", "{", "check", ",", "needsCheck", ":=", "v", ".", "Value", ".", "(", "interface", "{", "Check", "(", "*", "Schema", ")", "error", "\n", "}", ")", "\n", "if", "!...
// Check ensures that this value conforms to the given schema.
[ "Check", "ensures", "that", "this", "value", "conforms", "to", "the", "given", "schema", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/common/data/text/templateproto/normalize.go#L170-L178
129,610
luci/luci-go
common/data/text/templateproto/normalize.go
Normalize
func (v *Value) Normalize() error { norm, needsNormalization := v.Value.(interface { Normalize() error }) if !needsNormalization { return nil } return norm.Normalize() }
go
func (v *Value) Normalize() error { norm, needsNormalization := v.Value.(interface { Normalize() error }) if !needsNormalization { return nil } return norm.Normalize() }
[ "func", "(", "v", "*", "Value", ")", "Normalize", "(", ")", "error", "{", "norm", ",", "needsNormalization", ":=", "v", ".", "Value", ".", "(", "interface", "{", "Normalize", "(", ")", "error", "\n", "}", ")", "\n", "if", "!", "needsNormalization", "...
// Normalize returns a non-nil error if the Value is invalid for its nominal type.
[ "Normalize", "returns", "a", "non", "-", "nil", "error", "if", "the", "Value", "is", "invalid", "for", "its", "nominal", "type", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/common/data/text/templateproto/normalize.go#L181-L189
129,611
luci/luci-go
common/data/text/templateproto/normalize.go
Check
func (v *Value_Bytes) Check(schema *Schema) error { s := schema.GetBytes() if s.MaxLength > 0 && uint32(len(v.Bytes)) > s.MaxLength { return fmt.Errorf("value is too large: %d > %d", len(v.Bytes), s.MaxLength) } return nil }
go
func (v *Value_Bytes) Check(schema *Schema) error { s := schema.GetBytes() if s.MaxLength > 0 && uint32(len(v.Bytes)) > s.MaxLength { return fmt.Errorf("value is too large: %d > %d", len(v.Bytes), s.MaxLength) } return nil }
[ "func", "(", "v", "*", "Value_Bytes", ")", "Check", "(", "schema", "*", "Schema", ")", "error", "{", "s", ":=", "schema", ".", "GetBytes", "(", ")", "\n", "if", "s", ".", "MaxLength", ">", "0", "&&", "uint32", "(", "len", "(", "v", ".", "Bytes", ...
// Check returns nil iff this Value meets the max length criteria.
[ "Check", "returns", "nil", "iff", "this", "Value", "meets", "the", "max", "length", "criteria", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/common/data/text/templateproto/normalize.go#L192-L198
129,612
luci/luci-go
common/data/text/templateproto/normalize.go
Check
func (v *Value_Object) Check(schema *Schema) error { s := schema.GetObject() if s.MaxLength > 0 && uint32(len(v.Object)) > s.MaxLength { return fmt.Errorf("value is too large: %d > %d", len(v.Object), s.MaxLength) } return nil }
go
func (v *Value_Object) Check(schema *Schema) error { s := schema.GetObject() if s.MaxLength > 0 && uint32(len(v.Object)) > s.MaxLength { return fmt.Errorf("value is too large: %d > %d", len(v.Object), s.MaxLength) } return nil }
[ "func", "(", "v", "*", "Value_Object", ")", "Check", "(", "schema", "*", "Schema", ")", "error", "{", "s", ":=", "schema", ".", "GetObject", "(", ")", "\n", "if", "s", ".", "MaxLength", ">", "0", "&&", "uint32", "(", "len", "(", "v", ".", "Object...
// Check returns nil iff this Value correctly parses as a JSON object.
[ "Check", "returns", "nil", "iff", "this", "Value", "correctly", "parses", "as", "a", "JSON", "object", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/common/data/text/templateproto/normalize.go#L223-L229
129,613
luci/luci-go
common/data/text/templateproto/normalize.go
Normalize
func (v *Value_Object) Normalize() error { newObj, err := NormalizeJSON(v.Object, true) if err != nil { return err } v.Object = newObj return nil }
go
func (v *Value_Object) Normalize() error { newObj, err := NormalizeJSON(v.Object, true) if err != nil { return err } v.Object = newObj return nil }
[ "func", "(", "v", "*", "Value_Object", ")", "Normalize", "(", ")", "error", "{", "newObj", ",", "err", ":=", "NormalizeJSON", "(", "v", ".", "Object", ",", "true", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "v", "...
// Normalize returns nil iff this Value correctly parses as a JSON object.
[ "Normalize", "returns", "nil", "iff", "this", "Value", "correctly", "parses", "as", "a", "JSON", "object", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/common/data/text/templateproto/normalize.go#L232-L239
129,614
luci/luci-go
common/data/text/templateproto/normalize.go
Check
func (v *Value_Array) Check(schema *Schema) error { s := schema.GetArray() if s.MaxLength > 0 && uint32(len(v.Array)) > s.MaxLength { return fmt.Errorf("value is too large: %d > %d", len(v.Array), s.MaxLength) } return nil }
go
func (v *Value_Array) Check(schema *Schema) error { s := schema.GetArray() if s.MaxLength > 0 && uint32(len(v.Array)) > s.MaxLength { return fmt.Errorf("value is too large: %d > %d", len(v.Array), s.MaxLength) } return nil }
[ "func", "(", "v", "*", "Value_Array", ")", "Check", "(", "schema", "*", "Schema", ")", "error", "{", "s", ":=", "schema", ".", "GetArray", "(", ")", "\n", "if", "s", ".", "MaxLength", ">", "0", "&&", "uint32", "(", "len", "(", "v", ".", "Array", ...
// Check returns nil iff this Value correctly parses as a JSON array.
[ "Check", "returns", "nil", "iff", "this", "Value", "correctly", "parses", "as", "a", "JSON", "array", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/common/data/text/templateproto/normalize.go#L242-L248
129,615
luci/luci-go
common/data/text/templateproto/normalize.go
Normalize
func (v *Value_Array) Normalize() error { newAry, err := NormalizeJSON(v.Array, false) if err != nil { return err } v.Array = newAry return nil }
go
func (v *Value_Array) Normalize() error { newAry, err := NormalizeJSON(v.Array, false) if err != nil { return err } v.Array = newAry return nil }
[ "func", "(", "v", "*", "Value_Array", ")", "Normalize", "(", ")", "error", "{", "newAry", ",", "err", ":=", "NormalizeJSON", "(", "v", ".", "Array", ",", "false", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "v", "....
// Normalize returns nil iff this Value correctly parses as a JSON array.
[ "Normalize", "returns", "nil", "iff", "this", "Value", "correctly", "parses", "as", "a", "JSON", "array", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/common/data/text/templateproto/normalize.go#L251-L258
129,616
luci/luci-go
common/data/text/templateproto/normalize.go
Accepts
func (s *Schema) Accepts(v *Value) error { typ := reflect.TypeOf(s.Schema) if typ == typeOfSchemaEnum { typ = typeOfSchemaStr } if typ != reflect.TypeOf(v.schemaType()) { return fmt.Errorf("type is %q, expected %q", schemaTypeStr(v.schemaType()), schemaTypeStr(s.Schema)) } return nil }
go
func (s *Schema) Accepts(v *Value) error { typ := reflect.TypeOf(s.Schema) if typ == typeOfSchemaEnum { typ = typeOfSchemaStr } if typ != reflect.TypeOf(v.schemaType()) { return fmt.Errorf("type is %q, expected %q", schemaTypeStr(v.schemaType()), schemaTypeStr(s.Schema)) } return nil }
[ "func", "(", "s", "*", "Schema", ")", "Accepts", "(", "v", "*", "Value", ")", "error", "{", "typ", ":=", "reflect", ".", "TypeOf", "(", "s", ".", "Schema", ")", "\n", "if", "typ", "==", "typeOfSchemaEnum", "{", "typ", "=", "typeOfSchemaStr", "\n", ...
// Accepts returns nil if this Schema can accept the Value.
[ "Accepts", "returns", "nil", "if", "this", "Schema", "can", "accept", "the", "Value", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/common/data/text/templateproto/normalize.go#L266-L275
129,617
luci/luci-go
common/data/text/templateproto/normalize.go
Normalize
func (s *Specifier) Normalize() error { if s.TemplateName == "" { return errors.New("empty template_name") } for k, v := range s.Params { if k == "" { return errors.New("empty param key") } if err := v.Normalize(); err != nil { return fmt.Errorf("param %q: %s", k, err) } } return nil }
go
func (s *Specifier) Normalize() error { if s.TemplateName == "" { return errors.New("empty template_name") } for k, v := range s.Params { if k == "" { return errors.New("empty param key") } if err := v.Normalize(); err != nil { return fmt.Errorf("param %q: %s", k, err) } } return nil }
[ "func", "(", "s", "*", "Specifier", ")", "Normalize", "(", ")", "error", "{", "if", "s", ".", "TemplateName", "==", "\"", "\"", "{", "return", "errors", ".", "New", "(", "\"", "\"", ")", "\n", "}", "\n", "for", "k", ",", "v", ":=", "range", "s"...
// Normalize will normalize this Specifier
[ "Normalize", "will", "normalize", "this", "Specifier" ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/common/data/text/templateproto/normalize.go#L342-L355
129,618
luci/luci-go
server/tokens/tokens.go
hash
func (a TokenAlgo) hash(secret []byte) hash.Hash { switch a { case TokenAlgoHmacSHA256: return hmac.New(sha256.New, secret) } return nil }
go
func (a TokenAlgo) hash(secret []byte) hash.Hash { switch a { case TokenAlgoHmacSHA256: return hmac.New(sha256.New, secret) } return nil }
[ "func", "(", "a", "TokenAlgo", ")", "hash", "(", "secret", "[", "]", "byte", ")", "hash", ".", "Hash", "{", "switch", "a", "{", "case", "TokenAlgoHmacSHA256", ":", "return", "hmac", ".", "New", "(", "sha256", ".", "New", ",", "secret", ")", "\n", "...
// hash returns hash.Hash that computes the digest or nil if algo is unknown.
[ "hash", "returns", "hash", ".", "Hash", "that", "computes", "the", "digest", "or", "nil", "if", "algo", "is", "unknown", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/server/tokens/tokens.go#L49-L55
129,619
luci/luci-go
server/tokens/tokens.go
Validate
func (k *TokenKind) Validate(c context.Context, token string, state []byte) (map[string]string, error) { digestLen := k.Algo.digestLen() if digestLen == 0 { return nil, fmt.Errorf("tokens: unknown algo %q", k.Algo) } blob, err := base64.RawURLEncoding.DecodeString(token) if err != nil { return nil, err } //...
go
func (k *TokenKind) Validate(c context.Context, token string, state []byte) (map[string]string, error) { digestLen := k.Algo.digestLen() if digestLen == 0 { return nil, fmt.Errorf("tokens: unknown algo %q", k.Algo) } blob, err := base64.RawURLEncoding.DecodeString(token) if err != nil { return nil, err } //...
[ "func", "(", "k", "*", "TokenKind", ")", "Validate", "(", "c", "context", ".", "Context", ",", "token", "string", ",", "state", "[", "]", "byte", ")", "(", "map", "[", "string", "]", "string", ",", "error", ")", "{", "digestLen", ":=", "k", ".", ...
// Validate checks token MAC and expiration, decodes data embedded into it. // // 'state' must be exactly the same as passed to Generate when creating a token. // If it's different, the token is considered invalid. It usually contains some // implicitly passed state that should be the same when token is generated and /...
[ "Validate", "checks", "token", "MAC", "and", "expiration", "decodes", "data", "embedded", "into", "it", ".", "state", "must", "be", "exactly", "the", "same", "as", "passed", "to", "Generate", "when", "creating", "a", "token", ".", "If", "it", "s", "differe...
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/server/tokens/tokens.go#L142-L227
129,620
luci/luci-go
server/tokens/tokens.go
popInt
func popInt(m map[string]string, key string) (int64, error) { str, ok := m[key] if !ok { return 0, fmt.Errorf("tokens: bad token, missing %q key", key) } asInt, err := strconv.ParseInt(str, 10, 64) if err != nil { return 0, fmt.Errorf("tokens: bad token, %q is not a number", str) } delete(m, key) return asI...
go
func popInt(m map[string]string, key string) (int64, error) { str, ok := m[key] if !ok { return 0, fmt.Errorf("tokens: bad token, missing %q key", key) } asInt, err := strconv.ParseInt(str, 10, 64) if err != nil { return 0, fmt.Errorf("tokens: bad token, %q is not a number", str) } delete(m, key) return asI...
[ "func", "popInt", "(", "m", "map", "[", "string", "]", "string", ",", "key", "string", ")", "(", "int64", ",", "error", ")", "{", "str", ",", "ok", ":=", "m", "[", "key", "]", "\n", "if", "!", "ok", "{", "return", "0", ",", "fmt", ".", "Error...
// extractInt pops integer value from the map.
[ "extractInt", "pops", "integer", "value", "from", "the", "map", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/server/tokens/tokens.go#L230-L241
129,621
luci/luci-go
server/tokens/tokens.go
dataToAuth
func dataToAuth(version byte, public []byte, state []byte) [][]byte { out := [][]byte{ {version}, public, } if len(state) != 0 { out = append(out, state) } return out }
go
func dataToAuth(version byte, public []byte, state []byte) [][]byte { out := [][]byte{ {version}, public, } if len(state) != 0 { out = append(out, state) } return out }
[ "func", "dataToAuth", "(", "version", "byte", ",", "public", "[", "]", "byte", ",", "state", "[", "]", "byte", ")", "[", "]", "[", "]", "byte", "{", "out", ":=", "[", "]", "[", "]", "byte", "{", "{", "version", "}", ",", "public", ",", "}", "...
// dataToAuth generates list of byte blobs authenticated by MAC.
[ "dataToAuth", "generates", "list", "of", "byte", "blobs", "authenticated", "by", "MAC", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/server/tokens/tokens.go#L244-L253
129,622
luci/luci-go
server/tokens/tokens.go
computeMAC
func computeMAC(algo TokenAlgo, secret []byte, dataToAuth [][]byte) ([]byte, error) { hash := algo.hash(secret) if hash == nil { return nil, fmt.Errorf("tokens: unknown algo %q", algo) } for _, chunk := range dataToAuth { // Separator between length header and the body is needed because length // encoding is ...
go
func computeMAC(algo TokenAlgo, secret []byte, dataToAuth [][]byte) ([]byte, error) { hash := algo.hash(secret) if hash == nil { return nil, fmt.Errorf("tokens: unknown algo %q", algo) } for _, chunk := range dataToAuth { // Separator between length header and the body is needed because length // encoding is ...
[ "func", "computeMAC", "(", "algo", "TokenAlgo", ",", "secret", "[", "]", "byte", ",", "dataToAuth", "[", "]", "[", "]", "byte", ")", "(", "[", "]", "byte", ",", "error", ")", "{", "hash", ":=", "algo", ".", "hash", "(", "secret", ")", "\n", "if",...
// computeMAC packs dataToAuth into single blob and computes its MAC.
[ "computeMAC", "packs", "dataToAuth", "into", "single", "blob", "and", "computes", "its", "MAC", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/server/tokens/tokens.go#L256-L272
129,623
luci/luci-go
config/server/cfgclient/backend/caching/codec.go
Encode
func Encode(v interface{}) ([]byte, error) { var buf bytes.Buffer zw := zlib.NewWriter(&buf) enc := json.NewEncoder(zw) if err := enc.Encode(v); err != nil { zw.Close() return nil, errors.Annotate(err, "failed to JSON-encode").Err() } if err := zw.Close(); err != nil { return nil, errors.Annotate(err, "fai...
go
func Encode(v interface{}) ([]byte, error) { var buf bytes.Buffer zw := zlib.NewWriter(&buf) enc := json.NewEncoder(zw) if err := enc.Encode(v); err != nil { zw.Close() return nil, errors.Annotate(err, "failed to JSON-encode").Err() } if err := zw.Close(); err != nil { return nil, errors.Annotate(err, "fai...
[ "func", "Encode", "(", "v", "interface", "{", "}", ")", "(", "[", "]", "byte", ",", "error", ")", "{", "var", "buf", "bytes", ".", "Buffer", "\n", "zw", ":=", "zlib", ".", "NewWriter", "(", "&", "buf", ")", "\n", "enc", ":=", "json", ".", "NewE...
// Encode is a convenience method for generating a ZLIB-compressed JSON-encoded // object.
[ "Encode", "is", "a", "convenience", "method", "for", "generating", "a", "ZLIB", "-", "compressed", "JSON", "-", "encoded", "object", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/config/server/cfgclient/backend/caching/codec.go#L30-L43
129,624
luci/luci-go
config/server/cfgclient/backend/caching/codec.go
Decode
func Decode(d []byte, v interface{}) error { zr, err := zlib.NewReader(bytes.NewReader(d)) if err != nil { return errors.Annotate(err, "failed to create zlib Reader").Err() } defer zr.Close() if err := json.NewDecoder(zr).Decode(v); err != nil { return errors.Annotate(err, "failed to JSON-decode").Err() } r...
go
func Decode(d []byte, v interface{}) error { zr, err := zlib.NewReader(bytes.NewReader(d)) if err != nil { return errors.Annotate(err, "failed to create zlib Reader").Err() } defer zr.Close() if err := json.NewDecoder(zr).Decode(v); err != nil { return errors.Annotate(err, "failed to JSON-decode").Err() } r...
[ "func", "Decode", "(", "d", "[", "]", "byte", ",", "v", "interface", "{", "}", ")", "error", "{", "zr", ",", "err", ":=", "zlib", ".", "NewReader", "(", "bytes", ".", "NewReader", "(", "d", ")", ")", "\n", "if", "err", "!=", "nil", "{", "return...
// Decode is a convenience method for decoding a ZLIB-compressed JSON-encoded // object encoded by Encode.
[ "Decode", "is", "a", "convenience", "method", "for", "decoding", "a", "ZLIB", "-", "compressed", "JSON", "-", "encoded", "object", "encoded", "by", "Encode", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/config/server/cfgclient/backend/caching/codec.go#L47-L58
129,625
luci/luci-go
logdog/common/storage/bigtable/rowKey.go
newRowKey
func newRowKey(project, path string, index, count int64) *rowKey { h := sha256.New() _, _ = h.Write([]byte(project)) _, _ = h.Write([]byte("/")) _, _ = h.Write([]byte(path)) return &rowKey{ pathHash: h.Sum(nil), index: index, count: count, } }
go
func newRowKey(project, path string, index, count int64) *rowKey { h := sha256.New() _, _ = h.Write([]byte(project)) _, _ = h.Write([]byte("/")) _, _ = h.Write([]byte(path)) return &rowKey{ pathHash: h.Sum(nil), index: index, count: count, } }
[ "func", "newRowKey", "(", "project", ",", "path", "string", ",", "index", ",", "count", "int64", ")", "*", "rowKey", "{", "h", ":=", "sha256", ".", "New", "(", ")", "\n\n", "_", ",", "_", "=", "h", ".", "Write", "(", "[", "]", "byte", "(", "pro...
// newRowKey generates the row key matching a given entry path and index.
[ "newRowKey", "generates", "the", "row", "key", "matching", "a", "given", "entry", "path", "and", "index", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/logdog/common/storage/bigtable/rowKey.go#L119-L130
129,626
luci/luci-go
logdog/common/storage/bigtable/rowKey.go
decodeRowKey
func decodeRowKey(v string) (*rowKey, error) { keyParts := strings.SplitN(v, "~", 3) if len(keyParts) != 3 { return nil, errMalformedRowKey } hashEnc, idxEnc, countEnc := keyParts[0], keyParts[1], keyParts[2] if base64.URLEncoding.DecodedLen(len(hashEnc)) < sha256.Size { return nil, errMalformedRowKey } //...
go
func decodeRowKey(v string) (*rowKey, error) { keyParts := strings.SplitN(v, "~", 3) if len(keyParts) != 3 { return nil, errMalformedRowKey } hashEnc, idxEnc, countEnc := keyParts[0], keyParts[1], keyParts[2] if base64.URLEncoding.DecodedLen(len(hashEnc)) < sha256.Size { return nil, errMalformedRowKey } //...
[ "func", "decodeRowKey", "(", "v", "string", ")", "(", "*", "rowKey", ",", "error", ")", "{", "keyParts", ":=", "strings", ".", "SplitN", "(", "v", ",", "\"", "\"", ",", "3", ")", "\n", "if", "len", "(", "keyParts", ")", "!=", "3", "{", "return", ...
// decodeRowKey decodes an encoded row key into its structural components.
[ "decodeRowKey", "decodes", "an", "encoded", "row", "key", "into", "its", "structural", "components", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/logdog/common/storage/bigtable/rowKey.go#L133-L165
129,627
luci/luci-go
logdog/common/storage/bigtable/rowKey.go
encode
func (rk *rowKey) encode() (v string) { // Write the final key to "key": (base64(HASH)~hex(INDEX)) withRowKeyBuffers(func(rkb *rowKeyBuffers) { rkb.appendPathPrefix(rk.pathHash) rkb.appendBytes([]byte("~")) rkb.appendInt64(rk.index) rkb.appendBytes([]byte("~")) rkb.appendInt64(rk.count) v = rkb.value() }...
go
func (rk *rowKey) encode() (v string) { // Write the final key to "key": (base64(HASH)~hex(INDEX)) withRowKeyBuffers(func(rkb *rowKeyBuffers) { rkb.appendPathPrefix(rk.pathHash) rkb.appendBytes([]byte("~")) rkb.appendInt64(rk.index) rkb.appendBytes([]byte("~")) rkb.appendInt64(rk.count) v = rkb.value() }...
[ "func", "(", "rk", "*", "rowKey", ")", "encode", "(", ")", "(", "v", "string", ")", "{", "// Write the final key to \"key\": (base64(HASH)~hex(INDEX))", "withRowKeyBuffers", "(", "func", "(", "rkb", "*", "rowKeyBuffers", ")", "{", "rkb", ".", "appendPathPrefix", ...
// newRowKey instantiates a new rowKey from its components.
[ "newRowKey", "instantiates", "a", "new", "rowKey", "from", "its", "components", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/logdog/common/storage/bigtable/rowKey.go#L172-L183
129,628
luci/luci-go
logdog/common/storage/bigtable/rowKey.go
sharesPathWith
func (rk *rowKey) sharesPathWith(o *rowKey) bool { return bytes.Equal(rk.pathHash, o.pathHash) }
go
func (rk *rowKey) sharesPathWith(o *rowKey) bool { return bytes.Equal(rk.pathHash, o.pathHash) }
[ "func", "(", "rk", "*", "rowKey", ")", "sharesPathWith", "(", "o", "*", "rowKey", ")", "bool", "{", "return", "bytes", ".", "Equal", "(", "rk", ".", "pathHash", ",", "o", ".", "pathHash", ")", "\n", "}" ]
// sharesPrefixWith tests if the "path" component of the row key "rk" matches // the "path" component of "o".
[ "sharesPrefixWith", "tests", "if", "the", "path", "component", "of", "the", "row", "key", "rk", "matches", "the", "path", "component", "of", "o", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/logdog/common/storage/bigtable/rowKey.go#L220-L222
129,629
luci/luci-go
cipd/client/cipd/client.go
LoadFromEnv
func (opts *ClientOptions) LoadFromEnv(getEnv func(string) string) error { if opts.CacheDir == "" { if v := getEnv(EnvCacheDir); v != "" { if !filepath.IsAbs(v) { return fmt.Errorf("bad %s: not an absolute path - %s", EnvCacheDir, v) } opts.CacheDir = v } } if opts.UserAgent == "" { if v := getEnv...
go
func (opts *ClientOptions) LoadFromEnv(getEnv func(string) string) error { if opts.CacheDir == "" { if v := getEnv(EnvCacheDir); v != "" { if !filepath.IsAbs(v) { return fmt.Errorf("bad %s: not an absolute path - %s", EnvCacheDir, v) } opts.CacheDir = v } } if opts.UserAgent == "" { if v := getEnv...
[ "func", "(", "opts", "*", "ClientOptions", ")", "LoadFromEnv", "(", "getEnv", "func", "(", "string", ")", "string", ")", "error", "{", "if", "opts", ".", "CacheDir", "==", "\"", "\"", "{", "if", "v", ":=", "getEnv", "(", "EnvCacheDir", ")", ";", "v",...
// LoadFromEnv loads supplied default values from an environment into opts. // // The supplied getEnv function is used to access named enviornment variables, // and should return an empty string if the enviornment variable is not defined.
[ "LoadFromEnv", "loads", "supplied", "default", "values", "from", "an", "environment", "into", "opts", ".", "The", "supplied", "getEnv", "function", "is", "used", "to", "access", "named", "enviornment", "variables", "and", "should", "return", "an", "empty", "stri...
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/cipd/client/cipd/client.go#L365-L380
129,630
luci/luci-go
cipd/client/cipd/client.go
NewClient
func NewClient(opts ClientOptions) (Client, error) { if opts.AnonymousClient == nil { opts.AnonymousClient = http.DefaultClient } if opts.AuthenticatedClient == nil { opts.AuthenticatedClient = opts.AnonymousClient } if opts.UserAgent == "" { opts.UserAgent = UserAgent } // Validate and normalize service ...
go
func NewClient(opts ClientOptions) (Client, error) { if opts.AnonymousClient == nil { opts.AnonymousClient = http.DefaultClient } if opts.AuthenticatedClient == nil { opts.AuthenticatedClient = opts.AnonymousClient } if opts.UserAgent == "" { opts.UserAgent = UserAgent } // Validate and normalize service ...
[ "func", "NewClient", "(", "opts", "ClientOptions", ")", "(", "Client", ",", "error", ")", "{", "if", "opts", ".", "AnonymousClient", "==", "nil", "{", "opts", ".", "AnonymousClient", "=", "http", ".", "DefaultClient", "\n", "}", "\n", "if", "opts", ".", ...
// NewClient initializes CIPD client object.
[ "NewClient", "initializes", "CIPD", "client", "object", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/cipd/client/cipd/client.go#L383-L448
129,631
luci/luci-go
cipd/client/cipd/client.go
getTagCache
func (client *clientImpl) getTagCache() *internal.TagCache { client.tagCacheInit.Do(func() { var dir string switch { case client.CacheDir != "": dir = client.CacheDir case client.Root != "": dir = filepath.Join(client.Root, fs.SiteServiceDir) default: return } parsed, err := url.Parse(client.Ser...
go
func (client *clientImpl) getTagCache() *internal.TagCache { client.tagCacheInit.Do(func() { var dir string switch { case client.CacheDir != "": dir = client.CacheDir case client.Root != "": dir = filepath.Join(client.Root, fs.SiteServiceDir) default: return } parsed, err := url.Parse(client.Ser...
[ "func", "(", "client", "*", "clientImpl", ")", "getTagCache", "(", ")", "*", "internal", ".", "TagCache", "{", "client", ".", "tagCacheInit", ".", "Do", "(", "func", "(", ")", "{", "var", "dir", "string", "\n", "switch", "{", "case", "client", ".", "...
// getTagCache lazy-initializes tagCache and returns it. // // May return nil if tag cache is disabled.
[ "getTagCache", "lazy", "-", "initializes", "tagCache", "and", "returns", "it", ".", "May", "return", "nil", "if", "tag", "cache", "is", "disabled", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/cipd/client/cipd/client.go#L542-L560
129,632
luci/luci-go
cipd/client/cipd/client.go
getInstanceCache
func (client *clientImpl) getInstanceCache(ctx context.Context) *internal.InstanceCache { client.instanceCacheInit.Do(func() { if client.CacheDir == "" { return } path := filepath.Join(client.CacheDir, "instances") client.instanceCache = internal.NewInstanceCache(fs.NewFileSystem(path, "")) logging.Infof(...
go
func (client *clientImpl) getInstanceCache(ctx context.Context) *internal.InstanceCache { client.instanceCacheInit.Do(func() { if client.CacheDir == "" { return } path := filepath.Join(client.CacheDir, "instances") client.instanceCache = internal.NewInstanceCache(fs.NewFileSystem(path, "")) logging.Infof(...
[ "func", "(", "client", "*", "clientImpl", ")", "getInstanceCache", "(", "ctx", "context", ".", "Context", ")", "*", "internal", ".", "InstanceCache", "{", "client", ".", "instanceCacheInit", ".", "Do", "(", "func", "(", ")", "{", "if", "client", ".", "Ca...
// getInstanceCache lazy-initializes instanceCache and returns it. // // May return nil if instance cache is disabled.
[ "getInstanceCache", "lazy", "-", "initializes", "instanceCache", "and", "returns", "it", ".", "May", "return", "nil", "if", "instance", "cache", "is", "disabled", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/cipd/client/cipd/client.go#L565-L575
129,633
luci/luci-go
cipd/client/cipd/client.go
ensureClientVersionInfo
func (client *clientImpl) ensureClientVersionInfo(ctx context.Context, fs fs.FileSystem, pin common.Pin, clientExe string) { expect, err := json.Marshal(version.Info{ PackageName: pin.PackageName, InstanceID: pin.InstanceID, }) if err != nil { // Should never occur; only error could be if version.Info is not ...
go
func (client *clientImpl) ensureClientVersionInfo(ctx context.Context, fs fs.FileSystem, pin common.Pin, clientExe string) { expect, err := json.Marshal(version.Info{ PackageName: pin.PackageName, InstanceID: pin.InstanceID, }) if err != nil { // Should never occur; only error could be if version.Info is not ...
[ "func", "(", "client", "*", "clientImpl", ")", "ensureClientVersionInfo", "(", "ctx", "context", ".", "Context", ",", "fs", "fs", ".", "FileSystem", ",", "pin", "common", ".", "Pin", ",", "clientExe", "string", ")", "{", "expect", ",", "err", ":=", "json...
// ensureClientVersionInfo is called only with the specially constructed client, // see MaybeUpdateClient function.
[ "ensureClientVersionInfo", "is", "called", "only", "with", "the", "specially", "constructed", "client", "see", "MaybeUpdateClient", "function", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/cipd/client/cipd/client.go#L760-L786
129,634
luci/luci-go
cipd/client/cipd/client.go
finalizeUpload
func (client *clientImpl) finalizeUpload(ctx context.Context, opID string, timeout time.Duration) error { ctx, cancel := clock.WithTimeout(ctx, timeout) defer cancel() sleep := time.Second for { select { case <-ctx.Done(): return ErrFinalizationTimeout default: } op, err := client.cas.FinishUpload(ct...
go
func (client *clientImpl) finalizeUpload(ctx context.Context, opID string, timeout time.Duration) error { ctx, cancel := clock.WithTimeout(ctx, timeout) defer cancel() sleep := time.Second for { select { case <-ctx.Done(): return ErrFinalizationTimeout default: } op, err := client.cas.FinishUpload(ct...
[ "func", "(", "client", "*", "clientImpl", ")", "finalizeUpload", "(", "ctx", "context", ".", "Context", ",", "opID", "string", ",", "timeout", "time", ".", "Duration", ")", "error", "{", "ctx", ",", "cancel", ":=", "clock", ".", "WithTimeout", "(", "ctx"...
// finalizeUpload repeatedly calls FinishUpload RPC until server reports that // the uploaded file has been verified.
[ "finalizeUpload", "repeatedly", "calls", "FinishUpload", "RPC", "until", "server", "reports", "that", "the", "uploaded", "file", "has", "been", "verified", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/cipd/client/cipd/client.go#L994-L1030
129,635
luci/luci-go
cipd/client/cipd/client.go
remoteFetchInstance
func (client *clientImpl) remoteFetchInstance(ctx context.Context, pin common.Pin, output io.WriteSeeker) (err error) { startTS := clock.Now(ctx) defer func() { if err != nil { logging.Errorf(ctx, "cipd: failed to fetch %s - %s", pin, err) } else { logging.Infof(ctx, "cipd: successfully fetched %s in %.1fs"...
go
func (client *clientImpl) remoteFetchInstance(ctx context.Context, pin common.Pin, output io.WriteSeeker) (err error) { startTS := clock.Now(ctx) defer func() { if err != nil { logging.Errorf(ctx, "cipd: failed to fetch %s - %s", pin, err) } else { logging.Infof(ctx, "cipd: successfully fetched %s in %.1fs"...
[ "func", "(", "client", "*", "clientImpl", ")", "remoteFetchInstance", "(", "ctx", "context", ".", "Context", ",", "pin", "common", ".", "Pin", ",", "output", "io", ".", "WriteSeeker", ")", "(", "err", "error", ")", "{", "startTS", ":=", "clock", ".", "...
// remoteFetchInstance fetches the package file into 'output' and verifies its // hash along the way. Assumes 'pin' is already validated.
[ "remoteFetchInstance", "fetches", "the", "package", "file", "into", "output", "and", "verifies", "its", "hash", "along", "the", "way", ".", "Assumes", "pin", "is", "already", "validated", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/cipd/client/cipd/client.go#L1371-L1402
129,636
luci/luci-go
cipd/client/cipd/client.go
fetchAndDo
func (client *clientImpl) fetchAndDo(ctx context.Context, pin common.Pin, cb func(pkg.Instance) error) error { if err := common.ValidatePin(pin, common.KnownHash); err != nil { return err } doit := func() (err error) { // Fetch the package (verifying its hash) and obtain a pointer to its data. instanceFile, e...
go
func (client *clientImpl) fetchAndDo(ctx context.Context, pin common.Pin, cb func(pkg.Instance) error) error { if err := common.ValidatePin(pin, common.KnownHash); err != nil { return err } doit := func() (err error) { // Fetch the package (verifying its hash) and obtain a pointer to its data. instanceFile, e...
[ "func", "(", "client", "*", "clientImpl", ")", "fetchAndDo", "(", "ctx", "context", ".", "Context", ",", "pin", "common", ".", "Pin", ",", "cb", "func", "(", "pkg", ".", "Instance", ")", "error", ")", "error", "{", "if", "err", ":=", "common", ".", ...
// fetchAndDo will fetch and open an instance and pass it to the callback. // // If the callback fails with an error that indicates a corrupted instance, will // delete the instance from the cache, refetch it and call the callback again, // thus the callback should be idempotent. // // Any other error from the callback...
[ "fetchAndDo", "will", "fetch", "and", "open", "an", "instance", "and", "pass", "it", "to", "the", "callback", ".", "If", "the", "callback", "fails", "with", "an", "error", "that", "indicates", "a", "corrupted", "instance", "will", "delete", "the", "instance"...
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/cipd/client/cipd/client.go#L1411-L1458
129,637
luci/luci-go
cipd/client/cipd/client.go
makeRepairChecker
func (client *clientImpl) makeRepairChecker(ctx context.Context, paranoia ParanoidMode) repairCB { if paranoia == NotParanoid { return func(string, common.Pin) *RepairPlan { return nil } } return func(subdir string, pin common.Pin) *RepairPlan { switch state, err := client.deployer.CheckDeployed(ctx, subdir, pi...
go
func (client *clientImpl) makeRepairChecker(ctx context.Context, paranoia ParanoidMode) repairCB { if paranoia == NotParanoid { return func(string, common.Pin) *RepairPlan { return nil } } return func(subdir string, pin common.Pin) *RepairPlan { switch state, err := client.deployer.CheckDeployed(ctx, subdir, pi...
[ "func", "(", "client", "*", "clientImpl", ")", "makeRepairChecker", "(", "ctx", "context", ".", "Context", ",", "paranoia", "ParanoidMode", ")", "repairCB", "{", "if", "paranoia", "==", "NotParanoid", "{", "return", "func", "(", "string", ",", "common", ".",...
// makeRepairChecker returns a function that decided whether we should attempt // to repair an already installed package. // // The implementation depends on selected paranoia mode.
[ "makeRepairChecker", "returns", "a", "function", "that", "decided", "whether", "we", "should", "attempt", "to", "repair", "an", "already", "installed", "package", ".", "The", "implementation", "depends", "on", "selected", "paranoia", "mode", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/cipd/client/cipd/client.go#L1606-L1643
129,638
luci/luci-go
cipd/client/cipd/client.go
humanErr
func humanErr(err error) error { if err != nil { if status, ok := status.FromError(err); ok { return errors.New(status.Message()) } } return err }
go
func humanErr(err error) error { if err != nil { if status, ok := status.FromError(err); ok { return errors.New(status.Message()) } } return err }
[ "func", "humanErr", "(", "err", "error", ")", "error", "{", "if", "err", "!=", "nil", "{", "if", "status", ",", "ok", ":=", "status", ".", "FromError", "(", "err", ")", ";", "ok", "{", "return", "errors", ".", "New", "(", "status", ".", "Message", ...
// humanErr takes gRPC errors and returns a human readable error that can be // presented in the CLI. // // It basically strips scary looking gRPC framing around the error message.
[ "humanErr", "takes", "gRPC", "errors", "and", "returns", "a", "human", "readable", "error", "that", "can", "be", "presented", "in", "the", "CLI", ".", "It", "basically", "strips", "scary", "looking", "gRPC", "framing", "around", "the", "error", "message", "....
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/cipd/client/cipd/client.go#L1680-L1687
129,639
luci/luci-go
server/pprof/pprof.go
InstallHandlers
func InstallHandlers(r *router.Router, base router.MiddlewareChain) { // Pprof native routing structure is not supported by julienschmidt/httprouter // since it mixes prefix matches and direct matches. So we'll have to do some // manual routing for paths under /debug/pprof :( r.GET("/debug/pprof/*path", base, func(...
go
func InstallHandlers(r *router.Router, base router.MiddlewareChain) { // Pprof native routing structure is not supported by julienschmidt/httprouter // since it mixes prefix matches and direct matches. So we'll have to do some // manual routing for paths under /debug/pprof :( r.GET("/debug/pprof/*path", base, func(...
[ "func", "InstallHandlers", "(", "r", "*", "router", ".", "Router", ",", "base", "router", ".", "MiddlewareChain", ")", "{", "// Pprof native routing structure is not supported by julienschmidt/httprouter", "// since it mixes prefix matches and direct matches. So we'll have to do some...
// InstallHandlers installs HTTP handlers for pprof routes.
[ "InstallHandlers", "installs", "HTTP", "handlers", "for", "pprof", "routes", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/server/pprof/pprof.go#L43-L70
129,640
luci/luci-go
buildbucket/luciexe/logdog_posix.go
newLogDogStreamServerForPlatform
func newLogDogStreamServerForPlatform(ctx context.Context, workDir string) (streamserver.StreamServer, error) { // POSIX, use UNIX domain socket. return streamserver.NewUNIXDomainSocketServer(ctx, filepath.Join(workDir, "ld.sock")) }
go
func newLogDogStreamServerForPlatform(ctx context.Context, workDir string) (streamserver.StreamServer, error) { // POSIX, use UNIX domain socket. return streamserver.NewUNIXDomainSocketServer(ctx, filepath.Join(workDir, "ld.sock")) }
[ "func", "newLogDogStreamServerForPlatform", "(", "ctx", "context", ".", "Context", ",", "workDir", "string", ")", "(", "streamserver", ".", "StreamServer", ",", "error", ")", "{", "// POSIX, use UNIX domain socket.", "return", "streamserver", ".", "NewUNIXDomainSocketSe...
// newLogDogStreamServerForPlatform creates a StreamServer instance usable on // POSIX.
[ "newLogDogStreamServerForPlatform", "creates", "a", "StreamServer", "instance", "usable", "on", "POSIX", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/buildbucket/luciexe/logdog_posix.go#L28-L31
129,641
luci/luci-go
server/middleware/middleware.go
WithContextTimeout
func WithContextTimeout(timeout time.Duration) router.Middleware { return func(c *router.Context, next router.Handler) { c.Context, _ = clock.WithTimeout(c.Context, timeout) next(c) } }
go
func WithContextTimeout(timeout time.Duration) router.Middleware { return func(c *router.Context, next router.Handler) { c.Context, _ = clock.WithTimeout(c.Context, timeout) next(c) } }
[ "func", "WithContextTimeout", "(", "timeout", "time", ".", "Duration", ")", "router", ".", "Middleware", "{", "return", "func", "(", "c", "*", "router", ".", "Context", ",", "next", "router", ".", "Handler", ")", "{", "c", ".", "Context", ",", "_", "="...
// WithContextTimeout returns a middleware that adds a timeout to the context.
[ "WithContextTimeout", "returns", "a", "middleware", "that", "adds", "a", "timeout", "to", "the", "context", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/server/middleware/middleware.go#L54-L59
129,642
luci/luci-go
scheduler/appengine/engine/request.go
putRequestIntoInv
func putRequestIntoInv(inv *Invocation, req *task.Request) error { var props []byte if req.Properties != nil { var err error if props, err = proto.Marshal(req.Properties); err != nil { return errors.Annotate(err, "can't marshal Properties").Err() } } if err := utils.ValidateKVList("tag", req.Tags, ':'); e...
go
func putRequestIntoInv(inv *Invocation, req *task.Request) error { var props []byte if req.Properties != nil { var err error if props, err = proto.Marshal(req.Properties); err != nil { return errors.Annotate(err, "can't marshal Properties").Err() } } if err := utils.ValidateKVList("tag", req.Tags, ':'); e...
[ "func", "putRequestIntoInv", "(", "inv", "*", "Invocation", ",", "req", "*", "task", ".", "Request", ")", "error", "{", "var", "props", "[", "]", "byte", "\n", "if", "req", ".", "Properties", "!=", "nil", "{", "var", "err", "error", "\n", "if", "prop...
// putRequestIntoInv copies task.Request fields into Invocation. // // See getRequestFromInv for reverse. Fails only on serialization errors, // this should be rare.
[ "putRequestIntoInv", "copies", "task", ".", "Request", "fields", "into", "Invocation", ".", "See", "getRequestFromInv", "for", "reverse", ".", "Fails", "only", "on", "serialization", "errors", "this", "should", "be", "rare", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/scheduler/appengine/engine/request.go#L33-L54
129,643
luci/luci-go
scheduler/appengine/engine/request.go
getRequestFromInv
func getRequestFromInv(inv *Invocation) (r task.Request, err error) { r.TriggeredBy = inv.TriggeredBy if r.IncomingTriggers, err = inv.IncomingTriggers(); err != nil { return r, errors.Annotate(err, "failed to deserialize incoming triggers").Err() } if len(inv.PropertiesRaw) != 0 { props := &structpb.Struct{} ...
go
func getRequestFromInv(inv *Invocation) (r task.Request, err error) { r.TriggeredBy = inv.TriggeredBy if r.IncomingTriggers, err = inv.IncomingTriggers(); err != nil { return r, errors.Annotate(err, "failed to deserialize incoming triggers").Err() } if len(inv.PropertiesRaw) != 0 { props := &structpb.Struct{} ...
[ "func", "getRequestFromInv", "(", "inv", "*", "Invocation", ")", "(", "r", "task", ".", "Request", ",", "err", "error", ")", "{", "r", ".", "TriggeredBy", "=", "inv", ".", "TriggeredBy", "\n", "if", "r", ".", "IncomingTriggers", ",", "err", "=", "inv",...
// getRequestFromInv constructs task.Request from Invocation fields. // // It is reverse of putRequestIntoInv. Fails only on deserialization errors, // this should be rare.
[ "getRequestFromInv", "constructs", "task", ".", "Request", "from", "Invocation", "fields", ".", "It", "is", "reverse", "of", "putRequestIntoInv", ".", "Fails", "only", "on", "deserialization", "errors", "this", "should", "be", "rare", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/scheduler/appengine/engine/request.go#L60-L74
129,644
luci/luci-go
dm/appengine/distributor/fake/fake.go
Activate
func (t *Task) Activate(c context.Context, s dm.DepsServer) (*ActivatedTask, error) { newTok := model.MakeRandomToken(c, 32) _, err := s.ActivateExecution(c, &dm.ActivateExecutionReq{ Auth: t.Auth, ExecutionToken: newTok}) if err != nil { return nil, err } return &ActivatedTask{ s, c, &dm.Execution_Auth...
go
func (t *Task) Activate(c context.Context, s dm.DepsServer) (*ActivatedTask, error) { newTok := model.MakeRandomToken(c, 32) _, err := s.ActivateExecution(c, &dm.ActivateExecutionReq{ Auth: t.Auth, ExecutionToken: newTok}) if err != nil { return nil, err } return &ActivatedTask{ s, c, &dm.Execution_Auth...
[ "func", "(", "t", "*", "Task", ")", "Activate", "(", "c", "context", ".", "Context", ",", "s", "dm", ".", "DepsServer", ")", "(", "*", "ActivatedTask", ",", "error", ")", "{", "newTok", ":=", "model", ".", "MakeRandomToken", "(", "c", ",", "32", ")...
// Activate does the activation handshake with the provided DepsServer and // returns an ActivatedTask.
[ "Activate", "does", "the", "activation", "handshake", "with", "the", "provided", "DepsServer", "and", "returns", "an", "ActivatedTask", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/dm/appengine/distributor/fake/fake.go#L119-L134
129,645
luci/luci-go
dm/appengine/distributor/fake/fake.go
MustActivate
func (t *Task) MustActivate(c context.Context, s dm.DepsServer) *ActivatedTask { ret, err := t.Activate(c, s) panicIf(err) return ret }
go
func (t *Task) MustActivate(c context.Context, s dm.DepsServer) *ActivatedTask { ret, err := t.Activate(c, s) panicIf(err) return ret }
[ "func", "(", "t", "*", "Task", ")", "MustActivate", "(", "c", "context", ".", "Context", ",", "s", "dm", ".", "DepsServer", ")", "*", "ActivatedTask", "{", "ret", ",", "err", ":=", "t", ".", "Activate", "(", "c", ",", "s", ")", "\n", "panicIf", "...
// MustActivate does the same thing as Activate, but panics if err != nil.
[ "MustActivate", "does", "the", "same", "thing", "as", "Activate", "but", "panics", "if", "err", "!", "=", "nil", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/dm/appengine/distributor/fake/fake.go#L137-L141
129,646
luci/luci-go
dm/appengine/distributor/fake/fake.go
WalkGraph
func (t *ActivatedTask) WalkGraph(req *dm.WalkGraphReq) (*dm.GraphData, error) { newReq := *req newReq.Auth = t.Auth return t.s.WalkGraph(t.c, &newReq) }
go
func (t *ActivatedTask) WalkGraph(req *dm.WalkGraphReq) (*dm.GraphData, error) { newReq := *req newReq.Auth = t.Auth return t.s.WalkGraph(t.c, &newReq) }
[ "func", "(", "t", "*", "ActivatedTask", ")", "WalkGraph", "(", "req", "*", "dm", ".", "WalkGraphReq", ")", "(", "*", "dm", ".", "GraphData", ",", "error", ")", "{", "newReq", ":=", "*", "req", "\n", "newReq", ".", "Auth", "=", "t", ".", "Auth", "...
// WalkGraph calls the bound DepsServer's WalkGraph method with the activated // Auth field.
[ "WalkGraph", "calls", "the", "bound", "DepsServer", "s", "WalkGraph", "method", "with", "the", "activated", "Auth", "field", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/dm/appengine/distributor/fake/fake.go#L161-L165
129,647
luci/luci-go
dm/appengine/distributor/fake/fake.go
EnsureGraphData
func (t *ActivatedTask) EnsureGraphData(req *dm.EnsureGraphDataReq) (*dm.EnsureGraphDataRsp, error) { newReq := *req newReq.ForExecution = t.Auth return t.s.EnsureGraphData(t.c, &newReq) }
go
func (t *ActivatedTask) EnsureGraphData(req *dm.EnsureGraphDataReq) (*dm.EnsureGraphDataRsp, error) { newReq := *req newReq.ForExecution = t.Auth return t.s.EnsureGraphData(t.c, &newReq) }
[ "func", "(", "t", "*", "ActivatedTask", ")", "EnsureGraphData", "(", "req", "*", "dm", ".", "EnsureGraphDataReq", ")", "(", "*", "dm", ".", "EnsureGraphDataRsp", ",", "error", ")", "{", "newReq", ":=", "*", "req", "\n", "newReq", ".", "ForExecution", "="...
// EnsureGraphData calls the bound DepsServer's EnsureGraphData method with the // activated Auth field in ForExecution.
[ "EnsureGraphData", "calls", "the", "bound", "DepsServer", "s", "EnsureGraphData", "method", "with", "the", "activated", "Auth", "field", "in", "ForExecution", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/dm/appengine/distributor/fake/fake.go#L169-L173
129,648
luci/luci-go
dm/appengine/distributor/fake/fake.go
MustDepOn
func (t *ActivatedTask) MustDepOn(to ...*dm.Attempt_ID) (halt bool) { halt, err := t.DepOn(to...) panicIf(err) return }
go
func (t *ActivatedTask) MustDepOn(to ...*dm.Attempt_ID) (halt bool) { halt, err := t.DepOn(to...) panicIf(err) return }
[ "func", "(", "t", "*", "ActivatedTask", ")", "MustDepOn", "(", "to", "...", "*", "dm", ".", "Attempt_ID", ")", "(", "halt", "bool", ")", "{", "halt", ",", "err", ":=", "t", ".", "DepOn", "(", "to", "...", ")", "\n", "panicIf", "(", "err", ")", ...
// MustDepOn is the same as DepOn but will panic if DepOn would have returned // a non-nil error.
[ "MustDepOn", "is", "the", "same", "as", "DepOn", "but", "will", "panic", "if", "DepOn", "would", "have", "returned", "a", "non", "-", "nil", "error", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/dm/appengine/distributor/fake/fake.go#L189-L193
129,649
luci/luci-go
dm/appengine/distributor/fake/fake.go
Run
func (d *BoundDistributor) Run(desc *dm.Quest_Desc, exAuth *dm.Execution_Auth, prev *dm.JsonResult) (tok distributor.Token, pollbackTime time.Duration, err error) { if err = d.RunError; err != nil { return } pollbackTime = d.PollbackTime tok = MakeToken(exAuth.Id) tsk := &DistributorData{ Auth: exAuth, De...
go
func (d *BoundDistributor) Run(desc *dm.Quest_Desc, exAuth *dm.Execution_Auth, prev *dm.JsonResult) (tok distributor.Token, pollbackTime time.Duration, err error) { if err = d.RunError; err != nil { return } pollbackTime = d.PollbackTime tok = MakeToken(exAuth.Id) tsk := &DistributorData{ Auth: exAuth, De...
[ "func", "(", "d", "*", "BoundDistributor", ")", "Run", "(", "desc", "*", "dm", ".", "Quest_Desc", ",", "exAuth", "*", "dm", ".", "Execution_Auth", ",", "prev", "*", "dm", ".", "JsonResult", ")", "(", "tok", "distributor", ".", "Token", ",", "pollbackTi...
// Run implements distributor.D
[ "Run", "implements", "distributor", ".", "D" ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/dm/appengine/distributor/fake/fake.go#L264-L287
129,650
luci/luci-go
dm/appengine/distributor/fake/fake.go
Cancel
func (d *BoundDistributor) Cancel(_ *dm.Quest_Desc, tok distributor.Token) (err error) { d.Lock() defer d.Unlock() if tsk, ok := d.tasks[tok]; ok { tsk.done = true tsk.abnorm = &dm.AbnormalFinish{ Status: dm.AbnormalFinish_CANCELLED, Reason: "cancelled via Cancel()"} } else { err = fmt.Errorf("MISSING t...
go
func (d *BoundDistributor) Cancel(_ *dm.Quest_Desc, tok distributor.Token) (err error) { d.Lock() defer d.Unlock() if tsk, ok := d.tasks[tok]; ok { tsk.done = true tsk.abnorm = &dm.AbnormalFinish{ Status: dm.AbnormalFinish_CANCELLED, Reason: "cancelled via Cancel()"} } else { err = fmt.Errorf("MISSING t...
[ "func", "(", "d", "*", "BoundDistributor", ")", "Cancel", "(", "_", "*", "dm", ".", "Quest_Desc", ",", "tok", "distributor", ".", "Token", ")", "(", "err", "error", ")", "{", "d", ".", "Lock", "(", ")", "\n", "defer", "d", ".", "Unlock", "(", ")"...
// Cancel implements distributor.D
[ "Cancel", "implements", "distributor", ".", "D" ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/dm/appengine/distributor/fake/fake.go#L290-L302
129,651
luci/luci-go
dm/appengine/distributor/fake/fake.go
GetStatus
func (d *BoundDistributor) GetStatus(_ *dm.Quest_Desc, tok distributor.Token) (rslt *dm.Result, err error) { d.Lock() defer d.Unlock() if tsk, ok := d.tasks[tok]; ok { if tsk.done { if tsk.abnorm != nil { rslt = &dm.Result{AbnormalFinish: tsk.abnorm} } else { rslt = &dm.Result{Data: tsk.State} } ...
go
func (d *BoundDistributor) GetStatus(_ *dm.Quest_Desc, tok distributor.Token) (rslt *dm.Result, err error) { d.Lock() defer d.Unlock() if tsk, ok := d.tasks[tok]; ok { if tsk.done { if tsk.abnorm != nil { rslt = &dm.Result{AbnormalFinish: tsk.abnorm} } else { rslt = &dm.Result{Data: tsk.State} } ...
[ "func", "(", "d", "*", "BoundDistributor", ")", "GetStatus", "(", "_", "*", "dm", ".", "Quest_Desc", ",", "tok", "distributor", ".", "Token", ")", "(", "rslt", "*", "dm", ".", "Result", ",", "err", "error", ")", "{", "d", ".", "Lock", "(", ")", "...
// GetStatus implements distributor.D
[ "GetStatus", "implements", "distributor", ".", "D" ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/dm/appengine/distributor/fake/fake.go#L305-L324
129,652
luci/luci-go
dm/appengine/distributor/fake/fake.go
InfoURL
func (d *BoundDistributor) InfoURL(tok distributor.Token) string { return FakeURLPrefix + string(tok) }
go
func (d *BoundDistributor) InfoURL(tok distributor.Token) string { return FakeURLPrefix + string(tok) }
[ "func", "(", "d", "*", "BoundDistributor", ")", "InfoURL", "(", "tok", "distributor", ".", "Token", ")", "string", "{", "return", "FakeURLPrefix", "+", "string", "(", "tok", ")", "\n", "}" ]
// InfoURL implements distributor.D
[ "InfoURL", "implements", "distributor", ".", "D" ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/dm/appengine/distributor/fake/fake.go#L335-L337
129,653
luci/luci-go
dm/appengine/distributor/fake/fake.go
HandleNotification
func (d *BoundDistributor) HandleNotification(q *dm.Quest_Desc, n *distributor.Notification) (rslt *dm.Result, err error) { return d.GetStatus(q, distributor.Token(n.Attrs["token"])) }
go
func (d *BoundDistributor) HandleNotification(q *dm.Quest_Desc, n *distributor.Notification) (rslt *dm.Result, err error) { return d.GetStatus(q, distributor.Token(n.Attrs["token"])) }
[ "func", "(", "d", "*", "BoundDistributor", ")", "HandleNotification", "(", "q", "*", "dm", ".", "Quest_Desc", ",", "n", "*", "distributor", ".", "Notification", ")", "(", "rslt", "*", "dm", ".", "Result", ",", "err", "error", ")", "{", "return", "d", ...
// HandleNotification implements distributor.D
[ "HandleNotification", "implements", "distributor", ".", "D" ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/dm/appengine/distributor/fake/fake.go#L340-L342
129,654
luci/luci-go
dm/appengine/distributor/fake/fake.go
HandleTaskQueueTask
func (d *BoundDistributor) HandleTaskQueueTask(r *http.Request) ([]*distributor.Notification, error) { panic("not implemented") }
go
func (d *BoundDistributor) HandleTaskQueueTask(r *http.Request) ([]*distributor.Notification, error) { panic("not implemented") }
[ "func", "(", "d", "*", "BoundDistributor", ")", "HandleTaskQueueTask", "(", "r", "*", "http", ".", "Request", ")", "(", "[", "]", "*", "distributor", ".", "Notification", ",", "error", ")", "{", "panic", "(", "\"", "\"", ")", "\n", "}" ]
// HandleTaskQueueTask is not implemented, and shouldn't be needed for most // tests. It could be implemented if some new test required it, however.
[ "HandleTaskQueueTask", "is", "not", "implemented", "and", "shouldn", "t", "be", "needed", "for", "most", "tests", ".", "It", "could", "be", "implemented", "if", "some", "new", "test", "required", "it", "however", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/dm/appengine/distributor/fake/fake.go#L346-L348
129,655
luci/luci-go
lucicfg/gens.go
add
func (g *generators) add(cb starlark.Callable) error { if g.runningNow { return fmt.Errorf("can't add a generator while already running them") } g.gen = append(g.gen, cb) return nil }
go
func (g *generators) add(cb starlark.Callable) error { if g.runningNow { return fmt.Errorf("can't add a generator while already running them") } g.gen = append(g.gen, cb) return nil }
[ "func", "(", "g", "*", "generators", ")", "add", "(", "cb", "starlark", ".", "Callable", ")", "error", "{", "if", "g", ".", "runningNow", "{", "return", "fmt", ".", "Errorf", "(", "\"", "\"", ")", "\n", "}", "\n", "g", ".", "gen", "=", "append", ...
// add registers a new generator callback.
[ "add", "registers", "a", "new", "generator", "callback", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/lucicfg/gens.go#L36-L42
129,656
luci/luci-go
lucicfg/gens.go
call
func (g *generators) call(th *starlark.Thread, ctx *genCtx) (errs errors.MultiError) { if g.runningNow { return errors.MultiError{ fmt.Errorf("can't call generators while they are already running"), } } g.runningNow = true defer func() { g.runningNow = false }() fc := builtins.GetFailureCollector(th) for...
go
func (g *generators) call(th *starlark.Thread, ctx *genCtx) (errs errors.MultiError) { if g.runningNow { return errors.MultiError{ fmt.Errorf("can't call generators while they are already running"), } } g.runningNow = true defer func() { g.runningNow = false }() fc := builtins.GetFailureCollector(th) for...
[ "func", "(", "g", "*", "generators", ")", "call", "(", "th", "*", "starlark", ".", "Thread", ",", "ctx", "*", "genCtx", ")", "(", "errs", "errors", ".", "MultiError", ")", "{", "if", "g", ".", "runningNow", "{", "return", "errors", ".", "MultiError",...
// call calls all registered callbacks sequentially, collecting all errors.
[ "call", "calls", "all", "registered", "callbacks", "sequentially", "collecting", "all", "errors", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/lucicfg/gens.go#L45-L70
129,657
luci/luci-go
server/auth/config.go
Initialize
func Initialize(c context.Context, cfg *Config) context.Context { if getConfig(c) != nil { panic("auth.Initialize is called twice on same context") } return setConfig(c, cfg) }
go
func Initialize(c context.Context, cfg *Config) context.Context { if getConfig(c) != nil { panic("auth.Initialize is called twice on same context") } return setConfig(c, cfg) }
[ "func", "Initialize", "(", "c", "context", ".", "Context", ",", "cfg", "*", "Config", ")", "context", ".", "Context", "{", "if", "getConfig", "(", "c", ")", "!=", "nil", "{", "panic", "(", "\"", "\"", ")", "\n", "}", "\n", "return", "setConfig", "(...
// Initialize inserts authentication configuration into the context. // // An initialized context is required by any other function in the package. They // return ErrNotConfigured otherwise. // // Calling Initialize twice causes a panic.
[ "Initialize", "inserts", "authentication", "configuration", "into", "the", "context", ".", "An", "initialized", "context", "is", "required", "by", "any", "other", "function", "in", "the", "package", ".", "They", "return", "ErrNotConfigured", "otherwise", ".", "Cal...
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/server/auth/config.go#L91-L96
129,658
luci/luci-go
server/auth/config.go
adjustedTimeout
func (cfg *Config) adjustedTimeout(t time.Duration) time.Duration { if !cfg.IsDevMode { return t } if t > time.Minute { return t } return time.Minute }
go
func (cfg *Config) adjustedTimeout(t time.Duration) time.Duration { if !cfg.IsDevMode { return t } if t > time.Minute { return t } return time.Minute }
[ "func", "(", "cfg", "*", "Config", ")", "adjustedTimeout", "(", "t", "time", ".", "Duration", ")", "time", ".", "Duration", "{", "if", "!", "cfg", ".", "IsDevMode", "{", "return", "t", "\n", "}", "\n", "if", "t", ">", "time", ".", "Minute", "{", ...
// adjustedTimeout returns `t` if IsDevMode is false or >=1 min if true.
[ "adjustedTimeout", "returns", "t", "if", "IsDevMode", "is", "false", "or", ">", "=", "1", "min", "if", "true", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/server/auth/config.go#L116-L124
129,659
luci/luci-go
server/auth/config.go
setConfig
func setConfig(c context.Context, cfg *Config) context.Context { return context.WithValue(c, &cfgContextKey, cfg) }
go
func setConfig(c context.Context, cfg *Config) context.Context { return context.WithValue(c, &cfgContextKey, cfg) }
[ "func", "setConfig", "(", "c", "context", ".", "Context", ",", "cfg", "*", "Config", ")", "context", ".", "Context", "{", "return", "context", ".", "WithValue", "(", "c", ",", "&", "cfgContextKey", ",", "cfg", ")", "\n", "}" ]
// setConfig completely replaces the configuration in the context.
[ "setConfig", "completely", "replaces", "the", "configuration", "in", "the", "context", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/server/auth/config.go#L127-L129
129,660
luci/luci-go
server/auth/config.go
GetSigner
func GetSigner(c context.Context) signing.Signer { if cfg := getConfig(c); cfg != nil { return cfg.Signer } return nil }
go
func GetSigner(c context.Context) signing.Signer { if cfg := getConfig(c); cfg != nil { return cfg.Signer } return nil }
[ "func", "GetSigner", "(", "c", "context", ".", "Context", ")", "signing", ".", "Signer", "{", "if", "cfg", ":=", "getConfig", "(", "c", ")", ";", "cfg", "!=", "nil", "{", "return", "cfg", ".", "Signer", "\n", "}", "\n", "return", "nil", "\n", "}" ]
// GetSigner returns the signing.Signer instance representing the service. // // It is injected into the context as part of Config. It can be used to grab // a service account the service is running as or its current public // certificates. // // Returns nil if the signer is not available.
[ "GetSigner", "returns", "the", "signing", ".", "Signer", "instance", "representing", "the", "service", ".", "It", "is", "injected", "into", "the", "context", "as", "part", "of", "Config", ".", "It", "can", "be", "used", "to", "grab", "a", "service", "accou...
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/server/auth/config.go#L160-L165
129,661
luci/luci-go
common/api/gitiles/json.go
MarshalJSON
func (t ts) MarshalJSON() ([]byte, error) { stringTime := t.Format(time.ANSIC) return json.Marshal(stringTime) }
go
func (t ts) MarshalJSON() ([]byte, error) { stringTime := t.Format(time.ANSIC) return json.Marshal(stringTime) }
[ "func", "(", "t", "ts", ")", "MarshalJSON", "(", ")", "(", "[", "]", "byte", ",", "error", ")", "{", "stringTime", ":=", "t", ".", "Format", "(", "time", ".", "ANSIC", ")", "\n", "return", "json", ".", "Marshal", "(", "stringTime", ")", "\n", "}"...
// MarshalJSON converts Time to an ANSIC string before marshalling.
[ "MarshalJSON", "converts", "Time", "to", "an", "ANSIC", "string", "before", "marshalling", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/common/api/gitiles/json.go#L41-L44
129,662
luci/luci-go
common/api/gitiles/json.go
UnmarshalJSON
func (t *ts) UnmarshalJSON(b []byte) error { var s string if err := json.Unmarshal(b, &s); err != nil { return err } parsedTime, err := time.Parse(time.ANSIC, s) if err != nil { // Try it with the appended timezone version. parsedTime, err = time.Parse(time.ANSIC+" -0700", s) } t.Time = parsedTime return ...
go
func (t *ts) UnmarshalJSON(b []byte) error { var s string if err := json.Unmarshal(b, &s); err != nil { return err } parsedTime, err := time.Parse(time.ANSIC, s) if err != nil { // Try it with the appended timezone version. parsedTime, err = time.Parse(time.ANSIC+" -0700", s) } t.Time = parsedTime return ...
[ "func", "(", "t", "*", "ts", ")", "UnmarshalJSON", "(", "b", "[", "]", "byte", ")", "error", "{", "var", "s", "string", "\n", "if", "err", ":=", "json", ".", "Unmarshal", "(", "b", ",", "&", "s", ")", ";", "err", "!=", "nil", "{", "return", "...
// UnmarshalJSON unmarshals an ANSIC string before parsing it into a Time.
[ "UnmarshalJSON", "unmarshals", "an", "ANSIC", "string", "before", "parsing", "it", "into", "a", "Time", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/common/api/gitiles/json.go#L47-L59
129,663
luci/luci-go
common/api/gitiles/json.go
Proto
func (u *user) Proto() (ret *git.Commit_User, err error) { ret = &git.Commit_User{ Name: u.Name, Email: u.Email, } if !u.Time.IsZero() { ret.Time, err = ptypes.TimestampProto(u.Time.Time) err = errors.Annotate(err, "encoding time").Err() } return }
go
func (u *user) Proto() (ret *git.Commit_User, err error) { ret = &git.Commit_User{ Name: u.Name, Email: u.Email, } if !u.Time.IsZero() { ret.Time, err = ptypes.TimestampProto(u.Time.Time) err = errors.Annotate(err, "encoding time").Err() } return }
[ "func", "(", "u", "*", "user", ")", "Proto", "(", ")", "(", "ret", "*", "git", ".", "Commit_User", ",", "err", "error", ")", "{", "ret", "=", "&", "git", ".", "Commit_User", "{", "Name", ":", "u", ".", "Name", ",", "Email", ":", "u", ".", "Em...
// Proto converts this User to its protobuf equivalent.
[ "Proto", "converts", "this", "User", "to", "its", "protobuf", "equivalent", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/common/api/gitiles/json.go#L69-L79
129,664
luci/luci-go
common/api/gitiles/json.go
Proto
func (c *commit) Proto() (ret *git.Commit, err error) { ret = &git.Commit{ Id: c.Commit, Tree: c.Tree, Parents: c.Parents, Message: c.Message, TreeDiff: c.TreeDiff, } if ret.Author, err = c.Author.Proto(); err != nil { err = errors.Annotate(err, "decoding author").Err() return } if ret.C...
go
func (c *commit) Proto() (ret *git.Commit, err error) { ret = &git.Commit{ Id: c.Commit, Tree: c.Tree, Parents: c.Parents, Message: c.Message, TreeDiff: c.TreeDiff, } if ret.Author, err = c.Author.Proto(); err != nil { err = errors.Annotate(err, "decoding author").Err() return } if ret.C...
[ "func", "(", "c", "*", "commit", ")", "Proto", "(", ")", "(", "ret", "*", "git", ".", "Commit", ",", "err", "error", ")", "{", "ret", "=", "&", "git", ".", "Commit", "{", "Id", ":", "c", ".", "Commit", ",", "Tree", ":", "c", ".", "Tree", ",...
// Proto converts this git.Commit to its protobuf equivalent.
[ "Proto", "converts", "this", "git", ".", "Commit", "to", "its", "protobuf", "equivalent", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/common/api/gitiles/json.go#L93-L112
129,665
luci/luci-go
machine-db/client/cli/platforms.go
printPlatforms
func printPlatforms(tsv bool, platforms ...*crimson.Platform) { if len(platforms) > 0 { p := newStdoutPrinter(tsv) defer p.Flush() if !tsv { p.Row("Name", "Description", "Manufacturer") } for _, plat := range platforms { p.Row(plat.Name, plat.Description, plat.Manufacturer) } } }
go
func printPlatforms(tsv bool, platforms ...*crimson.Platform) { if len(platforms) > 0 { p := newStdoutPrinter(tsv) defer p.Flush() if !tsv { p.Row("Name", "Description", "Manufacturer") } for _, plat := range platforms { p.Row(plat.Name, plat.Description, plat.Manufacturer) } } }
[ "func", "printPlatforms", "(", "tsv", "bool", ",", "platforms", "...", "*", "crimson", ".", "Platform", ")", "{", "if", "len", "(", "platforms", ")", ">", "0", "{", "p", ":=", "newStdoutPrinter", "(", "tsv", ")", "\n", "defer", "p", ".", "Flush", "("...
// printPlatforms prints platform data to stdout in tab-separated columns.
[ "printPlatforms", "prints", "platform", "data", "to", "stdout", "in", "tab", "-", "separated", "columns", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/machine-db/client/cli/platforms.go#L28-L39
129,666
luci/luci-go
machine-db/client/cli/platforms.go
Run
func (c *GetPlatformsCmd) Run(app subcommands.Application, args []string, env subcommands.Env) int { ctx := cli.GetContext(app, c, env) client := getClient(ctx) resp, err := client.ListPlatforms(ctx, &c.req) if err != nil { errors.Log(ctx, err) return 1 } printPlatforms(c.f.tsv, resp.Platforms...) return 0 }
go
func (c *GetPlatformsCmd) Run(app subcommands.Application, args []string, env subcommands.Env) int { ctx := cli.GetContext(app, c, env) client := getClient(ctx) resp, err := client.ListPlatforms(ctx, &c.req) if err != nil { errors.Log(ctx, err) return 1 } printPlatforms(c.f.tsv, resp.Platforms...) return 0 }
[ "func", "(", "c", "*", "GetPlatformsCmd", ")", "Run", "(", "app", "subcommands", ".", "Application", ",", "args", "[", "]", "string", ",", "env", "subcommands", ".", "Env", ")", "int", "{", "ctx", ":=", "cli", ".", "GetContext", "(", "app", ",", "c",...
// Run runs the command to get platforms.
[ "Run", "runs", "the", "command", "to", "get", "platforms", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/machine-db/client/cli/platforms.go#L48-L58
129,667
luci/luci-go
machine-db/client/cli/platforms.go
getPlatformsCmd
func getPlatformsCmd(params *Parameters) *subcommands.Command { return &subcommands.Command{ UsageLine: "get-platforms [-name <name>]... [-man <manufacturer>]...", ShortDesc: "retrieves platforms", LongDesc: "Retrieves platforms matching the given names, or all platforms if names and manufacturers are omitted.\...
go
func getPlatformsCmd(params *Parameters) *subcommands.Command { return &subcommands.Command{ UsageLine: "get-platforms [-name <name>]... [-man <manufacturer>]...", ShortDesc: "retrieves platforms", LongDesc: "Retrieves platforms matching the given names, or all platforms if names and manufacturers are omitted.\...
[ "func", "getPlatformsCmd", "(", "params", "*", "Parameters", ")", "*", "subcommands", ".", "Command", "{", "return", "&", "subcommands", ".", "Command", "{", "UsageLine", ":", "\"", "\"", ",", "ShortDesc", ":", "\"", "\"", ",", "LongDesc", ":", "\"", "\\...
// getPlatformsCmd returns a command to get platforms.
[ "getPlatformsCmd", "returns", "a", "command", "to", "get", "platforms", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/machine-db/client/cli/platforms.go#L61-L74
129,668
luci/luci-go
dm/api/distributor/jobsim/validate.go
Normalize
func (p *Phrase) Normalize() error { if p != nil { if p.Name == "" { return fmt.Errorf("empty ID") } for _, s := range p.Stages { if err := s.Normalize(); err != nil { return err } } if p.ReturnStage == nil { p.ReturnStage = &ReturnStage{Retval: 1} } } return nil }
go
func (p *Phrase) Normalize() error { if p != nil { if p.Name == "" { return fmt.Errorf("empty ID") } for _, s := range p.Stages { if err := s.Normalize(); err != nil { return err } } if p.ReturnStage == nil { p.ReturnStage = &ReturnStage{Retval: 1} } } return nil }
[ "func", "(", "p", "*", "Phrase", ")", "Normalize", "(", ")", "error", "{", "if", "p", "!=", "nil", "{", "if", "p", ".", "Name", "==", "\"", "\"", "{", "return", "fmt", ".", "Errorf", "(", "\"", "\"", ")", "\n", "}", "\n", "for", "_", ",", "...
// Normalize checks Phrase for errors and converts it to its normalized form.
[ "Normalize", "checks", "Phrase", "for", "errors", "and", "converts", "it", "to", "its", "normalized", "form", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/dm/api/distributor/jobsim/validate.go#L26-L41
129,669
luci/luci-go
dm/api/distributor/jobsim/validate.go
Normalize
func (s *Stage) Normalize() error { switch st := s.GetStageType().(type) { case *Stage_Failure: return st.Failure.Normalize() case *Stage_Stall: return st.Stall.Normalize() case *Stage_Deps: return st.Deps.Normalize() } return fmt.Errorf("empty stage") }
go
func (s *Stage) Normalize() error { switch st := s.GetStageType().(type) { case *Stage_Failure: return st.Failure.Normalize() case *Stage_Stall: return st.Stall.Normalize() case *Stage_Deps: return st.Deps.Normalize() } return fmt.Errorf("empty stage") }
[ "func", "(", "s", "*", "Stage", ")", "Normalize", "(", ")", "error", "{", "switch", "st", ":=", "s", ".", "GetStageType", "(", ")", ".", "(", "type", ")", "{", "case", "*", "Stage_Failure", ":", "return", "st", ".", "Failure", ".", "Normalize", "("...
// Normalize checks Stage for errors and converts it to its normalized form.
[ "Normalize", "checks", "Stage", "for", "errors", "and", "converts", "it", "to", "its", "normalized", "form", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/dm/api/distributor/jobsim/validate.go#L44-L54
129,670
luci/luci-go
dm/api/distributor/jobsim/validate.go
Normalize
func (f *FailureStage) Normalize() error { if f.Chance < 0 { return fmt.Errorf("too small FailureStage chance") } if f.Chance > 1 { return fmt.Errorf("too large FailureStage chance") } return nil }
go
func (f *FailureStage) Normalize() error { if f.Chance < 0 { return fmt.Errorf("too small FailureStage chance") } if f.Chance > 1 { return fmt.Errorf("too large FailureStage chance") } return nil }
[ "func", "(", "f", "*", "FailureStage", ")", "Normalize", "(", ")", "error", "{", "if", "f", ".", "Chance", "<", "0", "{", "return", "fmt", ".", "Errorf", "(", "\"", "\"", ")", "\n", "}", "\n", "if", "f", ".", "Chance", ">", "1", "{", "return", ...
// Normalize checks FailureStage for errors and converts it to its normalized // form.
[ "Normalize", "checks", "FailureStage", "for", "errors", "and", "converts", "it", "to", "its", "normalized", "form", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/dm/api/distributor/jobsim/validate.go#L58-L66
129,671
luci/luci-go
dm/api/distributor/jobsim/validate.go
Normalize
func (d *DepsStage) Normalize() error { for _, d := range d.Deps { if err := d.Normalize(); err != nil { return err } } return nil }
go
func (d *DepsStage) Normalize() error { for _, d := range d.Deps { if err := d.Normalize(); err != nil { return err } } return nil }
[ "func", "(", "d", "*", "DepsStage", ")", "Normalize", "(", ")", "error", "{", "for", "_", ",", "d", ":=", "range", "d", ".", "Deps", "{", "if", "err", ":=", "d", ".", "Normalize", "(", ")", ";", "err", "!=", "nil", "{", "return", "err", "\n", ...
// Normalize checks DepsStage for errors and converts it to its normalized form.
[ "Normalize", "checks", "DepsStage", "for", "errors", "and", "converts", "it", "to", "its", "normalized", "form", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/dm/api/distributor/jobsim/validate.go#L75-L82
129,672
luci/luci-go
dm/api/distributor/jobsim/validate.go
Normalize
func (d *Dependency) Normalize() error { if d.Shards == 0 { d.Shards = 1 } if err := d.GetAttempts().Normalize(); err != nil { return err } return d.Phrase.Normalize() }
go
func (d *Dependency) Normalize() error { if d.Shards == 0 { d.Shards = 1 } if err := d.GetAttempts().Normalize(); err != nil { return err } return d.Phrase.Normalize() }
[ "func", "(", "d", "*", "Dependency", ")", "Normalize", "(", ")", "error", "{", "if", "d", ".", "Shards", "==", "0", "{", "d", ".", "Shards", "=", "1", "\n", "}", "\n", "if", "err", ":=", "d", ".", "GetAttempts", "(", ")", ".", "Normalize", "(",...
// Normalize checks Dependency for errors and converts it to its normalized form.
[ "Normalize", "checks", "Dependency", "for", "errors", "and", "converts", "it", "to", "its", "normalized", "form", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/dm/api/distributor/jobsim/validate.go#L85-L93
129,673
luci/luci-go
dm/api/distributor/jobsim/validate.go
Normalize
func (s *SparseRange) Normalize() error { if len(s.Items) == 0 { s.Items = []*RangeItem{{RangeItem: &RangeItem_Single{1}}} return nil } current := uint32(0) for _, itm := range s.Items { switch i := itm.RangeItem.(type) { case *RangeItem_Single: if i.Single <= current { return fmt.Errorf("malformed S...
go
func (s *SparseRange) Normalize() error { if len(s.Items) == 0 { s.Items = []*RangeItem{{RangeItem: &RangeItem_Single{1}}} return nil } current := uint32(0) for _, itm := range s.Items { switch i := itm.RangeItem.(type) { case *RangeItem_Single: if i.Single <= current { return fmt.Errorf("malformed S...
[ "func", "(", "s", "*", "SparseRange", ")", "Normalize", "(", ")", "error", "{", "if", "len", "(", "s", ".", "Items", ")", "==", "0", "{", "s", ".", "Items", "=", "[", "]", "*", "RangeItem", "{", "{", "RangeItem", ":", "&", "RangeItem_Single", "{"...
// Normalize checks SparseRange for errors and converts it to its normalized form.
[ "Normalize", "checks", "SparseRange", "for", "errors", "and", "converts", "it", "to", "its", "normalized", "form", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/dm/api/distributor/jobsim/validate.go#L96-L122
129,674
luci/luci-go
dm/api/distributor/jobsim/validate.go
Normalize
func (r *Range) Normalize() error { if r.High <= r.Low { return fmt.Errorf("malformed Range") } return nil }
go
func (r *Range) Normalize() error { if r.High <= r.Low { return fmt.Errorf("malformed Range") } return nil }
[ "func", "(", "r", "*", "Range", ")", "Normalize", "(", ")", "error", "{", "if", "r", ".", "High", "<=", "r", ".", "Low", "{", "return", "fmt", ".", "Errorf", "(", "\"", "\"", ")", "\n", "}", "\n", "return", "nil", "\n", "}" ]
// Normalize checks Range for errors and converts it to its normalized form.
[ "Normalize", "checks", "Range", "for", "errors", "and", "converts", "it", "to", "its", "normalized", "form", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/dm/api/distributor/jobsim/validate.go#L125-L130
129,675
luci/luci-go
tools/cmd/bqschemaupdater/schema.go
schema
func (c *schemaConverter) schema(messageName string) (schema bigquery.Schema, description string, err error) { file, obj, _ := descutil.Resolve(c.desc, messageName) if obj == nil { return nil, "", fmt.Errorf("message %q is not found", messageName) } msg, isMsg := obj.(*descriptor.DescriptorProto) if !isMsg { r...
go
func (c *schemaConverter) schema(messageName string) (schema bigquery.Schema, description string, err error) { file, obj, _ := descutil.Resolve(c.desc, messageName) if obj == nil { return nil, "", fmt.Errorf("message %q is not found", messageName) } msg, isMsg := obj.(*descriptor.DescriptorProto) if !isMsg { r...
[ "func", "(", "c", "*", "schemaConverter", ")", "schema", "(", "messageName", "string", ")", "(", "schema", "bigquery", ".", "Schema", ",", "description", "string", ",", "err", "error", ")", "{", "file", ",", "obj", ",", "_", ":=", "descutil", ".", "Res...
// schema constructs a bigquery.Schema from a named message.
[ "schema", "constructs", "a", "bigquery", ".", "Schema", "from", "a", "named", "message", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/tools/cmd/bqschemaupdater/schema.go#L45-L65
129,676
luci/luci-go
tools/cmd/bqschemaupdater/schema.go
field
func (c *schemaConverter) field(file *descriptor.FileDescriptorProto, field *descriptor.FieldDescriptorProto) (*bigquery.FieldSchema, error) { schema := &bigquery.FieldSchema{ Name: field.GetName(), Description: c.description(file, field), Repeated: descutil.Repeated(field), Required: descutil.Req...
go
func (c *schemaConverter) field(file *descriptor.FileDescriptorProto, field *descriptor.FieldDescriptorProto) (*bigquery.FieldSchema, error) { schema := &bigquery.FieldSchema{ Name: field.GetName(), Description: c.description(file, field), Repeated: descutil.Repeated(field), Required: descutil.Req...
[ "func", "(", "c", "*", "schemaConverter", ")", "field", "(", "file", "*", "descriptor", ".", "FileDescriptorProto", ",", "field", "*", "descriptor", ".", "FieldDescriptorProto", ")", "(", "*", "bigquery", ".", "FieldSchema", ",", "error", ")", "{", "schema",...
// field constructs bigquery.FieldSchema from proto field descriptor.
[ "field", "constructs", "bigquery", ".", "FieldSchema", "from", "proto", "field", "descriptor", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/tools/cmd/bqschemaupdater/schema.go#L68-L136
129,677
luci/luci-go
tools/cmd/bqschemaupdater/schema.go
schemaDiff
func schemaDiff(before, after bigquery.Schema) string { ret, err := difflib.GetUnifiedDiffString(difflib.UnifiedDiff{ A: difflib.SplitLines(schemaString(before)), B: difflib.SplitLines(schemaString(after)), FromFile: "Current", ToFile: "New", Context: 3, Eol: "\n", }) if err != nil ...
go
func schemaDiff(before, after bigquery.Schema) string { ret, err := difflib.GetUnifiedDiffString(difflib.UnifiedDiff{ A: difflib.SplitLines(schemaString(before)), B: difflib.SplitLines(schemaString(after)), FromFile: "Current", ToFile: "New", Context: 3, Eol: "\n", }) if err != nil ...
[ "func", "schemaDiff", "(", "before", ",", "after", "bigquery", ".", "Schema", ")", "string", "{", "ret", ",", "err", ":=", "difflib", ".", "GetUnifiedDiffString", "(", "difflib", ".", "UnifiedDiff", "{", "A", ":", "difflib", ".", "SplitLines", "(", "schema...
// schemaDiff returns unified diff of two schemas. // Returns "" if there is no difference.
[ "schemaDiff", "returns", "unified", "diff", "of", "two", "schemas", ".", "Returns", "if", "there", "is", "no", "difference", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/tools/cmd/bqschemaupdater/schema.go#L243-L259
129,678
luci/luci-go
tools/cmd/bqschemaupdater/schema.go
addMissingFields
func addMissingFields(dest *bigquery.Schema, src bigquery.Schema) { destFields := indexFields(*dest) for _, sf := range src { switch df := destFields[sf.Name]; { case df == nil: *dest = append(*dest, sf) default: addMissingFields(&df.Schema, sf.Schema) } } }
go
func addMissingFields(dest *bigquery.Schema, src bigquery.Schema) { destFields := indexFields(*dest) for _, sf := range src { switch df := destFields[sf.Name]; { case df == nil: *dest = append(*dest, sf) default: addMissingFields(&df.Schema, sf.Schema) } } }
[ "func", "addMissingFields", "(", "dest", "*", "bigquery", ".", "Schema", ",", "src", "bigquery", ".", "Schema", ")", "{", "destFields", ":=", "indexFields", "(", "*", "dest", ")", "\n", "for", "_", ",", "sf", ":=", "range", "src", "{", "switch", "df", ...
// addMissingFields copies fields from src to dest if they are not present in // dest.
[ "addMissingFields", "copies", "fields", "from", "src", "to", "dest", "if", "they", "are", "not", "present", "in", "dest", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/tools/cmd/bqschemaupdater/schema.go#L263-L273
129,679
luci/luci-go
logdog/client/cmd/logdog_butler/main.go
getOutputFactory
func (a *application) getOutputFactory() (outputFactory, error) { factory := a.outputConfig.getFactory() if factory == nil { return nil, errors.New("main: No output is configured") } return factory, nil }
go
func (a *application) getOutputFactory() (outputFactory, error) { factory := a.outputConfig.getFactory() if factory == nil { return nil, errors.New("main: No output is configured") } return factory, nil }
[ "func", "(", "a", "*", "application", ")", "getOutputFactory", "(", ")", "(", "outputFactory", ",", "error", ")", "{", "factory", ":=", "a", ".", "outputConfig", ".", "getFactory", "(", ")", "\n", "if", "factory", "==", "nil", "{", "return", "nil", ","...
// getOutputFactory returns the currently-configured output factory.
[ "getOutputFactory", "returns", "the", "currently", "-", "configured", "output", "factory", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/logdog/client/cmd/logdog_butler/main.go#L138-L144
129,680
luci/luci-go
logdog/client/cmd/logdog_butler/main.go
runWithButler
func (a *application) runWithButler(out output.Output, runFunc func(*butler.Butler) error) error { // Start our Profiler. a.prof.Logger = log.Get(a) if err := a.prof.Start(); err != nil { return fmt.Errorf("failed to start Profiler: %v", err) } defer a.prof.Stop() // Instantiate our Butler. butlerOpts := but...
go
func (a *application) runWithButler(out output.Output, runFunc func(*butler.Butler) error) error { // Start our Profiler. a.prof.Logger = log.Get(a) if err := a.prof.Start(); err != nil { return fmt.Errorf("failed to start Profiler: %v", err) } defer a.prof.Stop() // Instantiate our Butler. butlerOpts := but...
[ "func", "(", "a", "*", "application", ")", "runWithButler", "(", "out", "output", ".", "Output", ",", "runFunc", "func", "(", "*", "butler", ".", "Butler", ")", "error", ")", "error", "{", "// Start our Profiler.", "a", ".", "prof", ".", "Logger", "=", ...
// runWithButler is an execution harness that adds application-level management // to a Butler run.
[ "runWithButler", "is", "an", "execution", "harness", "that", "adds", "application", "-", "level", "management", "to", "a", "Butler", "run", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/logdog/client/cmd/logdog_butler/main.go#L148-L219
129,681
luci/luci-go
logdog/client/cmd/logdog_butler/main.go
logAnnotatedErr
func logAnnotatedErr(ctx context.Context, err error, f string, args ...interface{}) { if err == nil { return } nargs := make([]interface{}, len(args)+1) nargs[copy(nargs, args)] = strings.Join(errors.RenderStack(err), "\n") if f == "" { f = "Captured error stack:" } log.Errorf(ctx, f+"\n%s", nargs...) }
go
func logAnnotatedErr(ctx context.Context, err error, f string, args ...interface{}) { if err == nil { return } nargs := make([]interface{}, len(args)+1) nargs[copy(nargs, args)] = strings.Join(errors.RenderStack(err), "\n") if f == "" { f = "Captured error stack:" } log.Errorf(ctx, f+"\n%s", nargs...) }
[ "func", "logAnnotatedErr", "(", "ctx", "context", ".", "Context", ",", "err", "error", ",", "f", "string", ",", "args", "...", "interface", "{", "}", ")", "{", "if", "err", "==", "nil", "{", "return", "\n", "}", "\n\n", "nargs", ":=", "make", "(", ...
// logAnnotatedErr logs the full stack trace from an annotated error to the // installed logger at error level.
[ "logAnnotatedErr", "logs", "the", "full", "stack", "trace", "from", "an", "annotated", "error", "to", "the", "installed", "logger", "at", "error", "level", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/logdog/client/cmd/logdog_butler/main.go#L223-L235
129,682
luci/luci-go
logdog/client/cmd/logdog_butler/main.go
main
func main() { mathrand.SeedRandomly() ctx := context.Background() ctx = gologger.StdConfig.Use(ctx) // Exit with the specified return code. rc := 0 defer func() { log.Infof(log.SetField(ctx, "returnCode", rc), "Terminating.") os.Exit(rc) }() paniccatcher.Do(func() { rc = mainImpl(ctx, chromeinfra.Defau...
go
func main() { mathrand.SeedRandomly() ctx := context.Background() ctx = gologger.StdConfig.Use(ctx) // Exit with the specified return code. rc := 0 defer func() { log.Infof(log.SetField(ctx, "returnCode", rc), "Terminating.") os.Exit(rc) }() paniccatcher.Do(func() { rc = mainImpl(ctx, chromeinfra.Defau...
[ "func", "main", "(", ")", "{", "mathrand", ".", "SeedRandomly", "(", ")", "\n\n", "ctx", ":=", "context", ".", "Background", "(", ")", "\n", "ctx", "=", "gologger", ".", "StdConfig", ".", "Use", "(", "ctx", ")", "\n\n", "// Exit with the specified return c...
// Main execution function. This immediately jumps to 'mainImpl' and uses its // result as an exit code.
[ "Main", "execution", "function", ".", "This", "immediately", "jumps", "to", "mainImpl", "and", "uses", "its", "result", "as", "an", "exit", "code", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/logdog/client/cmd/logdog_butler/main.go#L347-L368
129,683
luci/luci-go
vpython/venv/iterator.go
ForEach
func (it *Iterator) ForEach(c context.Context, cfg *Config, cb func(context.Context, *Env) error) error { return iterDir(c, cfg.BaseDir, func(fileInfos []os.FileInfo) error { if it.Shuffle { for i := range fileInfos { j := mathrand.Intn(c, i+1) fileInfos[i], fileInfos[j] = fileInfos[j], fileInfos[i] } ...
go
func (it *Iterator) ForEach(c context.Context, cfg *Config, cb func(context.Context, *Env) error) error { return iterDir(c, cfg.BaseDir, func(fileInfos []os.FileInfo) error { if it.Shuffle { for i := range fileInfos { j := mathrand.Intn(c, i+1) fileInfos[i], fileInfos[j] = fileInfos[j], fileInfos[i] } ...
[ "func", "(", "it", "*", "Iterator", ")", "ForEach", "(", "c", "context", ".", "Context", ",", "cfg", "*", "Config", ",", "cb", "func", "(", "context", ".", "Context", ",", "*", "Env", ")", "error", ")", "error", "{", "return", "iterDir", "(", "c", ...
// ForEach iterates over all VirtualEnv installations for the supplied "cfg". // // "cb" will be invoked for each VirtualEnv, regardless of its completion // status. The callback may perform additional operations on the VirtualEnv to // determine its actual status. If the callback returns an error, iteration will // st...
[ "ForEach", "iterates", "over", "all", "VirtualEnv", "installations", "for", "the", "supplied", "cfg", ".", "cb", "will", "be", "invoked", "for", "each", "VirtualEnv", "regardless", "of", "its", "completion", "status", ".", "The", "callback", "may", "perform", ...
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/vpython/venv/iterator.go#L51-L81
129,684
luci/luci-go
dm/appengine/distributor/handlers.go
InstallHandlers
func InstallHandlers(r *router.Router, base router.MiddlewareChain) { r.POST(handlerPattern, base.Extend(gaemiddleware.RequireTaskQueue("")), TaskQueueHandler) r.POST("/_ah/push-handlers/"+notifyTopicSuffix, base, PubsubReceiver) }
go
func InstallHandlers(r *router.Router, base router.MiddlewareChain) { r.POST(handlerPattern, base.Extend(gaemiddleware.RequireTaskQueue("")), TaskQueueHandler) r.POST("/_ah/push-handlers/"+notifyTopicSuffix, base, PubsubReceiver) }
[ "func", "InstallHandlers", "(", "r", "*", "router", ".", "Router", ",", "base", "router", ".", "MiddlewareChain", ")", "{", "r", ".", "POST", "(", "handlerPattern", ",", "base", ".", "Extend", "(", "gaemiddleware", ".", "RequireTaskQueue", "(", "\"", "\"",...
// InstallHandlers installs the taskqueue callback handler. // // The `base` middleware must have a registry installed with WithRegistry.
[ "InstallHandlers", "installs", "the", "taskqueue", "callback", "handler", ".", "The", "base", "middleware", "must", "have", "a", "registry", "installed", "with", "WithRegistry", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/dm/appengine/distributor/handlers.go#L25-L28
129,685
luci/luci-go
vpython/python/interpreter.go
GetVersion
func (i *Interpreter) GetVersion(c context.Context) (v Version, err error) { i.cachedVersionMu.Lock() defer i.cachedVersionMu.Unlock() // Check again, under write-lock. if i.cachedVersion != nil { v = *i.cachedVersion return } cmd := i.IsolatedCommand(c, CommandTarget{ "import platform, sys; sys.stdout.wr...
go
func (i *Interpreter) GetVersion(c context.Context) (v Version, err error) { i.cachedVersionMu.Lock() defer i.cachedVersionMu.Unlock() // Check again, under write-lock. if i.cachedVersion != nil { v = *i.cachedVersion return } cmd := i.IsolatedCommand(c, CommandTarget{ "import platform, sys; sys.stdout.wr...
[ "func", "(", "i", "*", "Interpreter", ")", "GetVersion", "(", "c", "context", ".", "Context", ")", "(", "v", "Version", ",", "err", "error", ")", "{", "i", ".", "cachedVersionMu", ".", "Lock", "(", ")", "\n", "defer", "i", ".", "cachedVersionMu", "."...
// GetVersion runs the specified Python interpreter to extract its version // from `platform.python_version` and maps it to a known specification verison.
[ "GetVersion", "runs", "the", "specified", "Python", "interpreter", "to", "extract", "its", "version", "from", "platform", ".", "python_version", "and", "maps", "it", "to", "a", "known", "specification", "verison", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/vpython/python/interpreter.go#L73-L103
129,686
luci/luci-go
vpython/python/interpreter.go
IsolateEnvironment
func IsolateEnvironment(e *environ.Env, keepPythonPath bool) { if e == nil { return } // Remove PYTHONPATH if instructed. if !keepPythonPath { e.Remove("PYTHONPATH") } // Remove PYTHONHOME from the environment. PYTHONHOME is used to set the // location of standard Python libraries, which we make a point of...
go
func IsolateEnvironment(e *environ.Env, keepPythonPath bool) { if e == nil { return } // Remove PYTHONPATH if instructed. if !keepPythonPath { e.Remove("PYTHONPATH") } // Remove PYTHONHOME from the environment. PYTHONHOME is used to set the // location of standard Python libraries, which we make a point of...
[ "func", "IsolateEnvironment", "(", "e", "*", "environ", ".", "Env", ",", "keepPythonPath", "bool", ")", "{", "if", "e", "==", "nil", "{", "return", "\n", "}", "\n\n", "// Remove PYTHONPATH if instructed.", "if", "!", "keepPythonPath", "{", "e", ".", "Remove"...
// IsolateEnvironment mutates e to remove any environmental influence over // the Python interpreter. // // If keepPythonPath is true, PYTHONPATH will not be cleared. This is used // by the actual VirtualEnv Python invocation to preserve PYTHONPATH since it is // a form of user input. // // If e is nil, no operation wi...
[ "IsolateEnvironment", "mutates", "e", "to", "remove", "any", "environmental", "influence", "over", "the", "Python", "interpreter", ".", "If", "keepPythonPath", "is", "true", "PYTHONPATH", "will", "not", "be", "cleared", ".", "This", "is", "used", "by", "the", ...
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/vpython/python/interpreter.go#L113-L133
129,687
luci/luci-go
dm/appengine/model/fwddep.go
Edge
func (f *FwdDep) Edge() *FwdEdge { ret := &FwdEdge{To: &f.Dependee, From: &dm.Attempt_ID{}} if err := ret.From.SetDMEncoded(f.Depender.StringID()); err != nil { panic(err) } return ret }
go
func (f *FwdDep) Edge() *FwdEdge { ret := &FwdEdge{To: &f.Dependee, From: &dm.Attempt_ID{}} if err := ret.From.SetDMEncoded(f.Depender.StringID()); err != nil { panic(err) } return ret }
[ "func", "(", "f", "*", "FwdDep", ")", "Edge", "(", ")", "*", "FwdEdge", "{", "ret", ":=", "&", "FwdEdge", "{", "To", ":", "&", "f", ".", "Dependee", ",", "From", ":", "&", "dm", ".", "Attempt_ID", "{", "}", "}", "\n", "if", "err", ":=", "ret"...
// Edge produces a edge object which points 'forwards' from the depending // attempt to the depended-on attempt.
[ "Edge", "produces", "a", "edge", "object", "which", "points", "forwards", "from", "the", "depending", "attempt", "to", "the", "depended", "-", "on", "attempt", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/dm/appengine/model/fwddep.go#L57-L63
129,688
luci/luci-go
common/gcloud/pubsub/resource.go
resourceProjectName
func resourceProjectName(v string) (p, n string, err error) { parts := splitResource(v) if len(parts) != 4 { err = errors.New("malformed resource") return } p, n = parts[1], parts[3] return }
go
func resourceProjectName(v string) (p, n string, err error) { parts := splitResource(v) if len(parts) != 4 { err = errors.New("malformed resource") return } p, n = parts[1], parts[3] return }
[ "func", "resourceProjectName", "(", "v", "string", ")", "(", "p", ",", "n", "string", ",", "err", "error", ")", "{", "parts", ":=", "splitResource", "(", "v", ")", "\n", "if", "len", "(", "parts", ")", "!=", "4", "{", "err", "=", "errors", ".", "...
// resourceProjectName returns the resource's project and name components.
[ "resourceProjectName", "returns", "the", "resource", "s", "project", "and", "name", "components", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/common/gcloud/pubsub/resource.go#L33-L41
129,689
luci/luci-go
common/system/exitcode/exitcode.go
Get
func Get(err error) (int, bool) { err = errors.Unwrap(err) if err == nil { return 0, true } if ee, ok := err.(*exec.ExitError); ok { return ee.Sys().(syscall.WaitStatus).ExitStatus(), true } return 0, false }
go
func Get(err error) (int, bool) { err = errors.Unwrap(err) if err == nil { return 0, true } if ee, ok := err.(*exec.ExitError); ok { return ee.Sys().(syscall.WaitStatus).ExitStatus(), true } return 0, false }
[ "func", "Get", "(", "err", "error", ")", "(", "int", ",", "bool", ")", "{", "err", "=", "errors", ".", "Unwrap", "(", "err", ")", "\n", "if", "err", "==", "nil", "{", "return", "0", ",", "true", "\n", "}", "\n\n", "if", "ee", ",", "ok", ":=",...
// Get returns the process process exit return code given an error returned by // exec.Cmd's Wait or Run methods. If no exit code is present, Get will return // false.
[ "Get", "returns", "the", "process", "process", "exit", "return", "code", "given", "an", "error", "returned", "by", "exec", ".", "Cmd", "s", "Wait", "or", "Run", "methods", ".", "If", "no", "exit", "code", "is", "present", "Get", "will", "return", "false"...
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/common/system/exitcode/exitcode.go#L29-L39
129,690
luci/luci-go
cipd/client/cipd/template/template.go
ParsePlatform
func ParsePlatform(v string) (Platform, error) { parts := strings.Split(v, "-") if len(parts) != 2 { return Platform{}, errors.Reason("platform must be <os>-<arch>: %q", v).Err() } return Platform{parts[0], parts[1]}, nil }
go
func ParsePlatform(v string) (Platform, error) { parts := strings.Split(v, "-") if len(parts) != 2 { return Platform{}, errors.Reason("platform must be <os>-<arch>: %q", v).Err() } return Platform{parts[0], parts[1]}, nil }
[ "func", "ParsePlatform", "(", "v", "string", ")", "(", "Platform", ",", "error", ")", "{", "parts", ":=", "strings", ".", "Split", "(", "v", ",", "\"", "\"", ")", "\n", "if", "len", "(", "parts", ")", "!=", "2", "{", "return", "Platform", "{", "}...
// ParsePlatform parses a Platform from its string representation.
[ "ParsePlatform", "parses", "a", "Platform", "from", "its", "string", "representation", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/cipd/client/cipd/template/template.go#L133-L139
129,691
luci/luci-go
cipd/client/cipd/template/template.go
Expander
func (tp Platform) Expander() Expander { return Expander{ "os": tp.OS, "arch": tp.Arch, "platform": tp.String(), } }
go
func (tp Platform) Expander() Expander { return Expander{ "os": tp.OS, "arch": tp.Arch, "platform": tp.String(), } }
[ "func", "(", "tp", "Platform", ")", "Expander", "(", ")", "Expander", "{", "return", "Expander", "{", "\"", "\"", ":", "tp", ".", "OS", ",", "\"", "\"", ":", "tp", ".", "Arch", ",", "\"", "\"", ":", "tp", ".", "String", "(", ")", ",", "}", "\...
// Expander returns an Expander populated with tp's fields.
[ "Expander", "returns", "an", "Expander", "populated", "with", "tp", "s", "fields", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/cipd/client/cipd/template/template.go#L146-L152
129,692
luci/luci-go
common/system/prober/probe.go
ResolveSelf
func (p *Probe) ResolveSelf(argv0 string) error { if p.Self != "" { return nil } // Get the authoritative executable from the system. exec, err := os.Executable() if err != nil { return errors.Annotate(err, "failed to get executable").Err() } execStat, err := os.Stat(exec) if err != nil { return errors....
go
func (p *Probe) ResolveSelf(argv0 string) error { if p.Self != "" { return nil } // Get the authoritative executable from the system. exec, err := os.Executable() if err != nil { return errors.Annotate(err, "failed to get executable").Err() } execStat, err := os.Stat(exec) if err != nil { return errors....
[ "func", "(", "p", "*", "Probe", ")", "ResolveSelf", "(", "argv0", "string", ")", "error", "{", "if", "p", ".", "Self", "!=", "\"", "\"", "{", "return", "nil", "\n", "}", "\n\n", "// Get the authoritative executable from the system.", "exec", ",", "err", ":...
// ResolveSelf attempts to identify the current process. If successful, p's // Self will be set to an absolute path reference to Self, and its SelfStat // field will be set to the os.FileInfo for that path. // // If this process was invoked via symlink, the path to the symlink will be // returned if possible.
[ "ResolveSelf", "attempts", "to", "identify", "the", "current", "process", ".", "If", "successful", "p", "s", "Self", "will", "be", "set", "to", "an", "absolute", "path", "reference", "to", "Self", "and", "its", "SelfStat", "field", "will", "be", "set", "to...
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/common/system/prober/probe.go#L89-L118
129,693
luci/luci-go
common/system/prober/probe.go
Locate
func (p *Probe) Locate(c context.Context, cached string, env environ.Env) (string, error) { // If we have a cached path, check that it exists and is executable and use it // if it is. if cached != "" { switch cachedStat, err := os.Stat(cached); { case err == nil: // Use the cached path. First, pass it through...
go
func (p *Probe) Locate(c context.Context, cached string, env environ.Env) (string, error) { // If we have a cached path, check that it exists and is executable and use it // if it is. if cached != "" { switch cachedStat, err := os.Stat(cached); { case err == nil: // Use the cached path. First, pass it through...
[ "func", "(", "p", "*", "Probe", ")", "Locate", "(", "c", "context", ".", "Context", ",", "cached", "string", ",", "env", "environ", ".", "Env", ")", "(", "string", ",", "error", ")", "{", "// If we have a cached path, check that it exists and is executable and u...
// Locate attempts to locate the system's Target by traversing the available // PATH. // // cached is the cached path, passed from wrapper to wrapper through the a // State struct in the environment. This may be empty, if there was no cached // path or if the cached path was invalid. // // env is the environment to ope...
[ "Locate", "attempts", "to", "locate", "the", "system", "s", "Target", "by", "traversing", "the", "available", "PATH", ".", "cached", "is", "the", "cached", "path", "passed", "from", "wrapper", "to", "wrapper", "through", "the", "a", "State", "struct", "in", ...
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/common/system/prober/probe.go#L129-L199
129,694
luci/luci-go
common/system/prober/probe.go
checkDir
func (p *Probe) checkDir(c context.Context, dir string, selfDir os.FileInfo, env environ.Env) string { // If we have a self directory defined, ensure that "dir" isn't the same // directory. If it is, we will ignore this option, since we are looking for // something outside of the wrapper directory. if selfDir != ni...
go
func (p *Probe) checkDir(c context.Context, dir string, selfDir os.FileInfo, env environ.Env) string { // If we have a self directory defined, ensure that "dir" isn't the same // directory. If it is, we will ignore this option, since we are looking for // something outside of the wrapper directory. if selfDir != ni...
[ "func", "(", "p", "*", "Probe", ")", "checkDir", "(", "c", "context", ".", "Context", ",", "dir", "string", ",", "selfDir", "os", ".", "FileInfo", ",", "env", "environ", ".", "Env", ")", "string", "{", "// If we have a self directory defined, ensure that \"dir...
// checkDir checks "checkDir" for our Target executable. It ignores // executables whose target is the same file or shares the same parent directory // as "self".
[ "checkDir", "checks", "checkDir", "for", "our", "Target", "executable", ".", "It", "ignores", "executables", "whose", "target", "is", "the", "same", "file", "or", "shares", "the", "same", "parent", "directory", "as", "self", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/common/system/prober/probe.go#L204-L270
129,695
luci/luci-go
logdog/appengine/coordinator/flex/services.go
Base
func (gsvc *GlobalServices) Base(c *router.Context, next router.Handler) { services := flexServicesInst{ GlobalServices: gsvc, } c.Context = coordinator.WithConfigProvider(c.Context, &services) c.Context = WithServices(c.Context, &services) next(c) }
go
func (gsvc *GlobalServices) Base(c *router.Context, next router.Handler) { services := flexServicesInst{ GlobalServices: gsvc, } c.Context = coordinator.WithConfigProvider(c.Context, &services) c.Context = WithServices(c.Context, &services) next(c) }
[ "func", "(", "gsvc", "*", "GlobalServices", ")", "Base", "(", "c", "*", "router", ".", "Context", ",", "next", "router", ".", "Handler", ")", "{", "services", ":=", "flexServicesInst", "{", "GlobalServices", ":", "gsvc", ",", "}", "\n\n", "c", ".", "Co...
// Base is Middleware used by Coordinator Flex services. // // It installs a production Services instance into the Context.
[ "Base", "is", "Middleware", "used", "by", "Coordinator", "Flex", "services", ".", "It", "installs", "a", "production", "Services", "instance", "into", "the", "Context", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/logdog/appengine/coordinator/flex/services.go#L192-L200
129,696
luci/luci-go
config/set.go
RefSet
func RefSet(project string, ref string) Set { if ref == "" { return Set("projects/" + project) } return Set(strings.Join([]string{"projects", project, ref}, "/")) }
go
func RefSet(project string, ref string) Set { if ref == "" { return Set("projects/" + project) } return Set(strings.Join([]string{"projects", project, ref}, "/")) }
[ "func", "RefSet", "(", "project", "string", ",", "ref", "string", ")", "Set", "{", "if", "ref", "==", "\"", "\"", "{", "return", "Set", "(", "\"", "\"", "+", "project", ")", "\n", "}", "\n", "return", "Set", "(", "strings", ".", "Join", "(", "[",...
// RefSet returns the config set for the specified project and ref. If ref // is empty, this will equal the ProjectSet value.
[ "RefSet", "returns", "the", "config", "set", "for", "the", "specified", "project", "and", "ref", ".", "If", "ref", "is", "empty", "this", "will", "equal", "the", "ProjectSet", "value", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/config/set.go#L41-L46
129,697
luci/luci-go
config/set.go
Split
func (cs Set) Split() (domain, target, ref string) { switch p := strings.SplitN(string(cs), "/", 3); len(p) { case 1: return p[0], "", "" case 2: return p[0], p[1], "" default: return p[0], p[1], p[2] } }
go
func (cs Set) Split() (domain, target, ref string) { switch p := strings.SplitN(string(cs), "/", 3); len(p) { case 1: return p[0], "", "" case 2: return p[0], p[1], "" default: return p[0], p[1], p[2] } }
[ "func", "(", "cs", "Set", ")", "Split", "(", ")", "(", "domain", ",", "target", ",", "ref", "string", ")", "{", "switch", "p", ":=", "strings", ".", "SplitN", "(", "string", "(", "cs", ")", ",", "\"", "\"", ",", "3", ")", ";", "len", "(", "p"...
// Split splits a Set into its domain, target, and ref components.
[ "Split", "splits", "a", "Set", "into", "its", "domain", "target", "and", "ref", "components", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/config/set.go#L49-L58
129,698
luci/luci-go
config/set.go
Service
func (cs Set) Service() string { domain, target, _ := cs.Split() if domain == "services" { return target } return "" }
go
func (cs Set) Service() string { domain, target, _ := cs.Split() if domain == "services" { return target } return "" }
[ "func", "(", "cs", "Set", ")", "Service", "(", ")", "string", "{", "domain", ",", "target", ",", "_", ":=", "cs", ".", "Split", "(", ")", "\n", "if", "domain", "==", "\"", "\"", "{", "return", "target", "\n", "}", "\n", "return", "\"", "\"", "\...
// Service returns a service name for a service-rooted config set or empty // string for all other sets.
[ "Service", "returns", "a", "service", "name", "for", "a", "service", "-", "rooted", "config", "set", "or", "empty", "string", "for", "all", "other", "sets", "." ]
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/config/set.go#L62-L68
129,699
luci/luci-go
config/set.go
Project
func (cs Set) Project() string { domain, target, _ := cs.Split() if domain == "projects" { return target } return "" }
go
func (cs Set) Project() string { domain, target, _ := cs.Split() if domain == "projects" { return target } return "" }
[ "func", "(", "cs", "Set", ")", "Project", "(", ")", "string", "{", "domain", ",", "target", ",", "_", ":=", "cs", ".", "Split", "(", ")", "\n", "if", "domain", "==", "\"", "\"", "{", "return", "target", "\n", "}", "\n", "return", "\"", "\"", "\...
// Project returns a project name for a project-rooted config set or empty // string for all other sets. // // Use ProjectAndRef if you need to get both the project name and the ref.
[ "Project", "returns", "a", "project", "name", "for", "a", "project", "-", "rooted", "config", "set", "or", "empty", "string", "for", "all", "other", "sets", ".", "Use", "ProjectAndRef", "if", "you", "need", "to", "get", "both", "the", "project", "name", ...
f6cef429871eee3be7c6903af88d3ee884eaf683
https://github.com/luci/luci-go/blob/f6cef429871eee3be7c6903af88d3ee884eaf683/config/set.go#L74-L80