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/tide/history/history.go
ServeHTTP
func (h *History) ServeHTTP(w http.ResponseWriter, r *http.Request) { b, err := json.Marshal(h.AllRecords()) if err != nil { logrus.WithError(err).Error("Encoding JSON history.") b = []byte("{}") } if _, err = w.Write(b); err != nil { logrus.WithError(err).Error("Writing JSON history response.") } }
go
func (h *History) ServeHTTP(w http.ResponseWriter, r *http.Request) { b, err := json.Marshal(h.AllRecords()) if err != nil { logrus.WithError(err).Error("Encoding JSON history.") b = []byte("{}") } if _, err = w.Write(b); err != nil { logrus.WithError(err).Error("Writing JSON history response.") } }
[ "func", "(", "h", "*", "History", ")", "ServeHTTP", "(", "w", "http", ".", "ResponseWriter", ",", "r", "*", "http", ".", "Request", ")", "{", "b", ",", "err", ":=", "json", ".", "Marshal", "(", "h", ".", "AllRecords", "(", ")", ")", "\n", "if", ...
// ServeHTTP serves a JSON mapping from pool key -> sorted records for the pool.
[ "ServeHTTP", "serves", "a", "JSON", "mapping", "from", "pool", "key", "-", ">", "sorted", "records", "for", "the", "pool", "." ]
8125fbda10178887be5dff9e901d6a0a519b67bc
https://github.com/kubernetes/test-infra/blob/8125fbda10178887be5dff9e901d6a0a519b67bc/prow/tide/history/history.go#L165-L174
test
kubernetes/test-infra
prow/tide/history/history.go
Flush
func (h *History) Flush() { if h.path == "" { return } records := h.AllRecords() start := time.Now() err := writeHistory(h.opener, h.path, records) log := logrus.WithFields(logrus.Fields{ "duration": time.Since(start).String(), "path": h.path, }) if err != nil { log.WithError(err).Error("Error flushing action history to GCS.") } else { log.Debugf("Successfully flushed action history for %d pools.", len(h.logs)) } }
go
func (h *History) Flush() { if h.path == "" { return } records := h.AllRecords() start := time.Now() err := writeHistory(h.opener, h.path, records) log := logrus.WithFields(logrus.Fields{ "duration": time.Since(start).String(), "path": h.path, }) if err != nil { log.WithError(err).Error("Error flushing action history to GCS.") } else { log.Debugf("Successfully flushed action history for %d pools.", len(h.logs)) } }
[ "func", "(", "h", "*", "History", ")", "Flush", "(", ")", "{", "if", "h", ".", "path", "==", "\"\"", "{", "return", "\n", "}", "\n", "records", ":=", "h", ".", "AllRecords", "(", ")", "\n", "start", ":=", "time", ".", "Now", "(", ")", "\n", "...
// Flush writes the action history to persistent storage if configured to do so.
[ "Flush", "writes", "the", "action", "history", "to", "persistent", "storage", "if", "configured", "to", "do", "so", "." ]
8125fbda10178887be5dff9e901d6a0a519b67bc
https://github.com/kubernetes/test-infra/blob/8125fbda10178887be5dff9e901d6a0a519b67bc/prow/tide/history/history.go#L177-L193
test
kubernetes/test-infra
prow/tide/history/history.go
AllRecords
func (h *History) AllRecords() map[string][]*Record { h.Lock() defer h.Unlock() res := make(map[string][]*Record, len(h.logs)) for key, log := range h.logs { res[key] = log.toSlice() } return res }
go
func (h *History) AllRecords() map[string][]*Record { h.Lock() defer h.Unlock() res := make(map[string][]*Record, len(h.logs)) for key, log := range h.logs { res[key] = log.toSlice() } return res }
[ "func", "(", "h", "*", "History", ")", "AllRecords", "(", ")", "map", "[", "string", "]", "[", "]", "*", "Record", "{", "h", ".", "Lock", "(", ")", "\n", "defer", "h", ".", "Unlock", "(", ")", "\n", "res", ":=", "make", "(", "map", "[", "stri...
// AllRecords generates a map from pool key -> sorted records for the pool.
[ "AllRecords", "generates", "a", "map", "from", "pool", "key", "-", ">", "sorted", "records", "for", "the", "pool", "." ]
8125fbda10178887be5dff9e901d6a0a519b67bc
https://github.com/kubernetes/test-infra/blob/8125fbda10178887be5dff9e901d6a0a519b67bc/prow/tide/history/history.go#L196-L205
test
kubernetes/test-infra
robots/coverage/cmd/downloader/downloader.go
MakeCommand
func MakeCommand() *cobra.Command { flags := &flags{} cmd := &cobra.Command{ Use: "download [bucket] [prowjob]", Short: "Finds and downloads the coverage profile file from the latest healthy build", Long: `Finds and downloads the coverage profile file from the latest healthy build stored in given gcs directory.`, Run: func(cmd *cobra.Command, args []string) { run(flags, cmd, args) }, } cmd.Flags().StringVarP(&flags.outputFile, "output", "o", "-", "output file") cmd.Flags().StringVarP(&flags.artifactsDirName, "artifactsDir", "a", "artifacts", "artifact directory name in GCS") cmd.Flags().StringVarP(&flags.profileName, "profile", "p", "coverage-profile", "code coverage profile file name in GCS") return cmd }
go
func MakeCommand() *cobra.Command { flags := &flags{} cmd := &cobra.Command{ Use: "download [bucket] [prowjob]", Short: "Finds and downloads the coverage profile file from the latest healthy build", Long: `Finds and downloads the coverage profile file from the latest healthy build stored in given gcs directory.`, Run: func(cmd *cobra.Command, args []string) { run(flags, cmd, args) }, } cmd.Flags().StringVarP(&flags.outputFile, "output", "o", "-", "output file") cmd.Flags().StringVarP(&flags.artifactsDirName, "artifactsDir", "a", "artifacts", "artifact directory name in GCS") cmd.Flags().StringVarP(&flags.profileName, "profile", "p", "coverage-profile", "code coverage profile file name in GCS") return cmd }
[ "func", "MakeCommand", "(", ")", "*", "cobra", ".", "Command", "{", "flags", ":=", "&", "flags", "{", "}", "\n", "cmd", ":=", "&", "cobra", ".", "Command", "{", "Use", ":", "\"download [bucket] [prowjob]\"", ",", "Short", ":", "\"Finds and downloads the cove...
// MakeCommand returns a `download` command.
[ "MakeCommand", "returns", "a", "download", "command", "." ]
8125fbda10178887be5dff9e901d6a0a519b67bc
https://github.com/kubernetes/test-infra/blob/8125fbda10178887be5dff9e901d6a0a519b67bc/robots/coverage/cmd/downloader/downloader.go#L37-L52
test
kubernetes/test-infra
velodrome/transform/plugins/comment_counter.go
CheckFlags
func (c *CommentCounterPlugin) CheckFlags() error { for _, pattern := range c.pattern { matcher, err := regexp.Compile(pattern) if err != nil { return err } c.matcher = append(c.matcher, matcher) } return nil }
go
func (c *CommentCounterPlugin) CheckFlags() error { for _, pattern := range c.pattern { matcher, err := regexp.Compile(pattern) if err != nil { return err } c.matcher = append(c.matcher, matcher) } return nil }
[ "func", "(", "c", "*", "CommentCounterPlugin", ")", "CheckFlags", "(", ")", "error", "{", "for", "_", ",", "pattern", ":=", "range", "c", ".", "pattern", "{", "matcher", ",", "err", ":=", "regexp", ".", "Compile", "(", "pattern", ")", "\n", "if", "er...
// CheckFlags looks for comments matching regexes
[ "CheckFlags", "looks", "for", "comments", "matching", "regexes" ]
8125fbda10178887be5dff9e901d6a0a519b67bc
https://github.com/kubernetes/test-infra/blob/8125fbda10178887be5dff9e901d6a0a519b67bc/velodrome/transform/plugins/comment_counter.go#L40-L49
test
kubernetes/test-infra
velodrome/transform/plugins/comment_counter.go
ReceiveComment
func (c *CommentCounterPlugin) ReceiveComment(comment sql.Comment) []Point { points := []Point{} for _, matcher := range c.matcher { if matcher.MatchString(comment.Body) { points = append(points, Point{ Values: map[string]interface{}{ "comment": 1, }, Date: comment.CommentCreatedAt, }) } } return points }
go
func (c *CommentCounterPlugin) ReceiveComment(comment sql.Comment) []Point { points := []Point{} for _, matcher := range c.matcher { if matcher.MatchString(comment.Body) { points = append(points, Point{ Values: map[string]interface{}{ "comment": 1, }, Date: comment.CommentCreatedAt, }) } } return points }
[ "func", "(", "c", "*", "CommentCounterPlugin", ")", "ReceiveComment", "(", "comment", "sql", ".", "Comment", ")", "[", "]", "Point", "{", "points", ":=", "[", "]", "Point", "{", "}", "\n", "for", "_", ",", "matcher", ":=", "range", "c", ".", "matcher...
// ReceiveComment adds matching comments to InfluxDB
[ "ReceiveComment", "adds", "matching", "comments", "to", "InfluxDB" ]
8125fbda10178887be5dff9e901d6a0a519b67bc
https://github.com/kubernetes/test-infra/blob/8125fbda10178887be5dff9e901d6a0a519b67bc/velodrome/transform/plugins/comment_counter.go#L62-L75
test
kubernetes/test-infra
prow/crier/controller.go
NewController
func NewController( pjclientset clientset.Interface, queue workqueue.RateLimitingInterface, informer pjinformers.ProwJobInformer, reporter reportClient, numWorkers int, wg *sync.WaitGroup) *Controller { return &Controller{ pjclientset: pjclientset, queue: queue, informer: informer, reporter: reporter, numWorkers: numWorkers, wg: wg, } }
go
func NewController( pjclientset clientset.Interface, queue workqueue.RateLimitingInterface, informer pjinformers.ProwJobInformer, reporter reportClient, numWorkers int, wg *sync.WaitGroup) *Controller { return &Controller{ pjclientset: pjclientset, queue: queue, informer: informer, reporter: reporter, numWorkers: numWorkers, wg: wg, } }
[ "func", "NewController", "(", "pjclientset", "clientset", ".", "Interface", ",", "queue", "workqueue", ".", "RateLimitingInterface", ",", "informer", "pjinformers", ".", "ProwJobInformer", ",", "reporter", "reportClient", ",", "numWorkers", "int", ",", "wg", "*", ...
// NewController constructs a new instance of the crier controller.
[ "NewController", "constructs", "a", "new", "instance", "of", "the", "crier", "controller", "." ]
8125fbda10178887be5dff9e901d6a0a519b67bc
https://github.com/kubernetes/test-infra/blob/8125fbda10178887be5dff9e901d6a0a519b67bc/prow/crier/controller.go#L60-L75
test
kubernetes/test-infra
prow/crier/controller.go
Run
func (c *Controller) Run(stopCh <-chan struct{}) { // handle a panic with logging and exiting defer utilruntime.HandleCrash() // ignore new items in the queue but when all goroutines // have completed existing items then shutdown defer c.queue.ShutDown() logrus.Info("Initiating controller") c.informer.Informer().AddEventHandler(cache.ResourceEventHandlerFuncs{ AddFunc: func(obj interface{}) { key, err := cache.MetaNamespaceKeyFunc(obj) logrus.WithField("prowjob", key).Infof("Add prowjob") if err != nil { logrus.WithError(err).Error("Cannot get key from object meta") return } c.queue.AddRateLimited(key) }, UpdateFunc: func(oldObj, newObj interface{}) { key, err := cache.MetaNamespaceKeyFunc(newObj) logrus.WithField("prowjob", key).Infof("Update prowjob") if err != nil { logrus.WithError(err).Error("Cannot get key from object meta") return } c.queue.AddRateLimited(key) }, }) // run the informer to start listing and watching resources go c.informer.Informer().Run(stopCh) // do the initial synchronization (one time) to populate resources if !cache.WaitForCacheSync(stopCh, c.HasSynced) { utilruntime.HandleError(fmt.Errorf("Error syncing cache")) return } logrus.Info("Controller.Run: cache sync complete") // run the runWorker method every second with a stop channel for i := 0; i < c.numWorkers; i++ { go wait.Until(c.runWorker, time.Second, stopCh) } logrus.Infof("Started %d workers", c.numWorkers) <-stopCh logrus.Info("Shutting down workers") }
go
func (c *Controller) Run(stopCh <-chan struct{}) { // handle a panic with logging and exiting defer utilruntime.HandleCrash() // ignore new items in the queue but when all goroutines // have completed existing items then shutdown defer c.queue.ShutDown() logrus.Info("Initiating controller") c.informer.Informer().AddEventHandler(cache.ResourceEventHandlerFuncs{ AddFunc: func(obj interface{}) { key, err := cache.MetaNamespaceKeyFunc(obj) logrus.WithField("prowjob", key).Infof("Add prowjob") if err != nil { logrus.WithError(err).Error("Cannot get key from object meta") return } c.queue.AddRateLimited(key) }, UpdateFunc: func(oldObj, newObj interface{}) { key, err := cache.MetaNamespaceKeyFunc(newObj) logrus.WithField("prowjob", key).Infof("Update prowjob") if err != nil { logrus.WithError(err).Error("Cannot get key from object meta") return } c.queue.AddRateLimited(key) }, }) // run the informer to start listing and watching resources go c.informer.Informer().Run(stopCh) // do the initial synchronization (one time) to populate resources if !cache.WaitForCacheSync(stopCh, c.HasSynced) { utilruntime.HandleError(fmt.Errorf("Error syncing cache")) return } logrus.Info("Controller.Run: cache sync complete") // run the runWorker method every second with a stop channel for i := 0; i < c.numWorkers; i++ { go wait.Until(c.runWorker, time.Second, stopCh) } logrus.Infof("Started %d workers", c.numWorkers) <-stopCh logrus.Info("Shutting down workers") }
[ "func", "(", "c", "*", "Controller", ")", "Run", "(", "stopCh", "<-", "chan", "struct", "{", "}", ")", "{", "defer", "utilruntime", ".", "HandleCrash", "(", ")", "\n", "defer", "c", ".", "queue", ".", "ShutDown", "(", ")", "\n", "logrus", ".", "Inf...
// Run is the main path of execution for the controller loop.
[ "Run", "is", "the", "main", "path", "of", "execution", "for", "the", "controller", "loop", "." ]
8125fbda10178887be5dff9e901d6a0a519b67bc
https://github.com/kubernetes/test-infra/blob/8125fbda10178887be5dff9e901d6a0a519b67bc/prow/crier/controller.go#L78-L125
test
kubernetes/test-infra
prow/crier/controller.go
runWorker
func (c *Controller) runWorker() { c.wg.Add(1) for c.processNextItem() { } c.wg.Done() }
go
func (c *Controller) runWorker() { c.wg.Add(1) for c.processNextItem() { } c.wg.Done() }
[ "func", "(", "c", "*", "Controller", ")", "runWorker", "(", ")", "{", "c", ".", "wg", ".", "Add", "(", "1", ")", "\n", "for", "c", ".", "processNextItem", "(", ")", "{", "}", "\n", "c", ".", "wg", ".", "Done", "(", ")", "\n", "}" ]
// runWorker executes the loop to process new items added to the queue.
[ "runWorker", "executes", "the", "loop", "to", "process", "new", "items", "added", "to", "the", "queue", "." ]
8125fbda10178887be5dff9e901d6a0a519b67bc
https://github.com/kubernetes/test-infra/blob/8125fbda10178887be5dff9e901d6a0a519b67bc/prow/crier/controller.go#L134-L139
test
kubernetes/test-infra
prow/git/localgit/localgit.go
New
func New() (*LocalGit, *git.Client, error) { g, err := exec.LookPath("git") if err != nil { return nil, nil, err } t, err := ioutil.TempDir("", "localgit") if err != nil { return nil, nil, err } c, err := git.NewClient() if err != nil { os.RemoveAll(t) return nil, nil, err } getSecret := func() []byte { return []byte("") } c.SetCredentials("", getSecret) c.SetRemote(t) return &LocalGit{ Dir: t, Git: g, }, c, nil }
go
func New() (*LocalGit, *git.Client, error) { g, err := exec.LookPath("git") if err != nil { return nil, nil, err } t, err := ioutil.TempDir("", "localgit") if err != nil { return nil, nil, err } c, err := git.NewClient() if err != nil { os.RemoveAll(t) return nil, nil, err } getSecret := func() []byte { return []byte("") } c.SetCredentials("", getSecret) c.SetRemote(t) return &LocalGit{ Dir: t, Git: g, }, c, nil }
[ "func", "New", "(", ")", "(", "*", "LocalGit", ",", "*", "git", ".", "Client", ",", "error", ")", "{", "g", ",", "err", ":=", "exec", ".", "LookPath", "(", "\"git\"", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "nil", ",", ...
// New creates a LocalGit and a git.Client pointing at it.
[ "New", "creates", "a", "LocalGit", "and", "a", "git", ".", "Client", "pointing", "at", "it", "." ]
8125fbda10178887be5dff9e901d6a0a519b67bc
https://github.com/kubernetes/test-infra/blob/8125fbda10178887be5dff9e901d6a0a519b67bc/prow/git/localgit/localgit.go#L42-L68
test
kubernetes/test-infra
prow/git/localgit/localgit.go
MakeFakeRepo
func (lg *LocalGit) MakeFakeRepo(org, repo string) error { rdir := filepath.Join(lg.Dir, org, repo) if err := os.MkdirAll(rdir, os.ModePerm); err != nil { return err } if err := runCmd(lg.Git, rdir, "init"); err != nil { return err } if err := runCmd(lg.Git, rdir, "config", "user.email", "test@test.test"); err != nil { return err } if err := runCmd(lg.Git, rdir, "config", "user.name", "test test"); err != nil { return err } if err := runCmd(lg.Git, rdir, "config", "commit.gpgsign", "false"); err != nil { return err } if err := lg.AddCommit(org, repo, map[string][]byte{"initial": {}}); err != nil { return err } return nil }
go
func (lg *LocalGit) MakeFakeRepo(org, repo string) error { rdir := filepath.Join(lg.Dir, org, repo) if err := os.MkdirAll(rdir, os.ModePerm); err != nil { return err } if err := runCmd(lg.Git, rdir, "init"); err != nil { return err } if err := runCmd(lg.Git, rdir, "config", "user.email", "test@test.test"); err != nil { return err } if err := runCmd(lg.Git, rdir, "config", "user.name", "test test"); err != nil { return err } if err := runCmd(lg.Git, rdir, "config", "commit.gpgsign", "false"); err != nil { return err } if err := lg.AddCommit(org, repo, map[string][]byte{"initial": {}}); err != nil { return err } return nil }
[ "func", "(", "lg", "*", "LocalGit", ")", "MakeFakeRepo", "(", "org", ",", "repo", "string", ")", "error", "{", "rdir", ":=", "filepath", ".", "Join", "(", "lg", ".", "Dir", ",", "org", ",", "repo", ")", "\n", "if", "err", ":=", "os", ".", "MkdirA...
// MakeFakeRepo creates the given repo and makes an initial commit.
[ "MakeFakeRepo", "creates", "the", "given", "repo", "and", "makes", "an", "initial", "commit", "." ]
8125fbda10178887be5dff9e901d6a0a519b67bc
https://github.com/kubernetes/test-infra/blob/8125fbda10178887be5dff9e901d6a0a519b67bc/prow/git/localgit/localgit.go#L95-L118
test
kubernetes/test-infra
prow/git/localgit/localgit.go
AddCommit
func (lg *LocalGit) AddCommit(org, repo string, files map[string][]byte) error { rdir := filepath.Join(lg.Dir, org, repo) for f, b := range files { path := filepath.Join(rdir, f) if err := os.MkdirAll(filepath.Dir(path), os.ModePerm); err != nil { return err } if err := ioutil.WriteFile(path, b, os.ModePerm); err != nil { return err } if err := runCmd(lg.Git, rdir, "add", f); err != nil { return err } } return runCmd(lg.Git, rdir, "commit", "-m", "wow") }
go
func (lg *LocalGit) AddCommit(org, repo string, files map[string][]byte) error { rdir := filepath.Join(lg.Dir, org, repo) for f, b := range files { path := filepath.Join(rdir, f) if err := os.MkdirAll(filepath.Dir(path), os.ModePerm); err != nil { return err } if err := ioutil.WriteFile(path, b, os.ModePerm); err != nil { return err } if err := runCmd(lg.Git, rdir, "add", f); err != nil { return err } } return runCmd(lg.Git, rdir, "commit", "-m", "wow") }
[ "func", "(", "lg", "*", "LocalGit", ")", "AddCommit", "(", "org", ",", "repo", "string", ",", "files", "map", "[", "string", "]", "[", "]", "byte", ")", "error", "{", "rdir", ":=", "filepath", ".", "Join", "(", "lg", ".", "Dir", ",", "org", ",", ...
// AddCommit adds the files to a new commit in the repo.
[ "AddCommit", "adds", "the", "files", "to", "a", "new", "commit", "in", "the", "repo", "." ]
8125fbda10178887be5dff9e901d6a0a519b67bc
https://github.com/kubernetes/test-infra/blob/8125fbda10178887be5dff9e901d6a0a519b67bc/prow/git/localgit/localgit.go#L121-L136
test
kubernetes/test-infra
prow/git/localgit/localgit.go
CheckoutNewBranch
func (lg *LocalGit) CheckoutNewBranch(org, repo, branch string) error { rdir := filepath.Join(lg.Dir, org, repo) return runCmd(lg.Git, rdir, "checkout", "-b", branch) }
go
func (lg *LocalGit) CheckoutNewBranch(org, repo, branch string) error { rdir := filepath.Join(lg.Dir, org, repo) return runCmd(lg.Git, rdir, "checkout", "-b", branch) }
[ "func", "(", "lg", "*", "LocalGit", ")", "CheckoutNewBranch", "(", "org", ",", "repo", ",", "branch", "string", ")", "error", "{", "rdir", ":=", "filepath", ".", "Join", "(", "lg", ".", "Dir", ",", "org", ",", "repo", ")", "\n", "return", "runCmd", ...
// CheckoutNewBranch does git checkout -b.
[ "CheckoutNewBranch", "does", "git", "checkout", "-", "b", "." ]
8125fbda10178887be5dff9e901d6a0a519b67bc
https://github.com/kubernetes/test-infra/blob/8125fbda10178887be5dff9e901d6a0a519b67bc/prow/git/localgit/localgit.go#L139-L142
test
kubernetes/test-infra
prow/git/localgit/localgit.go
Checkout
func (lg *LocalGit) Checkout(org, repo, commitlike string) error { rdir := filepath.Join(lg.Dir, org, repo) return runCmd(lg.Git, rdir, "checkout", commitlike) }
go
func (lg *LocalGit) Checkout(org, repo, commitlike string) error { rdir := filepath.Join(lg.Dir, org, repo) return runCmd(lg.Git, rdir, "checkout", commitlike) }
[ "func", "(", "lg", "*", "LocalGit", ")", "Checkout", "(", "org", ",", "repo", ",", "commitlike", "string", ")", "error", "{", "rdir", ":=", "filepath", ".", "Join", "(", "lg", ".", "Dir", ",", "org", ",", "repo", ")", "\n", "return", "runCmd", "(",...
// Checkout does git checkout.
[ "Checkout", "does", "git", "checkout", "." ]
8125fbda10178887be5dff9e901d6a0a519b67bc
https://github.com/kubernetes/test-infra/blob/8125fbda10178887be5dff9e901d6a0a519b67bc/prow/git/localgit/localgit.go#L145-L148
test
kubernetes/test-infra
prow/git/localgit/localgit.go
RevParse
func (lg *LocalGit) RevParse(org, repo, commitlike string) (string, error) { rdir := filepath.Join(lg.Dir, org, repo) return runCmdOutput(lg.Git, rdir, "rev-parse", commitlike) }
go
func (lg *LocalGit) RevParse(org, repo, commitlike string) (string, error) { rdir := filepath.Join(lg.Dir, org, repo) return runCmdOutput(lg.Git, rdir, "rev-parse", commitlike) }
[ "func", "(", "lg", "*", "LocalGit", ")", "RevParse", "(", "org", ",", "repo", ",", "commitlike", "string", ")", "(", "string", ",", "error", ")", "{", "rdir", ":=", "filepath", ".", "Join", "(", "lg", ".", "Dir", ",", "org", ",", "repo", ")", "\n...
// RevParse does git rev-parse.
[ "RevParse", "does", "git", "rev", "-", "parse", "." ]
8125fbda10178887be5dff9e901d6a0a519b67bc
https://github.com/kubernetes/test-infra/blob/8125fbda10178887be5dff9e901d6a0a519b67bc/prow/git/localgit/localgit.go#L151-L154
test
kubernetes/test-infra
maintenance/aws-janitor/resources/clean.go
CleanAll
func CleanAll(sess *session.Session, region string) error { acct, err := account.GetAccount(sess, regions.Default) if err != nil { return errors.Wrap(err, "Failed to retrieve account") } klog.V(1).Infof("Account: %s", acct) var regionList []string if region == "" { regionList, err = regions.GetAll(sess) if err != nil { return errors.Wrap(err, "Couldn't retrieve list of regions") } } else { regionList = []string{region} } klog.Infof("Regions: %+v", regionList) for _, r := range regionList { for _, typ := range RegionalTypeList { set, err := typ.ListAll(sess, acct, r) if err != nil { return errors.Wrapf(err, "Failed to list resources of type %T", typ) } if err := typ.MarkAndSweep(sess, acct, r, set); err != nil { return errors.Wrapf(err, "Couldn't sweep resources of type %T", typ) } } } for _, typ := range GlobalTypeList { set, err := typ.ListAll(sess, acct, regions.Default) if err != nil { return errors.Wrapf(err, "Failed to list resources of type %T", typ) } if err := typ.MarkAndSweep(sess, acct, regions.Default, set); err != nil { return errors.Wrapf(err, "Couldn't sweep resources of type %T", typ) } } return nil }
go
func CleanAll(sess *session.Session, region string) error { acct, err := account.GetAccount(sess, regions.Default) if err != nil { return errors.Wrap(err, "Failed to retrieve account") } klog.V(1).Infof("Account: %s", acct) var regionList []string if region == "" { regionList, err = regions.GetAll(sess) if err != nil { return errors.Wrap(err, "Couldn't retrieve list of regions") } } else { regionList = []string{region} } klog.Infof("Regions: %+v", regionList) for _, r := range regionList { for _, typ := range RegionalTypeList { set, err := typ.ListAll(sess, acct, r) if err != nil { return errors.Wrapf(err, "Failed to list resources of type %T", typ) } if err := typ.MarkAndSweep(sess, acct, r, set); err != nil { return errors.Wrapf(err, "Couldn't sweep resources of type %T", typ) } } } for _, typ := range GlobalTypeList { set, err := typ.ListAll(sess, acct, regions.Default) if err != nil { return errors.Wrapf(err, "Failed to list resources of type %T", typ) } if err := typ.MarkAndSweep(sess, acct, regions.Default, set); err != nil { return errors.Wrapf(err, "Couldn't sweep resources of type %T", typ) } } return nil }
[ "func", "CleanAll", "(", "sess", "*", "session", ".", "Session", ",", "region", "string", ")", "error", "{", "acct", ",", "err", ":=", "account", ".", "GetAccount", "(", "sess", ",", "regions", ".", "Default", ")", "\n", "if", "err", "!=", "nil", "{"...
// CleanAll cleans all of the resources for all of the regions visible to // the provided AWS session.
[ "CleanAll", "cleans", "all", "of", "the", "resources", "for", "all", "of", "the", "regions", "visible", "to", "the", "provided", "AWS", "session", "." ]
8125fbda10178887be5dff9e901d6a0a519b67bc
https://github.com/kubernetes/test-infra/blob/8125fbda10178887be5dff9e901d6a0a519b67bc/maintenance/aws-janitor/resources/clean.go#L29-L70
test
kubernetes/test-infra
prow/plugins/lgtm/lgtm.go
optionsForRepo
func optionsForRepo(config *plugins.Configuration, org, repo string) *plugins.Lgtm { fullName := fmt.Sprintf("%s/%s", org, repo) for i := range config.Lgtm { if !strInSlice(org, config.Lgtm[i].Repos) && !strInSlice(fullName, config.Lgtm[i].Repos) { continue } return &config.Lgtm[i] } return &plugins.Lgtm{} }
go
func optionsForRepo(config *plugins.Configuration, org, repo string) *plugins.Lgtm { fullName := fmt.Sprintf("%s/%s", org, repo) for i := range config.Lgtm { if !strInSlice(org, config.Lgtm[i].Repos) && !strInSlice(fullName, config.Lgtm[i].Repos) { continue } return &config.Lgtm[i] } return &plugins.Lgtm{} }
[ "func", "optionsForRepo", "(", "config", "*", "plugins", ".", "Configuration", ",", "org", ",", "repo", "string", ")", "*", "plugins", ".", "Lgtm", "{", "fullName", ":=", "fmt", ".", "Sprintf", "(", "\"%s/%s\"", ",", "org", ",", "repo", ")", "\n", "for...
// optionsForRepo gets the plugins.Lgtm struct that is applicable to the indicated repo.
[ "optionsForRepo", "gets", "the", "plugins", ".", "Lgtm", "struct", "that", "is", "applicable", "to", "the", "indicated", "repo", "." ]
8125fbda10178887be5dff9e901d6a0a519b67bc
https://github.com/kubernetes/test-infra/blob/8125fbda10178887be5dff9e901d6a0a519b67bc/prow/plugins/lgtm/lgtm.go#L116-L125
test
kubernetes/test-infra
prow/plugins/lgtm/lgtm.go
getChangedFiles
func getChangedFiles(gc githubClient, org, repo string, number int) ([]string, error) { changes, err := gc.GetPullRequestChanges(org, repo, number) if err != nil { return nil, fmt.Errorf("cannot get PR changes for %s/%s#%d", org, repo, number) } var filenames []string for _, change := range changes { filenames = append(filenames, change.Filename) } return filenames, nil }
go
func getChangedFiles(gc githubClient, org, repo string, number int) ([]string, error) { changes, err := gc.GetPullRequestChanges(org, repo, number) if err != nil { return nil, fmt.Errorf("cannot get PR changes for %s/%s#%d", org, repo, number) } var filenames []string for _, change := range changes { filenames = append(filenames, change.Filename) } return filenames, nil }
[ "func", "getChangedFiles", "(", "gc", "githubClient", ",", "org", ",", "repo", "string", ",", "number", "int", ")", "(", "[", "]", "string", ",", "error", ")", "{", "changes", ",", "err", ":=", "gc", ".", "GetPullRequestChanges", "(", "org", ",", "repo...
// getChangedFiles returns all the changed files for the provided pull request.
[ "getChangedFiles", "returns", "all", "the", "changed", "files", "for", "the", "provided", "pull", "request", "." ]
8125fbda10178887be5dff9e901d6a0a519b67bc
https://github.com/kubernetes/test-infra/blob/8125fbda10178887be5dff9e901d6a0a519b67bc/prow/plugins/lgtm/lgtm.go#L504-L514
test
kubernetes/test-infra
prow/plugins/lgtm/lgtm.go
loadReviewers
func loadReviewers(ro repoowners.RepoOwner, filenames []string) sets.String { reviewers := sets.String{} for _, filename := range filenames { reviewers = reviewers.Union(ro.Approvers(filename)).Union(ro.Reviewers(filename)) } return reviewers }
go
func loadReviewers(ro repoowners.RepoOwner, filenames []string) sets.String { reviewers := sets.String{} for _, filename := range filenames { reviewers = reviewers.Union(ro.Approvers(filename)).Union(ro.Reviewers(filename)) } return reviewers }
[ "func", "loadReviewers", "(", "ro", "repoowners", ".", "RepoOwner", ",", "filenames", "[", "]", "string", ")", "sets", ".", "String", "{", "reviewers", ":=", "sets", ".", "String", "{", "}", "\n", "for", "_", ",", "filename", ":=", "range", "filenames", ...
// loadReviewers returns all reviewers and approvers from all OWNERS files that // cover the provided filenames.
[ "loadReviewers", "returns", "all", "reviewers", "and", "approvers", "from", "all", "OWNERS", "files", "that", "cover", "the", "provided", "filenames", "." ]
8125fbda10178887be5dff9e901d6a0a519b67bc
https://github.com/kubernetes/test-infra/blob/8125fbda10178887be5dff9e901d6a0a519b67bc/prow/plugins/lgtm/lgtm.go#L518-L524
test
kubernetes/test-infra
prow/gerrit/adapter/adapter.go
NewController
func NewController(lastSyncFallback, cookiefilePath string, projects map[string][]string, kc *kube.Client, cfg config.Getter) (*Controller, error) { if lastSyncFallback == "" { return nil, errors.New("empty lastSyncFallback") } var lastUpdate time.Time if buf, err := ioutil.ReadFile(lastSyncFallback); err == nil { unix, err := strconv.ParseInt(string(buf), 10, 64) if err != nil { return nil, err } lastUpdate = time.Unix(unix, 0) } else if err != nil && !os.IsNotExist(err) { return nil, fmt.Errorf("failed to read lastSyncFallback: %v", err) } else { logrus.Warnf("lastSyncFallback not found: %s", lastSyncFallback) lastUpdate = time.Now() } c, err := client.NewClient(projects) if err != nil { return nil, err } c.Start(cookiefilePath) return &Controller{ kc: kc, config: cfg, gc: c, lastUpdate: lastUpdate, lastSyncFallback: lastSyncFallback, }, nil }
go
func NewController(lastSyncFallback, cookiefilePath string, projects map[string][]string, kc *kube.Client, cfg config.Getter) (*Controller, error) { if lastSyncFallback == "" { return nil, errors.New("empty lastSyncFallback") } var lastUpdate time.Time if buf, err := ioutil.ReadFile(lastSyncFallback); err == nil { unix, err := strconv.ParseInt(string(buf), 10, 64) if err != nil { return nil, err } lastUpdate = time.Unix(unix, 0) } else if err != nil && !os.IsNotExist(err) { return nil, fmt.Errorf("failed to read lastSyncFallback: %v", err) } else { logrus.Warnf("lastSyncFallback not found: %s", lastSyncFallback) lastUpdate = time.Now() } c, err := client.NewClient(projects) if err != nil { return nil, err } c.Start(cookiefilePath) return &Controller{ kc: kc, config: cfg, gc: c, lastUpdate: lastUpdate, lastSyncFallback: lastSyncFallback, }, nil }
[ "func", "NewController", "(", "lastSyncFallback", ",", "cookiefilePath", "string", ",", "projects", "map", "[", "string", "]", "[", "]", "string", ",", "kc", "*", "kube", ".", "Client", ",", "cfg", "config", ".", "Getter", ")", "(", "*", "Controller", ",...
// NewController returns a new gerrit controller client
[ "NewController", "returns", "a", "new", "gerrit", "controller", "client" ]
8125fbda10178887be5dff9e901d6a0a519b67bc
https://github.com/kubernetes/test-infra/blob/8125fbda10178887be5dff9e901d6a0a519b67bc/prow/gerrit/adapter/adapter.go#L67-L99
test
kubernetes/test-infra
prow/gerrit/adapter/adapter.go
SaveLastSync
func (c *Controller) SaveLastSync(lastSync time.Time) error { if c.lastSyncFallback == "" { return nil } lastSyncUnix := strconv.FormatInt(lastSync.Unix(), 10) logrus.Infof("Writing last sync: %s", lastSyncUnix) tempFile, err := ioutil.TempFile(filepath.Dir(c.lastSyncFallback), "temp") if err != nil { return err } defer os.Remove(tempFile.Name()) err = ioutil.WriteFile(tempFile.Name(), []byte(lastSyncUnix), 0644) if err != nil { return err } err = os.Rename(tempFile.Name(), c.lastSyncFallback) if err != nil { logrus.WithError(err).Info("Rename failed, fallback to copyfile") return copyFile(tempFile.Name(), c.lastSyncFallback) } return nil }
go
func (c *Controller) SaveLastSync(lastSync time.Time) error { if c.lastSyncFallback == "" { return nil } lastSyncUnix := strconv.FormatInt(lastSync.Unix(), 10) logrus.Infof("Writing last sync: %s", lastSyncUnix) tempFile, err := ioutil.TempFile(filepath.Dir(c.lastSyncFallback), "temp") if err != nil { return err } defer os.Remove(tempFile.Name()) err = ioutil.WriteFile(tempFile.Name(), []byte(lastSyncUnix), 0644) if err != nil { return err } err = os.Rename(tempFile.Name(), c.lastSyncFallback) if err != nil { logrus.WithError(err).Info("Rename failed, fallback to copyfile") return copyFile(tempFile.Name(), c.lastSyncFallback) } return nil }
[ "func", "(", "c", "*", "Controller", ")", "SaveLastSync", "(", "lastSync", "time", ".", "Time", ")", "error", "{", "if", "c", ".", "lastSyncFallback", "==", "\"\"", "{", "return", "nil", "\n", "}", "\n", "lastSyncUnix", ":=", "strconv", ".", "FormatInt",...
// SaveLastSync saves last sync time in Unix to a volume
[ "SaveLastSync", "saves", "last", "sync", "time", "in", "Unix", "to", "a", "volume" ]
8125fbda10178887be5dff9e901d6a0a519b67bc
https://github.com/kubernetes/test-infra/blob/8125fbda10178887be5dff9e901d6a0a519b67bc/prow/gerrit/adapter/adapter.go#L122-L147
test
kubernetes/test-infra
prow/gerrit/adapter/adapter.go
Sync
func (c *Controller) Sync() error { syncTime := c.lastUpdate for instance, changes := range c.gc.QueryChanges(c.lastUpdate, c.config().Gerrit.RateLimit) { for _, change := range changes { if err := c.ProcessChange(instance, change); err != nil { logrus.WithError(err).Errorf("Failed process change %v", change.CurrentRevision) } if syncTime.Before(change.Updated.Time) { syncTime = change.Updated.Time } } logrus.Infof("Processed %d changes for instance %s", len(changes), instance) } c.lastUpdate = syncTime if err := c.SaveLastSync(syncTime); err != nil { logrus.WithError(err).Errorf("last sync %v, cannot save to path %v", syncTime, c.lastSyncFallback) } return nil }
go
func (c *Controller) Sync() error { syncTime := c.lastUpdate for instance, changes := range c.gc.QueryChanges(c.lastUpdate, c.config().Gerrit.RateLimit) { for _, change := range changes { if err := c.ProcessChange(instance, change); err != nil { logrus.WithError(err).Errorf("Failed process change %v", change.CurrentRevision) } if syncTime.Before(change.Updated.Time) { syncTime = change.Updated.Time } } logrus.Infof("Processed %d changes for instance %s", len(changes), instance) } c.lastUpdate = syncTime if err := c.SaveLastSync(syncTime); err != nil { logrus.WithError(err).Errorf("last sync %v, cannot save to path %v", syncTime, c.lastSyncFallback) } return nil }
[ "func", "(", "c", "*", "Controller", ")", "Sync", "(", ")", "error", "{", "syncTime", ":=", "c", ".", "lastUpdate", "\n", "for", "instance", ",", "changes", ":=", "range", "c", ".", "gc", ".", "QueryChanges", "(", "c", ".", "lastUpdate", ",", "c", ...
// Sync looks for newly made gerrit changes // and creates prowjobs according to specs
[ "Sync", "looks", "for", "newly", "made", "gerrit", "changes", "and", "creates", "prowjobs", "according", "to", "specs" ]
8125fbda10178887be5dff9e901d6a0a519b67bc
https://github.com/kubernetes/test-infra/blob/8125fbda10178887be5dff9e901d6a0a519b67bc/prow/gerrit/adapter/adapter.go#L151-L173
test
kubernetes/test-infra
velodrome/transform/plugins/event_counter.go
AddFlags
func (e *EventCounterPlugin) AddFlags(cmd *cobra.Command) { cmd.Flags().StringVar(&e.desc, "event", "", "Match event (eg: `opened`)") }
go
func (e *EventCounterPlugin) AddFlags(cmd *cobra.Command) { cmd.Flags().StringVar(&e.desc, "event", "", "Match event (eg: `opened`)") }
[ "func", "(", "e", "*", "EventCounterPlugin", ")", "AddFlags", "(", "cmd", "*", "cobra", ".", "Command", ")", "{", "cmd", ".", "Flags", "(", ")", ".", "StringVar", "(", "&", "e", ".", "desc", ",", "\"event\"", ",", "\"\"", ",", "\"Match event (eg: `open...
// AddFlags adds "event" to the command help
[ "AddFlags", "adds", "event", "to", "the", "command", "help" ]
8125fbda10178887be5dff9e901d6a0a519b67bc
https://github.com/kubernetes/test-infra/blob/8125fbda10178887be5dff9e901d6a0a519b67bc/velodrome/transform/plugins/event_counter.go#L33-L35
test
kubernetes/test-infra
velodrome/transform/plugins/event_counter.go
CheckFlags
func (e *EventCounterPlugin) CheckFlags() error { e.matcher = NewEventMatcher(e.desc) return nil }
go
func (e *EventCounterPlugin) CheckFlags() error { e.matcher = NewEventMatcher(e.desc) return nil }
[ "func", "(", "e", "*", "EventCounterPlugin", ")", "CheckFlags", "(", ")", "error", "{", "e", ".", "matcher", "=", "NewEventMatcher", "(", "e", ".", "desc", ")", "\n", "return", "nil", "\n", "}" ]
// CheckFlags is delegated to EventMatcher
[ "CheckFlags", "is", "delegated", "to", "EventMatcher" ]
8125fbda10178887be5dff9e901d6a0a519b67bc
https://github.com/kubernetes/test-infra/blob/8125fbda10178887be5dff9e901d6a0a519b67bc/velodrome/transform/plugins/event_counter.go#L38-L41
test
kubernetes/test-infra
velodrome/transform/plugins/event_counter.go
ReceiveIssueEvent
func (e *EventCounterPlugin) ReceiveIssueEvent(event sql.IssueEvent) []Point { var label string if event.Label != nil { label = *event.Label } if !e.matcher.Match(event.Event, label) { return nil } return []Point{ { Values: map[string]interface{}{"event": 1}, Date: event.EventCreatedAt, }, } }
go
func (e *EventCounterPlugin) ReceiveIssueEvent(event sql.IssueEvent) []Point { var label string if event.Label != nil { label = *event.Label } if !e.matcher.Match(event.Event, label) { return nil } return []Point{ { Values: map[string]interface{}{"event": 1}, Date: event.EventCreatedAt, }, } }
[ "func", "(", "e", "*", "EventCounterPlugin", ")", "ReceiveIssueEvent", "(", "event", "sql", ".", "IssueEvent", ")", "[", "]", "Point", "{", "var", "label", "string", "\n", "if", "event", ".", "Label", "!=", "nil", "{", "label", "=", "*", "event", ".", ...
// ReceiveIssueEvent adds issue events to InfluxDB
[ "ReceiveIssueEvent", "adds", "issue", "events", "to", "InfluxDB" ]
8125fbda10178887be5dff9e901d6a0a519b67bc
https://github.com/kubernetes/test-infra/blob/8125fbda10178887be5dff9e901d6a0a519b67bc/velodrome/transform/plugins/event_counter.go#L49-L64
test
kubernetes/test-infra
prow/pod-utils/gcs/upload.go
Upload
func Upload(bucket *storage.BucketHandle, uploadTargets map[string]UploadFunc) error { errCh := make(chan error, len(uploadTargets)) group := &sync.WaitGroup{} group.Add(len(uploadTargets)) for dest, upload := range uploadTargets { obj := bucket.Object(dest) logrus.WithField("dest", dest).Info("Queued for upload") go func(f UploadFunc, obj *storage.ObjectHandle, name string) { defer group.Done() if err := f(obj); err != nil { errCh <- err } logrus.WithField("dest", name).Info("Finished upload") }(upload, obj, dest) } group.Wait() close(errCh) if len(errCh) != 0 { var uploadErrors []error for err := range errCh { uploadErrors = append(uploadErrors, err) } return fmt.Errorf("encountered errors during upload: %v", uploadErrors) } return nil }
go
func Upload(bucket *storage.BucketHandle, uploadTargets map[string]UploadFunc) error { errCh := make(chan error, len(uploadTargets)) group := &sync.WaitGroup{} group.Add(len(uploadTargets)) for dest, upload := range uploadTargets { obj := bucket.Object(dest) logrus.WithField("dest", dest).Info("Queued for upload") go func(f UploadFunc, obj *storage.ObjectHandle, name string) { defer group.Done() if err := f(obj); err != nil { errCh <- err } logrus.WithField("dest", name).Info("Finished upload") }(upload, obj, dest) } group.Wait() close(errCh) if len(errCh) != 0 { var uploadErrors []error for err := range errCh { uploadErrors = append(uploadErrors, err) } return fmt.Errorf("encountered errors during upload: %v", uploadErrors) } return nil }
[ "func", "Upload", "(", "bucket", "*", "storage", ".", "BucketHandle", ",", "uploadTargets", "map", "[", "string", "]", "UploadFunc", ")", "error", "{", "errCh", ":=", "make", "(", "chan", "error", ",", "len", "(", "uploadTargets", ")", ")", "\n", "group"...
// Upload uploads all of the data in the // uploadTargets map to GCS in parallel. The map is // keyed on GCS path under the bucket
[ "Upload", "uploads", "all", "of", "the", "data", "in", "the", "uploadTargets", "map", "to", "GCS", "in", "parallel", ".", "The", "map", "is", "keyed", "on", "GCS", "path", "under", "the", "bucket" ]
8125fbda10178887be5dff9e901d6a0a519b67bc
https://github.com/kubernetes/test-infra/blob/8125fbda10178887be5dff9e901d6a0a519b67bc/prow/pod-utils/gcs/upload.go#L38-L64
test
kubernetes/test-infra
prow/pod-utils/gcs/upload.go
FileUploadWithMetadata
func FileUploadWithMetadata(file string, metadata map[string]string) UploadFunc { return func(obj *storage.ObjectHandle) error { reader, err := os.Open(file) if err != nil { return err } uploadErr := DataUploadWithMetadata(reader, metadata)(obj) closeErr := reader.Close() return errorutil.NewAggregate(uploadErr, closeErr) } }
go
func FileUploadWithMetadata(file string, metadata map[string]string) UploadFunc { return func(obj *storage.ObjectHandle) error { reader, err := os.Open(file) if err != nil { return err } uploadErr := DataUploadWithMetadata(reader, metadata)(obj) closeErr := reader.Close() return errorutil.NewAggregate(uploadErr, closeErr) } }
[ "func", "FileUploadWithMetadata", "(", "file", "string", ",", "metadata", "map", "[", "string", "]", "string", ")", "UploadFunc", "{", "return", "func", "(", "obj", "*", "storage", ".", "ObjectHandle", ")", "error", "{", "reader", ",", "err", ":=", "os", ...
// FileUploadWithMetadata returns an UploadFunc which copies all // data from the file on disk into GCS object and also sets the provided // metadata fields on the object.
[ "FileUploadWithMetadata", "returns", "an", "UploadFunc", "which", "copies", "all", "data", "from", "the", "file", "on", "disk", "into", "GCS", "object", "and", "also", "sets", "the", "provided", "metadata", "fields", "on", "the", "object", "." ]
8125fbda10178887be5dff9e901d6a0a519b67bc
https://github.com/kubernetes/test-infra/blob/8125fbda10178887be5dff9e901d6a0a519b67bc/prow/pod-utils/gcs/upload.go#L75-L87
test
kubernetes/test-infra
prow/pod-utils/gcs/upload.go
DataUploadWithMetadata
func DataUploadWithMetadata(src io.Reader, metadata map[string]string) UploadFunc { return func(obj *storage.ObjectHandle) error { writer := obj.NewWriter(context.Background()) writer.Metadata = metadata _, copyErr := io.Copy(writer, src) closeErr := writer.Close() return errorutil.NewAggregate(copyErr, closeErr) } }
go
func DataUploadWithMetadata(src io.Reader, metadata map[string]string) UploadFunc { return func(obj *storage.ObjectHandle) error { writer := obj.NewWriter(context.Background()) writer.Metadata = metadata _, copyErr := io.Copy(writer, src) closeErr := writer.Close() return errorutil.NewAggregate(copyErr, closeErr) } }
[ "func", "DataUploadWithMetadata", "(", "src", "io", ".", "Reader", ",", "metadata", "map", "[", "string", "]", "string", ")", "UploadFunc", "{", "return", "func", "(", "obj", "*", "storage", ".", "ObjectHandle", ")", "error", "{", "writer", ":=", "obj", ...
// DataUploadWithMetadata returns an UploadFunc which copies all // data from src reader into GCS and also sets the provided metadata // fields onto the object.
[ "DataUploadWithMetadata", "returns", "an", "UploadFunc", "which", "copies", "all", "data", "from", "src", "reader", "into", "GCS", "and", "also", "sets", "the", "provided", "metadata", "fields", "onto", "the", "object", "." ]
8125fbda10178887be5dff9e901d6a0a519b67bc
https://github.com/kubernetes/test-infra/blob/8125fbda10178887be5dff9e901d6a0a519b67bc/prow/pod-utils/gcs/upload.go#L98-L107
test
kubernetes/test-infra
prow/github/helpers.go
HasLabel
func HasLabel(label string, issueLabels []Label) bool { for _, l := range issueLabels { if strings.ToLower(l.Name) == strings.ToLower(label) { return true } } return false }
go
func HasLabel(label string, issueLabels []Label) bool { for _, l := range issueLabels { if strings.ToLower(l.Name) == strings.ToLower(label) { return true } } return false }
[ "func", "HasLabel", "(", "label", "string", ",", "issueLabels", "[", "]", "Label", ")", "bool", "{", "for", "_", ",", "l", ":=", "range", "issueLabels", "{", "if", "strings", ".", "ToLower", "(", "l", ".", "Name", ")", "==", "strings", ".", "ToLower"...
// HasLabel checks if label is in the label set "issueLabels".
[ "HasLabel", "checks", "if", "label", "is", "in", "the", "label", "set", "issueLabels", "." ]
8125fbda10178887be5dff9e901d6a0a519b67bc
https://github.com/kubernetes/test-infra/blob/8125fbda10178887be5dff9e901d6a0a519b67bc/prow/github/helpers.go#L27-L34
test
kubernetes/test-infra
prow/github/helpers.go
ImageTooBig
func ImageTooBig(url string) (bool, error) { // limit is 10MB limit := 10000000 // try to get the image size from Content-Length header resp, err := http.Head(url) if err != nil { return true, fmt.Errorf("HEAD error: %v", err) } if sc := resp.StatusCode; sc != http.StatusOK { return true, fmt.Errorf("failing %d response", sc) } size, _ := strconv.Atoi(resp.Header.Get("Content-Length")) if size > limit { return true, nil } return false, nil }
go
func ImageTooBig(url string) (bool, error) { // limit is 10MB limit := 10000000 // try to get the image size from Content-Length header resp, err := http.Head(url) if err != nil { return true, fmt.Errorf("HEAD error: %v", err) } if sc := resp.StatusCode; sc != http.StatusOK { return true, fmt.Errorf("failing %d response", sc) } size, _ := strconv.Atoi(resp.Header.Get("Content-Length")) if size > limit { return true, nil } return false, nil }
[ "func", "ImageTooBig", "(", "url", "string", ")", "(", "bool", ",", "error", ")", "{", "limit", ":=", "10000000", "\n", "resp", ",", "err", ":=", "http", ".", "Head", "(", "url", ")", "\n", "if", "err", "!=", "nil", "{", "return", "true", ",", "f...
// ImageTooBig checks if image is bigger than github limits
[ "ImageTooBig", "checks", "if", "image", "is", "bigger", "than", "github", "limits" ]
8125fbda10178887be5dff9e901d6a0a519b67bc
https://github.com/kubernetes/test-infra/blob/8125fbda10178887be5dff9e901d6a0a519b67bc/prow/github/helpers.go#L37-L53
test
kubernetes/test-infra
prow/github/helpers.go
LevelFromPermissions
func LevelFromPermissions(permissions RepoPermissions) RepoPermissionLevel { if permissions.Admin { return Admin } else if permissions.Push { return Write } else if permissions.Pull { return Read } else { return None } }
go
func LevelFromPermissions(permissions RepoPermissions) RepoPermissionLevel { if permissions.Admin { return Admin } else if permissions.Push { return Write } else if permissions.Pull { return Read } else { return None } }
[ "func", "LevelFromPermissions", "(", "permissions", "RepoPermissions", ")", "RepoPermissionLevel", "{", "if", "permissions", ".", "Admin", "{", "return", "Admin", "\n", "}", "else", "if", "permissions", ".", "Push", "{", "return", "Write", "\n", "}", "else", "...
// LevelFromPermissions adapts a repo permissions struct to the // appropriate permission level used elsewhere
[ "LevelFromPermissions", "adapts", "a", "repo", "permissions", "struct", "to", "the", "appropriate", "permission", "level", "used", "elsewhere" ]
8125fbda10178887be5dff9e901d6a0a519b67bc
https://github.com/kubernetes/test-infra/blob/8125fbda10178887be5dff9e901d6a0a519b67bc/prow/github/helpers.go#L57-L67
test
kubernetes/test-infra
prow/github/helpers.go
PermissionsFromLevel
func PermissionsFromLevel(permission RepoPermissionLevel) RepoPermissions { switch permission { case None: return RepoPermissions{} case Read: return RepoPermissions{Pull: true} case Write: return RepoPermissions{Pull: true, Push: true} case Admin: return RepoPermissions{Pull: true, Push: true, Admin: true} default: return RepoPermissions{} } }
go
func PermissionsFromLevel(permission RepoPermissionLevel) RepoPermissions { switch permission { case None: return RepoPermissions{} case Read: return RepoPermissions{Pull: true} case Write: return RepoPermissions{Pull: true, Push: true} case Admin: return RepoPermissions{Pull: true, Push: true, Admin: true} default: return RepoPermissions{} } }
[ "func", "PermissionsFromLevel", "(", "permission", "RepoPermissionLevel", ")", "RepoPermissions", "{", "switch", "permission", "{", "case", "None", ":", "return", "RepoPermissions", "{", "}", "\n", "case", "Read", ":", "return", "RepoPermissions", "{", "Pull", ":"...
// PermissionsFromLevel adapts a repo permission level to the // appropriate permissions struct used elsewhere
[ "PermissionsFromLevel", "adapts", "a", "repo", "permission", "level", "to", "the", "appropriate", "permissions", "struct", "used", "elsewhere" ]
8125fbda10178887be5dff9e901d6a0a519b67bc
https://github.com/kubernetes/test-infra/blob/8125fbda10178887be5dff9e901d6a0a519b67bc/prow/github/helpers.go#L71-L84
test
kubernetes/test-infra
prow/client/clientset/versioned/typed/prowjobs/v1/prowjob.go
newProwJobs
func newProwJobs(c *ProwV1Client, namespace string) *prowJobs { return &prowJobs{ client: c.RESTClient(), ns: namespace, } }
go
func newProwJobs(c *ProwV1Client, namespace string) *prowJobs { return &prowJobs{ client: c.RESTClient(), ns: namespace, } }
[ "func", "newProwJobs", "(", "c", "*", "ProwV1Client", ",", "namespace", "string", ")", "*", "prowJobs", "{", "return", "&", "prowJobs", "{", "client", ":", "c", ".", "RESTClient", "(", ")", ",", "ns", ":", "namespace", ",", "}", "\n", "}" ]
// newProwJobs returns a ProwJobs
[ "newProwJobs", "returns", "a", "ProwJobs" ]
8125fbda10178887be5dff9e901d6a0a519b67bc
https://github.com/kubernetes/test-infra/blob/8125fbda10178887be5dff9e901d6a0a519b67bc/prow/client/clientset/versioned/typed/prowjobs/v1/prowjob.go#L57-L62
test
kubernetes/test-infra
prow/tide/blockers/blockers.go
GetApplicable
func (b Blockers) GetApplicable(org, repo, branch string) []Blocker { var res []Blocker res = append(res, b.Repo[orgRepo{org: org, repo: repo}]...) res = append(res, b.Branch[orgRepoBranch{org: org, repo: repo, branch: branch}]...) sort.Slice(res, func(i, j int) bool { return res[i].Number < res[j].Number }) return res }
go
func (b Blockers) GetApplicable(org, repo, branch string) []Blocker { var res []Blocker res = append(res, b.Repo[orgRepo{org: org, repo: repo}]...) res = append(res, b.Branch[orgRepoBranch{org: org, repo: repo, branch: branch}]...) sort.Slice(res, func(i, j int) bool { return res[i].Number < res[j].Number }) return res }
[ "func", "(", "b", "Blockers", ")", "GetApplicable", "(", "org", ",", "repo", ",", "branch", "string", ")", "[", "]", "Blocker", "{", "var", "res", "[", "]", "Blocker", "\n", "res", "=", "append", "(", "res", ",", "b", ".", "Repo", "[", "orgRepo", ...
// GetApplicable returns the subset of blockers applicable to the specified branch.
[ "GetApplicable", "returns", "the", "subset", "of", "blockers", "applicable", "to", "the", "specified", "branch", "." ]
8125fbda10178887be5dff9e901d6a0a519b67bc
https://github.com/kubernetes/test-infra/blob/8125fbda10178887be5dff9e901d6a0a519b67bc/prow/tide/blockers/blockers.go#L61-L70
test
kubernetes/test-infra
prow/cmd/jenkins-operator/main.go
serve
func serve(jc *jenkins.Client) { http.Handle("/", gziphandler.GzipHandler(handleLog(jc))) http.Handle("/metrics", promhttp.Handler()) logrus.WithError(http.ListenAndServe(":8080", nil)).Fatal("ListenAndServe returned.") }
go
func serve(jc *jenkins.Client) { http.Handle("/", gziphandler.GzipHandler(handleLog(jc))) http.Handle("/metrics", promhttp.Handler()) logrus.WithError(http.ListenAndServe(":8080", nil)).Fatal("ListenAndServe returned.") }
[ "func", "serve", "(", "jc", "*", "jenkins", ".", "Client", ")", "{", "http", ".", "Handle", "(", "\"/\"", ",", "gziphandler", ".", "GzipHandler", "(", "handleLog", "(", "jc", ")", ")", ")", "\n", "http", ".", "Handle", "(", "\"/metrics\"", ",", "prom...
// serve starts a http server and serves Jenkins logs // and prometheus metrics. Meant to be called inside // a goroutine.
[ "serve", "starts", "a", "http", "server", "and", "serves", "Jenkins", "logs", "and", "prometheus", "metrics", ".", "Meant", "to", "be", "called", "inside", "a", "goroutine", "." ]
8125fbda10178887be5dff9e901d6a0a519b67bc
https://github.com/kubernetes/test-infra/blob/8125fbda10178887be5dff9e901d6a0a519b67bc/prow/cmd/jenkins-operator/main.go#L267-L271
test
kubernetes/test-infra
velodrome/transform/plugins/count.go
NewCountPlugin
func NewCountPlugin(runner func(Plugin) error) *cobra.Command { stateCounter := &StatePlugin{} eventCounter := &EventCounterPlugin{} commentsAsEvents := NewFakeCommentPluginWrapper(eventCounter) commentCounter := &CommentCounterPlugin{} authorLoggable := NewMultiplexerPluginWrapper( commentsAsEvents, commentCounter, ) authorLogged := NewAuthorLoggerPluginWrapper(authorLoggable) fullMultiplex := NewMultiplexerPluginWrapper(authorLogged, stateCounter) fakeOpen := NewFakeOpenPluginWrapper(fullMultiplex) typeFilter := NewTypeFilterWrapperPlugin(fakeOpen) authorFilter := NewAuthorFilterPluginWrapper(typeFilter) cmd := &cobra.Command{ Use: "count", Short: "Count events and number of issues in given state, and for how long", RunE: func(cmd *cobra.Command, args []string) error { if err := eventCounter.CheckFlags(); err != nil { return err } if err := stateCounter.CheckFlags(); err != nil { return err } if err := typeFilter.CheckFlags(); err != nil { return err } if err := commentCounter.CheckFlags(); err != nil { return err } return runner(authorFilter) }, } eventCounter.AddFlags(cmd) stateCounter.AddFlags(cmd) commentCounter.AddFlags(cmd) typeFilter.AddFlags(cmd) authorFilter.AddFlags(cmd) authorLogged.AddFlags(cmd) return cmd }
go
func NewCountPlugin(runner func(Plugin) error) *cobra.Command { stateCounter := &StatePlugin{} eventCounter := &EventCounterPlugin{} commentsAsEvents := NewFakeCommentPluginWrapper(eventCounter) commentCounter := &CommentCounterPlugin{} authorLoggable := NewMultiplexerPluginWrapper( commentsAsEvents, commentCounter, ) authorLogged := NewAuthorLoggerPluginWrapper(authorLoggable) fullMultiplex := NewMultiplexerPluginWrapper(authorLogged, stateCounter) fakeOpen := NewFakeOpenPluginWrapper(fullMultiplex) typeFilter := NewTypeFilterWrapperPlugin(fakeOpen) authorFilter := NewAuthorFilterPluginWrapper(typeFilter) cmd := &cobra.Command{ Use: "count", Short: "Count events and number of issues in given state, and for how long", RunE: func(cmd *cobra.Command, args []string) error { if err := eventCounter.CheckFlags(); err != nil { return err } if err := stateCounter.CheckFlags(); err != nil { return err } if err := typeFilter.CheckFlags(); err != nil { return err } if err := commentCounter.CheckFlags(); err != nil { return err } return runner(authorFilter) }, } eventCounter.AddFlags(cmd) stateCounter.AddFlags(cmd) commentCounter.AddFlags(cmd) typeFilter.AddFlags(cmd) authorFilter.AddFlags(cmd) authorLogged.AddFlags(cmd) return cmd }
[ "func", "NewCountPlugin", "(", "runner", "func", "(", "Plugin", ")", "error", ")", "*", "cobra", ".", "Command", "{", "stateCounter", ":=", "&", "StatePlugin", "{", "}", "\n", "eventCounter", ":=", "&", "EventCounterPlugin", "{", "}", "\n", "commentsAsEvents...
// NewCountPlugin counts events and number of issues in given state, and for how long.
[ "NewCountPlugin", "counts", "events", "and", "number", "of", "issues", "in", "given", "state", "and", "for", "how", "long", "." ]
8125fbda10178887be5dff9e901d6a0a519b67bc
https://github.com/kubernetes/test-infra/blob/8125fbda10178887be5dff9e901d6a0a519b67bc/velodrome/transform/plugins/count.go#L24-L68
test
kubernetes/test-infra
velodrome/transform/plugins/fake_comment_wrapper.go
ReceiveComment
func (o *FakeCommentPluginWrapper) ReceiveComment(comment sql.Comment) []Point { // Create a fake "commented" event for every comment we receive. fakeEvent := sql.IssueEvent{ IssueID: comment.IssueID, Event: "commented", EventCreatedAt: comment.CommentCreatedAt, Actor: &comment.User, } return append( o.plugin.ReceiveComment(comment), o.plugin.ReceiveIssueEvent(fakeEvent)..., ) }
go
func (o *FakeCommentPluginWrapper) ReceiveComment(comment sql.Comment) []Point { // Create a fake "commented" event for every comment we receive. fakeEvent := sql.IssueEvent{ IssueID: comment.IssueID, Event: "commented", EventCreatedAt: comment.CommentCreatedAt, Actor: &comment.User, } return append( o.plugin.ReceiveComment(comment), o.plugin.ReceiveIssueEvent(fakeEvent)..., ) }
[ "func", "(", "o", "*", "FakeCommentPluginWrapper", ")", "ReceiveComment", "(", "comment", "sql", ".", "Comment", ")", "[", "]", "Point", "{", "fakeEvent", ":=", "sql", ".", "IssueEvent", "{", "IssueID", ":", "comment", ".", "IssueID", ",", "Event", ":", ...
// ReceiveComment creates a fake "commented" event
[ "ReceiveComment", "creates", "a", "fake", "commented", "event" ]
8125fbda10178887be5dff9e901d6a0a519b67bc
https://github.com/kubernetes/test-infra/blob/8125fbda10178887be5dff9e901d6a0a519b67bc/velodrome/transform/plugins/fake_comment_wrapper.go#L50-L63
test
kubernetes/test-infra
greenhouse/main.go
updateMetrics
func updateMetrics(interval time.Duration, diskRoot string) { logger := logrus.WithField("sync-loop", "updateMetrics") ticker := time.NewTicker(interval) for ; true; <-ticker.C { logger.Info("tick") _, bytesFree, bytesUsed, err := diskutil.GetDiskUsage(diskRoot) if err != nil { logger.WithError(err).Error("Failed to get disk metrics") } else { promMetrics.DiskFree.Set(float64(bytesFree) / 1e9) promMetrics.DiskUsed.Set(float64(bytesUsed) / 1e9) promMetrics.DiskTotal.Set(float64(bytesFree+bytesUsed) / 1e9) } } }
go
func updateMetrics(interval time.Duration, diskRoot string) { logger := logrus.WithField("sync-loop", "updateMetrics") ticker := time.NewTicker(interval) for ; true; <-ticker.C { logger.Info("tick") _, bytesFree, bytesUsed, err := diskutil.GetDiskUsage(diskRoot) if err != nil { logger.WithError(err).Error("Failed to get disk metrics") } else { promMetrics.DiskFree.Set(float64(bytesFree) / 1e9) promMetrics.DiskUsed.Set(float64(bytesUsed) / 1e9) promMetrics.DiskTotal.Set(float64(bytesFree+bytesUsed) / 1e9) } } }
[ "func", "updateMetrics", "(", "interval", "time", ".", "Duration", ",", "diskRoot", "string", ")", "{", "logger", ":=", "logrus", ".", "WithField", "(", "\"sync-loop\"", ",", "\"updateMetrics\"", ")", "\n", "ticker", ":=", "time", ".", "NewTicker", "(", "int...
// helper to update disk metrics
[ "helper", "to", "update", "disk", "metrics" ]
8125fbda10178887be5dff9e901d6a0a519b67bc
https://github.com/kubernetes/test-infra/blob/8125fbda10178887be5dff9e901d6a0a519b67bc/greenhouse/main.go#L194-L208
test
kubernetes/test-infra
boskos/ranch/ranch.go
LogStatus
func (r *Ranch) LogStatus() { resources, err := r.Storage.GetResources() if err != nil { return } resJSON, err := json.Marshal(resources) if err != nil { logrus.WithError(err).Errorf("Fail to marshal Resources. %v", resources) } logrus.Infof("Current Resources : %v", string(resJSON)) }
go
func (r *Ranch) LogStatus() { resources, err := r.Storage.GetResources() if err != nil { return } resJSON, err := json.Marshal(resources) if err != nil { logrus.WithError(err).Errorf("Fail to marshal Resources. %v", resources) } logrus.Infof("Current Resources : %v", string(resJSON)) }
[ "func", "(", "r", "*", "Ranch", ")", "LogStatus", "(", ")", "{", "resources", ",", "err", ":=", "r", ".", "Storage", ".", "GetResources", "(", ")", "\n", "if", "err", "!=", "nil", "{", "return", "\n", "}", "\n", "resJSON", ",", "err", ":=", "json...
// LogStatus outputs current status of all resources
[ "LogStatus", "outputs", "current", "status", "of", "all", "resources" ]
8125fbda10178887be5dff9e901d6a0a519b67bc
https://github.com/kubernetes/test-infra/blob/8125fbda10178887be5dff9e901d6a0a519b67bc/boskos/ranch/ranch.go#L304-L316
test
kubernetes/test-infra
boskos/ranch/ranch.go
SyncConfig
func (r *Ranch) SyncConfig(config string) error { resources, err := ParseConfig(config) if err != nil { return err } if err := r.Storage.SyncResources(resources); err != nil { return err } return nil }
go
func (r *Ranch) SyncConfig(config string) error { resources, err := ParseConfig(config) if err != nil { return err } if err := r.Storage.SyncResources(resources); err != nil { return err } return nil }
[ "func", "(", "r", "*", "Ranch", ")", "SyncConfig", "(", "config", "string", ")", "error", "{", "resources", ",", "err", ":=", "ParseConfig", "(", "config", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "if", "err", ":=...
// SyncConfig updates resource list from a file
[ "SyncConfig", "updates", "resource", "list", "from", "a", "file" ]
8125fbda10178887be5dff9e901d6a0a519b67bc
https://github.com/kubernetes/test-infra/blob/8125fbda10178887be5dff9e901d6a0a519b67bc/boskos/ranch/ranch.go#L319-L328
test
kubernetes/test-infra
boskos/ranch/ranch.go
Metric
func (r *Ranch) Metric(rtype string) (common.Metric, error) { metric := common.Metric{ Type: rtype, Current: map[string]int{}, Owners: map[string]int{}, } resources, err := r.Storage.GetResources() if err != nil { logrus.WithError(err).Error("cannot find resources") return metric, &ResourceNotFound{rtype} } for _, res := range resources { if res.Type != rtype { continue } if _, ok := metric.Current[res.State]; !ok { metric.Current[res.State] = 0 } if _, ok := metric.Owners[res.Owner]; !ok { metric.Owners[res.Owner] = 0 } metric.Current[res.State]++ metric.Owners[res.Owner]++ } if len(metric.Current) == 0 && len(metric.Owners) == 0 { return metric, &ResourceNotFound{rtype} } return metric, nil }
go
func (r *Ranch) Metric(rtype string) (common.Metric, error) { metric := common.Metric{ Type: rtype, Current: map[string]int{}, Owners: map[string]int{}, } resources, err := r.Storage.GetResources() if err != nil { logrus.WithError(err).Error("cannot find resources") return metric, &ResourceNotFound{rtype} } for _, res := range resources { if res.Type != rtype { continue } if _, ok := metric.Current[res.State]; !ok { metric.Current[res.State] = 0 } if _, ok := metric.Owners[res.Owner]; !ok { metric.Owners[res.Owner] = 0 } metric.Current[res.State]++ metric.Owners[res.Owner]++ } if len(metric.Current) == 0 && len(metric.Owners) == 0 { return metric, &ResourceNotFound{rtype} } return metric, nil }
[ "func", "(", "r", "*", "Ranch", ")", "Metric", "(", "rtype", "string", ")", "(", "common", ".", "Metric", ",", "error", ")", "{", "metric", ":=", "common", ".", "Metric", "{", "Type", ":", "rtype", ",", "Current", ":", "map", "[", "string", "]", ...
// Metric returns a metric object with metrics filled in
[ "Metric", "returns", "a", "metric", "object", "with", "metrics", "filled", "in" ]
8125fbda10178887be5dff9e901d6a0a519b67bc
https://github.com/kubernetes/test-infra/blob/8125fbda10178887be5dff9e901d6a0a519b67bc/boskos/ranch/ranch.go#L331-L366
test
kubernetes/test-infra
prow/plugins/dog/dog.go
FormatURL
func FormatURL(dogURL string) (string, error) { if dogURL == "" { return "", errors.New("empty url") } src, err := url.ParseRequestURI(dogURL) if err != nil { return "", fmt.Errorf("invalid url %s: %v", dogURL, err) } return fmt.Sprintf("[![dog image](%s)](%s)", src, src), nil }
go
func FormatURL(dogURL string) (string, error) { if dogURL == "" { return "", errors.New("empty url") } src, err := url.ParseRequestURI(dogURL) if err != nil { return "", fmt.Errorf("invalid url %s: %v", dogURL, err) } return fmt.Sprintf("[![dog image](%s)](%s)", src, src), nil }
[ "func", "FormatURL", "(", "dogURL", "string", ")", "(", "string", ",", "error", ")", "{", "if", "dogURL", "==", "\"\"", "{", "return", "\"\"", ",", "errors", ".", "New", "(", "\"empty url\"", ")", "\n", "}", "\n", "src", ",", "err", ":=", "url", "....
// FormatURL will return the GH markdown to show the image for a specific dogURL.
[ "FormatURL", "will", "return", "the", "GH", "markdown", "to", "show", "the", "image", "for", "a", "specific", "dogURL", "." ]
8125fbda10178887be5dff9e901d6a0a519b67bc
https://github.com/kubernetes/test-infra/blob/8125fbda10178887be5dff9e901d6a0a519b67bc/prow/plugins/dog/dog.go#L87-L96
test
kubernetes/test-infra
prow/plugins/trigger/trigger.go
runAndSkipJobs
func runAndSkipJobs(c Client, pr *github.PullRequest, requestedJobs []config.Presubmit, skippedJobs []config.Presubmit, eventGUID string, elideSkippedContexts bool) error { if err := validateContextOverlap(requestedJobs, skippedJobs); err != nil { c.Logger.WithError(err).Warn("Could not run or skip requested jobs, overlapping contexts.") return err } runErr := RunRequested(c, pr, requestedJobs, eventGUID) var skipErr error if !elideSkippedContexts { skipErr = skipRequested(c, pr, skippedJobs) } return errorutil.NewAggregate(runErr, skipErr) }
go
func runAndSkipJobs(c Client, pr *github.PullRequest, requestedJobs []config.Presubmit, skippedJobs []config.Presubmit, eventGUID string, elideSkippedContexts bool) error { if err := validateContextOverlap(requestedJobs, skippedJobs); err != nil { c.Logger.WithError(err).Warn("Could not run or skip requested jobs, overlapping contexts.") return err } runErr := RunRequested(c, pr, requestedJobs, eventGUID) var skipErr error if !elideSkippedContexts { skipErr = skipRequested(c, pr, skippedJobs) } return errorutil.NewAggregate(runErr, skipErr) }
[ "func", "runAndSkipJobs", "(", "c", "Client", ",", "pr", "*", "github", ".", "PullRequest", ",", "requestedJobs", "[", "]", "config", ".", "Presubmit", ",", "skippedJobs", "[", "]", "config", ".", "Presubmit", ",", "eventGUID", "string", ",", "elideSkippedCo...
// runAndSkipJobs executes the config.Presubmits that are requested and posts skipped statuses // for the reporting jobs that are skipped
[ "runAndSkipJobs", "executes", "the", "config", ".", "Presubmits", "that", "are", "requested", "and", "posts", "skipped", "statuses", "for", "the", "reporting", "jobs", "that", "are", "skipped" ]
8125fbda10178887be5dff9e901d6a0a519b67bc
https://github.com/kubernetes/test-infra/blob/8125fbda10178887be5dff9e901d6a0a519b67bc/prow/plugins/trigger/trigger.go#L198-L210
test
kubernetes/test-infra
prow/plugins/trigger/trigger.go
validateContextOverlap
func validateContextOverlap(toRun, toSkip []config.Presubmit) error { requestedContexts := sets.NewString() for _, job := range toRun { requestedContexts.Insert(job.Context) } skippedContexts := sets.NewString() for _, job := range toSkip { skippedContexts.Insert(job.Context) } if overlap := requestedContexts.Intersection(skippedContexts).List(); len(overlap) > 0 { return fmt.Errorf("the following contexts are both triggered and skipped: %s", strings.Join(overlap, ", ")) } return nil }
go
func validateContextOverlap(toRun, toSkip []config.Presubmit) error { requestedContexts := sets.NewString() for _, job := range toRun { requestedContexts.Insert(job.Context) } skippedContexts := sets.NewString() for _, job := range toSkip { skippedContexts.Insert(job.Context) } if overlap := requestedContexts.Intersection(skippedContexts).List(); len(overlap) > 0 { return fmt.Errorf("the following contexts are both triggered and skipped: %s", strings.Join(overlap, ", ")) } return nil }
[ "func", "validateContextOverlap", "(", "toRun", ",", "toSkip", "[", "]", "config", ".", "Presubmit", ")", "error", "{", "requestedContexts", ":=", "sets", ".", "NewString", "(", ")", "\n", "for", "_", ",", "job", ":=", "range", "toRun", "{", "requestedCont...
// validateContextOverlap ensures that there will be no overlap in contexts between a set of jobs running and a set to skip
[ "validateContextOverlap", "ensures", "that", "there", "will", "be", "no", "overlap", "in", "contexts", "between", "a", "set", "of", "jobs", "running", "and", "a", "set", "to", "skip" ]
8125fbda10178887be5dff9e901d6a0a519b67bc
https://github.com/kubernetes/test-infra/blob/8125fbda10178887be5dff9e901d6a0a519b67bc/prow/plugins/trigger/trigger.go#L213-L227
test
kubernetes/test-infra
prow/plugins/trigger/trigger.go
RunRequested
func RunRequested(c Client, pr *github.PullRequest, requestedJobs []config.Presubmit, eventGUID string) error { baseSHA, err := c.GitHubClient.GetRef(pr.Base.Repo.Owner.Login, pr.Base.Repo.Name, "heads/"+pr.Base.Ref) if err != nil { return err } var errors []error for _, job := range requestedJobs { c.Logger.Infof("Starting %s build.", job.Name) pj := pjutil.NewPresubmit(*pr, baseSHA, job, eventGUID) c.Logger.WithFields(pjutil.ProwJobFields(&pj)).Info("Creating a new prowjob.") if _, err := c.ProwJobClient.Create(&pj); err != nil { c.Logger.WithError(err).Error("Failed to create prowjob.") errors = append(errors, err) } } return errorutil.NewAggregate(errors...) }
go
func RunRequested(c Client, pr *github.PullRequest, requestedJobs []config.Presubmit, eventGUID string) error { baseSHA, err := c.GitHubClient.GetRef(pr.Base.Repo.Owner.Login, pr.Base.Repo.Name, "heads/"+pr.Base.Ref) if err != nil { return err } var errors []error for _, job := range requestedJobs { c.Logger.Infof("Starting %s build.", job.Name) pj := pjutil.NewPresubmit(*pr, baseSHA, job, eventGUID) c.Logger.WithFields(pjutil.ProwJobFields(&pj)).Info("Creating a new prowjob.") if _, err := c.ProwJobClient.Create(&pj); err != nil { c.Logger.WithError(err).Error("Failed to create prowjob.") errors = append(errors, err) } } return errorutil.NewAggregate(errors...) }
[ "func", "RunRequested", "(", "c", "Client", ",", "pr", "*", "github", ".", "PullRequest", ",", "requestedJobs", "[", "]", "config", ".", "Presubmit", ",", "eventGUID", "string", ")", "error", "{", "baseSHA", ",", "err", ":=", "c", ".", "GitHubClient", "....
// RunRequested executes the config.Presubmits that are requested
[ "RunRequested", "executes", "the", "config", ".", "Presubmits", "that", "are", "requested" ]
8125fbda10178887be5dff9e901d6a0a519b67bc
https://github.com/kubernetes/test-infra/blob/8125fbda10178887be5dff9e901d6a0a519b67bc/prow/plugins/trigger/trigger.go#L230-L247
test
kubernetes/test-infra
prow/plugins/trigger/trigger.go
skipRequested
func skipRequested(c Client, pr *github.PullRequest, skippedJobs []config.Presubmit) error { var errors []error for _, job := range skippedJobs { if job.SkipReport { continue } c.Logger.Infof("Skipping %s build.", job.Name) if err := c.GitHubClient.CreateStatus(pr.Base.Repo.Owner.Login, pr.Base.Repo.Name, pr.Head.SHA, skippedStatusFor(job.Context)); err != nil { errors = append(errors, err) } } return errorutil.NewAggregate(errors...) }
go
func skipRequested(c Client, pr *github.PullRequest, skippedJobs []config.Presubmit) error { var errors []error for _, job := range skippedJobs { if job.SkipReport { continue } c.Logger.Infof("Skipping %s build.", job.Name) if err := c.GitHubClient.CreateStatus(pr.Base.Repo.Owner.Login, pr.Base.Repo.Name, pr.Head.SHA, skippedStatusFor(job.Context)); err != nil { errors = append(errors, err) } } return errorutil.NewAggregate(errors...) }
[ "func", "skipRequested", "(", "c", "Client", ",", "pr", "*", "github", ".", "PullRequest", ",", "skippedJobs", "[", "]", "config", ".", "Presubmit", ")", "error", "{", "var", "errors", "[", "]", "error", "\n", "for", "_", ",", "job", ":=", "range", "...
// skipRequested posts skipped statuses for the config.Presubmits that are requested
[ "skipRequested", "posts", "skipped", "statuses", "for", "the", "config", ".", "Presubmits", "that", "are", "requested" ]
8125fbda10178887be5dff9e901d6a0a519b67bc
https://github.com/kubernetes/test-infra/blob/8125fbda10178887be5dff9e901d6a0a519b67bc/prow/plugins/trigger/trigger.go#L250-L262
test
kubernetes/test-infra
velodrome/transform/plugins/events.go
Match
func (l LabelEvent) Match(eventName, label string) bool { return eventName == "labeled" && label == l.Label }
go
func (l LabelEvent) Match(eventName, label string) bool { return eventName == "labeled" && label == l.Label }
[ "func", "(", "l", "LabelEvent", ")", "Match", "(", "eventName", ",", "label", "string", ")", "bool", "{", "return", "eventName", "==", "\"labeled\"", "&&", "label", "==", "l", ".", "Label", "\n", "}" ]
// Match is "labeled" with label
[ "Match", "is", "labeled", "with", "label" ]
8125fbda10178887be5dff9e901d6a0a519b67bc
https://github.com/kubernetes/test-infra/blob/8125fbda10178887be5dff9e901d6a0a519b67bc/velodrome/transform/plugins/events.go#L100-L102
test
kubernetes/test-infra
velodrome/transform/plugins/events.go
Match
func (u UnlabelEvent) Match(eventName, label string) bool { return eventName == "unlabeled" && label == u.Label }
go
func (u UnlabelEvent) Match(eventName, label string) bool { return eventName == "unlabeled" && label == u.Label }
[ "func", "(", "u", "UnlabelEvent", ")", "Match", "(", "eventName", ",", "label", "string", ")", "bool", "{", "return", "eventName", "==", "\"unlabeled\"", "&&", "label", "==", "u", ".", "Label", "\n", "}" ]
// Match is "unlabeled"
[ "Match", "is", "unlabeled" ]
8125fbda10178887be5dff9e901d6a0a519b67bc
https://github.com/kubernetes/test-infra/blob/8125fbda10178887be5dff9e901d6a0a519b67bc/velodrome/transform/plugins/events.go#L117-L119
test
kubernetes/test-infra
prow/flagutil/github.go
AddFlags
func (o *GitHubOptions) AddFlags(fs *flag.FlagSet) { o.addFlags(true, fs) }
go
func (o *GitHubOptions) AddFlags(fs *flag.FlagSet) { o.addFlags(true, fs) }
[ "func", "(", "o", "*", "GitHubOptions", ")", "AddFlags", "(", "fs", "*", "flag", ".", "FlagSet", ")", "{", "o", ".", "addFlags", "(", "true", ",", "fs", ")", "\n", "}" ]
// AddFlags injects GitHub options into the given FlagSet.
[ "AddFlags", "injects", "GitHub", "options", "into", "the", "given", "FlagSet", "." ]
8125fbda10178887be5dff9e901d6a0a519b67bc
https://github.com/kubernetes/test-infra/blob/8125fbda10178887be5dff9e901d6a0a519b67bc/prow/flagutil/github.go#L40-L42
test
kubernetes/test-infra
prow/flagutil/github.go
AddFlagsWithoutDefaultGitHubTokenPath
func (o *GitHubOptions) AddFlagsWithoutDefaultGitHubTokenPath(fs *flag.FlagSet) { o.addFlags(false, fs) }
go
func (o *GitHubOptions) AddFlagsWithoutDefaultGitHubTokenPath(fs *flag.FlagSet) { o.addFlags(false, fs) }
[ "func", "(", "o", "*", "GitHubOptions", ")", "AddFlagsWithoutDefaultGitHubTokenPath", "(", "fs", "*", "flag", ".", "FlagSet", ")", "{", "o", ".", "addFlags", "(", "false", ",", "fs", ")", "\n", "}" ]
// AddFlagsWithoutDefaultGitHubTokenPath injects GitHub options into the given // Flagset without setting a default for for the githubTokenPath, allowing to // use an anonymous GitHub client
[ "AddFlagsWithoutDefaultGitHubTokenPath", "injects", "GitHub", "options", "into", "the", "given", "Flagset", "without", "setting", "a", "default", "for", "for", "the", "githubTokenPath", "allowing", "to", "use", "an", "anonymous", "GitHub", "client" ]
8125fbda10178887be5dff9e901d6a0a519b67bc
https://github.com/kubernetes/test-infra/blob/8125fbda10178887be5dff9e901d6a0a519b67bc/prow/flagutil/github.go#L47-L49
test
kubernetes/test-infra
prow/flagutil/github.go
Validate
func (o *GitHubOptions) Validate(dryRun bool) error { for _, uri := range o.endpoint.Strings() { if uri == "" { uri = github.DefaultAPIEndpoint } else if _, err := url.ParseRequestURI(uri); err != nil { return fmt.Errorf("invalid -github-endpoint URI: %q", uri) } } if o.graphqlEndpoint == "" { o.graphqlEndpoint = github.DefaultGraphQLEndpoint } else if _, err := url.Parse(o.graphqlEndpoint); err != nil { return fmt.Errorf("invalid -github-graphql-endpoint URI: %q", o.graphqlEndpoint) } if o.deprecatedTokenFile != "" { o.TokenPath = o.deprecatedTokenFile logrus.Error("-github-token-file is deprecated and may be removed anytime after 2019-01-01. Use -github-token-path instead.") } if o.TokenPath == "" { logrus.Warn("empty -github-token-path, will use anonymous github client") } return nil }
go
func (o *GitHubOptions) Validate(dryRun bool) error { for _, uri := range o.endpoint.Strings() { if uri == "" { uri = github.DefaultAPIEndpoint } else if _, err := url.ParseRequestURI(uri); err != nil { return fmt.Errorf("invalid -github-endpoint URI: %q", uri) } } if o.graphqlEndpoint == "" { o.graphqlEndpoint = github.DefaultGraphQLEndpoint } else if _, err := url.Parse(o.graphqlEndpoint); err != nil { return fmt.Errorf("invalid -github-graphql-endpoint URI: %q", o.graphqlEndpoint) } if o.deprecatedTokenFile != "" { o.TokenPath = o.deprecatedTokenFile logrus.Error("-github-token-file is deprecated and may be removed anytime after 2019-01-01. Use -github-token-path instead.") } if o.TokenPath == "" { logrus.Warn("empty -github-token-path, will use anonymous github client") } return nil }
[ "func", "(", "o", "*", "GitHubOptions", ")", "Validate", "(", "dryRun", "bool", ")", "error", "{", "for", "_", ",", "uri", ":=", "range", "o", ".", "endpoint", ".", "Strings", "(", ")", "{", "if", "uri", "==", "\"\"", "{", "uri", "=", "github", "...
// Validate validates GitHub options.
[ "Validate", "validates", "GitHub", "options", "." ]
8125fbda10178887be5dff9e901d6a0a519b67bc
https://github.com/kubernetes/test-infra/blob/8125fbda10178887be5dff9e901d6a0a519b67bc/prow/flagutil/github.go#L64-L89
test
kubernetes/test-infra
prow/flagutil/github.go
GitHubClientWithLogFields
func (o *GitHubOptions) GitHubClientWithLogFields(secretAgent *secret.Agent, dryRun bool, fields logrus.Fields) (client *github.Client, err error) { var generator *func() []byte if o.TokenPath == "" { generatorFunc := func() []byte { return []byte{} } generator = &generatorFunc } else { if secretAgent == nil { return nil, fmt.Errorf("cannot store token from %q without a secret agent", o.TokenPath) } generatorFunc := secretAgent.GetTokenGenerator(o.TokenPath) generator = &generatorFunc } if dryRun { return github.NewDryRunClientWithFields(fields, *generator, o.graphqlEndpoint, o.endpoint.Strings()...), nil } return github.NewClientWithFields(fields, *generator, o.graphqlEndpoint, o.endpoint.Strings()...), nil }
go
func (o *GitHubOptions) GitHubClientWithLogFields(secretAgent *secret.Agent, dryRun bool, fields logrus.Fields) (client *github.Client, err error) { var generator *func() []byte if o.TokenPath == "" { generatorFunc := func() []byte { return []byte{} } generator = &generatorFunc } else { if secretAgent == nil { return nil, fmt.Errorf("cannot store token from %q without a secret agent", o.TokenPath) } generatorFunc := secretAgent.GetTokenGenerator(o.TokenPath) generator = &generatorFunc } if dryRun { return github.NewDryRunClientWithFields(fields, *generator, o.graphqlEndpoint, o.endpoint.Strings()...), nil } return github.NewClientWithFields(fields, *generator, o.graphqlEndpoint, o.endpoint.Strings()...), nil }
[ "func", "(", "o", "*", "GitHubOptions", ")", "GitHubClientWithLogFields", "(", "secretAgent", "*", "secret", ".", "Agent", ",", "dryRun", "bool", ",", "fields", "logrus", ".", "Fields", ")", "(", "client", "*", "github", ".", "Client", ",", "err", "error",...
// GitHubClientWithLogFields returns a GitHub client with extra logging fields
[ "GitHubClientWithLogFields", "returns", "a", "GitHub", "client", "with", "extra", "logging", "fields" ]
8125fbda10178887be5dff9e901d6a0a519b67bc
https://github.com/kubernetes/test-infra/blob/8125fbda10178887be5dff9e901d6a0a519b67bc/prow/flagutil/github.go#L92-L111
test
kubernetes/test-infra
prow/flagutil/github.go
GitHubClient
func (o *GitHubOptions) GitHubClient(secretAgent *secret.Agent, dryRun bool) (client *github.Client, err error) { return o.GitHubClientWithLogFields(secretAgent, dryRun, logrus.Fields{}) }
go
func (o *GitHubOptions) GitHubClient(secretAgent *secret.Agent, dryRun bool) (client *github.Client, err error) { return o.GitHubClientWithLogFields(secretAgent, dryRun, logrus.Fields{}) }
[ "func", "(", "o", "*", "GitHubOptions", ")", "GitHubClient", "(", "secretAgent", "*", "secret", ".", "Agent", ",", "dryRun", "bool", ")", "(", "client", "*", "github", ".", "Client", ",", "err", "error", ")", "{", "return", "o", ".", "GitHubClientWithLog...
// GitHubClient returns a GitHub client.
[ "GitHubClient", "returns", "a", "GitHub", "client", "." ]
8125fbda10178887be5dff9e901d6a0a519b67bc
https://github.com/kubernetes/test-infra/blob/8125fbda10178887be5dff9e901d6a0a519b67bc/prow/flagutil/github.go#L114-L116
test
kubernetes/test-infra
prow/flagutil/github.go
GitClient
func (o *GitHubOptions) GitClient(secretAgent *secret.Agent, dryRun bool) (client *git.Client, err error) { client, err = git.NewClient() if err != nil { return nil, err } // We must capture the value of client here to prevent issues related // to the use of named return values when an error is encountered. // Without this, we risk a nil pointer dereference. defer func(client *git.Client) { if err != nil { client.Clean() } }(client) // Get the bot's name in order to set credentials for the Git client. githubClient, err := o.GitHubClient(secretAgent, dryRun) if err != nil { return nil, fmt.Errorf("error getting GitHub client: %v", err) } botName, err := githubClient.BotName() if err != nil { return nil, fmt.Errorf("error getting bot name: %v", err) } client.SetCredentials(botName, secretAgent.GetTokenGenerator(o.TokenPath)) return client, nil }
go
func (o *GitHubOptions) GitClient(secretAgent *secret.Agent, dryRun bool) (client *git.Client, err error) { client, err = git.NewClient() if err != nil { return nil, err } // We must capture the value of client here to prevent issues related // to the use of named return values when an error is encountered. // Without this, we risk a nil pointer dereference. defer func(client *git.Client) { if err != nil { client.Clean() } }(client) // Get the bot's name in order to set credentials for the Git client. githubClient, err := o.GitHubClient(secretAgent, dryRun) if err != nil { return nil, fmt.Errorf("error getting GitHub client: %v", err) } botName, err := githubClient.BotName() if err != nil { return nil, fmt.Errorf("error getting bot name: %v", err) } client.SetCredentials(botName, secretAgent.GetTokenGenerator(o.TokenPath)) return client, nil }
[ "func", "(", "o", "*", "GitHubOptions", ")", "GitClient", "(", "secretAgent", "*", "secret", ".", "Agent", ",", "dryRun", "bool", ")", "(", "client", "*", "git", ".", "Client", ",", "err", "error", ")", "{", "client", ",", "err", "=", "git", ".", "...
// GitClient returns a Git client.
[ "GitClient", "returns", "a", "Git", "client", "." ]
8125fbda10178887be5dff9e901d6a0a519b67bc
https://github.com/kubernetes/test-infra/blob/8125fbda10178887be5dff9e901d6a0a519b67bc/prow/flagutil/github.go#L119-L146
test
kubernetes/test-infra
robots/coverage/diff/diff.go
toMap
func toMap(g *calculation.CoverageList) map[string]calculation.Coverage { m := make(map[string]calculation.Coverage) for _, cov := range g.Group { m[cov.Name] = cov } return m }
go
func toMap(g *calculation.CoverageList) map[string]calculation.Coverage { m := make(map[string]calculation.Coverage) for _, cov := range g.Group { m[cov.Name] = cov } return m }
[ "func", "toMap", "(", "g", "*", "calculation", ".", "CoverageList", ")", "map", "[", "string", "]", "calculation", ".", "Coverage", "{", "m", ":=", "make", "(", "map", "[", "string", "]", "calculation", ".", "Coverage", ")", "\n", "for", "_", ",", "c...
// toMap returns maps the file name to its coverage for faster retrieval // & membership check
[ "toMap", "returns", "maps", "the", "file", "name", "to", "its", "coverage", "for", "faster", "retrieval", "&", "membership", "check" ]
8125fbda10178887be5dff9e901d6a0a519b67bc
https://github.com/kubernetes/test-infra/blob/8125fbda10178887be5dff9e901d6a0a519b67bc/robots/coverage/diff/diff.go#L44-L50
test
kubernetes/test-infra
robots/coverage/diff/diff.go
findChanges
func findChanges(baseList *calculation.CoverageList, newList *calculation.CoverageList) []*coverageChange { var changes []*coverageChange baseFilesMap := toMap(baseList) for _, newCov := range newList.Group { baseCov, ok := baseFilesMap[newCov.Name] var baseRatio float32 if !ok { baseRatio = -1 } else { baseRatio = baseCov.Ratio() } newRatio := newCov.Ratio() if isChangeSignificant(baseRatio, newRatio) { changes = append(changes, &coverageChange{ name: newCov.Name, baseRatio: baseRatio, newRatio: newRatio, }) } } return changes }
go
func findChanges(baseList *calculation.CoverageList, newList *calculation.CoverageList) []*coverageChange { var changes []*coverageChange baseFilesMap := toMap(baseList) for _, newCov := range newList.Group { baseCov, ok := baseFilesMap[newCov.Name] var baseRatio float32 if !ok { baseRatio = -1 } else { baseRatio = baseCov.Ratio() } newRatio := newCov.Ratio() if isChangeSignificant(baseRatio, newRatio) { changes = append(changes, &coverageChange{ name: newCov.Name, baseRatio: baseRatio, newRatio: newRatio, }) } } return changes }
[ "func", "findChanges", "(", "baseList", "*", "calculation", ".", "CoverageList", ",", "newList", "*", "calculation", ".", "CoverageList", ")", "[", "]", "*", "coverageChange", "{", "var", "changes", "[", "]", "*", "coverageChange", "\n", "baseFilesMap", ":=", ...
// findChanges compares the newList of coverage against the base list and returns the result
[ "findChanges", "compares", "the", "newList", "of", "coverage", "against", "the", "base", "list", "and", "returns", "the", "result" ]
8125fbda10178887be5dff9e901d6a0a519b67bc
https://github.com/kubernetes/test-infra/blob/8125fbda10178887be5dff9e901d6a0a519b67bc/robots/coverage/diff/diff.go#L53-L74
test
kubernetes/test-infra
velodrome/sql/mysql.go
CreateDatabase
func (config *MySQLConfig) CreateDatabase() (*gorm.DB, error) { db, err := gorm.Open("mysql", config.getDSN("")) if err != nil { return nil, err } db.Exec(fmt.Sprintf("CREATE DATABASE IF NOT EXISTS %v;", config.Db)) db.Close() db, err = gorm.Open("mysql", config.getDSN(config.Db)) err = db.AutoMigrate(&Assignee{}, &Issue{}, &IssueEvent{}, &Label{}, &Comment{}).Error if err != nil { return nil, err } return db, nil }
go
func (config *MySQLConfig) CreateDatabase() (*gorm.DB, error) { db, err := gorm.Open("mysql", config.getDSN("")) if err != nil { return nil, err } db.Exec(fmt.Sprintf("CREATE DATABASE IF NOT EXISTS %v;", config.Db)) db.Close() db, err = gorm.Open("mysql", config.getDSN(config.Db)) err = db.AutoMigrate(&Assignee{}, &Issue{}, &IssueEvent{}, &Label{}, &Comment{}).Error if err != nil { return nil, err } return db, nil }
[ "func", "(", "config", "*", "MySQLConfig", ")", "CreateDatabase", "(", ")", "(", "*", "gorm", ".", "DB", ",", "error", ")", "{", "db", ",", "err", ":=", "gorm", ".", "Open", "(", "\"mysql\"", ",", "config", ".", "getDSN", "(", "\"\"", ")", ")", "...
// CreateDatabase for the MySQLConfig
[ "CreateDatabase", "for", "the", "MySQLConfig" ]
8125fbda10178887be5dff9e901d6a0a519b67bc
https://github.com/kubernetes/test-infra/blob/8125fbda10178887be5dff9e901d6a0a519b67bc/velodrome/sql/mysql.go#L50-L66
test
kubernetes/test-infra
prow/github/reporter/reporter.go
ShouldReport
func (c *Client) ShouldReport(pj *v1.ProwJob) bool { if !pj.Spec.Report { // Respect report field return false } if pj.Spec.Type != v1.PresubmitJob && pj.Spec.Type != v1.PostsubmitJob { // Report presubmit and postsubmit github jobs for github reporter return false } if c.reportAgent != "" && pj.Spec.Agent != c.reportAgent { // Only report for specified agent return false } return true }
go
func (c *Client) ShouldReport(pj *v1.ProwJob) bool { if !pj.Spec.Report { // Respect report field return false } if pj.Spec.Type != v1.PresubmitJob && pj.Spec.Type != v1.PostsubmitJob { // Report presubmit and postsubmit github jobs for github reporter return false } if c.reportAgent != "" && pj.Spec.Agent != c.reportAgent { // Only report for specified agent return false } return true }
[ "func", "(", "c", "*", "Client", ")", "ShouldReport", "(", "pj", "*", "v1", ".", "ProwJob", ")", "bool", "{", "if", "!", "pj", ".", "Spec", ".", "Report", "{", "return", "false", "\n", "}", "\n", "if", "pj", ".", "Spec", ".", "Type", "!=", "v1"...
// ShouldReport returns if this prowjob should be reported by the github reporter
[ "ShouldReport", "returns", "if", "this", "prowjob", "should", "be", "reported", "by", "the", "github", "reporter" ]
8125fbda10178887be5dff9e901d6a0a519b67bc
https://github.com/kubernetes/test-infra/blob/8125fbda10178887be5dff9e901d6a0a519b67bc/prow/github/reporter/reporter.go#L54-L72
test
kubernetes/test-infra
prow/github/reporter/reporter.go
Report
func (c *Client) Report(pj *v1.ProwJob) ([]*v1.ProwJob, error) { // TODO(krzyzacy): ditch ReportTemplate, and we can drop reference to config.Getter return []*v1.ProwJob{pj}, report.Report(c.gc, c.config().Plank.ReportTemplate, *pj, c.config().GitHubReporter.JobTypesToReport) }
go
func (c *Client) Report(pj *v1.ProwJob) ([]*v1.ProwJob, error) { // TODO(krzyzacy): ditch ReportTemplate, and we can drop reference to config.Getter return []*v1.ProwJob{pj}, report.Report(c.gc, c.config().Plank.ReportTemplate, *pj, c.config().GitHubReporter.JobTypesToReport) }
[ "func", "(", "c", "*", "Client", ")", "Report", "(", "pj", "*", "v1", ".", "ProwJob", ")", "(", "[", "]", "*", "v1", ".", "ProwJob", ",", "error", ")", "{", "return", "[", "]", "*", "v1", ".", "ProwJob", "{", "pj", "}", ",", "report", ".", ...
// Report will report via reportlib
[ "Report", "will", "report", "via", "reportlib" ]
8125fbda10178887be5dff9e901d6a0a519b67bc
https://github.com/kubernetes/test-infra/blob/8125fbda10178887be5dff9e901d6a0a519b67bc/prow/github/reporter/reporter.go#L75-L78
test
kubernetes/test-infra
maintenance/aws-janitor/resources/set.go
MarkComplete
func (s *Set) MarkComplete() int { var gone []string for key := range s.firstSeen { if !s.marked[key] { gone = append(gone, key) } } for _, key := range gone { klog.V(1).Infof("%s: deleted since last run", key) delete(s.firstSeen, key) } if len(s.swept) > 0 { klog.Errorf("%d resources swept: %v", len(s.swept), s.swept) } return len(s.swept) }
go
func (s *Set) MarkComplete() int { var gone []string for key := range s.firstSeen { if !s.marked[key] { gone = append(gone, key) } } for _, key := range gone { klog.V(1).Infof("%s: deleted since last run", key) delete(s.firstSeen, key) } if len(s.swept) > 0 { klog.Errorf("%d resources swept: %v", len(s.swept), s.swept) } return len(s.swept) }
[ "func", "(", "s", "*", "Set", ")", "MarkComplete", "(", ")", "int", "{", "var", "gone", "[", "]", "string", "\n", "for", "key", ":=", "range", "s", ".", "firstSeen", "{", "if", "!", "s", ".", "marked", "[", "key", "]", "{", "gone", "=", "append...
// MarkComplete figures out which ARNs were in previous passes but not // this one, and eliminates them. It should only be run after all // resources have been marked.
[ "MarkComplete", "figures", "out", "which", "ARNs", "were", "in", "previous", "passes", "but", "not", "this", "one", "and", "eliminates", "them", ".", "It", "should", "only", "be", "run", "after", "all", "resources", "have", "been", "marked", "." ]
8125fbda10178887be5dff9e901d6a0a519b67bc
https://github.com/kubernetes/test-infra/blob/8125fbda10178887be5dff9e901d6a0a519b67bc/maintenance/aws-janitor/resources/set.go#L132-L150
test
kubernetes/test-infra
prow/deck/jobs/jobs.go
NewJobAgent
func NewJobAgent(kc serviceClusterClient, plClients map[string]PodLogClient, cfg config.Getter) *JobAgent { return &JobAgent{ kc: kc, pkcs: plClients, config: cfg, } }
go
func NewJobAgent(kc serviceClusterClient, plClients map[string]PodLogClient, cfg config.Getter) *JobAgent { return &JobAgent{ kc: kc, pkcs: plClients, config: cfg, } }
[ "func", "NewJobAgent", "(", "kc", "serviceClusterClient", ",", "plClients", "map", "[", "string", "]", "PodLogClient", ",", "cfg", "config", ".", "Getter", ")", "*", "JobAgent", "{", "return", "&", "JobAgent", "{", "kc", ":", "kc", ",", "pkcs", ":", "plC...
// NewJobAgent is a JobAgent constructor.
[ "NewJobAgent", "is", "a", "JobAgent", "constructor", "." ]
8125fbda10178887be5dff9e901d6a0a519b67bc
https://github.com/kubernetes/test-infra/blob/8125fbda10178887be5dff9e901d6a0a519b67bc/prow/deck/jobs/jobs.go#L80-L86
test
kubernetes/test-infra
prow/deck/jobs/jobs.go
Start
func (ja *JobAgent) Start() { ja.tryUpdate() go func() { t := time.Tick(period) for range t { ja.tryUpdate() } }() }
go
func (ja *JobAgent) Start() { ja.tryUpdate() go func() { t := time.Tick(period) for range t { ja.tryUpdate() } }() }
[ "func", "(", "ja", "*", "JobAgent", ")", "Start", "(", ")", "{", "ja", ".", "tryUpdate", "(", ")", "\n", "go", "func", "(", ")", "{", "t", ":=", "time", ".", "Tick", "(", "period", ")", "\n", "for", "range", "t", "{", "ja", ".", "tryUpdate", ...
// Start will start the job and periodically update it.
[ "Start", "will", "start", "the", "job", "and", "periodically", "update", "it", "." ]
8125fbda10178887be5dff9e901d6a0a519b67bc
https://github.com/kubernetes/test-infra/blob/8125fbda10178887be5dff9e901d6a0a519b67bc/prow/deck/jobs/jobs.go#L101-L109
test
kubernetes/test-infra
prow/deck/jobs/jobs.go
Jobs
func (ja *JobAgent) Jobs() []Job { ja.mut.Lock() defer ja.mut.Unlock() res := make([]Job, len(ja.jobs)) copy(res, ja.jobs) return res }
go
func (ja *JobAgent) Jobs() []Job { ja.mut.Lock() defer ja.mut.Unlock() res := make([]Job, len(ja.jobs)) copy(res, ja.jobs) return res }
[ "func", "(", "ja", "*", "JobAgent", ")", "Jobs", "(", ")", "[", "]", "Job", "{", "ja", ".", "mut", ".", "Lock", "(", ")", "\n", "defer", "ja", ".", "mut", ".", "Unlock", "(", ")", "\n", "res", ":=", "make", "(", "[", "]", "Job", ",", "len",...
// Jobs returns a thread-safe snapshot of the current job state.
[ "Jobs", "returns", "a", "thread", "-", "safe", "snapshot", "of", "the", "current", "job", "state", "." ]
8125fbda10178887be5dff9e901d6a0a519b67bc
https://github.com/kubernetes/test-infra/blob/8125fbda10178887be5dff9e901d6a0a519b67bc/prow/deck/jobs/jobs.go#L112-L118
test
kubernetes/test-infra
prow/deck/jobs/jobs.go
ProwJobs
func (ja *JobAgent) ProwJobs() []prowapi.ProwJob { ja.mut.Lock() defer ja.mut.Unlock() res := make([]prowapi.ProwJob, len(ja.prowJobs)) copy(res, ja.prowJobs) return res }
go
func (ja *JobAgent) ProwJobs() []prowapi.ProwJob { ja.mut.Lock() defer ja.mut.Unlock() res := make([]prowapi.ProwJob, len(ja.prowJobs)) copy(res, ja.prowJobs) return res }
[ "func", "(", "ja", "*", "JobAgent", ")", "ProwJobs", "(", ")", "[", "]", "prowapi", ".", "ProwJob", "{", "ja", ".", "mut", ".", "Lock", "(", ")", "\n", "defer", "ja", ".", "mut", ".", "Unlock", "(", ")", "\n", "res", ":=", "make", "(", "[", "...
// ProwJobs returns a thread-safe snapshot of the current prow jobs.
[ "ProwJobs", "returns", "a", "thread", "-", "safe", "snapshot", "of", "the", "current", "prow", "jobs", "." ]
8125fbda10178887be5dff9e901d6a0a519b67bc
https://github.com/kubernetes/test-infra/blob/8125fbda10178887be5dff9e901d6a0a519b67bc/prow/deck/jobs/jobs.go#L121-L127
test
kubernetes/test-infra
prow/deck/jobs/jobs.go
GetProwJob
func (ja *JobAgent) GetProwJob(job, id string) (prowapi.ProwJob, error) { if ja == nil { return prowapi.ProwJob{}, fmt.Errorf("Prow job agent doesn't exist (are you running locally?)") } var j prowapi.ProwJob ja.mut.Lock() idMap, ok := ja.jobsIDMap[job] if ok { j, ok = idMap[id] } ja.mut.Unlock() if !ok { return prowapi.ProwJob{}, errProwjobNotFound } return j, nil }
go
func (ja *JobAgent) GetProwJob(job, id string) (prowapi.ProwJob, error) { if ja == nil { return prowapi.ProwJob{}, fmt.Errorf("Prow job agent doesn't exist (are you running locally?)") } var j prowapi.ProwJob ja.mut.Lock() idMap, ok := ja.jobsIDMap[job] if ok { j, ok = idMap[id] } ja.mut.Unlock() if !ok { return prowapi.ProwJob{}, errProwjobNotFound } return j, nil }
[ "func", "(", "ja", "*", "JobAgent", ")", "GetProwJob", "(", "job", ",", "id", "string", ")", "(", "prowapi", ".", "ProwJob", ",", "error", ")", "{", "if", "ja", "==", "nil", "{", "return", "prowapi", ".", "ProwJob", "{", "}", ",", "fmt", ".", "Er...
// GetProwJob finds the corresponding Prowjob resource from the provided job name and build ID
[ "GetProwJob", "finds", "the", "corresponding", "Prowjob", "resource", "from", "the", "provided", "job", "name", "and", "build", "ID" ]
8125fbda10178887be5dff9e901d6a0a519b67bc
https://github.com/kubernetes/test-infra/blob/8125fbda10178887be5dff9e901d6a0a519b67bc/prow/deck/jobs/jobs.go#L132-L147
test
kubernetes/test-infra
prow/deck/jobs/jobs.go
GetJobLog
func (ja *JobAgent) GetJobLog(job, id string) ([]byte, error) { j, err := ja.GetProwJob(job, id) if err != nil { return nil, fmt.Errorf("error getting prowjob: %v", err) } if j.Spec.Agent == prowapi.KubernetesAgent { client, ok := ja.pkcs[j.ClusterAlias()] if !ok { return nil, fmt.Errorf("cannot get logs for prowjob %q with agent %q: unknown cluster alias %q", j.ObjectMeta.Name, j.Spec.Agent, j.ClusterAlias()) } return client.GetLogs(j.Status.PodName, &coreapi.PodLogOptions{Container: kube.TestContainerName}) } for _, agentToTmpl := range ja.config().Deck.ExternalAgentLogs { if agentToTmpl.Agent != string(j.Spec.Agent) { continue } if !agentToTmpl.Selector.Matches(labels.Set(j.ObjectMeta.Labels)) { continue } var b bytes.Buffer if err := agentToTmpl.URLTemplate.Execute(&b, &j); err != nil { return nil, fmt.Errorf("cannot execute URL template for prowjob %q with agent %q: %v", j.ObjectMeta.Name, j.Spec.Agent, err) } resp, err := http.Get(b.String()) if err != nil { return nil, err } defer resp.Body.Close() return ioutil.ReadAll(resp.Body) } return nil, fmt.Errorf("cannot get logs for prowjob %q with agent %q: the agent is missing from the prow config file", j.ObjectMeta.Name, j.Spec.Agent) }
go
func (ja *JobAgent) GetJobLog(job, id string) ([]byte, error) { j, err := ja.GetProwJob(job, id) if err != nil { return nil, fmt.Errorf("error getting prowjob: %v", err) } if j.Spec.Agent == prowapi.KubernetesAgent { client, ok := ja.pkcs[j.ClusterAlias()] if !ok { return nil, fmt.Errorf("cannot get logs for prowjob %q with agent %q: unknown cluster alias %q", j.ObjectMeta.Name, j.Spec.Agent, j.ClusterAlias()) } return client.GetLogs(j.Status.PodName, &coreapi.PodLogOptions{Container: kube.TestContainerName}) } for _, agentToTmpl := range ja.config().Deck.ExternalAgentLogs { if agentToTmpl.Agent != string(j.Spec.Agent) { continue } if !agentToTmpl.Selector.Matches(labels.Set(j.ObjectMeta.Labels)) { continue } var b bytes.Buffer if err := agentToTmpl.URLTemplate.Execute(&b, &j); err != nil { return nil, fmt.Errorf("cannot execute URL template for prowjob %q with agent %q: %v", j.ObjectMeta.Name, j.Spec.Agent, err) } resp, err := http.Get(b.String()) if err != nil { return nil, err } defer resp.Body.Close() return ioutil.ReadAll(resp.Body) } return nil, fmt.Errorf("cannot get logs for prowjob %q with agent %q: the agent is missing from the prow config file", j.ObjectMeta.Name, j.Spec.Agent) }
[ "func", "(", "ja", "*", "JobAgent", ")", "GetJobLog", "(", "job", ",", "id", "string", ")", "(", "[", "]", "byte", ",", "error", ")", "{", "j", ",", "err", ":=", "ja", ".", "GetProwJob", "(", "job", ",", "id", ")", "\n", "if", "err", "!=", "n...
// GetJobLog returns the job logs, works for both kubernetes and jenkins agent types.
[ "GetJobLog", "returns", "the", "job", "logs", "works", "for", "both", "kubernetes", "and", "jenkins", "agent", "types", "." ]
8125fbda10178887be5dff9e901d6a0a519b67bc
https://github.com/kubernetes/test-infra/blob/8125fbda10178887be5dff9e901d6a0a519b67bc/prow/deck/jobs/jobs.go#L150-L182
test
kubernetes/test-infra
prow/config/branch_protection.go
unionStrings
func unionStrings(parent, child []string) []string { if child == nil { return parent } if parent == nil { return child } s := sets.NewString(parent...) s.Insert(child...) return s.List() }
go
func unionStrings(parent, child []string) []string { if child == nil { return parent } if parent == nil { return child } s := sets.NewString(parent...) s.Insert(child...) return s.List() }
[ "func", "unionStrings", "(", "parent", ",", "child", "[", "]", "string", ")", "[", "]", "string", "{", "if", "child", "==", "nil", "{", "return", "parent", "\n", "}", "\n", "if", "parent", "==", "nil", "{", "return", "child", "\n", "}", "\n", "s", ...
// unionStrings merges the parent and child items together
[ "unionStrings", "merges", "the", "parent", "and", "child", "items", "together" ]
8125fbda10178887be5dff9e901d6a0a519b67bc
https://github.com/kubernetes/test-infra/blob/8125fbda10178887be5dff9e901d6a0a519b67bc/prow/config/branch_protection.go#L94-L104
test
kubernetes/test-infra
prow/config/branch_protection.go
Apply
func (p Policy) Apply(child Policy) Policy { return Policy{ Protect: selectBool(p.Protect, child.Protect), RequiredStatusChecks: mergeContextPolicy(p.RequiredStatusChecks, child.RequiredStatusChecks), Admins: selectBool(p.Admins, child.Admins), Restrictions: mergeRestrictions(p.Restrictions, child.Restrictions), RequiredPullRequestReviews: mergeReviewPolicy(p.RequiredPullRequestReviews, child.RequiredPullRequestReviews), } }
go
func (p Policy) Apply(child Policy) Policy { return Policy{ Protect: selectBool(p.Protect, child.Protect), RequiredStatusChecks: mergeContextPolicy(p.RequiredStatusChecks, child.RequiredStatusChecks), Admins: selectBool(p.Admins, child.Admins), Restrictions: mergeRestrictions(p.Restrictions, child.Restrictions), RequiredPullRequestReviews: mergeReviewPolicy(p.RequiredPullRequestReviews, child.RequiredPullRequestReviews), } }
[ "func", "(", "p", "Policy", ")", "Apply", "(", "child", "Policy", ")", "Policy", "{", "return", "Policy", "{", "Protect", ":", "selectBool", "(", "p", ".", "Protect", ",", "child", ".", "Protect", ")", ",", "RequiredStatusChecks", ":", "mergeContextPolicy"...
// Apply returns a policy that merges the child into the parent
[ "Apply", "returns", "a", "policy", "that", "merges", "the", "child", "into", "the", "parent" ]
8125fbda10178887be5dff9e901d6a0a519b67bc
https://github.com/kubernetes/test-infra/blob/8125fbda10178887be5dff9e901d6a0a519b67bc/prow/config/branch_protection.go#L148-L156
test
kubernetes/test-infra
prow/config/branch_protection.go
GetOrg
func (bp BranchProtection) GetOrg(name string) *Org { o, ok := bp.Orgs[name] if ok { o.Policy = bp.Apply(o.Policy) } else { o.Policy = bp.Policy } return &o }
go
func (bp BranchProtection) GetOrg(name string) *Org { o, ok := bp.Orgs[name] if ok { o.Policy = bp.Apply(o.Policy) } else { o.Policy = bp.Policy } return &o }
[ "func", "(", "bp", "BranchProtection", ")", "GetOrg", "(", "name", "string", ")", "*", "Org", "{", "o", ",", "ok", ":=", "bp", ".", "Orgs", "[", "name", "]", "\n", "if", "ok", "{", "o", ".", "Policy", "=", "bp", ".", "Apply", "(", "o", ".", "...
// GetOrg returns the org config after merging in any global policies.
[ "GetOrg", "returns", "the", "org", "config", "after", "merging", "in", "any", "global", "policies", "." ]
8125fbda10178887be5dff9e901d6a0a519b67bc
https://github.com/kubernetes/test-infra/blob/8125fbda10178887be5dff9e901d6a0a519b67bc/prow/config/branch_protection.go#L167-L175
test
kubernetes/test-infra
prow/config/branch_protection.go
GetRepo
func (o Org) GetRepo(name string) *Repo { r, ok := o.Repos[name] if ok { r.Policy = o.Apply(r.Policy) } else { r.Policy = o.Policy } return &r }
go
func (o Org) GetRepo(name string) *Repo { r, ok := o.Repos[name] if ok { r.Policy = o.Apply(r.Policy) } else { r.Policy = o.Policy } return &r }
[ "func", "(", "o", "Org", ")", "GetRepo", "(", "name", "string", ")", "*", "Repo", "{", "r", ",", "ok", ":=", "o", ".", "Repos", "[", "name", "]", "\n", "if", "ok", "{", "r", ".", "Policy", "=", "o", ".", "Apply", "(", "r", ".", "Policy", ")...
// GetRepo returns the repo config after merging in any org policies.
[ "GetRepo", "returns", "the", "repo", "config", "after", "merging", "in", "any", "org", "policies", "." ]
8125fbda10178887be5dff9e901d6a0a519b67bc
https://github.com/kubernetes/test-infra/blob/8125fbda10178887be5dff9e901d6a0a519b67bc/prow/config/branch_protection.go#L184-L192
test
kubernetes/test-infra
prow/config/branch_protection.go
GetBranch
func (r Repo) GetBranch(name string) (*Branch, error) { b, ok := r.Branches[name] if ok { b.Policy = r.Apply(b.Policy) if b.Protect == nil { return nil, errors.New("defined branch policies must set protect") } } else { b.Policy = r.Policy } return &b, nil }
go
func (r Repo) GetBranch(name string) (*Branch, error) { b, ok := r.Branches[name] if ok { b.Policy = r.Apply(b.Policy) if b.Protect == nil { return nil, errors.New("defined branch policies must set protect") } } else { b.Policy = r.Policy } return &b, nil }
[ "func", "(", "r", "Repo", ")", "GetBranch", "(", "name", "string", ")", "(", "*", "Branch", ",", "error", ")", "{", "b", ",", "ok", ":=", "r", ".", "Branches", "[", "name", "]", "\n", "if", "ok", "{", "b", ".", "Policy", "=", "r", ".", "Apply...
// GetBranch returns the branch config after merging in any repo policies.
[ "GetBranch", "returns", "the", "branch", "config", "after", "merging", "in", "any", "repo", "policies", "." ]
8125fbda10178887be5dff9e901d6a0a519b67bc
https://github.com/kubernetes/test-infra/blob/8125fbda10178887be5dff9e901d6a0a519b67bc/prow/config/branch_protection.go#L201-L212
test
kubernetes/test-infra
prow/config/branch_protection.go
GetPolicy
func (c *Config) GetPolicy(org, repo, branch string, b Branch) (*Policy, error) { policy := b.Policy // Automatically require contexts from prow which must always be present if prowContexts, _, _ := BranchRequirements(org, repo, branch, c.Presubmits); len(prowContexts) > 0 { // Error if protection is disabled if policy.Protect != nil && !*policy.Protect { return nil, fmt.Errorf("required prow jobs require branch protection") } ps := Policy{ RequiredStatusChecks: &ContextPolicy{ Contexts: prowContexts, }, } // Require protection by default if ProtectTested is true if c.BranchProtection.ProtectTested { yes := true ps.Protect = &yes } policy = policy.Apply(ps) } if policy.Protect != nil && !*policy.Protect { // Ensure that protection is false => no protection settings var old *bool old, policy.Protect = policy.Protect, old switch { case policy.defined() && c.BranchProtection.AllowDisabledPolicies: logrus.Warnf("%s/%s=%s defines a policy but has protect: false", org, repo, branch) policy = Policy{ Protect: policy.Protect, } case policy.defined(): return nil, fmt.Errorf("%s/%s=%s defines a policy, which requires protect: true", org, repo, branch) } policy.Protect = old } if !policy.defined() { return nil, nil } return &policy, nil }
go
func (c *Config) GetPolicy(org, repo, branch string, b Branch) (*Policy, error) { policy := b.Policy // Automatically require contexts from prow which must always be present if prowContexts, _, _ := BranchRequirements(org, repo, branch, c.Presubmits); len(prowContexts) > 0 { // Error if protection is disabled if policy.Protect != nil && !*policy.Protect { return nil, fmt.Errorf("required prow jobs require branch protection") } ps := Policy{ RequiredStatusChecks: &ContextPolicy{ Contexts: prowContexts, }, } // Require protection by default if ProtectTested is true if c.BranchProtection.ProtectTested { yes := true ps.Protect = &yes } policy = policy.Apply(ps) } if policy.Protect != nil && !*policy.Protect { // Ensure that protection is false => no protection settings var old *bool old, policy.Protect = policy.Protect, old switch { case policy.defined() && c.BranchProtection.AllowDisabledPolicies: logrus.Warnf("%s/%s=%s defines a policy but has protect: false", org, repo, branch) policy = Policy{ Protect: policy.Protect, } case policy.defined(): return nil, fmt.Errorf("%s/%s=%s defines a policy, which requires protect: true", org, repo, branch) } policy.Protect = old } if !policy.defined() { return nil, nil } return &policy, nil }
[ "func", "(", "c", "*", "Config", ")", "GetPolicy", "(", "org", ",", "repo", ",", "branch", "string", ",", "b", "Branch", ")", "(", "*", "Policy", ",", "error", ")", "{", "policy", ":=", "b", ".", "Policy", "\n", "if", "prowContexts", ",", "_", ",...
// GetPolicy returns the protection policy for the branch, after merging in presubmits.
[ "GetPolicy", "returns", "the", "protection", "policy", "for", "the", "branch", "after", "merging", "in", "presubmits", "." ]
8125fbda10178887be5dff9e901d6a0a519b67bc
https://github.com/kubernetes/test-infra/blob/8125fbda10178887be5dff9e901d6a0a519b67bc/prow/config/branch_protection.go#L235-L277
test
kubernetes/test-infra
velodrome/fetcher/issue-events.go
UpdateIssueEvents
func UpdateIssueEvents(issueID int, db *gorm.DB, client ClientInterface) { latest, err := findLatestEvent(issueID, db, client.RepositoryName()) if err != nil { glog.Error("Failed to find last event: ", err) return } c := make(chan *github.IssueEvent, 500) go client.FetchIssueEvents(issueID, latest, c) for event := range c { eventOrm, err := NewIssueEvent(event, issueID, client.RepositoryName()) if err != nil { glog.Error("Failed to create issue-event", err) } db.Create(eventOrm) } }
go
func UpdateIssueEvents(issueID int, db *gorm.DB, client ClientInterface) { latest, err := findLatestEvent(issueID, db, client.RepositoryName()) if err != nil { glog.Error("Failed to find last event: ", err) return } c := make(chan *github.IssueEvent, 500) go client.FetchIssueEvents(issueID, latest, c) for event := range c { eventOrm, err := NewIssueEvent(event, issueID, client.RepositoryName()) if err != nil { glog.Error("Failed to create issue-event", err) } db.Create(eventOrm) } }
[ "func", "UpdateIssueEvents", "(", "issueID", "int", ",", "db", "*", "gorm", ".", "DB", ",", "client", "ClientInterface", ")", "{", "latest", ",", "err", ":=", "findLatestEvent", "(", "issueID", ",", "db", ",", "client", ".", "RepositoryName", "(", ")", "...
// UpdateIssueEvents fetches all events until we find the most recent we // have in db, and saves everything in database
[ "UpdateIssueEvents", "fetches", "all", "events", "until", "we", "find", "the", "most", "recent", "we", "have", "in", "db", "and", "saves", "everything", "in", "database" ]
8125fbda10178887be5dff9e901d6a0a519b67bc
https://github.com/kubernetes/test-infra/blob/8125fbda10178887be5dff9e901d6a0a519b67bc/velodrome/fetcher/issue-events.go#L54-L70
test
kubernetes/test-infra
prow/cmd/build/controller.go
enqueueKey
func (c *controller) enqueueKey(ctx string, obj interface{}) { switch o := obj.(type) { case *prowjobv1.ProwJob: c.workqueue.AddRateLimited(toKey(ctx, o.Spec.Namespace, o.Name)) case *buildv1alpha1.Build: c.workqueue.AddRateLimited(toKey(ctx, o.Namespace, o.Name)) default: logrus.Warnf("cannot enqueue unknown type %T: %v", o, obj) return } }
go
func (c *controller) enqueueKey(ctx string, obj interface{}) { switch o := obj.(type) { case *prowjobv1.ProwJob: c.workqueue.AddRateLimited(toKey(ctx, o.Spec.Namespace, o.Name)) case *buildv1alpha1.Build: c.workqueue.AddRateLimited(toKey(ctx, o.Namespace, o.Name)) default: logrus.Warnf("cannot enqueue unknown type %T: %v", o, obj) return } }
[ "func", "(", "c", "*", "controller", ")", "enqueueKey", "(", "ctx", "string", ",", "obj", "interface", "{", "}", ")", "{", "switch", "o", ":=", "obj", ".", "(", "type", ")", "{", "case", "*", "prowjobv1", ".", "ProwJob", ":", "c", ".", "workqueue",...
// enqueueKey schedules an item for reconciliation.
[ "enqueueKey", "schedules", "an", "item", "for", "reconciliation", "." ]
8125fbda10178887be5dff9e901d6a0a519b67bc
https://github.com/kubernetes/test-infra/blob/8125fbda10178887be5dff9e901d6a0a519b67bc/prow/cmd/build/controller.go#L271-L281
test
kubernetes/test-infra
prow/cmd/build/controller.go
prowJobStatus
func prowJobStatus(bs buildv1alpha1.BuildStatus) (prowjobv1.ProwJobState, string) { started := bs.StartTime finished := bs.CompletionTime pcond := bs.GetCondition(buildv1alpha1.BuildSucceeded) if pcond == nil { if !finished.IsZero() { return prowjobv1.ErrorState, descMissingCondition } return prowjobv1.TriggeredState, descScheduling } cond := *pcond switch { case cond.Status == coreapi.ConditionTrue: return prowjobv1.SuccessState, description(cond, descSucceeded) case cond.Status == coreapi.ConditionFalse: return prowjobv1.FailureState, description(cond, descFailed) case started.IsZero(): return prowjobv1.TriggeredState, description(cond, descInitializing) case cond.Status == coreapi.ConditionUnknown, finished.IsZero(): return prowjobv1.PendingState, description(cond, descRunning) } logrus.Warnf("Unknown condition %#v", cond) return prowjobv1.ErrorState, description(cond, descUnknown) // shouldn't happen }
go
func prowJobStatus(bs buildv1alpha1.BuildStatus) (prowjobv1.ProwJobState, string) { started := bs.StartTime finished := bs.CompletionTime pcond := bs.GetCondition(buildv1alpha1.BuildSucceeded) if pcond == nil { if !finished.IsZero() { return prowjobv1.ErrorState, descMissingCondition } return prowjobv1.TriggeredState, descScheduling } cond := *pcond switch { case cond.Status == coreapi.ConditionTrue: return prowjobv1.SuccessState, description(cond, descSucceeded) case cond.Status == coreapi.ConditionFalse: return prowjobv1.FailureState, description(cond, descFailed) case started.IsZero(): return prowjobv1.TriggeredState, description(cond, descInitializing) case cond.Status == coreapi.ConditionUnknown, finished.IsZero(): return prowjobv1.PendingState, description(cond, descRunning) } logrus.Warnf("Unknown condition %#v", cond) return prowjobv1.ErrorState, description(cond, descUnknown) // shouldn't happen }
[ "func", "prowJobStatus", "(", "bs", "buildv1alpha1", ".", "BuildStatus", ")", "(", "prowjobv1", ".", "ProwJobState", ",", "string", ")", "{", "started", ":=", "bs", ".", "StartTime", "\n", "finished", ":=", "bs", ".", "CompletionTime", "\n", "pcond", ":=", ...
// prowJobStatus returns the desired state and description based on the build status.
[ "prowJobStatus", "returns", "the", "desired", "state", "and", "description", "based", "on", "the", "build", "status", "." ]
8125fbda10178887be5dff9e901d6a0a519b67bc
https://github.com/kubernetes/test-infra/blob/8125fbda10178887be5dff9e901d6a0a519b67bc/prow/cmd/build/controller.go#L519-L542
test
kubernetes/test-infra
prow/cmd/build/controller.go
buildEnv
func buildEnv(pj prowjobv1.ProwJob, buildID string) (map[string]string, error) { return downwardapi.EnvForSpec(downwardapi.NewJobSpec(pj.Spec, buildID, pj.Name)) }
go
func buildEnv(pj prowjobv1.ProwJob, buildID string) (map[string]string, error) { return downwardapi.EnvForSpec(downwardapi.NewJobSpec(pj.Spec, buildID, pj.Name)) }
[ "func", "buildEnv", "(", "pj", "prowjobv1", ".", "ProwJob", ",", "buildID", "string", ")", "(", "map", "[", "string", "]", "string", ",", "error", ")", "{", "return", "downwardapi", ".", "EnvForSpec", "(", "downwardapi", ".", "NewJobSpec", "(", "pj", "."...
// buildEnv constructs the environment map for the job
[ "buildEnv", "constructs", "the", "environment", "map", "for", "the", "job" ]
8125fbda10178887be5dff9e901d6a0a519b67bc
https://github.com/kubernetes/test-infra/blob/8125fbda10178887be5dff9e901d6a0a519b67bc/prow/cmd/build/controller.go#L574-L576
test
kubernetes/test-infra
prow/cmd/build/controller.go
defaultArguments
func defaultArguments(t *buildv1alpha1.TemplateInstantiationSpec, rawEnv map[string]string) { keys := sets.String{} for _, arg := range t.Arguments { keys.Insert(arg.Name) } for _, k := range sets.StringKeySet(rawEnv).List() { // deterministic ordering if keys.Has(k) { continue } t.Arguments = append(t.Arguments, buildv1alpha1.ArgumentSpec{Name: k, Value: rawEnv[k]}) } }
go
func defaultArguments(t *buildv1alpha1.TemplateInstantiationSpec, rawEnv map[string]string) { keys := sets.String{} for _, arg := range t.Arguments { keys.Insert(arg.Name) } for _, k := range sets.StringKeySet(rawEnv).List() { // deterministic ordering if keys.Has(k) { continue } t.Arguments = append(t.Arguments, buildv1alpha1.ArgumentSpec{Name: k, Value: rawEnv[k]}) } }
[ "func", "defaultArguments", "(", "t", "*", "buildv1alpha1", ".", "TemplateInstantiationSpec", ",", "rawEnv", "map", "[", "string", "]", "string", ")", "{", "keys", ":=", "sets", ".", "String", "{", "}", "\n", "for", "_", ",", "arg", ":=", "range", "t", ...
// defaultArguments will append each arg to the template, except where the argument name is already defined.
[ "defaultArguments", "will", "append", "each", "arg", "to", "the", "template", "except", "where", "the", "argument", "name", "is", "already", "defined", "." ]
8125fbda10178887be5dff9e901d6a0a519b67bc
https://github.com/kubernetes/test-infra/blob/8125fbda10178887be5dff9e901d6a0a519b67bc/prow/cmd/build/controller.go#L579-L590
test
kubernetes/test-infra
prow/cmd/build/controller.go
defaultEnv
func defaultEnv(c *coreapi.Container, rawEnv map[string]string) { keys := sets.String{} for _, arg := range c.Env { keys.Insert(arg.Name) } for _, k := range sets.StringKeySet(rawEnv).List() { // deterministic ordering if keys.Has(k) { continue } c.Env = append(c.Env, coreapi.EnvVar{Name: k, Value: rawEnv[k]}) } }
go
func defaultEnv(c *coreapi.Container, rawEnv map[string]string) { keys := sets.String{} for _, arg := range c.Env { keys.Insert(arg.Name) } for _, k := range sets.StringKeySet(rawEnv).List() { // deterministic ordering if keys.Has(k) { continue } c.Env = append(c.Env, coreapi.EnvVar{Name: k, Value: rawEnv[k]}) } }
[ "func", "defaultEnv", "(", "c", "*", "coreapi", ".", "Container", ",", "rawEnv", "map", "[", "string", "]", "string", ")", "{", "keys", ":=", "sets", ".", "String", "{", "}", "\n", "for", "_", ",", "arg", ":=", "range", "c", ".", "Env", "{", "key...
// defaultEnv adds the map of environment variables to the container, except keys already defined.
[ "defaultEnv", "adds", "the", "map", "of", "environment", "variables", "to", "the", "container", "except", "keys", "already", "defined", "." ]
8125fbda10178887be5dff9e901d6a0a519b67bc
https://github.com/kubernetes/test-infra/blob/8125fbda10178887be5dff9e901d6a0a519b67bc/prow/cmd/build/controller.go#L593-L604
test
kubernetes/test-infra
prow/cmd/build/controller.go
injectSource
func injectSource(b *buildv1alpha1.Build, pj prowjobv1.ProwJob) (bool, error) { if b.Spec.Source != nil { return false, nil } srcContainer, refs, cloneVolumes, err := decorate.CloneRefs(pj, codeMount, logMount) if err != nil { return false, fmt.Errorf("clone source error: %v", err) } if srcContainer == nil { return false, nil } else { srcContainer.Name = "" // knative-build requirement } b.Spec.Source = &buildv1alpha1.SourceSpec{ Custom: srcContainer, } b.Spec.Volumes = append(b.Spec.Volumes, cloneVolumes...) wd := workDir(refs[0]) // Inject correct working directory for i := range b.Spec.Steps { if b.Spec.Steps[i].WorkingDir != "" { continue } b.Spec.Steps[i].WorkingDir = wd.Value } if b.Spec.Template != nil { // Best we can do for a template is to set WORKDIR b.Spec.Template.Arguments = append(b.Spec.Template.Arguments, wd) } return true, nil }
go
func injectSource(b *buildv1alpha1.Build, pj prowjobv1.ProwJob) (bool, error) { if b.Spec.Source != nil { return false, nil } srcContainer, refs, cloneVolumes, err := decorate.CloneRefs(pj, codeMount, logMount) if err != nil { return false, fmt.Errorf("clone source error: %v", err) } if srcContainer == nil { return false, nil } else { srcContainer.Name = "" // knative-build requirement } b.Spec.Source = &buildv1alpha1.SourceSpec{ Custom: srcContainer, } b.Spec.Volumes = append(b.Spec.Volumes, cloneVolumes...) wd := workDir(refs[0]) // Inject correct working directory for i := range b.Spec.Steps { if b.Spec.Steps[i].WorkingDir != "" { continue } b.Spec.Steps[i].WorkingDir = wd.Value } if b.Spec.Template != nil { // Best we can do for a template is to set WORKDIR b.Spec.Template.Arguments = append(b.Spec.Template.Arguments, wd) } return true, nil }
[ "func", "injectSource", "(", "b", "*", "buildv1alpha1", ".", "Build", ",", "pj", "prowjobv1", ".", "ProwJob", ")", "(", "bool", ",", "error", ")", "{", "if", "b", ".", "Spec", ".", "Source", "!=", "nil", "{", "return", "false", ",", "nil", "\n", "}...
// injectSource adds the custom source container to call clonerefs correctly. // // Returns true if it added this container // // Does nothing if the build spec predefines Source
[ "injectSource", "adds", "the", "custom", "source", "container", "to", "call", "clonerefs", "correctly", ".", "Returns", "true", "if", "it", "added", "this", "container", "Does", "nothing", "if", "the", "build", "spec", "predefines", "Source" ]
8125fbda10178887be5dff9e901d6a0a519b67bc
https://github.com/kubernetes/test-infra/blob/8125fbda10178887be5dff9e901d6a0a519b67bc/prow/cmd/build/controller.go#L626-L659
test
kubernetes/test-infra
prow/cmd/build/controller.go
injectedSteps
func injectedSteps(encodedJobSpec string, dc prowjobv1.DecorationConfig, injectedSource bool, toolsMount coreapi.VolumeMount, entries []wrapper.Options) ([]coreapi.Container, *coreapi.Container, *coreapi.Volume, error) { gcsVol, gcsMount, gcsOptions := decorate.GCSOptions(dc) sidecar, err := decorate.Sidecar(dc.UtilityImages.Sidecar, gcsOptions, gcsMount, logMount, encodedJobSpec, decorate.RequirePassingEntries, entries...) if err != nil { return nil, nil, nil, fmt.Errorf("inject sidecar: %v", err) } var cloneLogMount *coreapi.VolumeMount if injectedSource { cloneLogMount = &logMount } initUpload, err := decorate.InitUpload(dc.UtilityImages.InitUpload, gcsOptions, gcsMount, cloneLogMount, encodedJobSpec) if err != nil { return nil, nil, nil, fmt.Errorf("inject initupload: %v", err) } placer := decorate.PlaceEntrypoint(dc.UtilityImages.Entrypoint, toolsMount) return []coreapi.Container{placer, *initUpload}, sidecar, &gcsVol, nil }
go
func injectedSteps(encodedJobSpec string, dc prowjobv1.DecorationConfig, injectedSource bool, toolsMount coreapi.VolumeMount, entries []wrapper.Options) ([]coreapi.Container, *coreapi.Container, *coreapi.Volume, error) { gcsVol, gcsMount, gcsOptions := decorate.GCSOptions(dc) sidecar, err := decorate.Sidecar(dc.UtilityImages.Sidecar, gcsOptions, gcsMount, logMount, encodedJobSpec, decorate.RequirePassingEntries, entries...) if err != nil { return nil, nil, nil, fmt.Errorf("inject sidecar: %v", err) } var cloneLogMount *coreapi.VolumeMount if injectedSource { cloneLogMount = &logMount } initUpload, err := decorate.InitUpload(dc.UtilityImages.InitUpload, gcsOptions, gcsMount, cloneLogMount, encodedJobSpec) if err != nil { return nil, nil, nil, fmt.Errorf("inject initupload: %v", err) } placer := decorate.PlaceEntrypoint(dc.UtilityImages.Entrypoint, toolsMount) return []coreapi.Container{placer, *initUpload}, sidecar, &gcsVol, nil }
[ "func", "injectedSteps", "(", "encodedJobSpec", "string", ",", "dc", "prowjobv1", ".", "DecorationConfig", ",", "injectedSource", "bool", ",", "toolsMount", "coreapi", ".", "VolumeMount", ",", "entries", "[", "]", "wrapper", ".", "Options", ")", "(", "[", "]",...
// injectedSteps returns initial containers, a final container and an additional volume.
[ "injectedSteps", "returns", "initial", "containers", "a", "final", "container", "and", "an", "additional", "volume", "." ]
8125fbda10178887be5dff9e901d6a0a519b67bc
https://github.com/kubernetes/test-infra/blob/8125fbda10178887be5dff9e901d6a0a519b67bc/prow/cmd/build/controller.go#L699-L719
test
kubernetes/test-infra
prow/cmd/build/controller.go
determineTimeout
func determineTimeout(spec *buildv1alpha1.BuildSpec, dc *prowjobv1.DecorationConfig, defaultTimeout time.Duration) time.Duration { switch { case spec.Timeout != nil: return spec.Timeout.Duration case dc != nil && dc.Timeout.Duration > 0: return dc.Timeout.Duration default: return defaultTimeout } }
go
func determineTimeout(spec *buildv1alpha1.BuildSpec, dc *prowjobv1.DecorationConfig, defaultTimeout time.Duration) time.Duration { switch { case spec.Timeout != nil: return spec.Timeout.Duration case dc != nil && dc.Timeout.Duration > 0: return dc.Timeout.Duration default: return defaultTimeout } }
[ "func", "determineTimeout", "(", "spec", "*", "buildv1alpha1", ".", "BuildSpec", ",", "dc", "*", "prowjobv1", ".", "DecorationConfig", ",", "defaultTimeout", "time", ".", "Duration", ")", "time", ".", "Duration", "{", "switch", "{", "case", "spec", ".", "Tim...
// determineTimeout decides the timeout value used for build
[ "determineTimeout", "decides", "the", "timeout", "value", "used", "for", "build" ]
8125fbda10178887be5dff9e901d6a0a519b67bc
https://github.com/kubernetes/test-infra/blob/8125fbda10178887be5dff9e901d6a0a519b67bc/prow/cmd/build/controller.go#L722-L731
test
kubernetes/test-infra
prow/cmd/build/controller.go
makeBuild
func makeBuild(pj prowjobv1.ProwJob, defaultTimeout time.Duration) (*buildv1alpha1.Build, error) { if pj.Spec.BuildSpec == nil { return nil, errors.New("nil BuildSpec in spec") } buildID := pj.Status.BuildID if buildID == "" { return nil, errors.New("empty BuildID in status") } b := buildv1alpha1.Build{ ObjectMeta: buildMeta(pj), Spec: *pj.Spec.BuildSpec.DeepCopy(), } rawEnv, err := buildEnv(pj, buildID) if err != nil { return nil, fmt.Errorf("environment error: %v", err) } injectEnvironment(&b, rawEnv) injectedSource, err := injectSource(&b, pj) if err != nil { return nil, fmt.Errorf("inject source: %v", err) } injectTimeout(&b.Spec, pj.Spec.DecorationConfig, defaultTimeout) if pj.Spec.DecorationConfig != nil { encodedJobSpec := rawEnv[downwardapi.JobSpecEnv] err = decorateBuild(&b.Spec, encodedJobSpec, *pj.Spec.DecorationConfig, injectedSource) if err != nil { return nil, fmt.Errorf("decorate build: %v", err) } } return &b, nil }
go
func makeBuild(pj prowjobv1.ProwJob, defaultTimeout time.Duration) (*buildv1alpha1.Build, error) { if pj.Spec.BuildSpec == nil { return nil, errors.New("nil BuildSpec in spec") } buildID := pj.Status.BuildID if buildID == "" { return nil, errors.New("empty BuildID in status") } b := buildv1alpha1.Build{ ObjectMeta: buildMeta(pj), Spec: *pj.Spec.BuildSpec.DeepCopy(), } rawEnv, err := buildEnv(pj, buildID) if err != nil { return nil, fmt.Errorf("environment error: %v", err) } injectEnvironment(&b, rawEnv) injectedSource, err := injectSource(&b, pj) if err != nil { return nil, fmt.Errorf("inject source: %v", err) } injectTimeout(&b.Spec, pj.Spec.DecorationConfig, defaultTimeout) if pj.Spec.DecorationConfig != nil { encodedJobSpec := rawEnv[downwardapi.JobSpecEnv] err = decorateBuild(&b.Spec, encodedJobSpec, *pj.Spec.DecorationConfig, injectedSource) if err != nil { return nil, fmt.Errorf("decorate build: %v", err) } } return &b, nil }
[ "func", "makeBuild", "(", "pj", "prowjobv1", ".", "ProwJob", ",", "defaultTimeout", "time", ".", "Duration", ")", "(", "*", "buildv1alpha1", ".", "Build", ",", "error", ")", "{", "if", "pj", ".", "Spec", ".", "BuildSpec", "==", "nil", "{", "return", "n...
// makeBuild creates a build from the prowjob, using the prowjob's buildspec.
[ "makeBuild", "creates", "a", "build", "from", "the", "prowjob", "using", "the", "prowjob", "s", "buildspec", "." ]
8125fbda10178887be5dff9e901d6a0a519b67bc
https://github.com/kubernetes/test-infra/blob/8125fbda10178887be5dff9e901d6a0a519b67bc/prow/cmd/build/controller.go#L757-L788
test
kubernetes/test-infra
velodrome/fetcher/conversion.go
newLabels
func newLabels(issueID int, gLabels []github.Label, repository string) ([]sql.Label, error) { labels := []sql.Label{} repository = strings.ToLower(repository) for _, label := range gLabels { if label.Name == nil { return nil, fmt.Errorf("Label is missing name field") } labels = append(labels, sql.Label{ IssueID: strconv.Itoa(issueID), Name: *label.Name, Repository: repository, }) } return labels, nil }
go
func newLabels(issueID int, gLabels []github.Label, repository string) ([]sql.Label, error) { labels := []sql.Label{} repository = strings.ToLower(repository) for _, label := range gLabels { if label.Name == nil { return nil, fmt.Errorf("Label is missing name field") } labels = append(labels, sql.Label{ IssueID: strconv.Itoa(issueID), Name: *label.Name, Repository: repository, }) } return labels, nil }
[ "func", "newLabels", "(", "issueID", "int", ",", "gLabels", "[", "]", "github", ".", "Label", ",", "repository", "string", ")", "(", "[", "]", "sql", ".", "Label", ",", "error", ")", "{", "labels", ":=", "[", "]", "sql", ".", "Label", "{", "}", "...
// newLabels creates a new Label for each label in the issue
[ "newLabels", "creates", "a", "new", "Label", "for", "each", "label", "in", "the", "issue" ]
8125fbda10178887be5dff9e901d6a0a519b67bc
https://github.com/kubernetes/test-infra/blob/8125fbda10178887be5dff9e901d6a0a519b67bc/velodrome/fetcher/conversion.go#L114-L130
test
kubernetes/test-infra
velodrome/fetcher/conversion.go
newAssignees
func newAssignees(issueID int, gAssignees []*github.User, repository string) ([]sql.Assignee, error) { assignees := []sql.Assignee{} repository = strings.ToLower(repository) for _, assignee := range gAssignees { if assignee != nil && assignee.Login == nil { return nil, fmt.Errorf("Assignee is missing Login field") } assignees = append(assignees, sql.Assignee{ IssueID: strconv.Itoa(issueID), Name: *assignee.Login, Repository: repository, }) } return assignees, nil }
go
func newAssignees(issueID int, gAssignees []*github.User, repository string) ([]sql.Assignee, error) { assignees := []sql.Assignee{} repository = strings.ToLower(repository) for _, assignee := range gAssignees { if assignee != nil && assignee.Login == nil { return nil, fmt.Errorf("Assignee is missing Login field") } assignees = append(assignees, sql.Assignee{ IssueID: strconv.Itoa(issueID), Name: *assignee.Login, Repository: repository, }) } return assignees, nil }
[ "func", "newAssignees", "(", "issueID", "int", ",", "gAssignees", "[", "]", "*", "github", ".", "User", ",", "repository", "string", ")", "(", "[", "]", "sql", ".", "Assignee", ",", "error", ")", "{", "assignees", ":=", "[", "]", "sql", ".", "Assigne...
// newAssignees creates a new Label for each label in the issue
[ "newAssignees", "creates", "a", "new", "Label", "for", "each", "label", "in", "the", "issue" ]
8125fbda10178887be5dff9e901d6a0a519b67bc
https://github.com/kubernetes/test-infra/blob/8125fbda10178887be5dff9e901d6a0a519b67bc/velodrome/fetcher/conversion.go#L133-L149
test
kubernetes/test-infra
velodrome/fetcher/conversion.go
NewIssueComment
func NewIssueComment(issueID int, gComment *github.IssueComment, repository string) (*sql.Comment, error) { if gComment.ID == nil || gComment.Body == nil || gComment.CreatedAt == nil || gComment.UpdatedAt == nil { return nil, fmt.Errorf("IssueComment is missing mandatory field: %s", gComment) } var login string if gComment.User != nil && gComment.User.Login != nil { login = *gComment.User.Login } return &sql.Comment{ ID: itoa(*gComment.ID), IssueID: strconv.Itoa(issueID), Body: *gComment.Body, User: login, CommentCreatedAt: *gComment.CreatedAt, CommentUpdatedAt: *gComment.UpdatedAt, PullRequest: false, Repository: strings.ToLower(repository), }, nil }
go
func NewIssueComment(issueID int, gComment *github.IssueComment, repository string) (*sql.Comment, error) { if gComment.ID == nil || gComment.Body == nil || gComment.CreatedAt == nil || gComment.UpdatedAt == nil { return nil, fmt.Errorf("IssueComment is missing mandatory field: %s", gComment) } var login string if gComment.User != nil && gComment.User.Login != nil { login = *gComment.User.Login } return &sql.Comment{ ID: itoa(*gComment.ID), IssueID: strconv.Itoa(issueID), Body: *gComment.Body, User: login, CommentCreatedAt: *gComment.CreatedAt, CommentUpdatedAt: *gComment.UpdatedAt, PullRequest: false, Repository: strings.ToLower(repository), }, nil }
[ "func", "NewIssueComment", "(", "issueID", "int", ",", "gComment", "*", "github", ".", "IssueComment", ",", "repository", "string", ")", "(", "*", "sql", ".", "Comment", ",", "error", ")", "{", "if", "gComment", ".", "ID", "==", "nil", "||", "gComment", ...
// NewIssueComment creates a Comment from a github.IssueComment
[ "NewIssueComment", "creates", "a", "Comment", "from", "a", "github", ".", "IssueComment" ]
8125fbda10178887be5dff9e901d6a0a519b67bc
https://github.com/kubernetes/test-infra/blob/8125fbda10178887be5dff9e901d6a0a519b67bc/velodrome/fetcher/conversion.go#L156-L179
test
kubernetes/test-infra
prow/gerrit/adapter/trigger.go
messageFilter
func messageFilter(lastUpdate time.Time, change client.ChangeInfo, presubmits []config.Presubmit) (pjutil.Filter, error) { var filters []pjutil.Filter currentRevision := change.Revisions[change.CurrentRevision].Number for _, message := range change.Messages { messageTime := message.Date.Time if message.RevisionNumber != currentRevision || !messageTime.After(lastUpdate) { continue } if !pjutil.TestAllRe.MatchString(message.Message) { for _, presubmit := range presubmits { if presubmit.TriggerMatches(message.Message) { logrus.Infof("Change %d: Comment %s matches triggering regex, for %s.", change.Number, message.Message, presubmit.Name) filters = append(filters, pjutil.CommandFilter(message.Message)) } } } else { filters = append(filters, pjutil.TestAllFilter()) } } return pjutil.AggregateFilter(filters), nil }
go
func messageFilter(lastUpdate time.Time, change client.ChangeInfo, presubmits []config.Presubmit) (pjutil.Filter, error) { var filters []pjutil.Filter currentRevision := change.Revisions[change.CurrentRevision].Number for _, message := range change.Messages { messageTime := message.Date.Time if message.RevisionNumber != currentRevision || !messageTime.After(lastUpdate) { continue } if !pjutil.TestAllRe.MatchString(message.Message) { for _, presubmit := range presubmits { if presubmit.TriggerMatches(message.Message) { logrus.Infof("Change %d: Comment %s matches triggering regex, for %s.", change.Number, message.Message, presubmit.Name) filters = append(filters, pjutil.CommandFilter(message.Message)) } } } else { filters = append(filters, pjutil.TestAllFilter()) } } return pjutil.AggregateFilter(filters), nil }
[ "func", "messageFilter", "(", "lastUpdate", "time", ".", "Time", ",", "change", "client", ".", "ChangeInfo", ",", "presubmits", "[", "]", "config", ".", "Presubmit", ")", "(", "pjutil", ".", "Filter", ",", "error", ")", "{", "var", "filters", "[", "]", ...
// messageFilter builds a filter for jobs based on the messageBody matching the trigger regex of the jobs.
[ "messageFilter", "builds", "a", "filter", "for", "jobs", "based", "on", "the", "messageBody", "matching", "the", "trigger", "regex", "of", "the", "jobs", "." ]
8125fbda10178887be5dff9e901d6a0a519b67bc
https://github.com/kubernetes/test-infra/blob/8125fbda10178887be5dff9e901d6a0a519b67bc/prow/gerrit/adapter/trigger.go#L30-L52
test
kubernetes/test-infra
prow/jenkins/jenkins.go
IsSuccess
func (jb *Build) IsSuccess() bool { return jb.Result != nil && *jb.Result == success }
go
func (jb *Build) IsSuccess() bool { return jb.Result != nil && *jb.Result == success }
[ "func", "(", "jb", "*", "Build", ")", "IsSuccess", "(", ")", "bool", "{", "return", "jb", ".", "Result", "!=", "nil", "&&", "*", "jb", ".", "Result", "==", "success", "\n", "}" ]
// IsSuccess means the job passed
[ "IsSuccess", "means", "the", "job", "passed" ]
8125fbda10178887be5dff9e901d6a0a519b67bc
https://github.com/kubernetes/test-infra/blob/8125fbda10178887be5dff9e901d6a0a519b67bc/prow/jenkins/jenkins.go#L130-L132
test
kubernetes/test-infra
prow/jenkins/jenkins.go
IsFailure
func (jb *Build) IsFailure() bool { return jb.Result != nil && (*jb.Result == failure || *jb.Result == unstable) }
go
func (jb *Build) IsFailure() bool { return jb.Result != nil && (*jb.Result == failure || *jb.Result == unstable) }
[ "func", "(", "jb", "*", "Build", ")", "IsFailure", "(", ")", "bool", "{", "return", "jb", ".", "Result", "!=", "nil", "&&", "(", "*", "jb", ".", "Result", "==", "failure", "||", "*", "jb", ".", "Result", "==", "unstable", ")", "\n", "}" ]
// IsFailure means the job completed with problems.
[ "IsFailure", "means", "the", "job", "completed", "with", "problems", "." ]
8125fbda10178887be5dff9e901d6a0a519b67bc
https://github.com/kubernetes/test-infra/blob/8125fbda10178887be5dff9e901d6a0a519b67bc/prow/jenkins/jenkins.go#L135-L137
test
kubernetes/test-infra
prow/jenkins/jenkins.go
IsAborted
func (jb *Build) IsAborted() bool { return jb.Result != nil && *jb.Result == aborted }
go
func (jb *Build) IsAborted() bool { return jb.Result != nil && *jb.Result == aborted }
[ "func", "(", "jb", "*", "Build", ")", "IsAborted", "(", ")", "bool", "{", "return", "jb", ".", "Result", "!=", "nil", "&&", "*", "jb", ".", "Result", "==", "aborted", "\n", "}" ]
// IsAborted means something stopped the job before it could finish.
[ "IsAborted", "means", "something", "stopped", "the", "job", "before", "it", "could", "finish", "." ]
8125fbda10178887be5dff9e901d6a0a519b67bc
https://github.com/kubernetes/test-infra/blob/8125fbda10178887be5dff9e901d6a0a519b67bc/prow/jenkins/jenkins.go#L140-L142
test
kubernetes/test-infra
prow/jenkins/jenkins.go
ProwJobID
func (jb *Build) ProwJobID() string { for _, action := range jb.Actions { for _, p := range action.Parameters { if p.Name == prowJobID { value, ok := p.Value.(string) if !ok { logrus.Errorf("Cannot determine %s value for %#v", p.Name, jb) continue } return value } } } return "" }
go
func (jb *Build) ProwJobID() string { for _, action := range jb.Actions { for _, p := range action.Parameters { if p.Name == prowJobID { value, ok := p.Value.(string) if !ok { logrus.Errorf("Cannot determine %s value for %#v", p.Name, jb) continue } return value } } } return "" }
[ "func", "(", "jb", "*", "Build", ")", "ProwJobID", "(", ")", "string", "{", "for", "_", ",", "action", ":=", "range", "jb", ".", "Actions", "{", "for", "_", ",", "p", ":=", "range", "action", ".", "Parameters", "{", "if", "p", ".", "Name", "==", ...
// ProwJobID extracts the ProwJob identifier for the // Jenkins build in order to correlate the build with // a ProwJob. If the build has an empty PROW_JOB_ID // it didn't start by prow.
[ "ProwJobID", "extracts", "the", "ProwJob", "identifier", "for", "the", "Jenkins", "build", "in", "order", "to", "correlate", "the", "build", "with", "a", "ProwJob", ".", "If", "the", "build", "has", "an", "empty", "PROW_JOB_ID", "it", "didn", "t", "start", ...
8125fbda10178887be5dff9e901d6a0a519b67bc
https://github.com/kubernetes/test-infra/blob/8125fbda10178887be5dff9e901d6a0a519b67bc/prow/jenkins/jenkins.go#L153-L167
test
kubernetes/test-infra
prow/jenkins/jenkins.go
BuildID
func (jb *Build) BuildID() string { var buildID string hasProwJobID := false for _, action := range jb.Actions { for _, p := range action.Parameters { hasProwJobID = hasProwJobID || p.Name == prowJobID if p.Name == statusBuildID { value, ok := p.Value.(string) if !ok { logrus.Errorf("Cannot determine %s value for %#v", p.Name, jb) continue } buildID = value } } } if !hasProwJobID { return "" } return buildID }
go
func (jb *Build) BuildID() string { var buildID string hasProwJobID := false for _, action := range jb.Actions { for _, p := range action.Parameters { hasProwJobID = hasProwJobID || p.Name == prowJobID if p.Name == statusBuildID { value, ok := p.Value.(string) if !ok { logrus.Errorf("Cannot determine %s value for %#v", p.Name, jb) continue } buildID = value } } } if !hasProwJobID { return "" } return buildID }
[ "func", "(", "jb", "*", "Build", ")", "BuildID", "(", ")", "string", "{", "var", "buildID", "string", "\n", "hasProwJobID", ":=", "false", "\n", "for", "_", ",", "action", ":=", "range", "jb", ".", "Actions", "{", "for", "_", ",", "p", ":=", "range...
// BuildID extracts the build identifier used for // placing and discovering build artifacts. // This identifier can either originate from tot // or the snowflake library, depending on how the // Jenkins operator is configured to run. // We return an empty string if we are dealing with // a build that does not have the ProwJobID set // explicitly, as in that case the Jenkins build has // not started by prow.
[ "BuildID", "extracts", "the", "build", "identifier", "used", "for", "placing", "and", "discovering", "build", "artifacts", ".", "This", "identifier", "can", "either", "originate", "from", "tot", "or", "the", "snowflake", "library", "depending", "on", "how", "the...
8125fbda10178887be5dff9e901d6a0a519b67bc
https://github.com/kubernetes/test-infra/blob/8125fbda10178887be5dff9e901d6a0a519b67bc/prow/jenkins/jenkins.go#L178-L199
test
kubernetes/test-infra
prow/jenkins/jenkins.go
CrumbRequest
func (c *Client) CrumbRequest() error { if c.authConfig.csrfToken != "" && c.authConfig.csrfRequestField != "" { return nil } c.logger.Debug("CrumbRequest") data, err := c.GetSkipMetrics("/crumbIssuer/api/json") if err != nil { return err } crumbResp := struct { Crumb string `json:"crumb"` CrumbRequestField string `json:"crumbRequestField"` }{} if err := json.Unmarshal(data, &crumbResp); err != nil { return fmt.Errorf("cannot unmarshal crumb response: %v", err) } c.authConfig.csrfToken = crumbResp.Crumb c.authConfig.csrfRequestField = crumbResp.CrumbRequestField return nil }
go
func (c *Client) CrumbRequest() error { if c.authConfig.csrfToken != "" && c.authConfig.csrfRequestField != "" { return nil } c.logger.Debug("CrumbRequest") data, err := c.GetSkipMetrics("/crumbIssuer/api/json") if err != nil { return err } crumbResp := struct { Crumb string `json:"crumb"` CrumbRequestField string `json:"crumbRequestField"` }{} if err := json.Unmarshal(data, &crumbResp); err != nil { return fmt.Errorf("cannot unmarshal crumb response: %v", err) } c.authConfig.csrfToken = crumbResp.Crumb c.authConfig.csrfRequestField = crumbResp.CrumbRequestField return nil }
[ "func", "(", "c", "*", "Client", ")", "CrumbRequest", "(", ")", "error", "{", "if", "c", ".", "authConfig", ".", "csrfToken", "!=", "\"\"", "&&", "c", ".", "authConfig", ".", "csrfRequestField", "!=", "\"\"", "{", "return", "nil", "\n", "}", "\n", "c...
// CrumbRequest requests a CSRF protection token from Jenkins to // use it in subsequent requests. Required for Jenkins masters that // prevent cross site request forgery exploits.
[ "CrumbRequest", "requests", "a", "CSRF", "protection", "token", "from", "Jenkins", "to", "use", "it", "in", "subsequent", "requests", ".", "Required", "for", "Jenkins", "masters", "that", "prevent", "cross", "site", "request", "forgery", "exploits", "." ]
8125fbda10178887be5dff9e901d6a0a519b67bc
https://github.com/kubernetes/test-infra/blob/8125fbda10178887be5dff9e901d6a0a519b67bc/prow/jenkins/jenkins.go#L295-L314
test
kubernetes/test-infra
prow/jenkins/jenkins.go
measure
func (c *Client) measure(method, path string, code int, start time.Time) { if c.metrics == nil { return } c.metrics.RequestLatency.WithLabelValues(method, path).Observe(time.Since(start).Seconds()) c.metrics.Requests.WithLabelValues(method, path, fmt.Sprintf("%d", code)).Inc() }
go
func (c *Client) measure(method, path string, code int, start time.Time) { if c.metrics == nil { return } c.metrics.RequestLatency.WithLabelValues(method, path).Observe(time.Since(start).Seconds()) c.metrics.Requests.WithLabelValues(method, path, fmt.Sprintf("%d", code)).Inc() }
[ "func", "(", "c", "*", "Client", ")", "measure", "(", "method", ",", "path", "string", ",", "code", "int", ",", "start", "time", ".", "Time", ")", "{", "if", "c", ".", "metrics", "==", "nil", "{", "return", "\n", "}", "\n", "c", ".", "metrics", ...
// measure records metrics about the provided method, path, and code. // start needs to be recorded before doing the request.
[ "measure", "records", "metrics", "about", "the", "provided", "method", "path", "and", "code", ".", "start", "needs", "to", "be", "recorded", "before", "doing", "the", "request", "." ]
8125fbda10178887be5dff9e901d6a0a519b67bc
https://github.com/kubernetes/test-infra/blob/8125fbda10178887be5dff9e901d6a0a519b67bc/prow/jenkins/jenkins.go#L318-L324
test
kubernetes/test-infra
prow/jenkins/jenkins.go
GetSkipMetrics
func (c *Client) GetSkipMetrics(path string) ([]byte, error) { resp, err := c.request(http.MethodGet, path, nil, false) if err != nil { return nil, err } return readResp(resp) }
go
func (c *Client) GetSkipMetrics(path string) ([]byte, error) { resp, err := c.request(http.MethodGet, path, nil, false) if err != nil { return nil, err } return readResp(resp) }
[ "func", "(", "c", "*", "Client", ")", "GetSkipMetrics", "(", "path", "string", ")", "(", "[", "]", "byte", ",", "error", ")", "{", "resp", ",", "err", ":=", "c", ".", "request", "(", "http", ".", "MethodGet", ",", "path", ",", "nil", ",", "false"...
// GetSkipMetrics fetches the data found in the provided path. It returns the // content of the response or any errors that occurred during the request or // http errors. Metrics will not be gathered for this request.
[ "GetSkipMetrics", "fetches", "the", "data", "found", "in", "the", "provided", "path", ".", "It", "returns", "the", "content", "of", "the", "response", "or", "any", "errors", "that", "occurred", "during", "the", "request", "or", "http", "errors", ".", "Metric...
8125fbda10178887be5dff9e901d6a0a519b67bc
https://github.com/kubernetes/test-infra/blob/8125fbda10178887be5dff9e901d6a0a519b67bc/prow/jenkins/jenkins.go#L329-L335
test
kubernetes/test-infra
prow/jenkins/jenkins.go
Get
func (c *Client) Get(path string) ([]byte, error) { resp, err := c.request(http.MethodGet, path, nil, true) if err != nil { return nil, err } return readResp(resp) }
go
func (c *Client) Get(path string) ([]byte, error) { resp, err := c.request(http.MethodGet, path, nil, true) if err != nil { return nil, err } return readResp(resp) }
[ "func", "(", "c", "*", "Client", ")", "Get", "(", "path", "string", ")", "(", "[", "]", "byte", ",", "error", ")", "{", "resp", ",", "err", ":=", "c", ".", "request", "(", "http", ".", "MethodGet", ",", "path", ",", "nil", ",", "true", ")", "...
// Get fetches the data found in the provided path. It returns the // content of the response or any errors that occurred during the // request or http errors.
[ "Get", "fetches", "the", "data", "found", "in", "the", "provided", "path", ".", "It", "returns", "the", "content", "of", "the", "response", "or", "any", "errors", "that", "occurred", "during", "the", "request", "or", "http", "errors", "." ]
8125fbda10178887be5dff9e901d6a0a519b67bc
https://github.com/kubernetes/test-infra/blob/8125fbda10178887be5dff9e901d6a0a519b67bc/prow/jenkins/jenkins.go#L340-L346
test
kubernetes/test-infra
prow/jenkins/jenkins.go
request
func (c *Client) request(method, path string, params url.Values, measure bool) (*http.Response, error) { var resp *http.Response var err error backoff := retryDelay urlPath := fmt.Sprintf("%s%s", c.baseURL, path) if params != nil { urlPath = fmt.Sprintf("%s?%s", urlPath, params.Encode()) } start := time.Now() for retries := 0; retries < maxRetries; retries++ { resp, err = c.doRequest(method, urlPath) if err == nil && resp.StatusCode < 500 { break } else if err == nil && retries+1 < maxRetries { resp.Body.Close() } // Capture the retry in a metric. if measure && c.metrics != nil { c.metrics.RequestRetries.Inc() } time.Sleep(backoff) backoff *= 2 } if measure && resp != nil { c.measure(method, path, resp.StatusCode, start) } return resp, err }
go
func (c *Client) request(method, path string, params url.Values, measure bool) (*http.Response, error) { var resp *http.Response var err error backoff := retryDelay urlPath := fmt.Sprintf("%s%s", c.baseURL, path) if params != nil { urlPath = fmt.Sprintf("%s?%s", urlPath, params.Encode()) } start := time.Now() for retries := 0; retries < maxRetries; retries++ { resp, err = c.doRequest(method, urlPath) if err == nil && resp.StatusCode < 500 { break } else if err == nil && retries+1 < maxRetries { resp.Body.Close() } // Capture the retry in a metric. if measure && c.metrics != nil { c.metrics.RequestRetries.Inc() } time.Sleep(backoff) backoff *= 2 } if measure && resp != nil { c.measure(method, path, resp.StatusCode, start) } return resp, err }
[ "func", "(", "c", "*", "Client", ")", "request", "(", "method", ",", "path", "string", ",", "params", "url", ".", "Values", ",", "measure", "bool", ")", "(", "*", "http", ".", "Response", ",", "error", ")", "{", "var", "resp", "*", "http", ".", "...
// request executes a request with the provided method and path. // It retries on transport failures and 500s. measure is provided // to enable or disable gathering metrics for specific requests // to avoid high-cardinality metrics.
[ "request", "executes", "a", "request", "with", "the", "provided", "method", "and", "path", ".", "It", "retries", "on", "transport", "failures", "and", "500s", ".", "measure", "is", "provided", "to", "enable", "or", "disable", "gathering", "metrics", "for", "...
8125fbda10178887be5dff9e901d6a0a519b67bc
https://github.com/kubernetes/test-infra/blob/8125fbda10178887be5dff9e901d6a0a519b67bc/prow/jenkins/jenkins.go#L368-L397
test
kubernetes/test-infra
prow/jenkins/jenkins.go
doRequest
func (c *Client) doRequest(method, path string) (*http.Response, error) { req, err := http.NewRequest(method, path, nil) if err != nil { return nil, err } if c.authConfig != nil { if c.authConfig.Basic != nil { req.SetBasicAuth(c.authConfig.Basic.User, string(c.authConfig.Basic.GetToken())) } if c.authConfig.BearerToken != nil { req.Header.Set("Authorization", fmt.Sprintf("Bearer %s", c.authConfig.BearerToken.GetToken())) } if c.authConfig.CSRFProtect && c.authConfig.csrfRequestField != "" && c.authConfig.csrfToken != "" { req.Header.Set(c.authConfig.csrfRequestField, c.authConfig.csrfToken) } } return c.client.Do(req) }
go
func (c *Client) doRequest(method, path string) (*http.Response, error) { req, err := http.NewRequest(method, path, nil) if err != nil { return nil, err } if c.authConfig != nil { if c.authConfig.Basic != nil { req.SetBasicAuth(c.authConfig.Basic.User, string(c.authConfig.Basic.GetToken())) } if c.authConfig.BearerToken != nil { req.Header.Set("Authorization", fmt.Sprintf("Bearer %s", c.authConfig.BearerToken.GetToken())) } if c.authConfig.CSRFProtect && c.authConfig.csrfRequestField != "" && c.authConfig.csrfToken != "" { req.Header.Set(c.authConfig.csrfRequestField, c.authConfig.csrfToken) } } return c.client.Do(req) }
[ "func", "(", "c", "*", "Client", ")", "doRequest", "(", "method", ",", "path", "string", ")", "(", "*", "http", ".", "Response", ",", "error", ")", "{", "req", ",", "err", ":=", "http", ".", "NewRequest", "(", "method", ",", "path", ",", "nil", "...
// doRequest executes a request with the provided method and path // exactly once. It sets up authentication if the jenkins client // is configured accordingly. It's up to callers of this function // to build retries and error handling.
[ "doRequest", "executes", "a", "request", "with", "the", "provided", "method", "and", "path", "exactly", "once", ".", "It", "sets", "up", "authentication", "if", "the", "jenkins", "client", "is", "configured", "accordingly", ".", "It", "s", "up", "to", "calle...
8125fbda10178887be5dff9e901d6a0a519b67bc
https://github.com/kubernetes/test-infra/blob/8125fbda10178887be5dff9e901d6a0a519b67bc/prow/jenkins/jenkins.go#L403-L420
test
kubernetes/test-infra
prow/jenkins/jenkins.go
getJobName
func getJobName(spec *prowapi.ProwJobSpec) string { if spec.JenkinsSpec != nil && spec.JenkinsSpec.GitHubBranchSourceJob && spec.Refs != nil { if len(spec.Refs.Pulls) > 0 { return fmt.Sprintf("%s/view/change-requests/job/PR-%d", spec.Job, spec.Refs.Pulls[0].Number) } return fmt.Sprintf("%s/job/%s", spec.Job, spec.Refs.BaseRef) } return spec.Job }
go
func getJobName(spec *prowapi.ProwJobSpec) string { if spec.JenkinsSpec != nil && spec.JenkinsSpec.GitHubBranchSourceJob && spec.Refs != nil { if len(spec.Refs.Pulls) > 0 { return fmt.Sprintf("%s/view/change-requests/job/PR-%d", spec.Job, spec.Refs.Pulls[0].Number) } return fmt.Sprintf("%s/job/%s", spec.Job, spec.Refs.BaseRef) } return spec.Job }
[ "func", "getJobName", "(", "spec", "*", "prowapi", ".", "ProwJobSpec", ")", "string", "{", "if", "spec", ".", "JenkinsSpec", "!=", "nil", "&&", "spec", ".", "JenkinsSpec", ".", "GitHubBranchSourceJob", "&&", "spec", ".", "Refs", "!=", "nil", "{", "if", "...
// getJobName generates the correct job name for this job type
[ "getJobName", "generates", "the", "correct", "job", "name", "for", "this", "job", "type" ]
8125fbda10178887be5dff9e901d6a0a519b67bc
https://github.com/kubernetes/test-infra/blob/8125fbda10178887be5dff9e901d6a0a519b67bc/prow/jenkins/jenkins.go#L423-L433
test
kubernetes/test-infra
prow/jenkins/jenkins.go
getBuildPath
func getBuildPath(spec *prowapi.ProwJobSpec) string { jenkinsJobName := getJobName(spec) jenkinsPath := fmt.Sprintf("/job/%s/build", jenkinsJobName) return jenkinsPath }
go
func getBuildPath(spec *prowapi.ProwJobSpec) string { jenkinsJobName := getJobName(spec) jenkinsPath := fmt.Sprintf("/job/%s/build", jenkinsJobName) return jenkinsPath }
[ "func", "getBuildPath", "(", "spec", "*", "prowapi", ".", "ProwJobSpec", ")", "string", "{", "jenkinsJobName", ":=", "getJobName", "(", "spec", ")", "\n", "jenkinsPath", ":=", "fmt", ".", "Sprintf", "(", "\"/job/%s/build\"", ",", "jenkinsJobName", ")", "\n", ...
// getBuildPath builds a path to trigger a regular build for this job
[ "getBuildPath", "builds", "a", "path", "to", "trigger", "a", "regular", "build", "for", "this", "job" ]
8125fbda10178887be5dff9e901d6a0a519b67bc
https://github.com/kubernetes/test-infra/blob/8125fbda10178887be5dff9e901d6a0a519b67bc/prow/jenkins/jenkins.go#L444-L449
test
kubernetes/test-infra
prow/jenkins/jenkins.go
GetJobInfo
func (c *Client) GetJobInfo(spec *prowapi.ProwJobSpec) (*JobInfo, error) { path := getJobInfoPath(spec) c.logger.Debugf("getJobInfoPath: %s", path) data, err := c.Get(path) if err != nil { c.logger.Errorf("Failed to get job info: %v", err) return nil, err } var jobInfo JobInfo if err := json.Unmarshal(data, &jobInfo); err != nil { return nil, fmt.Errorf("Cannot unmarshal job info from API: %v", err) } c.logger.Tracef("JobInfo: %+v", jobInfo) return &jobInfo, nil }
go
func (c *Client) GetJobInfo(spec *prowapi.ProwJobSpec) (*JobInfo, error) { path := getJobInfoPath(spec) c.logger.Debugf("getJobInfoPath: %s", path) data, err := c.Get(path) if err != nil { c.logger.Errorf("Failed to get job info: %v", err) return nil, err } var jobInfo JobInfo if err := json.Unmarshal(data, &jobInfo); err != nil { return nil, fmt.Errorf("Cannot unmarshal job info from API: %v", err) } c.logger.Tracef("JobInfo: %+v", jobInfo) return &jobInfo, nil }
[ "func", "(", "c", "*", "Client", ")", "GetJobInfo", "(", "spec", "*", "prowapi", ".", "ProwJobSpec", ")", "(", "*", "JobInfo", ",", "error", ")", "{", "path", ":=", "getJobInfoPath", "(", "spec", ")", "\n", "c", ".", "logger", ".", "Debugf", "(", "...
// GetJobInfo retrieves Jenkins job information
[ "GetJobInfo", "retrieves", "Jenkins", "job", "information" ]
8125fbda10178887be5dff9e901d6a0a519b67bc
https://github.com/kubernetes/test-infra/blob/8125fbda10178887be5dff9e901d6a0a519b67bc/prow/jenkins/jenkins.go#L460-L480
test