repo stringlengths 5 67 | path stringlengths 4 218 | func_name stringlengths 0 151 | original_string stringlengths 52 373k | language stringclasses 6
values | code stringlengths 52 373k | code_tokens listlengths 10 512 | docstring stringlengths 3 47.2k | docstring_tokens listlengths 3 234 | sha stringlengths 40 40 | url stringlengths 85 339 | partition stringclasses 3
values |
|---|---|---|---|---|---|---|---|---|---|---|---|
kubernetes/test-infra | prow/config/config.go | ValidateController | func ValidateController(c *Controller) error {
urlTmpl, err := template.New("JobURL").Parse(c.JobURLTemplateString)
if err != nil {
return fmt.Errorf("parsing template: %v", err)
}
c.JobURLTemplate = urlTmpl
reportTmpl, err := template.New("Report").Parse(c.ReportTemplateString)
if err != nil {
return fmt.Er... | go | func ValidateController(c *Controller) error {
urlTmpl, err := template.New("JobURL").Parse(c.JobURLTemplateString)
if err != nil {
return fmt.Errorf("parsing template: %v", err)
}
c.JobURLTemplate = urlTmpl
reportTmpl, err := template.New("Report").Parse(c.ReportTemplateString)
if err != nil {
return fmt.Er... | [
"func",
"ValidateController",
"(",
"c",
"*",
"Controller",
")",
"error",
"{",
"urlTmpl",
",",
"err",
":=",
"template",
".",
"New",
"(",
"\"JobURL\"",
")",
".",
"Parse",
"(",
"c",
".",
"JobURLTemplateString",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"r... | // ValidateController validates the provided controller config. | [
"ValidateController",
"validates",
"the",
"provided",
"controller",
"config",
"."
] | 8125fbda10178887be5dff9e901d6a0a519b67bc | https://github.com/kubernetes/test-infra/blob/8125fbda10178887be5dff9e901d6a0a519b67bc/prow/config/config.go#L1306-L1328 | test |
kubernetes/test-infra | prow/config/config.go | defaultJobBase | func (c *ProwConfig) defaultJobBase(base *JobBase) {
if base.Agent == "" { // Use kubernetes by default
base.Agent = string(prowapi.KubernetesAgent)
}
if base.Namespace == nil || *base.Namespace == "" {
s := c.PodNamespace
base.Namespace = &s
}
if base.Cluster == "" {
base.Cluster = kube.DefaultClusterAlia... | go | func (c *ProwConfig) defaultJobBase(base *JobBase) {
if base.Agent == "" { // Use kubernetes by default
base.Agent = string(prowapi.KubernetesAgent)
}
if base.Namespace == nil || *base.Namespace == "" {
s := c.PodNamespace
base.Namespace = &s
}
if base.Cluster == "" {
base.Cluster = kube.DefaultClusterAlia... | [
"func",
"(",
"c",
"*",
"ProwConfig",
")",
"defaultJobBase",
"(",
"base",
"*",
"JobBase",
")",
"{",
"if",
"base",
".",
"Agent",
"==",
"\"\"",
"{",
"base",
".",
"Agent",
"=",
"string",
"(",
"prowapi",
".",
"KubernetesAgent",
")",
"\n",
"}",
"\n",
"if",... | // defaultJobBase configures common parameters, currently Agent and Namespace. | [
"defaultJobBase",
"configures",
"common",
"parameters",
"currently",
"Agent",
"and",
"Namespace",
"."
] | 8125fbda10178887be5dff9e901d6a0a519b67bc | https://github.com/kubernetes/test-infra/blob/8125fbda10178887be5dff9e901d6a0a519b67bc/prow/config/config.go#L1343-L1354 | test |
kubernetes/test-infra | prow/config/config.go | SetPresubmitRegexes | func SetPresubmitRegexes(js []Presubmit) error {
for i, j := range js {
if re, err := regexp.Compile(j.Trigger); err == nil {
js[i].re = re
} else {
return fmt.Errorf("could not compile trigger regex for %s: %v", j.Name, err)
}
if !js[i].re.MatchString(j.RerunCommand) {
return fmt.Errorf("for job %s, ... | go | func SetPresubmitRegexes(js []Presubmit) error {
for i, j := range js {
if re, err := regexp.Compile(j.Trigger); err == nil {
js[i].re = re
} else {
return fmt.Errorf("could not compile trigger regex for %s: %v", j.Name, err)
}
if !js[i].re.MatchString(j.RerunCommand) {
return fmt.Errorf("for job %s, ... | [
"func",
"SetPresubmitRegexes",
"(",
"js",
"[",
"]",
"Presubmit",
")",
"error",
"{",
"for",
"i",
",",
"j",
":=",
"range",
"js",
"{",
"if",
"re",
",",
"err",
":=",
"regexp",
".",
"Compile",
"(",
"j",
".",
"Trigger",
")",
";",
"err",
"==",
"nil",
"{... | // SetPresubmitRegexes compiles and validates all the regular expressions for
// the provided presubmits. | [
"SetPresubmitRegexes",
"compiles",
"and",
"validates",
"all",
"the",
"regular",
"expressions",
"for",
"the",
"provided",
"presubmits",
"."
] | 8125fbda10178887be5dff9e901d6a0a519b67bc | https://github.com/kubernetes/test-infra/blob/8125fbda10178887be5dff9e901d6a0a519b67bc/prow/config/config.go#L1389-L1412 | test |
kubernetes/test-infra | prow/config/config.go | setBrancherRegexes | func setBrancherRegexes(br Brancher) (Brancher, error) {
if len(br.Branches) > 0 {
if re, err := regexp.Compile(strings.Join(br.Branches, `|`)); err == nil {
br.re = re
} else {
return br, fmt.Errorf("could not compile positive branch regex: %v", err)
}
}
if len(br.SkipBranches) > 0 {
if re, err := reg... | go | func setBrancherRegexes(br Brancher) (Brancher, error) {
if len(br.Branches) > 0 {
if re, err := regexp.Compile(strings.Join(br.Branches, `|`)); err == nil {
br.re = re
} else {
return br, fmt.Errorf("could not compile positive branch regex: %v", err)
}
}
if len(br.SkipBranches) > 0 {
if re, err := reg... | [
"func",
"setBrancherRegexes",
"(",
"br",
"Brancher",
")",
"(",
"Brancher",
",",
"error",
")",
"{",
"if",
"len",
"(",
"br",
".",
"Branches",
")",
">",
"0",
"{",
"if",
"re",
",",
"err",
":=",
"regexp",
".",
"Compile",
"(",
"strings",
".",
"Join",
"("... | // setBrancherRegexes compiles and validates all the regular expressions for
// the provided branch specifiers. | [
"setBrancherRegexes",
"compiles",
"and",
"validates",
"all",
"the",
"regular",
"expressions",
"for",
"the",
"provided",
"branch",
"specifiers",
"."
] | 8125fbda10178887be5dff9e901d6a0a519b67bc | https://github.com/kubernetes/test-infra/blob/8125fbda10178887be5dff9e901d6a0a519b67bc/prow/config/config.go#L1416-L1432 | test |
kubernetes/test-infra | prow/config/config.go | SetPostsubmitRegexes | func SetPostsubmitRegexes(ps []Postsubmit) error {
for i, j := range ps {
b, err := setBrancherRegexes(j.Brancher)
if err != nil {
return fmt.Errorf("could not set branch regexes for %s: %v", j.Name, err)
}
ps[i].Brancher = b
c, err := setChangeRegexes(j.RegexpChangeMatcher)
if err != nil {
return fm... | go | func SetPostsubmitRegexes(ps []Postsubmit) error {
for i, j := range ps {
b, err := setBrancherRegexes(j.Brancher)
if err != nil {
return fmt.Errorf("could not set branch regexes for %s: %v", j.Name, err)
}
ps[i].Brancher = b
c, err := setChangeRegexes(j.RegexpChangeMatcher)
if err != nil {
return fm... | [
"func",
"SetPostsubmitRegexes",
"(",
"ps",
"[",
"]",
"Postsubmit",
")",
"error",
"{",
"for",
"i",
",",
"j",
":=",
"range",
"ps",
"{",
"b",
",",
"err",
":=",
"setBrancherRegexes",
"(",
"j",
".",
"Brancher",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
... | // SetPostsubmitRegexes compiles and validates all the regular expressions for
// the provided postsubmits. | [
"SetPostsubmitRegexes",
"compiles",
"and",
"validates",
"all",
"the",
"regular",
"expressions",
"for",
"the",
"provided",
"postsubmits",
"."
] | 8125fbda10178887be5dff9e901d6a0a519b67bc | https://github.com/kubernetes/test-infra/blob/8125fbda10178887be5dff9e901d6a0a519b67bc/prow/config/config.go#L1447-L1461 | test |
kubernetes/test-infra | prow/spyglass/lenses/metadata/lens.go | Body | func (lens Lens) Body(artifacts []lenses.Artifact, resourceDir string, data string) string {
var buf bytes.Buffer
type MetadataViewData struct {
Status string
StartTime time.Time
FinishedTime time.Time
Elapsed time.Duration
Metadata map[string]string
}
metadataViewData := MetadataViewDat... | go | func (lens Lens) Body(artifacts []lenses.Artifact, resourceDir string, data string) string {
var buf bytes.Buffer
type MetadataViewData struct {
Status string
StartTime time.Time
FinishedTime time.Time
Elapsed time.Duration
Metadata map[string]string
}
metadataViewData := MetadataViewDat... | [
"func",
"(",
"lens",
"Lens",
")",
"Body",
"(",
"artifacts",
"[",
"]",
"lenses",
".",
"Artifact",
",",
"resourceDir",
"string",
",",
"data",
"string",
")",
"string",
"{",
"var",
"buf",
"bytes",
".",
"Buffer",
"\n",
"type",
"MetadataViewData",
"struct",
"{... | // Body creates a view for prow job metadata. | [
"Body",
"creates",
"a",
"view",
"for",
"prow",
"job",
"metadata",
"."
] | 8125fbda10178887be5dff9e901d6a0a519b67bc | https://github.com/kubernetes/test-infra/blob/8125fbda10178887be5dff9e901d6a0a519b67bc/prow/spyglass/lenses/metadata/lens.go#L77-L140 | test |
kubernetes/test-infra | boskos/boskos.go | NewBoskosHandler | func NewBoskosHandler(r *ranch.Ranch) *http.ServeMux {
mux := http.NewServeMux()
mux.Handle("/", handleDefault(r))
mux.Handle("/acquire", handleAcquire(r))
mux.Handle("/acquirebystate", handleAcquireByState(r))
mux.Handle("/release", handleRelease(r))
mux.Handle("/reset", handleReset(r))
mux.Handle("/update", ha... | go | func NewBoskosHandler(r *ranch.Ranch) *http.ServeMux {
mux := http.NewServeMux()
mux.Handle("/", handleDefault(r))
mux.Handle("/acquire", handleAcquire(r))
mux.Handle("/acquirebystate", handleAcquireByState(r))
mux.Handle("/release", handleRelease(r))
mux.Handle("/reset", handleReset(r))
mux.Handle("/update", ha... | [
"func",
"NewBoskosHandler",
"(",
"r",
"*",
"ranch",
".",
"Ranch",
")",
"*",
"http",
".",
"ServeMux",
"{",
"mux",
":=",
"http",
".",
"NewServeMux",
"(",
")",
"\n",
"mux",
".",
"Handle",
"(",
"\"/\"",
",",
"handleDefault",
"(",
"r",
")",
")",
"\n",
"... | //NewBoskosHandler constructs the boskos handler. | [
"NewBoskosHandler",
"constructs",
"the",
"boskos",
"handler",
"."
] | 8125fbda10178887be5dff9e901d6a0a519b67bc | https://github.com/kubernetes/test-infra/blob/8125fbda10178887be5dff9e901d6a0a519b67bc/boskos/boskos.go#L88-L98 | test |
kubernetes/test-infra | boskos/boskos.go | ErrorToStatus | func ErrorToStatus(err error) int {
switch err.(type) {
default:
return http.StatusInternalServerError
case *ranch.OwnerNotMatch:
return http.StatusUnauthorized
case *ranch.ResourceNotFound:
return http.StatusNotFound
case *ranch.ResourceTypeNotFound:
return http.StatusNotFound
case *ranch.StateNotMatch:
... | go | func ErrorToStatus(err error) int {
switch err.(type) {
default:
return http.StatusInternalServerError
case *ranch.OwnerNotMatch:
return http.StatusUnauthorized
case *ranch.ResourceNotFound:
return http.StatusNotFound
case *ranch.ResourceTypeNotFound:
return http.StatusNotFound
case *ranch.StateNotMatch:
... | [
"func",
"ErrorToStatus",
"(",
"err",
"error",
")",
"int",
"{",
"switch",
"err",
".",
"(",
"type",
")",
"{",
"default",
":",
"return",
"http",
".",
"StatusInternalServerError",
"\n",
"case",
"*",
"ranch",
".",
"OwnerNotMatch",
":",
"return",
"http",
".",
... | // ErrorToStatus translates error into http code | [
"ErrorToStatus",
"translates",
"error",
"into",
"http",
"code"
] | 8125fbda10178887be5dff9e901d6a0a519b67bc | https://github.com/kubernetes/test-infra/blob/8125fbda10178887be5dff9e901d6a0a519b67bc/boskos/boskos.go#L101-L114 | test |
kubernetes/test-infra | gopherage/pkg/util/util.go | DumpProfile | func DumpProfile(destination string, profile []*cover.Profile) error {
var output io.Writer
if destination == "-" {
output = os.Stdout
} else {
f, err := os.Create(destination)
if err != nil {
return fmt.Errorf("failed to open %s: %v", destination, err)
}
defer f.Close()
output = f
}
err := cov.Dump... | go | func DumpProfile(destination string, profile []*cover.Profile) error {
var output io.Writer
if destination == "-" {
output = os.Stdout
} else {
f, err := os.Create(destination)
if err != nil {
return fmt.Errorf("failed to open %s: %v", destination, err)
}
defer f.Close()
output = f
}
err := cov.Dump... | [
"func",
"DumpProfile",
"(",
"destination",
"string",
",",
"profile",
"[",
"]",
"*",
"cover",
".",
"Profile",
")",
"error",
"{",
"var",
"output",
"io",
".",
"Writer",
"\n",
"if",
"destination",
"==",
"\"-\"",
"{",
"output",
"=",
"os",
".",
"Stdout",
"\n... | // DumpProfile dumps the profile to the given file destination.
// If the destination is "-", it instead writes to stdout. | [
"DumpProfile",
"dumps",
"the",
"profile",
"to",
"the",
"given",
"file",
"destination",
".",
"If",
"the",
"destination",
"is",
"-",
"it",
"instead",
"writes",
"to",
"stdout",
"."
] | 8125fbda10178887be5dff9e901d6a0a519b67bc | https://github.com/kubernetes/test-infra/blob/8125fbda10178887be5dff9e901d6a0a519b67bc/gopherage/pkg/util/util.go#L30-L47 | test |
kubernetes/test-infra | gopherage/pkg/util/util.go | LoadProfile | func LoadProfile(origin string) ([]*cover.Profile, error) {
filename := origin
if origin == "-" {
// Annoyingly, ParseProfiles only accepts a filename, so we have to write the bytes to disk
// so it can read them back.
// We could probably also just give it /dev/stdin, but that'll break on Windows.
tf, err :=... | go | func LoadProfile(origin string) ([]*cover.Profile, error) {
filename := origin
if origin == "-" {
// Annoyingly, ParseProfiles only accepts a filename, so we have to write the bytes to disk
// so it can read them back.
// We could probably also just give it /dev/stdin, but that'll break on Windows.
tf, err :=... | [
"func",
"LoadProfile",
"(",
"origin",
"string",
")",
"(",
"[",
"]",
"*",
"cover",
".",
"Profile",
",",
"error",
")",
"{",
"filename",
":=",
"origin",
"\n",
"if",
"origin",
"==",
"\"-\"",
"{",
"tf",
",",
"err",
":=",
"ioutil",
".",
"TempFile",
"(",
... | // LoadProfile loads a profile from the given filename.
// If the filename is "-", it instead reads from stdin. | [
"LoadProfile",
"loads",
"a",
"profile",
"from",
"the",
"given",
"filename",
".",
"If",
"the",
"filename",
"is",
"-",
"it",
"instead",
"reads",
"from",
"stdin",
"."
] | 8125fbda10178887be5dff9e901d6a0a519b67bc | https://github.com/kubernetes/test-infra/blob/8125fbda10178887be5dff9e901d6a0a519b67bc/gopherage/pkg/util/util.go#L51-L69 | test |
kubernetes/test-infra | prow/git/git.go | NewClient | func NewClient() (*Client, error) {
g, err := exec.LookPath("git")
if err != nil {
return nil, err
}
t, err := ioutil.TempDir("", "git")
if err != nil {
return nil, err
}
return &Client{
logger: logrus.WithField("client", "git"),
dir: t,
git: g,
base: fmt.Sprintf("https://%s", git... | go | func NewClient() (*Client, error) {
g, err := exec.LookPath("git")
if err != nil {
return nil, err
}
t, err := ioutil.TempDir("", "git")
if err != nil {
return nil, err
}
return &Client{
logger: logrus.WithField("client", "git"),
dir: t,
git: g,
base: fmt.Sprintf("https://%s", git... | [
"func",
"NewClient",
"(",
")",
"(",
"*",
"Client",
",",
"error",
")",
"{",
"g",
",",
"err",
":=",
"exec",
".",
"LookPath",
"(",
"\"git\"",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n",
"t",
",",
"err",
... | // NewClient returns a client that talks to GitHub. It will fail if git is not
// in the PATH. | [
"NewClient",
"returns",
"a",
"client",
"that",
"talks",
"to",
"GitHub",
".",
"It",
"will",
"fail",
"if",
"git",
"is",
"not",
"in",
"the",
"PATH",
"."
] | 8125fbda10178887be5dff9e901d6a0a519b67bc | https://github.com/kubernetes/test-infra/blob/8125fbda10178887be5dff9e901d6a0a519b67bc/prow/git/git.go#L74-L90 | test |
kubernetes/test-infra | prow/git/git.go | SetCredentials | func (c *Client) SetCredentials(user string, tokenGenerator func() []byte) {
c.credLock.Lock()
defer c.credLock.Unlock()
c.user = user
c.tokenGenerator = tokenGenerator
} | go | func (c *Client) SetCredentials(user string, tokenGenerator func() []byte) {
c.credLock.Lock()
defer c.credLock.Unlock()
c.user = user
c.tokenGenerator = tokenGenerator
} | [
"func",
"(",
"c",
"*",
"Client",
")",
"SetCredentials",
"(",
"user",
"string",
",",
"tokenGenerator",
"func",
"(",
")",
"[",
"]",
"byte",
")",
"{",
"c",
".",
"credLock",
".",
"Lock",
"(",
")",
"\n",
"defer",
"c",
".",
"credLock",
".",
"Unlock",
"("... | // SetCredentials sets credentials in the client to be used for pushing to
// or pulling from remote repositories. | [
"SetCredentials",
"sets",
"credentials",
"in",
"the",
"client",
"to",
"be",
"used",
"for",
"pushing",
"to",
"or",
"pulling",
"from",
"remote",
"repositories",
"."
] | 8125fbda10178887be5dff9e901d6a0a519b67bc | https://github.com/kubernetes/test-infra/blob/8125fbda10178887be5dff9e901d6a0a519b67bc/prow/git/git.go#L101-L106 | test |
kubernetes/test-infra | prow/git/git.go | Checkout | func (r *Repo) Checkout(commitlike string) error {
r.logger.Infof("Checkout %s.", commitlike)
co := r.gitCommand("checkout", commitlike)
if b, err := co.CombinedOutput(); err != nil {
return fmt.Errorf("error checking out %s: %v. output: %s", commitlike, err, string(b))
}
return nil
} | go | func (r *Repo) Checkout(commitlike string) error {
r.logger.Infof("Checkout %s.", commitlike)
co := r.gitCommand("checkout", commitlike)
if b, err := co.CombinedOutput(); err != nil {
return fmt.Errorf("error checking out %s: %v. output: %s", commitlike, err, string(b))
}
return nil
} | [
"func",
"(",
"r",
"*",
"Repo",
")",
"Checkout",
"(",
"commitlike",
"string",
")",
"error",
"{",
"r",
".",
"logger",
".",
"Infof",
"(",
"\"Checkout %s.\"",
",",
"commitlike",
")",
"\n",
"co",
":=",
"r",
".",
"gitCommand",
"(",
"\"checkout\"",
",",
"comm... | // Checkout runs git checkout. | [
"Checkout",
"runs",
"git",
"checkout",
"."
] | 8125fbda10178887be5dff9e901d6a0a519b67bc | https://github.com/kubernetes/test-infra/blob/8125fbda10178887be5dff9e901d6a0a519b67bc/prow/git/git.go#L215-L222 | test |
kubernetes/test-infra | prow/git/git.go | CheckoutNewBranch | func (r *Repo) CheckoutNewBranch(branch string) error {
r.logger.Infof("Create and checkout %s.", branch)
co := r.gitCommand("checkout", "-b", branch)
if b, err := co.CombinedOutput(); err != nil {
return fmt.Errorf("error checking out %s: %v. output: %s", branch, err, string(b))
}
return nil
} | go | func (r *Repo) CheckoutNewBranch(branch string) error {
r.logger.Infof("Create and checkout %s.", branch)
co := r.gitCommand("checkout", "-b", branch)
if b, err := co.CombinedOutput(); err != nil {
return fmt.Errorf("error checking out %s: %v. output: %s", branch, err, string(b))
}
return nil
} | [
"func",
"(",
"r",
"*",
"Repo",
")",
"CheckoutNewBranch",
"(",
"branch",
"string",
")",
"error",
"{",
"r",
".",
"logger",
".",
"Infof",
"(",
"\"Create and checkout %s.\"",
",",
"branch",
")",
"\n",
"co",
":=",
"r",
".",
"gitCommand",
"(",
"\"checkout\"",
... | // CheckoutNewBranch creates a new branch and checks it out. | [
"CheckoutNewBranch",
"creates",
"a",
"new",
"branch",
"and",
"checks",
"it",
"out",
"."
] | 8125fbda10178887be5dff9e901d6a0a519b67bc | https://github.com/kubernetes/test-infra/blob/8125fbda10178887be5dff9e901d6a0a519b67bc/prow/git/git.go#L235-L242 | test |
kubernetes/test-infra | prow/git/git.go | Merge | func (r *Repo) Merge(commitlike string) (bool, error) {
r.logger.Infof("Merging %s.", commitlike)
co := r.gitCommand("merge", "--no-ff", "--no-stat", "-m merge", commitlike)
b, err := co.CombinedOutput()
if err == nil {
return true, nil
}
r.logger.WithError(err).Infof("Merge failed with output: %s", string(b))... | go | func (r *Repo) Merge(commitlike string) (bool, error) {
r.logger.Infof("Merging %s.", commitlike)
co := r.gitCommand("merge", "--no-ff", "--no-stat", "-m merge", commitlike)
b, err := co.CombinedOutput()
if err == nil {
return true, nil
}
r.logger.WithError(err).Infof("Merge failed with output: %s", string(b))... | [
"func",
"(",
"r",
"*",
"Repo",
")",
"Merge",
"(",
"commitlike",
"string",
")",
"(",
"bool",
",",
"error",
")",
"{",
"r",
".",
"logger",
".",
"Infof",
"(",
"\"Merging %s.\"",
",",
"commitlike",
")",
"\n",
"co",
":=",
"r",
".",
"gitCommand",
"(",
"\"... | // Merge attempts to merge commitlike into the current branch. It returns true
// if the merge completes. It returns an error if the abort fails. | [
"Merge",
"attempts",
"to",
"merge",
"commitlike",
"into",
"the",
"current",
"branch",
".",
"It",
"returns",
"true",
"if",
"the",
"merge",
"completes",
".",
"It",
"returns",
"an",
"error",
"if",
"the",
"abort",
"fails",
"."
] | 8125fbda10178887be5dff9e901d6a0a519b67bc | https://github.com/kubernetes/test-infra/blob/8125fbda10178887be5dff9e901d6a0a519b67bc/prow/git/git.go#L246-L261 | test |
kubernetes/test-infra | prow/git/git.go | CheckoutPullRequest | func (r *Repo) CheckoutPullRequest(number int) error {
r.logger.Infof("Fetching and checking out %s#%d.", r.repo, number)
if b, err := retryCmd(r.logger, r.Dir, r.git, "fetch", r.base+"/"+r.repo, fmt.Sprintf("pull/%d/head:pull%d", number, number)); err != nil {
return fmt.Errorf("git fetch failed for PR %d: %v. out... | go | func (r *Repo) CheckoutPullRequest(number int) error {
r.logger.Infof("Fetching and checking out %s#%d.", r.repo, number)
if b, err := retryCmd(r.logger, r.Dir, r.git, "fetch", r.base+"/"+r.repo, fmt.Sprintf("pull/%d/head:pull%d", number, number)); err != nil {
return fmt.Errorf("git fetch failed for PR %d: %v. out... | [
"func",
"(",
"r",
"*",
"Repo",
")",
"CheckoutPullRequest",
"(",
"number",
"int",
")",
"error",
"{",
"r",
".",
"logger",
".",
"Infof",
"(",
"\"Fetching and checking out %s#%d.\"",
",",
"r",
".",
"repo",
",",
"number",
")",
"\n",
"if",
"b",
",",
"err",
"... | // CheckoutPullRequest does exactly that. | [
"CheckoutPullRequest",
"does",
"exactly",
"that",
"."
] | 8125fbda10178887be5dff9e901d6a0a519b67bc | https://github.com/kubernetes/test-infra/blob/8125fbda10178887be5dff9e901d6a0a519b67bc/prow/git/git.go#L300-L310 | test |
kubernetes/test-infra | prow/git/git.go | Config | func (r *Repo) Config(key, value string) error {
r.logger.Infof("Running git config %s %s", key, value)
if b, err := r.gitCommand("config", key, value).CombinedOutput(); err != nil {
return fmt.Errorf("git config %s %s failed: %v. output: %s", key, value, err, string(b))
}
return nil
} | go | func (r *Repo) Config(key, value string) error {
r.logger.Infof("Running git config %s %s", key, value)
if b, err := r.gitCommand("config", key, value).CombinedOutput(); err != nil {
return fmt.Errorf("git config %s %s failed: %v. output: %s", key, value, err, string(b))
}
return nil
} | [
"func",
"(",
"r",
"*",
"Repo",
")",
"Config",
"(",
"key",
",",
"value",
"string",
")",
"error",
"{",
"r",
".",
"logger",
".",
"Infof",
"(",
"\"Running git config %s %s\"",
",",
"key",
",",
"value",
")",
"\n",
"if",
"b",
",",
"err",
":=",
"r",
".",
... | // Config runs git config. | [
"Config",
"runs",
"git",
"config",
"."
] | 8125fbda10178887be5dff9e901d6a0a519b67bc | https://github.com/kubernetes/test-infra/blob/8125fbda10178887be5dff9e901d6a0a519b67bc/prow/git/git.go#L313-L319 | test |
kubernetes/test-infra | prow/git/git.go | retryCmd | func retryCmd(l *logrus.Entry, dir, cmd string, arg ...string) ([]byte, error) {
var b []byte
var err error
sleepyTime := time.Second
for i := 0; i < 3; i++ {
c := exec.Command(cmd, arg...)
c.Dir = dir
b, err = c.CombinedOutput()
if err != nil {
l.Warningf("Running %s %v returned error %v with output %s.... | go | func retryCmd(l *logrus.Entry, dir, cmd string, arg ...string) ([]byte, error) {
var b []byte
var err error
sleepyTime := time.Second
for i := 0; i < 3; i++ {
c := exec.Command(cmd, arg...)
c.Dir = dir
b, err = c.CombinedOutput()
if err != nil {
l.Warningf("Running %s %v returned error %v with output %s.... | [
"func",
"retryCmd",
"(",
"l",
"*",
"logrus",
".",
"Entry",
",",
"dir",
",",
"cmd",
"string",
",",
"arg",
"...",
"string",
")",
"(",
"[",
"]",
"byte",
",",
"error",
")",
"{",
"var",
"b",
"[",
"]",
"byte",
"\n",
"var",
"err",
"error",
"\n",
"slee... | // retryCmd will retry the command a few times with backoff. Use this for any
// commands that will be talking to GitHub, such as clones or fetches. | [
"retryCmd",
"will",
"retry",
"the",
"command",
"a",
"few",
"times",
"with",
"backoff",
".",
"Use",
"this",
"for",
"any",
"commands",
"that",
"will",
"be",
"talking",
"to",
"GitHub",
"such",
"as",
"clones",
"or",
"fetches",
"."
] | 8125fbda10178887be5dff9e901d6a0a519b67bc | https://github.com/kubernetes/test-infra/blob/8125fbda10178887be5dff9e901d6a0a519b67bc/prow/git/git.go#L323-L340 | test |
kubernetes/test-infra | prow/pod-utils/decorate/podspec.go | LabelsAndAnnotationsForSpec | func LabelsAndAnnotationsForSpec(spec prowapi.ProwJobSpec, extraLabels, extraAnnotations map[string]string) (map[string]string, map[string]string) {
jobNameForLabel := spec.Job
if len(jobNameForLabel) > validation.LabelValueMaxLength {
// TODO(fejta): consider truncating middle rather than end.
jobNameForLabel = ... | go | func LabelsAndAnnotationsForSpec(spec prowapi.ProwJobSpec, extraLabels, extraAnnotations map[string]string) (map[string]string, map[string]string) {
jobNameForLabel := spec.Job
if len(jobNameForLabel) > validation.LabelValueMaxLength {
// TODO(fejta): consider truncating middle rather than end.
jobNameForLabel = ... | [
"func",
"LabelsAndAnnotationsForSpec",
"(",
"spec",
"prowapi",
".",
"ProwJobSpec",
",",
"extraLabels",
",",
"extraAnnotations",
"map",
"[",
"string",
"]",
"string",
")",
"(",
"map",
"[",
"string",
"]",
"string",
",",
"map",
"[",
"string",
"]",
"string",
")",... | // LabelsAndAnnotationsForSpec returns a minimal set of labels to add to prowjobs or its owned resources.
//
// User-provided extraLabels and extraAnnotations values will take precedence over auto-provided values. | [
"LabelsAndAnnotationsForSpec",
"returns",
"a",
"minimal",
"set",
"of",
"labels",
"to",
"add",
"to",
"prowjobs",
"or",
"its",
"owned",
"resources",
".",
"User",
"-",
"provided",
"extraLabels",
"and",
"extraAnnotations",
"values",
"will",
"take",
"precedence",
"over... | 8125fbda10178887be5dff9e901d6a0a519b67bc | https://github.com/kubernetes/test-infra/blob/8125fbda10178887be5dff9e901d6a0a519b67bc/prow/pod-utils/decorate/podspec.go#L77-L132 | test |
kubernetes/test-infra | prow/pod-utils/decorate/podspec.go | ProwJobToPod | func ProwJobToPod(pj prowapi.ProwJob, buildID string) (*coreapi.Pod, error) {
if pj.Spec.PodSpec == nil {
return nil, fmt.Errorf("prowjob %q lacks a pod spec", pj.Name)
}
rawEnv, err := downwardapi.EnvForSpec(downwardapi.NewJobSpec(pj.Spec, buildID, pj.Name))
if err != nil {
return nil, err
}
spec := pj.Spe... | go | func ProwJobToPod(pj prowapi.ProwJob, buildID string) (*coreapi.Pod, error) {
if pj.Spec.PodSpec == nil {
return nil, fmt.Errorf("prowjob %q lacks a pod spec", pj.Name)
}
rawEnv, err := downwardapi.EnvForSpec(downwardapi.NewJobSpec(pj.Spec, buildID, pj.Name))
if err != nil {
return nil, err
}
spec := pj.Spe... | [
"func",
"ProwJobToPod",
"(",
"pj",
"prowapi",
".",
"ProwJob",
",",
"buildID",
"string",
")",
"(",
"*",
"coreapi",
".",
"Pod",
",",
"error",
")",
"{",
"if",
"pj",
".",
"Spec",
".",
"PodSpec",
"==",
"nil",
"{",
"return",
"nil",
",",
"fmt",
".",
"Erro... | // ProwJobToPod converts a ProwJob to a Pod that will run the tests. | [
"ProwJobToPod",
"converts",
"a",
"ProwJob",
"to",
"a",
"Pod",
"that",
"will",
"run",
"the",
"tests",
"."
] | 8125fbda10178887be5dff9e901d6a0a519b67bc | https://github.com/kubernetes/test-infra/blob/8125fbda10178887be5dff9e901d6a0a519b67bc/prow/pod-utils/decorate/podspec.go#L145-L185 | test |
kubernetes/test-infra | prow/pod-utils/decorate/podspec.go | CloneLogPath | func CloneLogPath(logMount coreapi.VolumeMount) string {
return filepath.Join(logMount.MountPath, cloneLogPath)
} | go | func CloneLogPath(logMount coreapi.VolumeMount) string {
return filepath.Join(logMount.MountPath, cloneLogPath)
} | [
"func",
"CloneLogPath",
"(",
"logMount",
"coreapi",
".",
"VolumeMount",
")",
"string",
"{",
"return",
"filepath",
".",
"Join",
"(",
"logMount",
".",
"MountPath",
",",
"cloneLogPath",
")",
"\n",
"}"
] | // CloneLogPath returns the path to the clone log file in the volume mount.
// CloneLogPath returns the path to the clone log file in the volume mount. | [
"CloneLogPath",
"returns",
"the",
"path",
"to",
"the",
"clone",
"log",
"file",
"in",
"the",
"volume",
"mount",
".",
"CloneLogPath",
"returns",
"the",
"path",
"to",
"the",
"clone",
"log",
"file",
"in",
"the",
"volume",
"mount",
"."
] | 8125fbda10178887be5dff9e901d6a0a519b67bc | https://github.com/kubernetes/test-infra/blob/8125fbda10178887be5dff9e901d6a0a519b67bc/prow/pod-utils/decorate/podspec.go#L191-L193 | test |
kubernetes/test-infra | prow/pod-utils/decorate/podspec.go | cloneEnv | func cloneEnv(opt clonerefs.Options) ([]coreapi.EnvVar, error) {
// TODO(fejta): use flags
cloneConfigEnv, err := clonerefs.Encode(opt)
if err != nil {
return nil, err
}
return kubeEnv(map[string]string{clonerefs.JSONConfigEnvVar: cloneConfigEnv}), nil
} | go | func cloneEnv(opt clonerefs.Options) ([]coreapi.EnvVar, error) {
// TODO(fejta): use flags
cloneConfigEnv, err := clonerefs.Encode(opt)
if err != nil {
return nil, err
}
return kubeEnv(map[string]string{clonerefs.JSONConfigEnvVar: cloneConfigEnv}), nil
} | [
"func",
"cloneEnv",
"(",
"opt",
"clonerefs",
".",
"Options",
")",
"(",
"[",
"]",
"coreapi",
".",
"EnvVar",
",",
"error",
")",
"{",
"cloneConfigEnv",
",",
"err",
":=",
"clonerefs",
".",
"Encode",
"(",
"opt",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
... | // cloneEnv encodes clonerefs Options into json and puts it into an environment variable | [
"cloneEnv",
"encodes",
"clonerefs",
"Options",
"into",
"json",
"and",
"puts",
"it",
"into",
"an",
"environment",
"variable"
] | 8125fbda10178887be5dff9e901d6a0a519b67bc | https://github.com/kubernetes/test-infra/blob/8125fbda10178887be5dff9e901d6a0a519b67bc/prow/pod-utils/decorate/podspec.go#L202-L209 | test |
kubernetes/test-infra | prow/pod-utils/decorate/podspec.go | sshVolume | func sshVolume(secret string) (coreapi.Volume, coreapi.VolumeMount) {
var sshKeyMode int32 = 0400 // this is octal, so symbolic ref is `u+r`
name := strings.Join([]string{"ssh-keys", secret}, "-")
mountPath := path.Join("/secrets/ssh", secret)
v := coreapi.Volume{
Name: name,
VolumeSource: coreapi.VolumeSource{... | go | func sshVolume(secret string) (coreapi.Volume, coreapi.VolumeMount) {
var sshKeyMode int32 = 0400 // this is octal, so symbolic ref is `u+r`
name := strings.Join([]string{"ssh-keys", secret}, "-")
mountPath := path.Join("/secrets/ssh", secret)
v := coreapi.Volume{
Name: name,
VolumeSource: coreapi.VolumeSource{... | [
"func",
"sshVolume",
"(",
"secret",
"string",
")",
"(",
"coreapi",
".",
"Volume",
",",
"coreapi",
".",
"VolumeMount",
")",
"{",
"var",
"sshKeyMode",
"int32",
"=",
"0400",
"\n",
"name",
":=",
"strings",
".",
"Join",
"(",
"[",
"]",
"string",
"{",
"\"ssh-... | // sshVolume converts a secret holding ssh keys into the corresponding volume and mount.
//
// This is used by CloneRefs to attach the mount to the clonerefs container. | [
"sshVolume",
"converts",
"a",
"secret",
"holding",
"ssh",
"keys",
"into",
"the",
"corresponding",
"volume",
"and",
"mount",
".",
"This",
"is",
"used",
"by",
"CloneRefs",
"to",
"attach",
"the",
"mount",
"to",
"the",
"clonerefs",
"container",
"."
] | 8125fbda10178887be5dff9e901d6a0a519b67bc | https://github.com/kubernetes/test-infra/blob/8125fbda10178887be5dff9e901d6a0a519b67bc/prow/pod-utils/decorate/podspec.go#L214-L235 | test |
kubernetes/test-infra | prow/pod-utils/decorate/podspec.go | InjectEntrypoint | func InjectEntrypoint(c *coreapi.Container, timeout, gracePeriod time.Duration, prefix, previousMarker string, exitZero bool, log, tools coreapi.VolumeMount) (*wrapper.Options, error) {
wrapperOptions := &wrapper.Options{
Args: append(c.Command, c.Args...),
ProcessLog: processLog(log, prefix),
MarkerFi... | go | func InjectEntrypoint(c *coreapi.Container, timeout, gracePeriod time.Duration, prefix, previousMarker string, exitZero bool, log, tools coreapi.VolumeMount) (*wrapper.Options, error) {
wrapperOptions := &wrapper.Options{
Args: append(c.Command, c.Args...),
ProcessLog: processLog(log, prefix),
MarkerFi... | [
"func",
"InjectEntrypoint",
"(",
"c",
"*",
"coreapi",
".",
"Container",
",",
"timeout",
",",
"gracePeriod",
"time",
".",
"Duration",
",",
"prefix",
",",
"previousMarker",
"string",
",",
"exitZero",
"bool",
",",
"log",
",",
"tools",
"coreapi",
".",
"VolumeMou... | // InjectEntrypoint will make the entrypoint binary in the tools volume the container's entrypoint, which will output to the log volume. | [
"InjectEntrypoint",
"will",
"make",
"the",
"entrypoint",
"binary",
"in",
"the",
"tools",
"volume",
"the",
"container",
"s",
"entrypoint",
"which",
"will",
"output",
"to",
"the",
"log",
"volume",
"."
] | 8125fbda10178887be5dff9e901d6a0a519b67bc | https://github.com/kubernetes/test-infra/blob/8125fbda10178887be5dff9e901d6a0a519b67bc/prow/pod-utils/decorate/podspec.go#L381-L406 | test |
kubernetes/test-infra | prow/pod-utils/decorate/podspec.go | PlaceEntrypoint | func PlaceEntrypoint(image string, toolsMount coreapi.VolumeMount) coreapi.Container {
return coreapi.Container{
Name: "place-entrypoint",
Image: image,
Command: []string{"/bin/cp"},
Args: []string{"/entrypoint", entrypointLocation(toolsMount)},
VolumeMounts: []coreapi.VolumeMount... | go | func PlaceEntrypoint(image string, toolsMount coreapi.VolumeMount) coreapi.Container {
return coreapi.Container{
Name: "place-entrypoint",
Image: image,
Command: []string{"/bin/cp"},
Args: []string{"/entrypoint", entrypointLocation(toolsMount)},
VolumeMounts: []coreapi.VolumeMount... | [
"func",
"PlaceEntrypoint",
"(",
"image",
"string",
",",
"toolsMount",
"coreapi",
".",
"VolumeMount",
")",
"coreapi",
".",
"Container",
"{",
"return",
"coreapi",
".",
"Container",
"{",
"Name",
":",
"\"place-entrypoint\"",
",",
"Image",
":",
"image",
",",
"Comma... | // PlaceEntrypoint will copy entrypoint from the entrypoint image to the tools volume | [
"PlaceEntrypoint",
"will",
"copy",
"entrypoint",
"from",
"the",
"entrypoint",
"image",
"to",
"the",
"tools",
"volume"
] | 8125fbda10178887be5dff9e901d6a0a519b67bc | https://github.com/kubernetes/test-infra/blob/8125fbda10178887be5dff9e901d6a0a519b67bc/prow/pod-utils/decorate/podspec.go#L409-L417 | test |
kubernetes/test-infra | prow/pod-utils/decorate/podspec.go | kubeEnv | func kubeEnv(environment map[string]string) []coreapi.EnvVar {
var keys []string
for key := range environment {
keys = append(keys, key)
}
sort.Strings(keys)
var kubeEnvironment []coreapi.EnvVar
for _, key := range keys {
kubeEnvironment = append(kubeEnvironment, coreapi.EnvVar{
Name: key,
Value: envi... | go | func kubeEnv(environment map[string]string) []coreapi.EnvVar {
var keys []string
for key := range environment {
keys = append(keys, key)
}
sort.Strings(keys)
var kubeEnvironment []coreapi.EnvVar
for _, key := range keys {
kubeEnvironment = append(kubeEnvironment, coreapi.EnvVar{
Name: key,
Value: envi... | [
"func",
"kubeEnv",
"(",
"environment",
"map",
"[",
"string",
"]",
"string",
")",
"[",
"]",
"coreapi",
".",
"EnvVar",
"{",
"var",
"keys",
"[",
"]",
"string",
"\n",
"for",
"key",
":=",
"range",
"environment",
"{",
"keys",
"=",
"append",
"(",
"keys",
",... | // kubeEnv transforms a mapping of environment variables
// into their serialized form for a PodSpec, sorting by
// the name of the env vars | [
"kubeEnv",
"transforms",
"a",
"mapping",
"of",
"environment",
"variables",
"into",
"their",
"serialized",
"form",
"for",
"a",
"PodSpec",
"sorting",
"by",
"the",
"name",
"of",
"the",
"env",
"vars"
] | 8125fbda10178887be5dff9e901d6a0a519b67bc | https://github.com/kubernetes/test-infra/blob/8125fbda10178887be5dff9e901d6a0a519b67bc/prow/pod-utils/decorate/podspec.go#L592-L608 | test |
kubernetes/test-infra | prow/flagutil/kubernetes.go | Client | func (o *KubernetesOptions) Client(namespace string, dryRun bool) (*kube.Client, error) {
if dryRun {
return kube.NewFakeClient(o.DeckURI), nil
}
if o.cluster == "" {
return kube.NewClientInCluster(namespace)
}
return kube.NewClientFromFile(o.cluster, namespace)
} | go | func (o *KubernetesOptions) Client(namespace string, dryRun bool) (*kube.Client, error) {
if dryRun {
return kube.NewFakeClient(o.DeckURI), nil
}
if o.cluster == "" {
return kube.NewClientInCluster(namespace)
}
return kube.NewClientFromFile(o.cluster, namespace)
} | [
"func",
"(",
"o",
"*",
"KubernetesOptions",
")",
"Client",
"(",
"namespace",
"string",
",",
"dryRun",
"bool",
")",
"(",
"*",
"kube",
".",
"Client",
",",
"error",
")",
"{",
"if",
"dryRun",
"{",
"return",
"kube",
".",
"NewFakeClient",
"(",
"o",
".",
"D... | // Client returns a Kubernetes client. | [
"Client",
"returns",
"a",
"Kubernetes",
"client",
"."
] | 8125fbda10178887be5dff9e901d6a0a519b67bc | https://github.com/kubernetes/test-infra/blob/8125fbda10178887be5dff9e901d6a0a519b67bc/prow/flagutil/kubernetes.go#L63-L73 | test |
kubernetes/test-infra | prow/plugins/wip/wip-label.go | handle | func handle(gc githubClient, le *logrus.Entry, e *event) error {
needsLabel := e.draft || titleRegex.MatchString(e.title)
if needsLabel && !e.hasLabel {
if err := gc.AddLabel(e.org, e.repo, e.number, labels.WorkInProgress); err != nil {
le.Warnf("error while adding Label %q: %v", labels.WorkInProgress, err)
... | go | func handle(gc githubClient, le *logrus.Entry, e *event) error {
needsLabel := e.draft || titleRegex.MatchString(e.title)
if needsLabel && !e.hasLabel {
if err := gc.AddLabel(e.org, e.repo, e.number, labels.WorkInProgress); err != nil {
le.Warnf("error while adding Label %q: %v", labels.WorkInProgress, err)
... | [
"func",
"handle",
"(",
"gc",
"githubClient",
",",
"le",
"*",
"logrus",
".",
"Entry",
",",
"e",
"*",
"event",
")",
"error",
"{",
"needsLabel",
":=",
"e",
".",
"draft",
"||",
"titleRegex",
".",
"MatchString",
"(",
"e",
".",
"title",
")",
"\n",
"if",
... | // handle interacts with GitHub to drive the pull request to the
// proper state by adding and removing comments and labels. If a
// PR has a WIP prefix, it needs an explanatory comment and label.
// Otherwise, neither should be present. | [
"handle",
"interacts",
"with",
"GitHub",
"to",
"drive",
"the",
"pull",
"request",
"to",
"the",
"proper",
"state",
"by",
"adding",
"and",
"removing",
"comments",
"and",
"labels",
".",
"If",
"a",
"PR",
"has",
"a",
"WIP",
"prefix",
"it",
"needs",
"an",
"exp... | 8125fbda10178887be5dff9e901d6a0a519b67bc | https://github.com/kubernetes/test-infra/blob/8125fbda10178887be5dff9e901d6a0a519b67bc/prow/plugins/wip/wip-label.go#L115-L130 | test |
kubernetes/test-infra | prow/phony/phony.go | SendHook | func SendHook(address, eventType string, payload, hmac []byte) error {
req, err := http.NewRequest(http.MethodPost, address, bytes.NewBuffer(payload))
if err != nil {
return err
}
req.Header.Set("X-GitHub-Event", eventType)
req.Header.Set("X-GitHub-Delivery", "GUID")
req.Header.Set("X-Hub-Signature", github.Pay... | go | func SendHook(address, eventType string, payload, hmac []byte) error {
req, err := http.NewRequest(http.MethodPost, address, bytes.NewBuffer(payload))
if err != nil {
return err
}
req.Header.Set("X-GitHub-Event", eventType)
req.Header.Set("X-GitHub-Delivery", "GUID")
req.Header.Set("X-Hub-Signature", github.Pay... | [
"func",
"SendHook",
"(",
"address",
",",
"eventType",
"string",
",",
"payload",
",",
"hmac",
"[",
"]",
"byte",
")",
"error",
"{",
"req",
",",
"err",
":=",
"http",
".",
"NewRequest",
"(",
"http",
".",
"MethodPost",
",",
"address",
",",
"bytes",
".",
"... | // SendHook sends a GitHub event of type eventType to the provided address. | [
"SendHook",
"sends",
"a",
"GitHub",
"event",
"of",
"type",
"eventType",
"to",
"the",
"provided",
"address",
"."
] | 8125fbda10178887be5dff9e901d6a0a519b67bc | https://github.com/kubernetes/test-infra/blob/8125fbda10178887be5dff9e901d6a0a519b67bc/prow/phony/phony.go#L29-L53 | test |
kubernetes/test-infra | boskos/janitor/janitor.go | janitorClean | func janitorClean(resource *common.Resource, flags []string) error {
args := append([]string{fmt.Sprintf("--%s=%s", format(resource.Type), resource.Name)}, flags...)
logrus.Infof("executing janitor: %s %s", *janitorPath, strings.Join(args, " "))
cmd := exec.Command(*janitorPath, args...)
b, err := cmd.CombinedOutpu... | go | func janitorClean(resource *common.Resource, flags []string) error {
args := append([]string{fmt.Sprintf("--%s=%s", format(resource.Type), resource.Name)}, flags...)
logrus.Infof("executing janitor: %s %s", *janitorPath, strings.Join(args, " "))
cmd := exec.Command(*janitorPath, args...)
b, err := cmd.CombinedOutpu... | [
"func",
"janitorClean",
"(",
"resource",
"*",
"common",
".",
"Resource",
",",
"flags",
"[",
"]",
"string",
")",
"error",
"{",
"args",
":=",
"append",
"(",
"[",
"]",
"string",
"{",
"fmt",
".",
"Sprintf",
"(",
"\"--%s=%s\"",
",",
"format",
"(",
"resource... | // Clean by janitor script | [
"Clean",
"by",
"janitor",
"script"
] | 8125fbda10178887be5dff9e901d6a0a519b67bc | https://github.com/kubernetes/test-infra/blob/8125fbda10178887be5dff9e901d6a0a519b67bc/boskos/janitor/janitor.go#L76-L88 | test |
kubernetes/test-infra | boskos/janitor/janitor.go | janitor | func janitor(c boskosClient, buffer <-chan *common.Resource, fn clean, flags []string) {
for {
resource := <-buffer
dest := common.Free
if err := fn(resource, flags); err != nil {
logrus.WithError(err).Errorf("%s failed!", *janitorPath)
dest = common.Dirty
}
if err := c.ReleaseOne(resource.Name, dest... | go | func janitor(c boskosClient, buffer <-chan *common.Resource, fn clean, flags []string) {
for {
resource := <-buffer
dest := common.Free
if err := fn(resource, flags); err != nil {
logrus.WithError(err).Errorf("%s failed!", *janitorPath)
dest = common.Dirty
}
if err := c.ReleaseOne(resource.Name, dest... | [
"func",
"janitor",
"(",
"c",
"boskosClient",
",",
"buffer",
"<-",
"chan",
"*",
"common",
".",
"Resource",
",",
"fn",
"clean",
",",
"flags",
"[",
"]",
"string",
")",
"{",
"for",
"{",
"resource",
":=",
"<-",
"buffer",
"\n",
"dest",
":=",
"common",
".",... | // async janitor goroutine | [
"async",
"janitor",
"goroutine"
] | 8125fbda10178887be5dff9e901d6a0a519b67bc | https://github.com/kubernetes/test-infra/blob/8125fbda10178887be5dff9e901d6a0a519b67bc/boskos/janitor/janitor.go#L137-L151 | test |
kubernetes/test-infra | prow/pubsub/subscriber/server.go | Run | func (s *PullServer) Run(ctx context.Context) error {
configEvent := make(chan config.Delta, 2)
s.Subscriber.ConfigAgent.Subscribe(configEvent)
var err error
defer func() {
if err != nil {
logrus.WithError(ctx.Err()).Error("Pull server shutting down")
}
logrus.Warn("Pull server shutting down")
}()
curre... | go | func (s *PullServer) Run(ctx context.Context) error {
configEvent := make(chan config.Delta, 2)
s.Subscriber.ConfigAgent.Subscribe(configEvent)
var err error
defer func() {
if err != nil {
logrus.WithError(ctx.Err()).Error("Pull server shutting down")
}
logrus.Warn("Pull server shutting down")
}()
curre... | [
"func",
"(",
"s",
"*",
"PullServer",
")",
"Run",
"(",
"ctx",
"context",
".",
"Context",
")",
"error",
"{",
"configEvent",
":=",
"make",
"(",
"chan",
"config",
".",
"Delta",
",",
"2",
")",
"\n",
"s",
".",
"Subscriber",
".",
"ConfigAgent",
".",
"Subscr... | // Run will block listening to all subscriptions and return once the context is cancelled
// or one of the subscription has a unrecoverable error. | [
"Run",
"will",
"block",
"listening",
"to",
"all",
"subscriptions",
"and",
"return",
"once",
"the",
"context",
"is",
"cancelled",
"or",
"one",
"of",
"the",
"subscription",
"has",
"a",
"unrecoverable",
"error",
"."
] | 8125fbda10178887be5dff9e901d6a0a519b67bc | https://github.com/kubernetes/test-infra/blob/8125fbda10178887be5dff9e901d6a0a519b67bc/prow/pubsub/subscriber/server.go#L199-L242 | test |
kubernetes/test-infra | prow/initupload/run.go | specToStarted | func specToStarted(spec *downwardapi.JobSpec, mainRefSHA string) gcs.Started {
started := gcs.Started{
Timestamp: time.Now().Unix(),
RepoVersion: downwardapi.GetRevisionFromSpec(spec),
}
if mainRefSHA != "" {
started.RepoVersion = mainRefSHA
}
// TODO(fejta): VM name
if spec.Refs != nil && len(spec.Ref... | go | func specToStarted(spec *downwardapi.JobSpec, mainRefSHA string) gcs.Started {
started := gcs.Started{
Timestamp: time.Now().Unix(),
RepoVersion: downwardapi.GetRevisionFromSpec(spec),
}
if mainRefSHA != "" {
started.RepoVersion = mainRefSHA
}
// TODO(fejta): VM name
if spec.Refs != nil && len(spec.Ref... | [
"func",
"specToStarted",
"(",
"spec",
"*",
"downwardapi",
".",
"JobSpec",
",",
"mainRefSHA",
"string",
")",
"gcs",
".",
"Started",
"{",
"started",
":=",
"gcs",
".",
"Started",
"{",
"Timestamp",
":",
"time",
".",
"Now",
"(",
")",
".",
"Unix",
"(",
")",
... | // specToStarted translate a jobspec into a started struct
// optionally overwrite RepoVersion with provided mainRefSHA | [
"specToStarted",
"translate",
"a",
"jobspec",
"into",
"a",
"started",
"struct",
"optionally",
"overwrite",
"RepoVersion",
"with",
"provided",
"mainRefSHA"
] | 8125fbda10178887be5dff9e901d6a0a519b67bc | https://github.com/kubernetes/test-infra/blob/8125fbda10178887be5dff9e901d6a0a519b67bc/prow/initupload/run.go#L35-L61 | test |
kubernetes/test-infra | prow/initupload/run.go | Run | func (o Options) Run() error {
spec, err := downwardapi.ResolveSpecFromEnv()
if err != nil {
return fmt.Errorf("could not resolve job spec: %v", err)
}
uploadTargets := map[string]gcs.UploadFunc{}
var failed bool
var mainRefSHA string
if o.Log != "" {
if failed, mainRefSHA, err = processCloneLog(o.Log, upl... | go | func (o Options) Run() error {
spec, err := downwardapi.ResolveSpecFromEnv()
if err != nil {
return fmt.Errorf("could not resolve job spec: %v", err)
}
uploadTargets := map[string]gcs.UploadFunc{}
var failed bool
var mainRefSHA string
if o.Log != "" {
if failed, mainRefSHA, err = processCloneLog(o.Log, upl... | [
"func",
"(",
"o",
"Options",
")",
"Run",
"(",
")",
"error",
"{",
"spec",
",",
"err",
":=",
"downwardapi",
".",
"ResolveSpecFromEnv",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"fmt",
".",
"Errorf",
"(",
"\"could not resolve job spec: %v\"",
... | // Run will start the initupload job to upload the artifacts, logs and clone status. | [
"Run",
"will",
"start",
"the",
"initupload",
"job",
"to",
"upload",
"the",
"artifacts",
"logs",
"and",
"clone",
"status",
"."
] | 8125fbda10178887be5dff9e901d6a0a519b67bc | https://github.com/kubernetes/test-infra/blob/8125fbda10178887be5dff9e901d6a0a519b67bc/prow/initupload/run.go#L64-L98 | test |
kubernetes/test-infra | prow/plugins/invalidcommitmsg/invalidcommitmsg.go | hasPRChanged | func hasPRChanged(pr github.PullRequestEvent) bool {
switch pr.Action {
case github.PullRequestActionOpened:
return true
case github.PullRequestActionReopened:
return true
case github.PullRequestActionSynchronize:
return true
default:
return false
}
} | go | func hasPRChanged(pr github.PullRequestEvent) bool {
switch pr.Action {
case github.PullRequestActionOpened:
return true
case github.PullRequestActionReopened:
return true
case github.PullRequestActionSynchronize:
return true
default:
return false
}
} | [
"func",
"hasPRChanged",
"(",
"pr",
"github",
".",
"PullRequestEvent",
")",
"bool",
"{",
"switch",
"pr",
".",
"Action",
"{",
"case",
"github",
".",
"PullRequestActionOpened",
":",
"return",
"true",
"\n",
"case",
"github",
".",
"PullRequestActionReopened",
":",
... | // hasPRChanged indicates that the code diff may have changed. | [
"hasPRChanged",
"indicates",
"that",
"the",
"code",
"diff",
"may",
"have",
"changed",
"."
] | 8125fbda10178887be5dff9e901d6a0a519b67bc | https://github.com/kubernetes/test-infra/blob/8125fbda10178887be5dff9e901d6a0a519b67bc/prow/plugins/invalidcommitmsg/invalidcommitmsg.go#L158-L169 | test |
kubernetes/test-infra | velodrome/fetcher/issues.go | UpdateIssues | func UpdateIssues(db *gorm.DB, client ClientInterface) {
latest, err := findLatestIssueUpdate(db, client.RepositoryName())
if err != nil {
glog.Error("Failed to find last issue update: ", err)
return
}
c := make(chan *github.Issue, 200)
go client.FetchIssues(latest, c)
for issue := range c {
issueOrm, err ... | go | func UpdateIssues(db *gorm.DB, client ClientInterface) {
latest, err := findLatestIssueUpdate(db, client.RepositoryName())
if err != nil {
glog.Error("Failed to find last issue update: ", err)
return
}
c := make(chan *github.Issue, 200)
go client.FetchIssues(latest, c)
for issue := range c {
issueOrm, err ... | [
"func",
"UpdateIssues",
"(",
"db",
"*",
"gorm",
".",
"DB",
",",
"client",
"ClientInterface",
")",
"{",
"latest",
",",
"err",
":=",
"findLatestIssueUpdate",
"(",
"db",
",",
"client",
".",
"RepositoryName",
"(",
")",
")",
"\n",
"if",
"err",
"!=",
"nil",
... | // UpdateIssues downloads new issues and saves in database | [
"UpdateIssues",
"downloads",
"new",
"issues",
"and",
"saves",
"in",
"database"
] | 8125fbda10178887be5dff9e901d6a0a519b67bc | https://github.com/kubernetes/test-infra/blob/8125fbda10178887be5dff9e901d6a0a519b67bc/velodrome/fetcher/issues.go#L46-L83 | test |
kubernetes/test-infra | prow/plugins/approve/approve.go | handleReviewEvent | func handleReviewEvent(pc plugins.Agent, re github.ReviewEvent) error {
return handleReview(
pc.Logger,
pc.GitHubClient,
pc.OwnersClient,
pc.Config.GitHubOptions,
pc.PluginConfig,
&re,
)
} | go | func handleReviewEvent(pc plugins.Agent, re github.ReviewEvent) error {
return handleReview(
pc.Logger,
pc.GitHubClient,
pc.OwnersClient,
pc.Config.GitHubOptions,
pc.PluginConfig,
&re,
)
} | [
"func",
"handleReviewEvent",
"(",
"pc",
"plugins",
".",
"Agent",
",",
"re",
"github",
".",
"ReviewEvent",
")",
"error",
"{",
"return",
"handleReview",
"(",
"pc",
".",
"Logger",
",",
"pc",
".",
"GitHubClient",
",",
"pc",
".",
"OwnersClient",
",",
"pc",
".... | // handleReviewEvent should only handle reviews that have no approval command.
// Reviews with approval commands will be handled by handleGenericCommentEvent. | [
"handleReviewEvent",
"should",
"only",
"handle",
"reviews",
"that",
"have",
"no",
"approval",
"command",
".",
"Reviews",
"with",
"approval",
"commands",
"will",
"be",
"handled",
"by",
"handleGenericCommentEvent",
"."
] | 8125fbda10178887be5dff9e901d6a0a519b67bc | https://github.com/kubernetes/test-infra/blob/8125fbda10178887be5dff9e901d6a0a519b67bc/prow/plugins/approve/approve.go#L201-L210 | test |
kubernetes/test-infra | prow/plugins/approve/approve.go | findAssociatedIssue | func findAssociatedIssue(body, org string) (int, error) {
associatedIssueRegex, err := regexp.Compile(fmt.Sprintf(associatedIssueRegexFormat, org))
if err != nil {
return 0, err
}
match := associatedIssueRegex.FindStringSubmatch(body)
if len(match) == 0 {
return 0, nil
}
v, err := strconv.Atoi(match[1])
if ... | go | func findAssociatedIssue(body, org string) (int, error) {
associatedIssueRegex, err := regexp.Compile(fmt.Sprintf(associatedIssueRegexFormat, org))
if err != nil {
return 0, err
}
match := associatedIssueRegex.FindStringSubmatch(body)
if len(match) == 0 {
return 0, nil
}
v, err := strconv.Atoi(match[1])
if ... | [
"func",
"findAssociatedIssue",
"(",
"body",
",",
"org",
"string",
")",
"(",
"int",
",",
"error",
")",
"{",
"associatedIssueRegex",
",",
"err",
":=",
"regexp",
".",
"Compile",
"(",
"fmt",
".",
"Sprintf",
"(",
"associatedIssueRegexFormat",
",",
"org",
")",
"... | // Returns associated issue, or 0 if it can't find any.
// This is really simple, and could be improved later. | [
"Returns",
"associated",
"issue",
"or",
"0",
"if",
"it",
"can",
"t",
"find",
"any",
".",
"This",
"is",
"really",
"simple",
"and",
"could",
"be",
"improved",
"later",
"."
] | 8125fbda10178887be5dff9e901d6a0a519b67bc | https://github.com/kubernetes/test-infra/blob/8125fbda10178887be5dff9e901d6a0a519b67bc/prow/plugins/approve/approve.go#L315-L329 | test |
kubernetes/test-infra | prow/plugins/approve/approve.go | optionsForRepo | func optionsForRepo(config *plugins.Configuration, org, repo string) *plugins.Approve {
fullName := fmt.Sprintf("%s/%s", org, repo)
a := func() *plugins.Approve {
// First search for repo config
for _, c := range config.Approve {
if !strInSlice(fullName, c.Repos) {
continue
}
return &c
}
// If ... | go | func optionsForRepo(config *plugins.Configuration, org, repo string) *plugins.Approve {
fullName := fmt.Sprintf("%s/%s", org, repo)
a := func() *plugins.Approve {
// First search for repo config
for _, c := range config.Approve {
if !strInSlice(fullName, c.Repos) {
continue
}
return &c
}
// If ... | [
"func",
"optionsForRepo",
"(",
"config",
"*",
"plugins",
".",
"Configuration",
",",
"org",
",",
"repo",
"string",
")",
"*",
"plugins",
".",
"Approve",
"{",
"fullName",
":=",
"fmt",
".",
"Sprintf",
"(",
"\"%s/%s\"",
",",
"org",
",",
"repo",
")",
"\n",
"... | // optionsForRepo gets the plugins.Approve struct that is applicable to the indicated repo. | [
"optionsForRepo",
"gets",
"the",
"plugins",
".",
"Approve",
"struct",
"that",
"is",
"applicable",
"to",
"the",
"indicated",
"repo",
"."
] | 8125fbda10178887be5dff9e901d6a0a519b67bc | https://github.com/kubernetes/test-infra/blob/8125fbda10178887be5dff9e901d6a0a519b67bc/prow/plugins/approve/approve.go#L607-L639 | test |
kubernetes/test-infra | prow/cmd/deck/main.go | localOnlyMain | func localOnlyMain(cfg config.Getter, o options, mux *http.ServeMux) *http.ServeMux {
mux.Handle("/github-login", gziphandler.GzipHandler(handleSimpleTemplate(o, cfg, "github-login.html", nil)))
if o.spyglass {
initSpyglass(cfg, o, mux, nil)
}
return mux
} | go | func localOnlyMain(cfg config.Getter, o options, mux *http.ServeMux) *http.ServeMux {
mux.Handle("/github-login", gziphandler.GzipHandler(handleSimpleTemplate(o, cfg, "github-login.html", nil)))
if o.spyglass {
initSpyglass(cfg, o, mux, nil)
}
return mux
} | [
"func",
"localOnlyMain",
"(",
"cfg",
"config",
".",
"Getter",
",",
"o",
"options",
",",
"mux",
"*",
"http",
".",
"ServeMux",
")",
"*",
"http",
".",
"ServeMux",
"{",
"mux",
".",
"Handle",
"(",
"\"/github-login\"",
",",
"gziphandler",
".",
"GzipHandler",
"... | // localOnlyMain contains logic used only when running locally, and is mutually exclusive with
// prodOnlyMain. | [
"localOnlyMain",
"contains",
"logic",
"used",
"only",
"when",
"running",
"locally",
"and",
"is",
"mutually",
"exclusive",
"with",
"prodOnlyMain",
"."
] | 8125fbda10178887be5dff9e901d6a0a519b67bc | https://github.com/kubernetes/test-infra/blob/8125fbda10178887be5dff9e901d6a0a519b67bc/prow/cmd/deck/main.go#L219-L227 | test |
kubernetes/test-infra | gopherage/pkg/cov/junit/calculation/coveragelist.go | summarize | func (covList *CoverageList) summarize() {
covList.NumCoveredStmts = 0
covList.NumAllStmts = 0
for _, item := range covList.Group {
covList.NumCoveredStmts += item.NumCoveredStmts
covList.NumAllStmts += item.NumAllStmts
}
} | go | func (covList *CoverageList) summarize() {
covList.NumCoveredStmts = 0
covList.NumAllStmts = 0
for _, item := range covList.Group {
covList.NumCoveredStmts += item.NumCoveredStmts
covList.NumAllStmts += item.NumAllStmts
}
} | [
"func",
"(",
"covList",
"*",
"CoverageList",
")",
"summarize",
"(",
")",
"{",
"covList",
".",
"NumCoveredStmts",
"=",
"0",
"\n",
"covList",
".",
"NumAllStmts",
"=",
"0",
"\n",
"for",
"_",
",",
"item",
":=",
"range",
"covList",
".",
"Group",
"{",
"covLi... | // summarize summarizes all items in the Group and stores the result | [
"summarize",
"summarizes",
"all",
"items",
"in",
"the",
"Group",
"and",
"stores",
"the",
"result"
] | 8125fbda10178887be5dff9e901d6a0a519b67bc | https://github.com/kubernetes/test-infra/blob/8125fbda10178887be5dff9e901d6a0a519b67bc/gopherage/pkg/cov/junit/calculation/coveragelist.go#L45-L52 | test |
kubernetes/test-infra | gopherage/pkg/cov/junit/calculation/coveragelist.go | Subset | func (covList *CoverageList) Subset(prefix string) *CoverageList {
s := newCoverageList("Filtered Summary")
for _, c := range covList.Group {
if strings.HasPrefix(c.Name, prefix) {
covList.Group = append(covList.Group, c)
}
}
return s
} | go | func (covList *CoverageList) Subset(prefix string) *CoverageList {
s := newCoverageList("Filtered Summary")
for _, c := range covList.Group {
if strings.HasPrefix(c.Name, prefix) {
covList.Group = append(covList.Group, c)
}
}
return s
} | [
"func",
"(",
"covList",
"*",
"CoverageList",
")",
"Subset",
"(",
"prefix",
"string",
")",
"*",
"CoverageList",
"{",
"s",
":=",
"newCoverageList",
"(",
"\"Filtered Summary\"",
")",
"\n",
"for",
"_",
",",
"c",
":=",
"range",
"covList",
".",
"Group",
"{",
"... | // Subset returns the subset obtained through applying filter | [
"Subset",
"returns",
"the",
"subset",
"obtained",
"through",
"applying",
"filter"
] | 8125fbda10178887be5dff9e901d6a0a519b67bc | https://github.com/kubernetes/test-infra/blob/8125fbda10178887be5dff9e901d6a0a519b67bc/gopherage/pkg/cov/junit/calculation/coveragelist.go#L55-L63 | test |
kubernetes/test-infra | gopherage/pkg/cov/junit/calculation/coveragelist.go | ListDirectories | func (covList CoverageList) ListDirectories() []string {
dirSet := map[string]bool{}
for _, cov := range covList.Group {
dirSet[path.Dir(cov.Name)] = true
}
var result []string
for key := range dirSet {
result = append(result, key)
}
return result
} | go | func (covList CoverageList) ListDirectories() []string {
dirSet := map[string]bool{}
for _, cov := range covList.Group {
dirSet[path.Dir(cov.Name)] = true
}
var result []string
for key := range dirSet {
result = append(result, key)
}
return result
} | [
"func",
"(",
"covList",
"CoverageList",
")",
"ListDirectories",
"(",
")",
"[",
"]",
"string",
"{",
"dirSet",
":=",
"map",
"[",
"string",
"]",
"bool",
"{",
"}",
"\n",
"for",
"_",
",",
"cov",
":=",
"range",
"covList",
".",
"Group",
"{",
"dirSet",
"[",
... | // ListDirectories gets a list a sub-directories that contains source code. | [
"ListDirectories",
"gets",
"a",
"list",
"a",
"sub",
"-",
"directories",
"that",
"contains",
"source",
"code",
"."
] | 8125fbda10178887be5dff9e901d6a0a519b67bc | https://github.com/kubernetes/test-infra/blob/8125fbda10178887be5dff9e901d6a0a519b67bc/gopherage/pkg/cov/junit/calculation/coveragelist.go#L66-L76 | test |
kubernetes/test-infra | prow/cmd/admission/admission.go | readRequest | func readRequest(r io.Reader, contentType string) (*admissionapi.AdmissionRequest, error) {
if contentType != contentTypeJSON {
return nil, fmt.Errorf("Content-Type=%s, expected %s", contentType, contentTypeJSON)
}
// Can we read the body?
if r == nil {
return nil, fmt.Errorf("no body")
}
body, err := ioutil... | go | func readRequest(r io.Reader, contentType string) (*admissionapi.AdmissionRequest, error) {
if contentType != contentTypeJSON {
return nil, fmt.Errorf("Content-Type=%s, expected %s", contentType, contentTypeJSON)
}
// Can we read the body?
if r == nil {
return nil, fmt.Errorf("no body")
}
body, err := ioutil... | [
"func",
"readRequest",
"(",
"r",
"io",
".",
"Reader",
",",
"contentType",
"string",
")",
"(",
"*",
"admissionapi",
".",
"AdmissionRequest",
",",
"error",
")",
"{",
"if",
"contentType",
"!=",
"contentTypeJSON",
"{",
"return",
"nil",
",",
"fmt",
".",
"Errorf... | // readRequest extracts the request from the AdmissionReview reader | [
"readRequest",
"extracts",
"the",
"request",
"from",
"the",
"AdmissionReview",
"reader"
] | 8125fbda10178887be5dff9e901d6a0a519b67bc | https://github.com/kubernetes/test-infra/blob/8125fbda10178887be5dff9e901d6a0a519b67bc/prow/cmd/admission/admission.go#L59-L80 | test |
kubernetes/test-infra | prow/cmd/admission/admission.go | handle | func handle(w http.ResponseWriter, r *http.Request) {
req, err := readRequest(r.Body, r.Header.Get("Content-Type"))
if err != nil {
logrus.WithError(err).Error("read")
}
if err := writeResponse(*req, w, onlyUpdateStatus); err != nil {
logrus.WithError(err).Error("write")
}
} | go | func handle(w http.ResponseWriter, r *http.Request) {
req, err := readRequest(r.Body, r.Header.Get("Content-Type"))
if err != nil {
logrus.WithError(err).Error("read")
}
if err := writeResponse(*req, w, onlyUpdateStatus); err != nil {
logrus.WithError(err).Error("write")
}
} | [
"func",
"handle",
"(",
"w",
"http",
".",
"ResponseWriter",
",",
"r",
"*",
"http",
".",
"Request",
")",
"{",
"req",
",",
"err",
":=",
"readRequest",
"(",
"r",
".",
"Body",
",",
"r",
".",
"Header",
".",
"Get",
"(",
"\"Content-Type\"",
")",
")",
"\n",... | // handle reads the request and writes the response | [
"handle",
"reads",
"the",
"request",
"and",
"writes",
"the",
"response"
] | 8125fbda10178887be5dff9e901d6a0a519b67bc | https://github.com/kubernetes/test-infra/blob/8125fbda10178887be5dff9e901d6a0a519b67bc/prow/cmd/admission/admission.go#L83-L92 | test |
kubernetes/test-infra | prow/cmd/admission/admission.go | writeResponse | func writeResponse(ar admissionapi.AdmissionRequest, w io.Writer, decide decider) error {
response, err := decide(ar)
if err != nil {
logrus.WithError(err).Error("failed decision")
response = &admissionapi.AdmissionResponse{
Result: &meta.Status{
Message: err.Error(),
},
}
}
var result admissionapi.... | go | func writeResponse(ar admissionapi.AdmissionRequest, w io.Writer, decide decider) error {
response, err := decide(ar)
if err != nil {
logrus.WithError(err).Error("failed decision")
response = &admissionapi.AdmissionResponse{
Result: &meta.Status{
Message: err.Error(),
},
}
}
var result admissionapi.... | [
"func",
"writeResponse",
"(",
"ar",
"admissionapi",
".",
"AdmissionRequest",
",",
"w",
"io",
".",
"Writer",
",",
"decide",
"decider",
")",
"error",
"{",
"response",
",",
"err",
":=",
"decide",
"(",
"ar",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"logru... | // writeResponse gets the response from onlyUpdateStatus and writes it to w. | [
"writeResponse",
"gets",
"the",
"response",
"from",
"onlyUpdateStatus",
"and",
"writes",
"it",
"to",
"w",
"."
] | 8125fbda10178887be5dff9e901d6a0a519b67bc | https://github.com/kubernetes/test-infra/blob/8125fbda10178887be5dff9e901d6a0a519b67bc/prow/cmd/admission/admission.go#L97-L118 | test |
kubernetes/test-infra | prow/cmd/admission/admission.go | onlyUpdateStatus | func onlyUpdateStatus(req admissionapi.AdmissionRequest) (*admissionapi.AdmissionResponse, error) {
logger := logrus.WithFields(logrus.Fields{
"resource": req.Resource,
"subresource": req.SubResource,
"name": req.Name,
"namespace": req.Namespace,
"operation": req.Operation,
})
// Does this o... | go | func onlyUpdateStatus(req admissionapi.AdmissionRequest) (*admissionapi.AdmissionResponse, error) {
logger := logrus.WithFields(logrus.Fields{
"resource": req.Resource,
"subresource": req.SubResource,
"name": req.Name,
"namespace": req.Namespace,
"operation": req.Operation,
})
// Does this o... | [
"func",
"onlyUpdateStatus",
"(",
"req",
"admissionapi",
".",
"AdmissionRequest",
")",
"(",
"*",
"admissionapi",
".",
"AdmissionResponse",
",",
"error",
")",
"{",
"logger",
":=",
"logrus",
".",
"WithFields",
"(",
"logrus",
".",
"Fields",
"{",
"\"resource\"",
":... | // onlyUpdateStatus returns the response to the request | [
"onlyUpdateStatus",
"returns",
"the",
"response",
"to",
"the",
"request"
] | 8125fbda10178887be5dff9e901d6a0a519b67bc | https://github.com/kubernetes/test-infra/blob/8125fbda10178887be5dff9e901d6a0a519b67bc/prow/cmd/admission/admission.go#L133-L163 | test |
kubernetes/test-infra | experiment/resultstore/convert.go | convertSuiteMeta | func convertSuiteMeta(suiteMeta gcs.SuitesMeta) resultstore.Suite {
out := resultstore.Suite{
Name: path.Base(suiteMeta.Path),
Files: []resultstore.File{
{
ContentType: "text/xml",
ID: resultstore.UUID(),
URL: suiteMeta.Path, // ensure the junit.xml file appears in artifacts list
... | go | func convertSuiteMeta(suiteMeta gcs.SuitesMeta) resultstore.Suite {
out := resultstore.Suite{
Name: path.Base(suiteMeta.Path),
Files: []resultstore.File{
{
ContentType: "text/xml",
ID: resultstore.UUID(),
URL: suiteMeta.Path, // ensure the junit.xml file appears in artifacts list
... | [
"func",
"convertSuiteMeta",
"(",
"suiteMeta",
"gcs",
".",
"SuitesMeta",
")",
"resultstore",
".",
"Suite",
"{",
"out",
":=",
"resultstore",
".",
"Suite",
"{",
"Name",
":",
"path",
".",
"Base",
"(",
"suiteMeta",
".",
"Path",
")",
",",
"Files",
":",
"[",
... | // convertSuiteMeta converts a junit result in gcs to a ResultStore Suite. | [
"convertSuiteMeta",
"converts",
"a",
"junit",
"result",
"in",
"gcs",
"to",
"a",
"ResultStore",
"Suite",
"."
] | 8125fbda10178887be5dff9e901d6a0a519b67bc | https://github.com/kubernetes/test-infra/blob/8125fbda10178887be5dff9e901d6a0a519b67bc/experiment/resultstore/convert.go#L34-L105 | test |
kubernetes/test-infra | prow/pjutil/health.go | NewHealth | func NewHealth() *Health {
healthMux := http.NewServeMux()
healthMux.HandleFunc("/healthz", func(w http.ResponseWriter, r *http.Request) { fmt.Fprint(w, "OK") })
go func() {
logrus.WithError(http.ListenAndServe(":"+strconv.Itoa(healthPort), healthMux)).Fatal("ListenAndServe returned.")
}()
return &Health{
heal... | go | func NewHealth() *Health {
healthMux := http.NewServeMux()
healthMux.HandleFunc("/healthz", func(w http.ResponseWriter, r *http.Request) { fmt.Fprint(w, "OK") })
go func() {
logrus.WithError(http.ListenAndServe(":"+strconv.Itoa(healthPort), healthMux)).Fatal("ListenAndServe returned.")
}()
return &Health{
heal... | [
"func",
"NewHealth",
"(",
")",
"*",
"Health",
"{",
"healthMux",
":=",
"http",
".",
"NewServeMux",
"(",
")",
"\n",
"healthMux",
".",
"HandleFunc",
"(",
"\"/healthz\"",
",",
"func",
"(",
"w",
"http",
".",
"ResponseWriter",
",",
"r",
"*",
"http",
".",
"Re... | // NewHealth creates a new health request multiplexer and starts serving the liveness endpoint
// on the given port | [
"NewHealth",
"creates",
"a",
"new",
"health",
"request",
"multiplexer",
"and",
"starts",
"serving",
"the",
"liveness",
"endpoint",
"on",
"the",
"given",
"port"
] | 8125fbda10178887be5dff9e901d6a0a519b67bc | https://github.com/kubernetes/test-infra/blob/8125fbda10178887be5dff9e901d6a0a519b67bc/prow/pjutil/health.go#L37-L46 | test |
kubernetes/test-infra | prow/pjutil/health.go | ServeReady | func (h *Health) ServeReady() {
h.healthMux.HandleFunc("/healthz/ready", func(w http.ResponseWriter, r *http.Request) { fmt.Fprint(w, "OK") })
} | go | func (h *Health) ServeReady() {
h.healthMux.HandleFunc("/healthz/ready", func(w http.ResponseWriter, r *http.Request) { fmt.Fprint(w, "OK") })
} | [
"func",
"(",
"h",
"*",
"Health",
")",
"ServeReady",
"(",
")",
"{",
"h",
".",
"healthMux",
".",
"HandleFunc",
"(",
"\"/healthz/ready\"",
",",
"func",
"(",
"w",
"http",
".",
"ResponseWriter",
",",
"r",
"*",
"http",
".",
"Request",
")",
"{",
"fmt",
".",... | // ServeReady starts serving the readiness endpoint | [
"ServeReady",
"starts",
"serving",
"the",
"readiness",
"endpoint"
] | 8125fbda10178887be5dff9e901d6a0a519b67bc | https://github.com/kubernetes/test-infra/blob/8125fbda10178887be5dff9e901d6a0a519b67bc/prow/pjutil/health.go#L49-L51 | test |
kubernetes/test-infra | prow/tide/tide.go | NewController | func NewController(ghcSync, ghcStatus *github.Client, prowJobClient prowv1.ProwJobInterface, cfg config.Getter, gc *git.Client, maxRecordsPerPool int, opener io.Opener, historyURI, statusURI string, logger *logrus.Entry) (*Controller, error) {
if logger == nil {
logger = logrus.NewEntry(logrus.StandardLogger())
}
... | go | func NewController(ghcSync, ghcStatus *github.Client, prowJobClient prowv1.ProwJobInterface, cfg config.Getter, gc *git.Client, maxRecordsPerPool int, opener io.Opener, historyURI, statusURI string, logger *logrus.Entry) (*Controller, error) {
if logger == nil {
logger = logrus.NewEntry(logrus.StandardLogger())
}
... | [
"func",
"NewController",
"(",
"ghcSync",
",",
"ghcStatus",
"*",
"github",
".",
"Client",
",",
"prowJobClient",
"prowv1",
".",
"ProwJobInterface",
",",
"cfg",
"config",
".",
"Getter",
",",
"gc",
"*",
"git",
".",
"Client",
",",
"maxRecordsPerPool",
"int",
",",... | // NewController makes a Controller out of the given clients. | [
"NewController",
"makes",
"a",
"Controller",
"out",
"of",
"the",
"given",
"clients",
"."
] | 8125fbda10178887be5dff9e901d6a0a519b67bc | https://github.com/kubernetes/test-infra/blob/8125fbda10178887be5dff9e901d6a0a519b67bc/prow/tide/tide.go#L203-L234 | test |
kubernetes/test-infra | prow/tide/tide.go | newExpectedContext | func newExpectedContext(c string) Context {
return Context{
Context: githubql.String(c),
State: githubql.StatusStateExpected,
Description: githubql.String(""),
}
} | go | func newExpectedContext(c string) Context {
return Context{
Context: githubql.String(c),
State: githubql.StatusStateExpected,
Description: githubql.String(""),
}
} | [
"func",
"newExpectedContext",
"(",
"c",
"string",
")",
"Context",
"{",
"return",
"Context",
"{",
"Context",
":",
"githubql",
".",
"String",
"(",
"c",
")",
",",
"State",
":",
"githubql",
".",
"StatusStateExpected",
",",
"Description",
":",
"githubql",
".",
... | // newExpectedContext creates a Context with Expected state. | [
"newExpectedContext",
"creates",
"a",
"Context",
"with",
"Expected",
"state",
"."
] | 8125fbda10178887be5dff9e901d6a0a519b67bc | https://github.com/kubernetes/test-infra/blob/8125fbda10178887be5dff9e901d6a0a519b67bc/prow/tide/tide.go#L259-L265 | test |
kubernetes/test-infra | prow/tide/tide.go | contextsToStrings | func contextsToStrings(contexts []Context) []string {
var names []string
for _, c := range contexts {
names = append(names, string(c.Context))
}
return names
} | go | func contextsToStrings(contexts []Context) []string {
var names []string
for _, c := range contexts {
names = append(names, string(c.Context))
}
return names
} | [
"func",
"contextsToStrings",
"(",
"contexts",
"[",
"]",
"Context",
")",
"[",
"]",
"string",
"{",
"var",
"names",
"[",
"]",
"string",
"\n",
"for",
"_",
",",
"c",
":=",
"range",
"contexts",
"{",
"names",
"=",
"append",
"(",
"names",
",",
"string",
"(",... | // contextsToStrings converts a list Context to a list of string | [
"contextsToStrings",
"converts",
"a",
"list",
"Context",
"to",
"a",
"list",
"of",
"string"
] | 8125fbda10178887be5dff9e901d6a0a519b67bc | https://github.com/kubernetes/test-infra/blob/8125fbda10178887be5dff9e901d6a0a519b67bc/prow/tide/tide.go#L268-L274 | test |
kubernetes/test-infra | prow/tide/tide.go | filterSubpools | func (c *Controller) filterSubpools(goroutines int, raw map[string]*subpool) map[string]*subpool {
filtered := make(map[string]*subpool)
var lock sync.Mutex
subpoolsInParallel(
goroutines,
raw,
func(sp *subpool) {
if err := c.initSubpoolData(sp); err != nil {
sp.log.WithError(err).Error("Error initiali... | go | func (c *Controller) filterSubpools(goroutines int, raw map[string]*subpool) map[string]*subpool {
filtered := make(map[string]*subpool)
var lock sync.Mutex
subpoolsInParallel(
goroutines,
raw,
func(sp *subpool) {
if err := c.initSubpoolData(sp); err != nil {
sp.log.WithError(err).Error("Error initiali... | [
"func",
"(",
"c",
"*",
"Controller",
")",
"filterSubpools",
"(",
"goroutines",
"int",
",",
"raw",
"map",
"[",
"string",
"]",
"*",
"subpool",
")",
"map",
"[",
"string",
"]",
"*",
"subpool",
"{",
"filtered",
":=",
"make",
"(",
"map",
"[",
"string",
"]"... | // filterSubpools filters non-pool PRs out of the initially identified subpools,
// deleting any pools that become empty.
// See filterSubpool for filtering details. | [
"filterSubpools",
"filters",
"non",
"-",
"pool",
"PRs",
"out",
"of",
"the",
"initially",
"identified",
"subpools",
"deleting",
"any",
"pools",
"that",
"become",
"empty",
".",
"See",
"filterSubpool",
"for",
"filtering",
"details",
"."
] | 8125fbda10178887be5dff9e901d6a0a519b67bc | https://github.com/kubernetes/test-infra/blob/8125fbda10178887be5dff9e901d6a0a519b67bc/prow/tide/tide.go#L416-L441 | test |
kubernetes/test-infra | prow/tide/tide.go | filterSubpool | func filterSubpool(ghc githubClient, sp *subpool) *subpool {
var toKeep []PullRequest
for _, pr := range sp.prs {
if !filterPR(ghc, sp, &pr) {
toKeep = append(toKeep, pr)
}
}
if len(toKeep) == 0 {
return nil
}
sp.prs = toKeep
return sp
} | go | func filterSubpool(ghc githubClient, sp *subpool) *subpool {
var toKeep []PullRequest
for _, pr := range sp.prs {
if !filterPR(ghc, sp, &pr) {
toKeep = append(toKeep, pr)
}
}
if len(toKeep) == 0 {
return nil
}
sp.prs = toKeep
return sp
} | [
"func",
"filterSubpool",
"(",
"ghc",
"githubClient",
",",
"sp",
"*",
"subpool",
")",
"*",
"subpool",
"{",
"var",
"toKeep",
"[",
"]",
"PullRequest",
"\n",
"for",
"_",
",",
"pr",
":=",
"range",
"sp",
".",
"prs",
"{",
"if",
"!",
"filterPR",
"(",
"ghc",
... | // filterSubpool filters PRs from an initially identified subpool, returning the
// filtered subpool.
// If the subpool becomes empty 'nil' is returned to indicate that the subpool
// should be deleted. | [
"filterSubpool",
"filters",
"PRs",
"from",
"an",
"initially",
"identified",
"subpool",
"returning",
"the",
"filtered",
"subpool",
".",
"If",
"the",
"subpool",
"becomes",
"empty",
"nil",
"is",
"returned",
"to",
"indicate",
"that",
"the",
"subpool",
"should",
"be"... | 8125fbda10178887be5dff9e901d6a0a519b67bc | https://github.com/kubernetes/test-infra/blob/8125fbda10178887be5dff9e901d6a0a519b67bc/prow/tide/tide.go#L460-L472 | test |
kubernetes/test-infra | prow/tide/tide.go | poolPRMap | func poolPRMap(subpoolMap map[string]*subpool) map[string]PullRequest {
prs := make(map[string]PullRequest)
for _, sp := range subpoolMap {
for _, pr := range sp.prs {
prs[prKey(&pr)] = pr
}
}
return prs
} | go | func poolPRMap(subpoolMap map[string]*subpool) map[string]PullRequest {
prs := make(map[string]PullRequest)
for _, sp := range subpoolMap {
for _, pr := range sp.prs {
prs[prKey(&pr)] = pr
}
}
return prs
} | [
"func",
"poolPRMap",
"(",
"subpoolMap",
"map",
"[",
"string",
"]",
"*",
"subpool",
")",
"map",
"[",
"string",
"]",
"PullRequest",
"{",
"prs",
":=",
"make",
"(",
"map",
"[",
"string",
"]",
"PullRequest",
")",
"\n",
"for",
"_",
",",
"sp",
":=",
"range"... | // poolPRMap collects all subpool PRs into a map containing all pooled PRs. | [
"poolPRMap",
"collects",
"all",
"subpool",
"PRs",
"into",
"a",
"map",
"containing",
"all",
"pooled",
"PRs",
"."
] | 8125fbda10178887be5dff9e901d6a0a519b67bc | https://github.com/kubernetes/test-infra/blob/8125fbda10178887be5dff9e901d6a0a519b67bc/prow/tide/tide.go#L520-L528 | test |
kubernetes/test-infra | prow/tide/tide.go | unsuccessfulContexts | func unsuccessfulContexts(contexts []Context, cc contextChecker, log *logrus.Entry) []Context {
var failed []Context
for _, ctx := range contexts {
if string(ctx.Context) == statusContext {
continue
}
if cc.IsOptional(string(ctx.Context)) {
continue
}
if ctx.State != githubql.StatusStateSuccess {
f... | go | func unsuccessfulContexts(contexts []Context, cc contextChecker, log *logrus.Entry) []Context {
var failed []Context
for _, ctx := range contexts {
if string(ctx.Context) == statusContext {
continue
}
if cc.IsOptional(string(ctx.Context)) {
continue
}
if ctx.State != githubql.StatusStateSuccess {
f... | [
"func",
"unsuccessfulContexts",
"(",
"contexts",
"[",
"]",
"Context",
",",
"cc",
"contextChecker",
",",
"log",
"*",
"logrus",
".",
"Entry",
")",
"[",
"]",
"Context",
"{",
"var",
"failed",
"[",
"]",
"Context",
"\n",
"for",
"_",
",",
"ctx",
":=",
"range"... | // unsuccessfulContexts determines which contexts from the list that we care about are
// failed. For instance, we do not care about our own context.
// If the branchProtection is set to only check for required checks, we will skip
// all non-required tests. If required tests are missing from the list, they will be
// ... | [
"unsuccessfulContexts",
"determines",
"which",
"contexts",
"from",
"the",
"list",
"that",
"we",
"care",
"about",
"are",
"failed",
".",
"For",
"instance",
"we",
"do",
"not",
"care",
"about",
"our",
"own",
"context",
".",
"If",
"the",
"branchProtection",
"is",
... | 8125fbda10178887be5dff9e901d6a0a519b67bc | https://github.com/kubernetes/test-infra/blob/8125fbda10178887be5dff9e901d6a0a519b67bc/prow/tide/tide.go#L566-L585 | test |
kubernetes/test-infra | prow/tide/tide.go | accumulate | func accumulate(presubmits map[int][]config.Presubmit, prs []PullRequest, pjs []prowapi.ProwJob, log *logrus.Entry) (successes, pendings, nones []PullRequest) {
for _, pr := range prs {
// Accumulate the best result for each job.
psStates := make(map[string]simpleState)
for _, pj := range pjs {
if pj.Spec.Typ... | go | func accumulate(presubmits map[int][]config.Presubmit, prs []PullRequest, pjs []prowapi.ProwJob, log *logrus.Entry) (successes, pendings, nones []PullRequest) {
for _, pr := range prs {
// Accumulate the best result for each job.
psStates := make(map[string]simpleState)
for _, pj := range pjs {
if pj.Spec.Typ... | [
"func",
"accumulate",
"(",
"presubmits",
"map",
"[",
"int",
"]",
"[",
"]",
"config",
".",
"Presubmit",
",",
"prs",
"[",
"]",
"PullRequest",
",",
"pjs",
"[",
"]",
"prowapi",
".",
"ProwJob",
",",
"log",
"*",
"logrus",
".",
"Entry",
")",
"(",
"successes... | // accumulate returns the supplied PRs sorted into three buckets based on their
// accumulated state across the presubmits. | [
"accumulate",
"returns",
"the",
"supplied",
"PRs",
"sorted",
"into",
"three",
"buckets",
"based",
"on",
"their",
"accumulated",
"state",
"across",
"the",
"presubmits",
"."
] | 8125fbda10178887be5dff9e901d6a0a519b67bc | https://github.com/kubernetes/test-infra/blob/8125fbda10178887be5dff9e901d6a0a519b67bc/prow/tide/tide.go#L701-L750 | test |
kubernetes/test-infra | prow/tide/tide.go | tryMerge | func tryMerge(mergeFunc func() error) (bool, error) {
var err error
const maxRetries = 3
backoff := time.Second * 4
for retry := 0; retry < maxRetries; retry++ {
if err = mergeFunc(); err == nil {
// Successful merge!
return true, nil
}
// TODO: Add a config option to abort batches if a PR in the batch
... | go | func tryMerge(mergeFunc func() error) (bool, error) {
var err error
const maxRetries = 3
backoff := time.Second * 4
for retry := 0; retry < maxRetries; retry++ {
if err = mergeFunc(); err == nil {
// Successful merge!
return true, nil
}
// TODO: Add a config option to abort batches if a PR in the batch
... | [
"func",
"tryMerge",
"(",
"mergeFunc",
"func",
"(",
")",
"error",
")",
"(",
"bool",
",",
"error",
")",
"{",
"var",
"err",
"error",
"\n",
"const",
"maxRetries",
"=",
"3",
"\n",
"backoff",
":=",
"time",
".",
"Second",
"*",
"4",
"\n",
"for",
"retry",
"... | // tryMerge attempts 1 merge and returns a bool indicating if we should try
// to merge the remaining PRs and possibly an error. | [
"tryMerge",
"attempts",
"1",
"merge",
"and",
"returns",
"a",
"bool",
"indicating",
"if",
"we",
"should",
"try",
"to",
"merge",
"the",
"remaining",
"PRs",
"and",
"possibly",
"an",
"error",
"."
] | 8125fbda10178887be5dff9e901d6a0a519b67bc | https://github.com/kubernetes/test-infra/blob/8125fbda10178887be5dff9e901d6a0a519b67bc/prow/tide/tide.go#L930-L988 | test |
kubernetes/test-infra | prow/tide/tide.go | prChanges | func (c *changedFilesAgent) prChanges(pr *PullRequest) config.ChangedFilesProvider {
return func() ([]string, error) {
cacheKey := changeCacheKey{
org: string(pr.Repository.Owner.Login),
repo: string(pr.Repository.Name),
number: int(pr.Number),
sha: string(pr.HeadRefOID),
}
c.RLock()
chang... | go | func (c *changedFilesAgent) prChanges(pr *PullRequest) config.ChangedFilesProvider {
return func() ([]string, error) {
cacheKey := changeCacheKey{
org: string(pr.Repository.Owner.Login),
repo: string(pr.Repository.Name),
number: int(pr.Number),
sha: string(pr.HeadRefOID),
}
c.RLock()
chang... | [
"func",
"(",
"c",
"*",
"changedFilesAgent",
")",
"prChanges",
"(",
"pr",
"*",
"PullRequest",
")",
"config",
".",
"ChangedFilesProvider",
"{",
"return",
"func",
"(",
")",
"(",
"[",
"]",
"string",
",",
"error",
")",
"{",
"cacheKey",
":=",
"changeCacheKey",
... | // prChanges gets the files changed by the PR, either from the cache or by
// querying GitHub. | [
"prChanges",
"gets",
"the",
"files",
"changed",
"by",
"the",
"PR",
"either",
"from",
"the",
"cache",
"or",
"by",
"querying",
"GitHub",
"."
] | 8125fbda10178887be5dff9e901d6a0a519b67bc | https://github.com/kubernetes/test-infra/blob/8125fbda10178887be5dff9e901d6a0a519b67bc/prow/tide/tide.go#L1090-L1133 | test |
kubernetes/test-infra | prow/tide/tide.go | prune | func (c *changedFilesAgent) prune() {
c.Lock()
defer c.Unlock()
c.changeCache = c.nextChangeCache
c.nextChangeCache = make(map[changeCacheKey][]string)
} | go | func (c *changedFilesAgent) prune() {
c.Lock()
defer c.Unlock()
c.changeCache = c.nextChangeCache
c.nextChangeCache = make(map[changeCacheKey][]string)
} | [
"func",
"(",
"c",
"*",
"changedFilesAgent",
")",
"prune",
"(",
")",
"{",
"c",
".",
"Lock",
"(",
")",
"\n",
"defer",
"c",
".",
"Unlock",
"(",
")",
"\n",
"c",
".",
"changeCache",
"=",
"c",
".",
"nextChangeCache",
"\n",
"c",
".",
"nextChangeCache",
"=... | // prune removes any cached file changes that were not used since the last prune. | [
"prune",
"removes",
"any",
"cached",
"file",
"changes",
"that",
"were",
"not",
"used",
"since",
"the",
"last",
"prune",
"."
] | 8125fbda10178887be5dff9e901d6a0a519b67bc | https://github.com/kubernetes/test-infra/blob/8125fbda10178887be5dff9e901d6a0a519b67bc/prow/tide/tide.go#L1136-L1141 | test |
kubernetes/test-infra | prow/tide/tide.go | dividePool | func (c *Controller) dividePool(pool map[string]PullRequest, pjs []prowapi.ProwJob) (map[string]*subpool, error) {
sps := make(map[string]*subpool)
for _, pr := range pool {
org := string(pr.Repository.Owner.Login)
repo := string(pr.Repository.Name)
branch := string(pr.BaseRef.Name)
branchRef := string(pr.Bas... | go | func (c *Controller) dividePool(pool map[string]PullRequest, pjs []prowapi.ProwJob) (map[string]*subpool, error) {
sps := make(map[string]*subpool)
for _, pr := range pool {
org := string(pr.Repository.Owner.Login)
repo := string(pr.Repository.Name)
branch := string(pr.BaseRef.Name)
branchRef := string(pr.Bas... | [
"func",
"(",
"c",
"*",
"Controller",
")",
"dividePool",
"(",
"pool",
"map",
"[",
"string",
"]",
"PullRequest",
",",
"pjs",
"[",
"]",
"prowapi",
".",
"ProwJob",
")",
"(",
"map",
"[",
"string",
"]",
"*",
"subpool",
",",
"error",
")",
"{",
"sps",
":="... | // dividePool splits up the list of pull requests and prow jobs into a group
// per repo and branch. It only keeps ProwJobs that match the latest branch. | [
"dividePool",
"splits",
"up",
"the",
"list",
"of",
"pull",
"requests",
"and",
"prow",
"jobs",
"into",
"a",
"group",
"per",
"repo",
"and",
"branch",
".",
"It",
"only",
"keeps",
"ProwJobs",
"that",
"match",
"the",
"latest",
"branch",
"."
] | 8125fbda10178887be5dff9e901d6a0a519b67bc | https://github.com/kubernetes/test-infra/blob/8125fbda10178887be5dff9e901d6a0a519b67bc/prow/tide/tide.go#L1283-L1322 | test |
kubernetes/test-infra | gopherage/pkg/cov/aggregate.go | AggregateProfiles | func AggregateProfiles(profiles [][]*cover.Profile) ([]*cover.Profile, error) {
setProfiles := make([][]*cover.Profile, 0, len(profiles))
for _, p := range profiles {
c := countToBoolean(p)
setProfiles = append(setProfiles, c)
}
aggregateProfiles, err := MergeMultipleProfiles(setProfiles)
if err != nil {
ret... | go | func AggregateProfiles(profiles [][]*cover.Profile) ([]*cover.Profile, error) {
setProfiles := make([][]*cover.Profile, 0, len(profiles))
for _, p := range profiles {
c := countToBoolean(p)
setProfiles = append(setProfiles, c)
}
aggregateProfiles, err := MergeMultipleProfiles(setProfiles)
if err != nil {
ret... | [
"func",
"AggregateProfiles",
"(",
"profiles",
"[",
"]",
"[",
"]",
"*",
"cover",
".",
"Profile",
")",
"(",
"[",
"]",
"*",
"cover",
".",
"Profile",
",",
"error",
")",
"{",
"setProfiles",
":=",
"make",
"(",
"[",
"]",
"[",
"]",
"*",
"cover",
".",
"Pr... | // AggregateProfiles takes multiple coverage profiles and produces a new
// coverage profile that counts the number of profiles that hit a block at least
// once. | [
"AggregateProfiles",
"takes",
"multiple",
"coverage",
"profiles",
"and",
"produces",
"a",
"new",
"coverage",
"profile",
"that",
"counts",
"the",
"number",
"of",
"profiles",
"that",
"hit",
"a",
"block",
"at",
"least",
"once",
"."
] | 8125fbda10178887be5dff9e901d6a0a519b67bc | https://github.com/kubernetes/test-infra/blob/8125fbda10178887be5dff9e901d6a0a519b67bc/gopherage/pkg/cov/aggregate.go#L26-L37 | test |
kubernetes/test-infra | gopherage/pkg/cov/aggregate.go | countToBoolean | func countToBoolean(profile []*cover.Profile) []*cover.Profile {
setProfile := make([]*cover.Profile, 0, len(profile))
for _, p := range profile {
pc := deepCopyProfile(*p)
for i := range pc.Blocks {
if pc.Blocks[i].Count > 0 {
pc.Blocks[i].Count = 1
}
}
setProfile = append(setProfile, &pc)
}
retu... | go | func countToBoolean(profile []*cover.Profile) []*cover.Profile {
setProfile := make([]*cover.Profile, 0, len(profile))
for _, p := range profile {
pc := deepCopyProfile(*p)
for i := range pc.Blocks {
if pc.Blocks[i].Count > 0 {
pc.Blocks[i].Count = 1
}
}
setProfile = append(setProfile, &pc)
}
retu... | [
"func",
"countToBoolean",
"(",
"profile",
"[",
"]",
"*",
"cover",
".",
"Profile",
")",
"[",
"]",
"*",
"cover",
".",
"Profile",
"{",
"setProfile",
":=",
"make",
"(",
"[",
"]",
"*",
"cover",
".",
"Profile",
",",
"0",
",",
"len",
"(",
"profile",
")",
... | // countToBoolean converts a profile containing hit counts to instead contain
// only 1s or 0s. | [
"countToBoolean",
"converts",
"a",
"profile",
"containing",
"hit",
"counts",
"to",
"instead",
"contain",
"only",
"1s",
"or",
"0s",
"."
] | 8125fbda10178887be5dff9e901d6a0a519b67bc | https://github.com/kubernetes/test-infra/blob/8125fbda10178887be5dff9e901d6a0a519b67bc/gopherage/pkg/cov/aggregate.go#L41-L53 | test |
kubernetes/test-infra | boskos/ranch/storage.go | NewStorage | func NewStorage(r storage.PersistenceLayer, storage string) (*Storage, error) {
s := &Storage{
resources: r,
}
if storage != "" {
var data struct {
Resources []common.Resource
}
buf, err := ioutil.ReadFile(storage)
if err == nil {
logrus.Infof("Current state: %s.", string(buf))
err = json.Unmarsh... | go | func NewStorage(r storage.PersistenceLayer, storage string) (*Storage, error) {
s := &Storage{
resources: r,
}
if storage != "" {
var data struct {
Resources []common.Resource
}
buf, err := ioutil.ReadFile(storage)
if err == nil {
logrus.Infof("Current state: %s.", string(buf))
err = json.Unmarsh... | [
"func",
"NewStorage",
"(",
"r",
"storage",
".",
"PersistenceLayer",
",",
"storage",
"string",
")",
"(",
"*",
"Storage",
",",
"error",
")",
"{",
"s",
":=",
"&",
"Storage",
"{",
"resources",
":",
"r",
",",
"}",
"\n",
"if",
"storage",
"!=",
"\"\"",
"{",... | // NewStorage instantiates a new Storage with a PersistenceLayer implementation
// If storage string is not empty, it will read resource data from the file | [
"NewStorage",
"instantiates",
"a",
"new",
"Storage",
"with",
"a",
"PersistenceLayer",
"implementation",
"If",
"storage",
"string",
"is",
"not",
"empty",
"it",
"will",
"read",
"resource",
"data",
"from",
"the",
"file"
] | 8125fbda10178887be5dff9e901d6a0a519b67bc | https://github.com/kubernetes/test-infra/blob/8125fbda10178887be5dff9e901d6a0a519b67bc/boskos/ranch/storage.go#L42-L71 | test |
kubernetes/test-infra | boskos/ranch/storage.go | AddResource | func (s *Storage) AddResource(resource common.Resource) error {
return s.resources.Add(resource)
} | go | func (s *Storage) AddResource(resource common.Resource) error {
return s.resources.Add(resource)
} | [
"func",
"(",
"s",
"*",
"Storage",
")",
"AddResource",
"(",
"resource",
"common",
".",
"Resource",
")",
"error",
"{",
"return",
"s",
".",
"resources",
".",
"Add",
"(",
"resource",
")",
"\n",
"}"
] | // AddResource adds a new resource | [
"AddResource",
"adds",
"a",
"new",
"resource"
] | 8125fbda10178887be5dff9e901d6a0a519b67bc | https://github.com/kubernetes/test-infra/blob/8125fbda10178887be5dff9e901d6a0a519b67bc/boskos/ranch/storage.go#L74-L76 | test |
kubernetes/test-infra | boskos/ranch/storage.go | DeleteResource | func (s *Storage) DeleteResource(name string) error {
return s.resources.Delete(name)
} | go | func (s *Storage) DeleteResource(name string) error {
return s.resources.Delete(name)
} | [
"func",
"(",
"s",
"*",
"Storage",
")",
"DeleteResource",
"(",
"name",
"string",
")",
"error",
"{",
"return",
"s",
".",
"resources",
".",
"Delete",
"(",
"name",
")",
"\n",
"}"
] | // DeleteResource deletes a resource if it exists, errors otherwise | [
"DeleteResource",
"deletes",
"a",
"resource",
"if",
"it",
"exists",
"errors",
"otherwise"
] | 8125fbda10178887be5dff9e901d6a0a519b67bc | https://github.com/kubernetes/test-infra/blob/8125fbda10178887be5dff9e901d6a0a519b67bc/boskos/ranch/storage.go#L79-L81 | test |
kubernetes/test-infra | boskos/ranch/storage.go | UpdateResource | func (s *Storage) UpdateResource(resource common.Resource) error {
return s.resources.Update(resource)
} | go | func (s *Storage) UpdateResource(resource common.Resource) error {
return s.resources.Update(resource)
} | [
"func",
"(",
"s",
"*",
"Storage",
")",
"UpdateResource",
"(",
"resource",
"common",
".",
"Resource",
")",
"error",
"{",
"return",
"s",
".",
"resources",
".",
"Update",
"(",
"resource",
")",
"\n",
"}"
] | // UpdateResource updates a resource if it exists, errors otherwise | [
"UpdateResource",
"updates",
"a",
"resource",
"if",
"it",
"exists",
"errors",
"otherwise"
] | 8125fbda10178887be5dff9e901d6a0a519b67bc | https://github.com/kubernetes/test-infra/blob/8125fbda10178887be5dff9e901d6a0a519b67bc/boskos/ranch/storage.go#L84-L86 | test |
kubernetes/test-infra | boskos/ranch/storage.go | GetResource | func (s *Storage) GetResource(name string) (common.Resource, error) {
i, err := s.resources.Get(name)
if err != nil {
return common.Resource{}, err
}
var res common.Resource
res, err = common.ItemToResource(i)
if err != nil {
return common.Resource{}, err
}
return res, nil
} | go | func (s *Storage) GetResource(name string) (common.Resource, error) {
i, err := s.resources.Get(name)
if err != nil {
return common.Resource{}, err
}
var res common.Resource
res, err = common.ItemToResource(i)
if err != nil {
return common.Resource{}, err
}
return res, nil
} | [
"func",
"(",
"s",
"*",
"Storage",
")",
"GetResource",
"(",
"name",
"string",
")",
"(",
"common",
".",
"Resource",
",",
"error",
")",
"{",
"i",
",",
"err",
":=",
"s",
".",
"resources",
".",
"Get",
"(",
"name",
")",
"\n",
"if",
"err",
"!=",
"nil",
... | // GetResource gets an existing resource, errors otherwise | [
"GetResource",
"gets",
"an",
"existing",
"resource",
"errors",
"otherwise"
] | 8125fbda10178887be5dff9e901d6a0a519b67bc | https://github.com/kubernetes/test-infra/blob/8125fbda10178887be5dff9e901d6a0a519b67bc/boskos/ranch/storage.go#L89-L100 | test |
kubernetes/test-infra | boskos/ranch/storage.go | GetResources | func (s *Storage) GetResources() ([]common.Resource, error) {
var resources []common.Resource
items, err := s.resources.List()
if err != nil {
return resources, err
}
for _, i := range items {
var res common.Resource
res, err = common.ItemToResource(i)
if err != nil {
return nil, err
}
resources = a... | go | func (s *Storage) GetResources() ([]common.Resource, error) {
var resources []common.Resource
items, err := s.resources.List()
if err != nil {
return resources, err
}
for _, i := range items {
var res common.Resource
res, err = common.ItemToResource(i)
if err != nil {
return nil, err
}
resources = a... | [
"func",
"(",
"s",
"*",
"Storage",
")",
"GetResources",
"(",
")",
"(",
"[",
"]",
"common",
".",
"Resource",
",",
"error",
")",
"{",
"var",
"resources",
"[",
"]",
"common",
".",
"Resource",
"\n",
"items",
",",
"err",
":=",
"s",
".",
"resources",
".",... | // GetResources list all resources | [
"GetResources",
"list",
"all",
"resources"
] | 8125fbda10178887be5dff9e901d6a0a519b67bc | https://github.com/kubernetes/test-infra/blob/8125fbda10178887be5dff9e901d6a0a519b67bc/boskos/ranch/storage.go#L103-L119 | test |
kubernetes/test-infra | boskos/ranch/storage.go | SyncResources | func (s *Storage) SyncResources(data []common.Resource) error {
s.resourcesLock.Lock()
defer s.resourcesLock.Unlock()
resources, err := s.GetResources()
if err != nil {
logrus.WithError(err).Error("cannot find resources")
return err
}
var finalError error
// delete non-exist resource
valid := 0
for _, r... | go | func (s *Storage) SyncResources(data []common.Resource) error {
s.resourcesLock.Lock()
defer s.resourcesLock.Unlock()
resources, err := s.GetResources()
if err != nil {
logrus.WithError(err).Error("cannot find resources")
return err
}
var finalError error
// delete non-exist resource
valid := 0
for _, r... | [
"func",
"(",
"s",
"*",
"Storage",
")",
"SyncResources",
"(",
"data",
"[",
"]",
"common",
".",
"Resource",
")",
"error",
"{",
"s",
".",
"resourcesLock",
".",
"Lock",
"(",
")",
"\n",
"defer",
"s",
".",
"resourcesLock",
".",
"Unlock",
"(",
")",
"\n",
... | // SyncResources will update resources every 10 mins.
// It will append newly added resources to ranch.Resources,
// And try to remove newly deleted resources from ranch.Resources.
// If the newly deleted resource is currently held by a user, the deletion will
// yield to next update cycle. | [
"SyncResources",
"will",
"update",
"resources",
"every",
"10",
"mins",
".",
"It",
"will",
"append",
"newly",
"added",
"resources",
"to",
"ranch",
".",
"Resources",
"And",
"try",
"to",
"remove",
"newly",
"deleted",
"resources",
"from",
"ranch",
".",
"Resources"... | 8125fbda10178887be5dff9e901d6a0a519b67bc | https://github.com/kubernetes/test-infra/blob/8125fbda10178887be5dff9e901d6a0a519b67bc/boskos/ranch/storage.go#L126-L191 | test |
kubernetes/test-infra | boskos/ranch/storage.go | ParseConfig | func ParseConfig(configPath string) ([]common.Resource, error) {
file, err := ioutil.ReadFile(configPath)
if err != nil {
return nil, err
}
var data common.BoskosConfig
err = yaml.Unmarshal(file, &data)
if err != nil {
return nil, err
}
var resources []common.Resource
for _, entry := range data.Resources... | go | func ParseConfig(configPath string) ([]common.Resource, error) {
file, err := ioutil.ReadFile(configPath)
if err != nil {
return nil, err
}
var data common.BoskosConfig
err = yaml.Unmarshal(file, &data)
if err != nil {
return nil, err
}
var resources []common.Resource
for _, entry := range data.Resources... | [
"func",
"ParseConfig",
"(",
"configPath",
"string",
")",
"(",
"[",
"]",
"common",
".",
"Resource",
",",
"error",
")",
"{",
"file",
",",
"err",
":=",
"ioutil",
".",
"ReadFile",
"(",
"configPath",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"ni... | // ParseConfig reads in configPath and returns a list of resource objects
// on success. | [
"ParseConfig",
"reads",
"in",
"configPath",
"and",
"returns",
"a",
"list",
"of",
"resource",
"objects",
"on",
"success",
"."
] | 8125fbda10178887be5dff9e901d6a0a519b67bc | https://github.com/kubernetes/test-infra/blob/8125fbda10178887be5dff9e901d6a0a519b67bc/boskos/ranch/storage.go#L195-L212 | test |
kubernetes/test-infra | prow/plugins/buildifier/buildifier.go | problemsInFiles | func problemsInFiles(r *git.Repo, files map[string]string) (map[string][]string, error) {
problems := make(map[string][]string)
for f := range files {
src, err := ioutil.ReadFile(filepath.Join(r.Dir, f))
if err != nil {
return nil, err
}
// This is modeled after the logic from buildifier:
// https://gith... | go | func problemsInFiles(r *git.Repo, files map[string]string) (map[string][]string, error) {
problems := make(map[string][]string)
for f := range files {
src, err := ioutil.ReadFile(filepath.Join(r.Dir, f))
if err != nil {
return nil, err
}
// This is modeled after the logic from buildifier:
// https://gith... | [
"func",
"problemsInFiles",
"(",
"r",
"*",
"git",
".",
"Repo",
",",
"files",
"map",
"[",
"string",
"]",
"string",
")",
"(",
"map",
"[",
"string",
"]",
"[",
"]",
"string",
",",
"error",
")",
"{",
"problems",
":=",
"make",
"(",
"map",
"[",
"string",
... | // problemsInFiles runs buildifier on the files. It returns a map from the file to
// a list of problems with that file. | [
"problemsInFiles",
"runs",
"buildifier",
"on",
"the",
"files",
".",
"It",
"returns",
"a",
"map",
"from",
"the",
"file",
"to",
"a",
"list",
"of",
"problems",
"with",
"that",
"file",
"."
] | 8125fbda10178887be5dff9e901d6a0a519b67bc | https://github.com/kubernetes/test-infra/blob/8125fbda10178887be5dff9e901d6a0a519b67bc/prow/plugins/buildifier/buildifier.go#L127-L150 | test |
kubernetes/test-infra | prow/spyglass/podlogartifact.go | NewPodLogArtifact | func NewPodLogArtifact(jobName string, buildID string, sizeLimit int64, ja jobAgent) (*PodLogArtifact, error) {
if jobName == "" {
return nil, errInsufficientJobInfo
}
if buildID == "" {
return nil, errInsufficientJobInfo
}
if sizeLimit < 0 {
return nil, errInvalidSizeLimit
}
return &PodLogArtifact{
name... | go | func NewPodLogArtifact(jobName string, buildID string, sizeLimit int64, ja jobAgent) (*PodLogArtifact, error) {
if jobName == "" {
return nil, errInsufficientJobInfo
}
if buildID == "" {
return nil, errInsufficientJobInfo
}
if sizeLimit < 0 {
return nil, errInvalidSizeLimit
}
return &PodLogArtifact{
name... | [
"func",
"NewPodLogArtifact",
"(",
"jobName",
"string",
",",
"buildID",
"string",
",",
"sizeLimit",
"int64",
",",
"ja",
"jobAgent",
")",
"(",
"*",
"PodLogArtifact",
",",
"error",
")",
"{",
"if",
"jobName",
"==",
"\"\"",
"{",
"return",
"nil",
",",
"errInsuff... | // NewPodLogArtifact creates a new PodLogArtifact | [
"NewPodLogArtifact",
"creates",
"a",
"new",
"PodLogArtifact"
] | 8125fbda10178887be5dff9e901d6a0a519b67bc | https://github.com/kubernetes/test-infra/blob/8125fbda10178887be5dff9e901d6a0a519b67bc/prow/spyglass/podlogartifact.go#L50-L66 | test |
kubernetes/test-infra | prow/spyglass/podlogartifact.go | CanonicalLink | func (a *PodLogArtifact) CanonicalLink() string {
q := url.Values{
"job": []string{a.name},
"id": []string{a.buildID},
}
u := url.URL{
Path: "/log",
RawQuery: q.Encode(),
}
return u.String()
} | go | func (a *PodLogArtifact) CanonicalLink() string {
q := url.Values{
"job": []string{a.name},
"id": []string{a.buildID},
}
u := url.URL{
Path: "/log",
RawQuery: q.Encode(),
}
return u.String()
} | [
"func",
"(",
"a",
"*",
"PodLogArtifact",
")",
"CanonicalLink",
"(",
")",
"string",
"{",
"q",
":=",
"url",
".",
"Values",
"{",
"\"job\"",
":",
"[",
"]",
"string",
"{",
"a",
".",
"name",
"}",
",",
"\"id\"",
":",
"[",
"]",
"string",
"{",
"a",
".",
... | // CanonicalLink returns a link to where pod logs are streamed | [
"CanonicalLink",
"returns",
"a",
"link",
"to",
"where",
"pod",
"logs",
"are",
"streamed"
] | 8125fbda10178887be5dff9e901d6a0a519b67bc | https://github.com/kubernetes/test-infra/blob/8125fbda10178887be5dff9e901d6a0a519b67bc/prow/spyglass/podlogartifact.go#L69-L79 | test |
kubernetes/test-infra | prow/spyglass/podlogartifact.go | ReadAt | func (a *PodLogArtifact) ReadAt(p []byte, off int64) (n int, err error) {
logs, err := a.jobAgent.GetJobLog(a.name, a.buildID)
if err != nil {
return 0, fmt.Errorf("error getting pod log: %v", err)
}
r := bytes.NewReader(logs)
readBytes, err := r.ReadAt(p, off)
if err == io.EOF {
return readBytes, io.EOF
}
... | go | func (a *PodLogArtifact) ReadAt(p []byte, off int64) (n int, err error) {
logs, err := a.jobAgent.GetJobLog(a.name, a.buildID)
if err != nil {
return 0, fmt.Errorf("error getting pod log: %v", err)
}
r := bytes.NewReader(logs)
readBytes, err := r.ReadAt(p, off)
if err == io.EOF {
return readBytes, io.EOF
}
... | [
"func",
"(",
"a",
"*",
"PodLogArtifact",
")",
"ReadAt",
"(",
"p",
"[",
"]",
"byte",
",",
"off",
"int64",
")",
"(",
"n",
"int",
",",
"err",
"error",
")",
"{",
"logs",
",",
"err",
":=",
"a",
".",
"jobAgent",
".",
"GetJobLog",
"(",
"a",
".",
"name... | // ReadAt implements reading a range of bytes from the pod logs endpoint | [
"ReadAt",
"implements",
"reading",
"a",
"range",
"of",
"bytes",
"from",
"the",
"pod",
"logs",
"endpoint"
] | 8125fbda10178887be5dff9e901d6a0a519b67bc | https://github.com/kubernetes/test-infra/blob/8125fbda10178887be5dff9e901d6a0a519b67bc/prow/spyglass/podlogartifact.go#L89-L103 | test |
kubernetes/test-infra | prow/spyglass/podlogartifact.go | ReadAll | func (a *PodLogArtifact) ReadAll() ([]byte, error) {
size, err := a.Size()
if err != nil {
return nil, fmt.Errorf("error getting pod log size: %v", err)
}
if size > a.sizeLimit {
return nil, lenses.ErrFileTooLarge
}
logs, err := a.jobAgent.GetJobLog(a.name, a.buildID)
if err != nil {
return nil, fmt.Errorf... | go | func (a *PodLogArtifact) ReadAll() ([]byte, error) {
size, err := a.Size()
if err != nil {
return nil, fmt.Errorf("error getting pod log size: %v", err)
}
if size > a.sizeLimit {
return nil, lenses.ErrFileTooLarge
}
logs, err := a.jobAgent.GetJobLog(a.name, a.buildID)
if err != nil {
return nil, fmt.Errorf... | [
"func",
"(",
"a",
"*",
"PodLogArtifact",
")",
"ReadAll",
"(",
")",
"(",
"[",
"]",
"byte",
",",
"error",
")",
"{",
"size",
",",
"err",
":=",
"a",
".",
"Size",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"fmt",
".",
"Er... | // ReadAll reads all available pod logs, failing if they are too large | [
"ReadAll",
"reads",
"all",
"available",
"pod",
"logs",
"failing",
"if",
"they",
"are",
"too",
"large"
] | 8125fbda10178887be5dff9e901d6a0a519b67bc | https://github.com/kubernetes/test-infra/blob/8125fbda10178887be5dff9e901d6a0a519b67bc/prow/spyglass/podlogartifact.go#L106-L119 | test |
kubernetes/test-infra | prow/spyglass/podlogartifact.go | ReadAtMost | func (a *PodLogArtifact) ReadAtMost(n int64) ([]byte, error) {
logs, err := a.jobAgent.GetJobLog(a.name, a.buildID)
if err != nil {
return nil, fmt.Errorf("error getting pod log: %v", err)
}
reader := bytes.NewReader(logs)
var byteCount int64
var p []byte
for byteCount < n {
b, err := reader.ReadByte()
if ... | go | func (a *PodLogArtifact) ReadAtMost(n int64) ([]byte, error) {
logs, err := a.jobAgent.GetJobLog(a.name, a.buildID)
if err != nil {
return nil, fmt.Errorf("error getting pod log: %v", err)
}
reader := bytes.NewReader(logs)
var byteCount int64
var p []byte
for byteCount < n {
b, err := reader.ReadByte()
if ... | [
"func",
"(",
"a",
"*",
"PodLogArtifact",
")",
"ReadAtMost",
"(",
"n",
"int64",
")",
"(",
"[",
"]",
"byte",
",",
"error",
")",
"{",
"logs",
",",
"err",
":=",
"a",
".",
"jobAgent",
".",
"GetJobLog",
"(",
"a",
".",
"name",
",",
"a",
".",
"buildID",
... | // ReadAtMost reads at most n bytes | [
"ReadAtMost",
"reads",
"at",
"most",
"n",
"bytes"
] | 8125fbda10178887be5dff9e901d6a0a519b67bc | https://github.com/kubernetes/test-infra/blob/8125fbda10178887be5dff9e901d6a0a519b67bc/prow/spyglass/podlogartifact.go#L122-L142 | test |
kubernetes/test-infra | prow/spyglass/podlogartifact.go | ReadTail | func (a *PodLogArtifact) ReadTail(n int64) ([]byte, error) {
logs, err := a.jobAgent.GetJobLog(a.name, a.buildID)
if err != nil {
return nil, fmt.Errorf("error getting pod log tail: %v", err)
}
size := int64(len(logs))
var off int64
if n > size {
off = 0
} else {
off = size - n
}
p := make([]byte, n)
re... | go | func (a *PodLogArtifact) ReadTail(n int64) ([]byte, error) {
logs, err := a.jobAgent.GetJobLog(a.name, a.buildID)
if err != nil {
return nil, fmt.Errorf("error getting pod log tail: %v", err)
}
size := int64(len(logs))
var off int64
if n > size {
off = 0
} else {
off = size - n
}
p := make([]byte, n)
re... | [
"func",
"(",
"a",
"*",
"PodLogArtifact",
")",
"ReadTail",
"(",
"n",
"int64",
")",
"(",
"[",
"]",
"byte",
",",
"error",
")",
"{",
"logs",
",",
"err",
":=",
"a",
".",
"jobAgent",
".",
"GetJobLog",
"(",
"a",
".",
"name",
",",
"a",
".",
"buildID",
... | // ReadTail reads the last n bytes of the pod log | [
"ReadTail",
"reads",
"the",
"last",
"n",
"bytes",
"of",
"the",
"pod",
"log"
] | 8125fbda10178887be5dff9e901d6a0a519b67bc | https://github.com/kubernetes/test-infra/blob/8125fbda10178887be5dff9e901d6a0a519b67bc/prow/spyglass/podlogartifact.go#L145-L163 | test |
kubernetes/test-infra | prow/plugins/golint/golint.go | newProblems | func newProblems(cs []github.ReviewComment, ps map[string]map[int]lint.Problem) map[string]map[int]lint.Problem {
// Make a copy, then remove the old elements.
res := make(map[string]map[int]lint.Problem)
for f, ls := range ps {
res[f] = make(map[int]lint.Problem)
for l, p := range ls {
res[f][l] = p
}
}
... | go | func newProblems(cs []github.ReviewComment, ps map[string]map[int]lint.Problem) map[string]map[int]lint.Problem {
// Make a copy, then remove the old elements.
res := make(map[string]map[int]lint.Problem)
for f, ls := range ps {
res[f] = make(map[int]lint.Problem)
for l, p := range ls {
res[f][l] = p
}
}
... | [
"func",
"newProblems",
"(",
"cs",
"[",
"]",
"github",
".",
"ReviewComment",
",",
"ps",
"map",
"[",
"string",
"]",
"map",
"[",
"int",
"]",
"lint",
".",
"Problem",
")",
"map",
"[",
"string",
"]",
"map",
"[",
"int",
"]",
"lint",
".",
"Problem",
"{",
... | // newProblems compares the list of problems with the list of past comments on
// the PR to decide which are new. | [
"newProblems",
"compares",
"the",
"list",
"of",
"problems",
"with",
"the",
"list",
"of",
"past",
"comments",
"on",
"the",
"PR",
"to",
"decide",
"which",
"are",
"new",
"."
] | 8125fbda10178887be5dff9e901d6a0a519b67bc | https://github.com/kubernetes/test-infra/blob/8125fbda10178887be5dff9e901d6a0a519b67bc/prow/plugins/golint/golint.go#L121-L140 | test |
kubernetes/test-infra | prow/plugins/golint/golint.go | problemsInFiles | func problemsInFiles(r *git.Repo, files map[string]string) (map[string]map[int]lint.Problem, []github.DraftReviewComment) {
problems := make(map[string]map[int]lint.Problem)
var lintErrorComments []github.DraftReviewComment
l := new(lint.Linter)
for f, patch := range files {
problems[f] = make(map[int]lint.Proble... | go | func problemsInFiles(r *git.Repo, files map[string]string) (map[string]map[int]lint.Problem, []github.DraftReviewComment) {
problems := make(map[string]map[int]lint.Problem)
var lintErrorComments []github.DraftReviewComment
l := new(lint.Linter)
for f, patch := range files {
problems[f] = make(map[int]lint.Proble... | [
"func",
"problemsInFiles",
"(",
"r",
"*",
"git",
".",
"Repo",
",",
"files",
"map",
"[",
"string",
"]",
"string",
")",
"(",
"map",
"[",
"string",
"]",
"map",
"[",
"int",
"]",
"lint",
".",
"Problem",
",",
"[",
"]",
"github",
".",
"DraftReviewComment",
... | // problemsInFiles runs golint on the files. It returns a map from the file to
// a map from the line in the patch to the problem. | [
"problemsInFiles",
"runs",
"golint",
"on",
"the",
"files",
".",
"It",
"returns",
"a",
"map",
"from",
"the",
"file",
"to",
"a",
"map",
"from",
"the",
"line",
"in",
"the",
"patch",
"to",
"the",
"problem",
"."
] | 8125fbda10178887be5dff9e901d6a0a519b67bc | https://github.com/kubernetes/test-infra/blob/8125fbda10178887be5dff9e901d6a0a519b67bc/prow/plugins/golint/golint.go#L144-L197 | test |
kubernetes/test-infra | config/jobs/kubernetes-security/genjobs.go | undoPreset | func undoPreset(preset *config.Preset, labels map[string]string, pod *coreapi.PodSpec) {
// skip presets that do not match the job labels
for l, v := range preset.Labels {
if v2, ok := labels[l]; !ok || v2 != v {
return
}
}
// collect up preset created keys
removeEnvNames := sets.NewString()
for _, e1 := ... | go | func undoPreset(preset *config.Preset, labels map[string]string, pod *coreapi.PodSpec) {
// skip presets that do not match the job labels
for l, v := range preset.Labels {
if v2, ok := labels[l]; !ok || v2 != v {
return
}
}
// collect up preset created keys
removeEnvNames := sets.NewString()
for _, e1 := ... | [
"func",
"undoPreset",
"(",
"preset",
"*",
"config",
".",
"Preset",
",",
"labels",
"map",
"[",
"string",
"]",
"string",
",",
"pod",
"*",
"coreapi",
".",
"PodSpec",
")",
"{",
"for",
"l",
",",
"v",
":=",
"range",
"preset",
".",
"Labels",
"{",
"if",
"v... | // remove merged presets from a podspec | [
"remove",
"merged",
"presets",
"from",
"a",
"podspec"
] | 8125fbda10178887be5dff9e901d6a0a519b67bc | https://github.com/kubernetes/test-infra/blob/8125fbda10178887be5dff9e901d6a0a519b67bc/config/jobs/kubernetes-security/genjobs.go#L55-L104 | test |
kubernetes/test-infra | config/jobs/kubernetes-security/genjobs.go | undoPresubmitPresets | func undoPresubmitPresets(presets []config.Preset, presubmit *config.Presubmit) {
if presubmit.Spec == nil {
return
}
for _, preset := range presets {
undoPreset(&preset, presubmit.Labels, presubmit.Spec)
}
} | go | func undoPresubmitPresets(presets []config.Preset, presubmit *config.Presubmit) {
if presubmit.Spec == nil {
return
}
for _, preset := range presets {
undoPreset(&preset, presubmit.Labels, presubmit.Spec)
}
} | [
"func",
"undoPresubmitPresets",
"(",
"presets",
"[",
"]",
"config",
".",
"Preset",
",",
"presubmit",
"*",
"config",
".",
"Presubmit",
")",
"{",
"if",
"presubmit",
".",
"Spec",
"==",
"nil",
"{",
"return",
"\n",
"}",
"\n",
"for",
"_",
",",
"preset",
":="... | // undo merged presets from loaded presubmit and its children | [
"undo",
"merged",
"presets",
"from",
"loaded",
"presubmit",
"and",
"its",
"children"
] | 8125fbda10178887be5dff9e901d6a0a519b67bc | https://github.com/kubernetes/test-infra/blob/8125fbda10178887be5dff9e901d6a0a519b67bc/config/jobs/kubernetes-security/genjobs.go#L107-L114 | test |
kubernetes/test-infra | config/jobs/kubernetes-security/genjobs.go | yamlBytesStripNulls | func yamlBytesStripNulls(yamlBytes []byte) []byte {
nullRE := regexp.MustCompile("(?m)[\n]+^[^\n]+: null$")
return nullRE.ReplaceAll(yamlBytes, []byte{})
} | go | func yamlBytesStripNulls(yamlBytes []byte) []byte {
nullRE := regexp.MustCompile("(?m)[\n]+^[^\n]+: null$")
return nullRE.ReplaceAll(yamlBytes, []byte{})
} | [
"func",
"yamlBytesStripNulls",
"(",
"yamlBytes",
"[",
"]",
"byte",
")",
"[",
"]",
"byte",
"{",
"nullRE",
":=",
"regexp",
".",
"MustCompile",
"(",
"\"(?m)[\\n]+^[^\\n]+: null$\"",
")",
"\n",
"\\n",
"\n",
"}"
] | // these are unnecessary, and make the config larger so we strip them out | [
"these",
"are",
"unnecessary",
"and",
"make",
"the",
"config",
"larger",
"so",
"we",
"strip",
"them",
"out"
] | 8125fbda10178887be5dff9e901d6a0a519b67bc | https://github.com/kubernetes/test-infra/blob/8125fbda10178887be5dff9e901d6a0a519b67bc/config/jobs/kubernetes-security/genjobs.go#L266-L269 | test |
kubernetes/test-infra | greenhouse/eviction.go | monitorDiskAndEvict | func monitorDiskAndEvict(
c *diskcache.Cache,
interval time.Duration,
minPercentBlocksFree, evictUntilPercentBlocksFree float64,
) {
diskRoot := c.DiskRoot()
// forever check if usage is past thresholds and evict
ticker := time.NewTicker(interval)
for ; true; <-ticker.C {
blocksFree, _, _, err := diskutil.GetD... | go | func monitorDiskAndEvict(
c *diskcache.Cache,
interval time.Duration,
minPercentBlocksFree, evictUntilPercentBlocksFree float64,
) {
diskRoot := c.DiskRoot()
// forever check if usage is past thresholds and evict
ticker := time.NewTicker(interval)
for ; true; <-ticker.C {
blocksFree, _, _, err := diskutil.GetD... | [
"func",
"monitorDiskAndEvict",
"(",
"c",
"*",
"diskcache",
".",
"Cache",
",",
"interval",
"time",
".",
"Duration",
",",
"minPercentBlocksFree",
",",
"evictUntilPercentBlocksFree",
"float64",
",",
")",
"{",
"diskRoot",
":=",
"c",
".",
"DiskRoot",
"(",
")",
"\n"... | // monitorDiskAndEvict loops monitoring the disk, evicting cache entries
// when the disk passes either minPercentBlocksFree until the disk is above
// evictUntilPercentBlocksFree | [
"monitorDiskAndEvict",
"loops",
"monitoring",
"the",
"disk",
"evicting",
"cache",
"entries",
"when",
"the",
"disk",
"passes",
"either",
"minPercentBlocksFree",
"until",
"the",
"disk",
"is",
"above",
"evictUntilPercentBlocksFree"
] | 8125fbda10178887be5dff9e901d6a0a519b67bc | https://github.com/kubernetes/test-infra/blob/8125fbda10178887be5dff9e901d6a0a519b67bc/greenhouse/eviction.go#L31-L88 | test |
kubernetes/test-infra | prow/cmd/checkconfig/main.go | difference | func (c *orgRepoConfig) difference(c2 *orgRepoConfig) *orgRepoConfig {
res := &orgRepoConfig{
orgExceptions: make(map[string]sets.String),
repos: sets.NewString().Union(c.repos),
}
for org, excepts1 := range c.orgExceptions {
if excepts2, ok := c2.orgExceptions[org]; ok {
res.repos.Insert(excepts2.D... | go | func (c *orgRepoConfig) difference(c2 *orgRepoConfig) *orgRepoConfig {
res := &orgRepoConfig{
orgExceptions: make(map[string]sets.String),
repos: sets.NewString().Union(c.repos),
}
for org, excepts1 := range c.orgExceptions {
if excepts2, ok := c2.orgExceptions[org]; ok {
res.repos.Insert(excepts2.D... | [
"func",
"(",
"c",
"*",
"orgRepoConfig",
")",
"difference",
"(",
"c2",
"*",
"orgRepoConfig",
")",
"*",
"orgRepoConfig",
"{",
"res",
":=",
"&",
"orgRepoConfig",
"{",
"orgExceptions",
":",
"make",
"(",
"map",
"[",
"string",
"]",
"sets",
".",
"String",
")",
... | // difference returns a new orgRepoConfig that represents the set difference of
// the repos specified by the receiver and the parameter orgRepoConfigs. | [
"difference",
"returns",
"a",
"new",
"orgRepoConfig",
"that",
"represents",
"the",
"set",
"difference",
"of",
"the",
"repos",
"specified",
"by",
"the",
"receiver",
"and",
"the",
"parameter",
"orgRepoConfigs",
"."
] | 8125fbda10178887be5dff9e901d6a0a519b67bc | https://github.com/kubernetes/test-infra/blob/8125fbda10178887be5dff9e901d6a0a519b67bc/prow/cmd/checkconfig/main.go#L586-L616 | test |
kubernetes/test-infra | prow/cmd/checkconfig/main.go | union | func (c *orgRepoConfig) union(c2 *orgRepoConfig) *orgRepoConfig {
res := &orgRepoConfig{
orgExceptions: make(map[string]sets.String),
repos: sets.NewString(),
}
for org, excepts1 := range c.orgExceptions {
// keep only items in both blacklists that are not in the
// explicit repo whitelists for the ... | go | func (c *orgRepoConfig) union(c2 *orgRepoConfig) *orgRepoConfig {
res := &orgRepoConfig{
orgExceptions: make(map[string]sets.String),
repos: sets.NewString(),
}
for org, excepts1 := range c.orgExceptions {
// keep only items in both blacklists that are not in the
// explicit repo whitelists for the ... | [
"func",
"(",
"c",
"*",
"orgRepoConfig",
")",
"union",
"(",
"c2",
"*",
"orgRepoConfig",
")",
"*",
"orgRepoConfig",
"{",
"res",
":=",
"&",
"orgRepoConfig",
"{",
"orgExceptions",
":",
"make",
"(",
"map",
"[",
"string",
"]",
"sets",
".",
"String",
")",
","... | // union returns a new orgRepoConfig that represents the set union of the
// repos specified by the receiver and the parameter orgRepoConfigs | [
"union",
"returns",
"a",
"new",
"orgRepoConfig",
"that",
"represents",
"the",
"set",
"union",
"of",
"the",
"repos",
"specified",
"by",
"the",
"receiver",
"and",
"the",
"parameter",
"orgRepoConfigs"
] | 8125fbda10178887be5dff9e901d6a0a519b67bc | https://github.com/kubernetes/test-infra/blob/8125fbda10178887be5dff9e901d6a0a519b67bc/prow/cmd/checkconfig/main.go#L653-L693 | test |
kubernetes/test-infra | prow/plugins/releasenote/releasenote.go | clearStaleComments | func clearStaleComments(gc githubClient, log *logrus.Entry, pr *github.PullRequestEvent, prLabels sets.String, comments []github.IssueComment) error {
// If the PR must follow the process and hasn't yet completed the process, don't remove comments.
if prMustFollowRelNoteProcess(gc, log, pr, prLabels, false) && !relea... | go | func clearStaleComments(gc githubClient, log *logrus.Entry, pr *github.PullRequestEvent, prLabels sets.String, comments []github.IssueComment) error {
// If the PR must follow the process and hasn't yet completed the process, don't remove comments.
if prMustFollowRelNoteProcess(gc, log, pr, prLabels, false) && !relea... | [
"func",
"clearStaleComments",
"(",
"gc",
"githubClient",
",",
"log",
"*",
"logrus",
".",
"Entry",
",",
"pr",
"*",
"github",
".",
"PullRequestEvent",
",",
"prLabels",
"sets",
".",
"String",
",",
"comments",
"[",
"]",
"github",
".",
"IssueComment",
")",
"err... | // clearStaleComments deletes old comments that are no longer applicable. | [
"clearStaleComments",
"deletes",
"old",
"comments",
"that",
"are",
"no",
"longer",
"applicable",
"."
] | 8125fbda10178887be5dff9e901d6a0a519b67bc | https://github.com/kubernetes/test-infra/blob/8125fbda10178887be5dff9e901d6a0a519b67bc/prow/plugins/releasenote/releasenote.go#L264-L284 | test |
kubernetes/test-infra | prow/plugins/releasenote/releasenote.go | determineReleaseNoteLabel | func determineReleaseNoteLabel(body string) string {
composedReleaseNote := strings.ToLower(strings.TrimSpace(getReleaseNote(body)))
if composedReleaseNote == "" {
return ReleaseNoteLabelNeeded
}
if noneRe.MatchString(composedReleaseNote) {
return releaseNoteNone
}
if strings.Contains(composedReleaseNote, ac... | go | func determineReleaseNoteLabel(body string) string {
composedReleaseNote := strings.ToLower(strings.TrimSpace(getReleaseNote(body)))
if composedReleaseNote == "" {
return ReleaseNoteLabelNeeded
}
if noneRe.MatchString(composedReleaseNote) {
return releaseNoteNone
}
if strings.Contains(composedReleaseNote, ac... | [
"func",
"determineReleaseNoteLabel",
"(",
"body",
"string",
")",
"string",
"{",
"composedReleaseNote",
":=",
"strings",
".",
"ToLower",
"(",
"strings",
".",
"TrimSpace",
"(",
"getReleaseNote",
"(",
"body",
")",
")",
")",
"\n",
"if",
"composedReleaseNote",
"==",
... | // determineReleaseNoteLabel returns the label to be added based on the contents of the 'release-note'
// section of a PR's body text. | [
"determineReleaseNoteLabel",
"returns",
"the",
"label",
"to",
"be",
"added",
"based",
"on",
"the",
"contents",
"of",
"the",
"release",
"-",
"note",
"section",
"of",
"a",
"PR",
"s",
"body",
"text",
"."
] | 8125fbda10178887be5dff9e901d6a0a519b67bc | https://github.com/kubernetes/test-infra/blob/8125fbda10178887be5dff9e901d6a0a519b67bc/prow/plugins/releasenote/releasenote.go#L308-L321 | test |
kubernetes/test-infra | prow/plugins/releasenote/releasenote.go | getReleaseNote | func getReleaseNote(body string) string {
potentialMatch := noteMatcherRE.FindStringSubmatch(body)
if potentialMatch == nil {
return ""
}
return strings.TrimSpace(potentialMatch[1])
} | go | func getReleaseNote(body string) string {
potentialMatch := noteMatcherRE.FindStringSubmatch(body)
if potentialMatch == nil {
return ""
}
return strings.TrimSpace(potentialMatch[1])
} | [
"func",
"getReleaseNote",
"(",
"body",
"string",
")",
"string",
"{",
"potentialMatch",
":=",
"noteMatcherRE",
".",
"FindStringSubmatch",
"(",
"body",
")",
"\n",
"if",
"potentialMatch",
"==",
"nil",
"{",
"return",
"\"\"",
"\n",
"}",
"\n",
"return",
"strings",
... | // getReleaseNote returns the release note from a PR body
// assumes that the PR body followed the PR template | [
"getReleaseNote",
"returns",
"the",
"release",
"note",
"from",
"a",
"PR",
"body",
"assumes",
"that",
"the",
"PR",
"body",
"followed",
"the",
"PR",
"template"
] | 8125fbda10178887be5dff9e901d6a0a519b67bc | https://github.com/kubernetes/test-infra/blob/8125fbda10178887be5dff9e901d6a0a519b67bc/prow/plugins/releasenote/releasenote.go#L325-L331 | test |
kubernetes/test-infra | boskos/mason/client.go | NewClient | func NewClient(boskosClient boskosClient) *Client {
return &Client{
basic: boskosClient,
resources: map[string]common.Resource{},
}
} | go | func NewClient(boskosClient boskosClient) *Client {
return &Client{
basic: boskosClient,
resources: map[string]common.Resource{},
}
} | [
"func",
"NewClient",
"(",
"boskosClient",
"boskosClient",
")",
"*",
"Client",
"{",
"return",
"&",
"Client",
"{",
"basic",
":",
"boskosClient",
",",
"resources",
":",
"map",
"[",
"string",
"]",
"common",
".",
"Resource",
"{",
"}",
",",
"}",
"\n",
"}"
] | // NewClient creates a new client from a boskosClient interface | [
"NewClient",
"creates",
"a",
"new",
"client",
"from",
"a",
"boskosClient",
"interface"
] | 8125fbda10178887be5dff9e901d6a0a519b67bc | https://github.com/kubernetes/test-infra/blob/8125fbda10178887be5dff9e901d6a0a519b67bc/boskos/mason/client.go#L37-L42 | test |
kubernetes/test-infra | boskos/mason/client.go | Acquire | func (c *Client) Acquire(rtype, state, dest string) (*common.Resource, error) {
var resourcesToRelease []common.Resource
releaseOnFailure := func() {
for _, r := range resourcesToRelease {
if err := c.basic.ReleaseOne(r.Name, common.Dirty); err != nil {
logrus.WithError(err).Warningf("failed to release resou... | go | func (c *Client) Acquire(rtype, state, dest string) (*common.Resource, error) {
var resourcesToRelease []common.Resource
releaseOnFailure := func() {
for _, r := range resourcesToRelease {
if err := c.basic.ReleaseOne(r.Name, common.Dirty); err != nil {
logrus.WithError(err).Warningf("failed to release resou... | [
"func",
"(",
"c",
"*",
"Client",
")",
"Acquire",
"(",
"rtype",
",",
"state",
",",
"dest",
"string",
")",
"(",
"*",
"common",
".",
"Resource",
",",
"error",
")",
"{",
"var",
"resourcesToRelease",
"[",
"]",
"common",
".",
"Resource",
"\n",
"releaseOnFail... | // Acquire gets a resource with associated leased resources | [
"Acquire",
"gets",
"a",
"resource",
"with",
"associated",
"leased",
"resources"
] | 8125fbda10178887be5dff9e901d6a0a519b67bc | https://github.com/kubernetes/test-infra/blob/8125fbda10178887be5dff9e901d6a0a519b67bc/boskos/mason/client.go#L45-L74 | test |
kubernetes/test-infra | boskos/mason/client.go | ReleaseOne | func (c *Client) ReleaseOne(name, dest string) (allErrors error) {
res, err := c.getResource(name)
if err != nil {
allErrors = err
return
}
resourceNames := []string{name}
var leasedResources common.LeasedResources
if err := res.UserData.Extract(LeasedResources, &leasedResources); err != nil {
if _, ok := e... | go | func (c *Client) ReleaseOne(name, dest string) (allErrors error) {
res, err := c.getResource(name)
if err != nil {
allErrors = err
return
}
resourceNames := []string{name}
var leasedResources common.LeasedResources
if err := res.UserData.Extract(LeasedResources, &leasedResources); err != nil {
if _, ok := e... | [
"func",
"(",
"c",
"*",
"Client",
")",
"ReleaseOne",
"(",
"name",
",",
"dest",
"string",
")",
"(",
"allErrors",
"error",
")",
"{",
"res",
",",
"err",
":=",
"c",
".",
"getResource",
"(",
"name",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"allErrors",
... | // ReleaseOne will release a resource as well as leased resources associated to it | [
"ReleaseOne",
"will",
"release",
"a",
"resource",
"as",
"well",
"as",
"leased",
"resources",
"associated",
"to",
"it"
] | 8125fbda10178887be5dff9e901d6a0a519b67bc | https://github.com/kubernetes/test-infra/blob/8125fbda10178887be5dff9e901d6a0a519b67bc/boskos/mason/client.go#L77-L105 | test |
kubernetes/test-infra | boskos/mason/client.go | UpdateAll | func (c *Client) UpdateAll(state string) error {
return c.basic.UpdateAll(state)
} | go | func (c *Client) UpdateAll(state string) error {
return c.basic.UpdateAll(state)
} | [
"func",
"(",
"c",
"*",
"Client",
")",
"UpdateAll",
"(",
"state",
"string",
")",
"error",
"{",
"return",
"c",
".",
"basic",
".",
"UpdateAll",
"(",
"state",
")",
"\n",
"}"
] | // UpdateAll updates all the acquired resources with a given state | [
"UpdateAll",
"updates",
"all",
"the",
"acquired",
"resources",
"with",
"a",
"given",
"state"
] | 8125fbda10178887be5dff9e901d6a0a519b67bc | https://github.com/kubernetes/test-infra/blob/8125fbda10178887be5dff9e901d6a0a519b67bc/boskos/mason/client.go#L108-L110 | test |
kubernetes/test-infra | velodrome/token-counter/token-counter.go | GetGitHubClient | func GetGitHubClient(token string) *github.Client {
return github.NewClient(
oauth2.NewClient(
oauth2.NoContext,
oauth2.StaticTokenSource(&oauth2.Token{AccessToken: token}),
),
)
} | go | func GetGitHubClient(token string) *github.Client {
return github.NewClient(
oauth2.NewClient(
oauth2.NoContext,
oauth2.StaticTokenSource(&oauth2.Token{AccessToken: token}),
),
)
} | [
"func",
"GetGitHubClient",
"(",
"token",
"string",
")",
"*",
"github",
".",
"Client",
"{",
"return",
"github",
".",
"NewClient",
"(",
"oauth2",
".",
"NewClient",
"(",
"oauth2",
".",
"NoContext",
",",
"oauth2",
".",
"StaticTokenSource",
"(",
"&",
"oauth2",
... | // GetGitHubClient creates a client for each token | [
"GetGitHubClient",
"creates",
"a",
"client",
"for",
"each",
"token"
] | 8125fbda10178887be5dff9e901d6a0a519b67bc | https://github.com/kubernetes/test-infra/blob/8125fbda10178887be5dff9e901d6a0a519b67bc/velodrome/token-counter/token-counter.go#L55-L62 | test |
kubernetes/test-infra | velodrome/token-counter/token-counter.go | GetUsername | func GetUsername(client *github.Client) (string, error) {
user, _, err := client.Users.Get(context.Background(), "")
if err != nil {
return "", err
}
if user.Login == nil {
return "", errors.New("Users.Get(\"\") returned empty login")
}
return *user.Login, nil
} | go | func GetUsername(client *github.Client) (string, error) {
user, _, err := client.Users.Get(context.Background(), "")
if err != nil {
return "", err
}
if user.Login == nil {
return "", errors.New("Users.Get(\"\") returned empty login")
}
return *user.Login, nil
} | [
"func",
"GetUsername",
"(",
"client",
"*",
"github",
".",
"Client",
")",
"(",
"string",
",",
"error",
")",
"{",
"user",
",",
"_",
",",
"err",
":=",
"client",
".",
"Users",
".",
"Get",
"(",
"context",
".",
"Background",
"(",
")",
",",
"\"\"",
")",
... | // GetUsername finds the login for each token | [
"GetUsername",
"finds",
"the",
"login",
"for",
"each",
"token"
] | 8125fbda10178887be5dff9e901d6a0a519b67bc | https://github.com/kubernetes/test-infra/blob/8125fbda10178887be5dff9e901d6a0a519b67bc/velodrome/token-counter/token-counter.go#L65-L75 | test |
kubernetes/test-infra | velodrome/token-counter/token-counter.go | CreateTokenHandler | func CreateTokenHandler(tokenStream io.Reader, influxdb *InfluxDB) (*TokenHandler, error) {
token, err := ioutil.ReadAll(tokenStream)
if err != nil {
return nil, err
}
client := GetGitHubClient(strings.TrimSpace(string(token)))
login, err := GetUsername(client) // Get user name for token
if err != nil {
retur... | go | func CreateTokenHandler(tokenStream io.Reader, influxdb *InfluxDB) (*TokenHandler, error) {
token, err := ioutil.ReadAll(tokenStream)
if err != nil {
return nil, err
}
client := GetGitHubClient(strings.TrimSpace(string(token)))
login, err := GetUsername(client) // Get user name for token
if err != nil {
retur... | [
"func",
"CreateTokenHandler",
"(",
"tokenStream",
"io",
".",
"Reader",
",",
"influxdb",
"*",
"InfluxDB",
")",
"(",
"*",
"TokenHandler",
",",
"error",
")",
"{",
"token",
",",
"err",
":=",
"ioutil",
".",
"ReadAll",
"(",
"tokenStream",
")",
"\n",
"if",
"err... | // CreateTokenHandler parses the token and create a handler | [
"CreateTokenHandler",
"parses",
"the",
"token",
"and",
"create",
"a",
"handler"
] | 8125fbda10178887be5dff9e901d6a0a519b67bc | https://github.com/kubernetes/test-infra/blob/8125fbda10178887be5dff9e901d6a0a519b67bc/velodrome/token-counter/token-counter.go#L78-L94 | test |
kubernetes/test-infra | velodrome/token-counter/token-counter.go | CreateTokenHandlers | func CreateTokenHandlers(tokenFiles []string, influxdb *InfluxDB) ([]TokenHandler, error) {
tokens := []TokenHandler{}
for _, tokenFile := range tokenFiles {
f, err := os.Open(tokenFile)
if err != nil {
return nil, fmt.Errorf("Can't open token-file (%s): %s", tokenFile, err)
}
token, err := CreateTokenHand... | go | func CreateTokenHandlers(tokenFiles []string, influxdb *InfluxDB) ([]TokenHandler, error) {
tokens := []TokenHandler{}
for _, tokenFile := range tokenFiles {
f, err := os.Open(tokenFile)
if err != nil {
return nil, fmt.Errorf("Can't open token-file (%s): %s", tokenFile, err)
}
token, err := CreateTokenHand... | [
"func",
"CreateTokenHandlers",
"(",
"tokenFiles",
"[",
"]",
"string",
",",
"influxdb",
"*",
"InfluxDB",
")",
"(",
"[",
"]",
"TokenHandler",
",",
"error",
")",
"{",
"tokens",
":=",
"[",
"]",
"TokenHandler",
"{",
"}",
"\n",
"for",
"_",
",",
"tokenFile",
... | // CreateTokenHandlers goes through the list of token files, and create handlers | [
"CreateTokenHandlers",
"goes",
"through",
"the",
"list",
"of",
"token",
"files",
"and",
"create",
"handlers"
] | 8125fbda10178887be5dff9e901d6a0a519b67bc | https://github.com/kubernetes/test-infra/blob/8125fbda10178887be5dff9e901d6a0a519b67bc/velodrome/token-counter/token-counter.go#L97-L111 | test |
kubernetes/test-infra | prow/pjutil/abort.go | String | func (i *jobIndentifier) String() string {
return fmt.Sprintf("%s %s/%s#%d", i.job, i.organization, i.repository, i.pullRequest)
} | go | func (i *jobIndentifier) String() string {
return fmt.Sprintf("%s %s/%s#%d", i.job, i.organization, i.repository, i.pullRequest)
} | [
"func",
"(",
"i",
"*",
"jobIndentifier",
")",
"String",
"(",
")",
"string",
"{",
"return",
"fmt",
".",
"Sprintf",
"(",
"\"%s %s/%s#%d\"",
",",
"i",
".",
"job",
",",
"i",
".",
"organization",
",",
"i",
".",
"repository",
",",
"i",
".",
"pullRequest",
... | // String returns the string representation of a prow job identifier | [
"String",
"returns",
"the",
"string",
"representation",
"of",
"a",
"prow",
"job",
"identifier"
] | 8125fbda10178887be5dff9e901d6a0a519b67bc | https://github.com/kubernetes/test-infra/blob/8125fbda10178887be5dff9e901d6a0a519b67bc/prow/pjutil/abort.go#L48-L50 | test |
kubernetes/test-infra | prow/pjutil/abort.go | TerminateOlderPresubmitJobs | func TerminateOlderPresubmitJobs(pjc prowClient, log *logrus.Entry, pjs []prowapi.ProwJob,
cleanup ProwJobResourcesCleanup) error {
dupes := map[jobIndentifier]int{}
for i, pj := range pjs {
if pj.Complete() || pj.Spec.Type != prowapi.PresubmitJob {
continue
}
ji := jobIndentifier{
job: pj.Spec... | go | func TerminateOlderPresubmitJobs(pjc prowClient, log *logrus.Entry, pjs []prowapi.ProwJob,
cleanup ProwJobResourcesCleanup) error {
dupes := map[jobIndentifier]int{}
for i, pj := range pjs {
if pj.Complete() || pj.Spec.Type != prowapi.PresubmitJob {
continue
}
ji := jobIndentifier{
job: pj.Spec... | [
"func",
"TerminateOlderPresubmitJobs",
"(",
"pjc",
"prowClient",
",",
"log",
"*",
"logrus",
".",
"Entry",
",",
"pjs",
"[",
"]",
"prowapi",
".",
"ProwJob",
",",
"cleanup",
"ProwJobResourcesCleanup",
")",
"error",
"{",
"dupes",
":=",
"map",
"[",
"jobIndentifier"... | // TerminateOlderPresubmitJobs aborts all presubmit jobs from the given list that have a newer version. It calls
// the cleanup callback for each job before updating its status as aborted. | [
"TerminateOlderPresubmitJobs",
"aborts",
"all",
"presubmit",
"jobs",
"from",
"the",
"given",
"list",
"that",
"have",
"a",
"newer",
"version",
".",
"It",
"calls",
"the",
"cleanup",
"callback",
"for",
"each",
"job",
"before",
"updating",
"its",
"status",
"as",
"... | 8125fbda10178887be5dff9e901d6a0a519b67bc | https://github.com/kubernetes/test-infra/blob/8125fbda10178887be5dff9e901d6a0a519b67bc/prow/pjutil/abort.go#L54-L102 | test |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.