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