id
stringlengths
95
167
text
stringlengths
69
15.9k
title
stringclasses
1 value
https://github.com/kubernetes/test-infra/blob/8125fbda10178887be5dff9e901d6a0a519b67bc/prow/gcsupload/run.go#L41-L62
func (o Options) Run(spec *downwardapi.JobSpec, extra map[string]gcs.UploadFunc) error { uploadTargets := o.assembleTargets(spec, extra) if !o.DryRun { ctx := context.Background() gcsClient, err := storage.NewClient(ctx, option.WithCredentialsFile(o.GcsCredentialsFile)) if err != nil { return fmt.Errorf("co...
https://github.com/hashicorp/raft/blob/773bcaa2009bf059c5c06457b9fccd156d5e91e7/fuzzy/cluster.go#L144-L162
func (c *cluster) LeaderPlus(n int) []*raftNode { r := make([]*raftNode, 0, n+1) ldr := c.Leader(time.Second) if ldr != nil { r = append(r, ldr) } if len(r) >= n { return r } for _, node := range c.nodes { if !containsNode(r, node) { r = append(r, node) if len(r) >= n { return r } } } retu...
https://github.com/kubernetes/test-infra/blob/8125fbda10178887be5dff9e901d6a0a519b67bc/prow/cmd/pipeline/controller.go#L467-L473
func finalState(status prowjobv1.ProwJobState) bool { switch status { case "", prowjobv1.PendingState, prowjobv1.TriggeredState: return false } return true }
https://github.com/kubernetes/test-infra/blob/8125fbda10178887be5dff9e901d6a0a519b67bc/prow/deck/jobs/jobs.go#L132-L147
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 { ...
https://github.com/kubernetes/test-infra/blob/8125fbda10178887be5dff9e901d6a0a519b67bc/prow/plugins/plugins.go#L65-L68
func RegisterIssueHandler(name string, fn IssueHandler, help HelpProvider) { pluginHelp[name] = help issueHandlers[name] = fn }
https://github.com/dgraph-io/badger/blob/6b796b3ebec3ff006fcb1b425836cd784651e9fd/iterator.go#L120-L128
func (item *Item) ValueCopy(dst []byte) ([]byte, error) { item.wg.Wait() if item.status == prefetched { return y.SafeCopy(dst, item.val), item.err } buf, cb, err := item.yieldItemValue() defer runCallback(cb) return y.SafeCopy(dst, buf), err }
https://github.com/kubernetes/test-infra/blob/8125fbda10178887be5dff9e901d6a0a519b67bc/prow/pubsub/reporter/reporter.go#L92-L120
func (c *Client) Report(pj *prowapi.ProwJob) ([]*prowapi.ProwJob, error) { message := c.generateMessageFromPJ(pj) ctx := context.Background() client, err := pubsub.NewClient(ctx, message.Project) if err != nil { return nil, fmt.Errorf("could not create pubsub Client: %v", err) } topic := client.Topic(message....
https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/clientv3/op.go#L383-L391
func WithPrefix() OpOption { return func(op *Op) { if len(op.key) == 0 { op.key, op.end = []byte{0}, []byte{0} return } op.end = getPrefix(op.key) } }
https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/clientv3/watch.go#L688-L696
func (w *watchGrpcStream) broadcastResponse(wr *WatchResponse) bool { for _, ws := range w.substreams { select { case ws.recvc <- wr: case <-ws.donec: } } return true }
https://github.com/dgraph-io/badger/blob/6b796b3ebec3ff006fcb1b425836cd784651e9fd/skl/skl.go#L472-L477
func (s *Skiplist) NewUniIterator(reversed bool) *UniIterator { return &UniIterator{ iter: s.NewIterator(), reversed: reversed, } }
https://github.com/gobuffalo/buffalo/blob/7f360181f4ccd79dcc9dcea2c904a4801f194f04/render/js.go#L9-L12
func JavaScript(names ...string) Renderer { e := New(Options{}) return e.JavaScript(names...) }
https://github.com/dgraph-io/badger/blob/6b796b3ebec3ff006fcb1b425836cd784651e9fd/db.go#L1110-L1130
func (db *DB) GetSequence(key []byte, bandwidth uint64) (*Sequence, error) { if db.opt.managedTxns { panic("Cannot use GetSequence with managedDB=true.") } switch { case len(key) == 0: return nil, ErrEmptyKey case bandwidth == 0: return nil, ErrZeroBandwidth } seq := &Sequence{ db: db, key: ...
https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/etcdserver/api/v2auth/auth.go#L197-L205
func (s *store) CreateOrUpdateUser(user User) (out User, created bool, err error) { _, err = s.getUser(user.User, true) if err == nil { out, err = s.UpdateUser(user) return out, false, err } u, err := s.CreateUser(user) return u, true, err }
https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/client/keys.go#L311-L313
func (n *Node) TTLDuration() time.Duration { return time.Duration(n.TTL) * time.Second }
https://github.com/gobuffalo/buffalo/blob/7f360181f4ccd79dcc9dcea2c904a4801f194f04/binding/binding.go#L78-L91
func Exec(req *http.Request, value interface{}) error { if ba, ok := value.(Bindable); ok { return ba.Bind(req) } ct := httpx.ContentType(req) if ct == "" { return errors.New("blank content type") } if b, ok := binders[ct]; ok { return b(req, value) } return fmt.Errorf("could not find a binder for %s", c...
https://github.com/dgraph-io/badger/blob/6b796b3ebec3ff006fcb1b425836cd784651e9fd/dir_unix.go#L45-L80
func acquireDirectoryLock(dirPath string, pidFileName string, readOnly bool) (*directoryLockGuard, error) { // Convert to absolute path so that Release still works even if we do an unbalanced // chdir in the meantime. absPidFilePath, err := filepath.Abs(filepath.Join(dirPath, pidFileName)) if err != nil { return ...
https://github.com/kubernetes/test-infra/blob/8125fbda10178887be5dff9e901d6a0a519b67bc/prow/pluginhelp/externalplugins/externalplugins.go#L40-L85
func ServeExternalPluginHelp(mux *http.ServeMux, log *logrus.Entry, provider ExternalPluginHelpProvider) { mux.HandleFunc( "/help", func(w http.ResponseWriter, r *http.Request) { w.Header().Set("Cache-Control", "no-cache") serverError := func(action string, err error) { log.WithError(err).Errorf("Error ...
https://github.com/kubernetes/test-infra/blob/8125fbda10178887be5dff9e901d6a0a519b67bc/velodrome/transform/plugins/comment_counter.go#L35-L37
func (c *CommentCounterPlugin) AddFlags(cmd *cobra.Command) { cmd.Flags().StringSliceVar(&c.pattern, "comments", []string{}, "Regexps to match comments") }
https://github.com/gobuffalo/buffalo/blob/7f360181f4ccd79dcc9dcea2c904a4801f194f04/render/string.go#L35-L38
func String(s string, args ...interface{}) Renderer { e := New(Options{}) return e.String(s, args...) }
https://github.com/dgraph-io/badger/blob/6b796b3ebec3ff006fcb1b425836cd784651e9fd/skl/skl.go#L489-L495
func (s *UniIterator) Rewind() { if !s.reversed { s.iter.SeekToFirst() } else { s.iter.SeekToLast() } }
https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/clientv3/compact_op.go#L37-L41
func OpCompact(rev int64, opts ...CompactOption) CompactOp { ret := CompactOp{revision: rev} ret.applyCompactOpts(opts) return ret }
https://github.com/kubernetes/test-infra/blob/8125fbda10178887be5dff9e901d6a0a519b67bc/maintenance/aws-janitor/resources/dhcp_options.go#L125-L159
func defaultLookingDHCPOptions(dhcp *ec2.DhcpOptions, region string) bool { if len(dhcp.Tags) != 0 { return false } for _, conf := range dhcp.DhcpConfigurations { switch *conf.Key { case "domain-name": var domain string // TODO(akutz): Should this be updated to regions.Default, or is // this relying ...
https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/integration/cluster.go#L427-L470
func (c *cluster) waitLeader(t testing.TB, membs []*member) int { possibleLead := make(map[uint64]bool) var lead uint64 for _, m := range membs { possibleLead[uint64(m.s.ID())] = true } cc := MustNewHTTPClient(t, getMembersURLs(membs), nil) kapi := client.NewKeysAPI(cc) // ensure leader is up via linearizable...
https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/etcdserver/api/v2discovery/discovery.go#L95-L122
func newProxyFunc(lg *zap.Logger, proxy string) (func(*http.Request) (*url.URL, error), error) { if proxy == "" { return nil, nil } // Do a small amount of URL sanitization to help the user // Derived from net/http.ProxyFromEnvironment proxyURL, err := url.Parse(proxy) if err != nil || !strings.HasPrefix(proxyU...
https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/etcdserver/snapshot_merge.go#L31-L62
func (s *EtcdServer) createMergedSnapshotMessage(m raftpb.Message, snapt, snapi uint64, confState raftpb.ConfState) snap.Message { // get a snapshot of v2 store as []byte clone := s.v2store.Clone() d, err := clone.SaveNoCopy() if err != nil { if lg := s.getLogger(); lg != nil { lg.Panic("failed to save v2 stor...
https://github.com/kubernetes/test-infra/blob/8125fbda10178887be5dff9e901d6a0a519b67bc/velodrome/fetcher/conversion.go#L156-L179
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 st...
https://github.com/kubernetes/test-infra/blob/8125fbda10178887be5dff9e901d6a0a519b67bc/prow/cmd/pipeline/controller.go#L476-L484
func description(cond duckv1alpha1.Condition, fallback string) string { switch { case cond.Message != "": return cond.Message case cond.Reason != "": return cond.Reason } return fallback }
https://github.com/dgraph-io/badger/blob/6b796b3ebec3ff006fcb1b425836cd784651e9fd/txn.go#L741-L753
func (db *DB) Update(fn func(txn *Txn) error) error { if db.opt.managedTxns { panic("Update can only be used with managedDB=false.") } txn := db.NewTransaction(true) defer txn.Discard() if err := fn(txn); err != nil { return err } return txn.Commit() }
https://github.com/dgraph-io/badger/blob/6b796b3ebec3ff006fcb1b425836cd784651e9fd/db.go#L330-L427
func (db *DB) Close() (err error) { db.elog.Printf("Closing database") atomic.StoreInt32(&db.blockWrites, 1) // Stop value GC first. db.closers.valueGC.SignalAndWait() // Stop writes next. db.closers.writes.SignalAndWait() // Now close the value log. if vlogErr := db.vlog.Close(); vlogErr != nil { err = er...
https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/etcdserver/api/v2stats/leader.go#L124-L128
func (fs *FollowerStats) Fail() { fs.Lock() defer fs.Unlock() fs.Counts.Fail++ }
https://github.com/hashicorp/raft/blob/773bcaa2009bf059c5c06457b9fccd156d5e91e7/inmem_store.go#L107-L115
func (i *InmemStore) Get(key []byte) ([]byte, error) { i.l.RLock() defer i.l.RUnlock() val := i.kv[string(key)] if val == nil { return nil, errors.New("not found") } return val, nil }
https://github.com/gobuffalo/buffalo/blob/7f360181f4ccd79dcc9dcea2c904a4801f194f04/worker/simple.go#L75-L100
func (w Simple) Perform(job Job) error { w.Logger.Debugf("Performing job %s", job) if job.Handler == "" { err := fmt.Errorf("no handler name given for %s", job) w.Logger.Error(err) return err } w.moot.Lock() defer w.moot.Unlock() if h, ok := w.handlers[job.Handler]; ok { go func() { err := safe.RunE(fu...
https://github.com/kubernetes/test-infra/blob/8125fbda10178887be5dff9e901d6a0a519b67bc/prow/client/clientset/versioned/typed/prowjobs/v1/fake/fake_prowjob.go#L93-L101
func (c *FakeProwJobs) Update(prowJob *prowjobsv1.ProwJob) (result *prowjobsv1.ProwJob, err error) { obj, err := c.Fake. Invokes(testing.NewUpdateAction(prowjobsResource, c.ns, prowJob), &prowjobsv1.ProwJob{}) if obj == nil { return nil, err } return obj.(*prowjobsv1.ProwJob), err }
https://github.com/kubernetes/test-infra/blob/8125fbda10178887be5dff9e901d6a0a519b67bc/prow/external-plugins/needs-rebase/plugin/plugin.go#L71-L96
func HandleEvent(log *logrus.Entry, ghc githubClient, pre *github.PullRequestEvent) error { if pre.Action != github.PullRequestActionOpened && pre.Action != github.PullRequestActionSynchronize && pre.Action != github.PullRequestActionReopened { return nil } // Before checking mergeability wait a few seconds to gi...
https://github.com/kubernetes/test-infra/blob/8125fbda10178887be5dff9e901d6a0a519b67bc/prow/plugins/trigger/trigger.go#L230-L247
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....
https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/raft/rawnode.go#L143-L150
func (rn *RawNode) Propose(data []byte) error { return rn.raft.Step(pb.Message{ Type: pb.MsgProp, From: rn.raft.id, Entries: []pb.Entry{ {Data: data}, }}) }
https://github.com/gobuffalo/buffalo/blob/7f360181f4ccd79dcc9dcea2c904a4801f194f04/mail/internal/mail/message.go#L309-L311
func (m *Message) EmbedReader(name string, r io.Reader, settings ...FileSetting) { m.embedded = m.appendFile(m.embedded, fileFromReader(name, r), settings) }
https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/functional/runner/watch_command.go#L41-L54
func NewWatchCommand() *cobra.Command { cmd := &cobra.Command{ Use: "watcher", Short: "Performs watch operation", Run: runWatcherFunc, } cmd.Flags().DurationVar(&runningTime, "running-time", 60, "number of seconds to run") cmd.Flags().StringVar(&watchPrefix, "prefix", "", "the prefix to append on all keys...
https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/pkg/tlsutil/tlsutil.go#L53-L73
func NewCert(certfile, keyfile string, parseFunc func([]byte, []byte) (tls.Certificate, error)) (*tls.Certificate, error) { cert, err := ioutil.ReadFile(certfile) if err != nil { return nil, err } key, err := ioutil.ReadFile(keyfile) if err != nil { return nil, err } if parseFunc == nil { parseFunc = tls...
https://github.com/dgraph-io/badger/blob/6b796b3ebec3ff006fcb1b425836cd784651e9fd/table/iterator.go#L508-L529
func (s *ConcatIterator) Next() { s.cur.Next() if s.cur.Valid() { // Nothing to do. Just stay with the current table. return } for { // In case there are empty tables. if !s.reversed { s.setIdx(s.idx + 1) } else { s.setIdx(s.idx - 1) } if s.cur == nil { // End of list. Valid will become false. ...
https://github.com/kubernetes/test-infra/blob/8125fbda10178887be5dff9e901d6a0a519b67bc/prow/github/reporter/reporter.go#L75-L78
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) }
https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/clientv3/retry_interceptor.go#L339-L343
func withMax(maxRetries uint) retryOption { return retryOption{applyFunc: func(o *options) { o.max = maxRetries }} }
https://github.com/dgraph-io/badger/blob/6b796b3ebec3ff006fcb1b425836cd784651e9fd/table/iterator.go#L485-L505
func (s *ConcatIterator) Seek(key []byte) { var idx int if !s.reversed { idx = sort.Search(len(s.tables), func(i int) bool { return y.CompareKeys(s.tables[i].Biggest(), key) >= 0 }) } else { n := len(s.tables) idx = n - 1 - sort.Search(n, func(i int) bool { return y.CompareKeys(s.tables[n-1-i].Smallest...
https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/raft/progress.go#L213-L227
func (in *inflights) add(inflight uint64) { if in.full() { panic("cannot add into a full inflights") } next := in.start + in.count size := in.size if next >= size { next -= size } if next >= len(in.buffer) { in.growBuf() } in.buffer[next] = inflight in.count++ }
https://github.com/gobuffalo/buffalo/blob/7f360181f4ccd79dcc9dcea2c904a4801f194f04/worker/simple.go#L50-L58
func (w *Simple) Register(name string, h Handler) error { w.moot.Lock() defer w.moot.Unlock() if _, ok := w.handlers[name]; ok { return fmt.Errorf("handler already mapped for name %s", name) } w.handlers[name] = h return nil }
https://github.com/kubernetes/test-infra/blob/8125fbda10178887be5dff9e901d6a0a519b67bc/prow/kube/client.go#L572-L578
func (c *Client) GetContainerLog(pod, container string) ([]byte, error) { c.log("GetContainerLog", pod) return c.requestRetry(&request{ path: fmt.Sprintf("/api/v1/namespaces/%s/pods/%s/log", c.namespace, pod), query: map[string]string{"container": container}, }) }
https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/etcdserver/api/v3rpc/header.go#L39-L49
func (h *header) fill(rh *pb.ResponseHeader) { if rh == nil { plog.Panic("unexpected nil resp.Header") } rh.ClusterId = uint64(h.clusterID) rh.MemberId = uint64(h.memberID) rh.RaftTerm = h.sg.Term() if rh.Revision == 0 { rh.Revision = h.rev() } }
https://github.com/kubernetes/test-infra/blob/8125fbda10178887be5dff9e901d6a0a519b67bc/velodrome/transform/plugins/comment_counter.go#L40-L49
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 }
https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/pkg/netutil/isolate_linux.go#L45-L67
func SetLatency(ms, rv int) error { ifces, err := GetDefaultInterfaces() if err != nil { return err } if rv > ms { rv = 1 } for ifce := range ifces { cmdStr := fmt.Sprintf("sudo tc qdisc add dev %s root netem delay %dms %dms distribution normal", ifce, ms, rv) _, err = exec.Command("/bin/sh", "-c", cmdSt...
https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/etcdserver/api/v2http/client.go#L556-L578
func writeKeyEvent(w http.ResponseWriter, resp etcdserver.Response, noValueOnSuccess bool) error { ev := resp.Event if ev == nil { return errors.New("cannot write empty Event") } w.Header().Set("Content-Type", "application/json") w.Header().Set("X-Etcd-Index", fmt.Sprint(ev.EtcdIndex)) w.Header().Set("X-Raft-In...
https://github.com/dgraph-io/badger/blob/6b796b3ebec3ff006fcb1b425836cd784651e9fd/logger.go#L50-L55
func (opt *Options) Warningf(format string, v ...interface{}) { if opt.Logger == nil { return } opt.Logger.Warningf(format, v...) }
https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/etcdserver/api/v2store/store.go#L162-L188
func (s *store) Create(nodePath string, dir bool, value string, unique bool, expireOpts TTLOptionSet) (*Event, error) { var err *v2error.Error s.worldLock.Lock() defer s.worldLock.Unlock() defer func() { if err == nil { s.Stats.Inc(CreateSuccess) reportWriteSuccess(Create) return } s.Stats.Inc(Cre...
https://github.com/gobuffalo/buffalo/blob/7f360181f4ccd79dcc9dcea2c904a4801f194f04/mail/internal/mail/message.go#L314-L316
func (m *Message) Embed(filename string, settings ...FileSetting) { m.embedded = m.appendFile(m.embedded, fileFromFilename(filename), settings) }
https://github.com/hashicorp/raft/blob/773bcaa2009bf059c5c06457b9fccd156d5e91e7/fuzzy/cluster.go#L133-L140
func containsNode(nodes []*raftNode, n *raftNode) bool { for _, rn := range nodes { if rn == n { return true } } return false }
https://github.com/kubernetes/test-infra/blob/8125fbda10178887be5dff9e901d6a0a519b67bc/prow/github/fakegithub/fakegithub.go#L445-L447
func (f *FakeClient) GetOrgProjects(org string) ([]github.Project, error) { return f.RepoProjects[fmt.Sprintf("%s/*", org)], nil }
https://github.com/gobuffalo/buffalo/blob/7f360181f4ccd79dcc9dcea2c904a4801f194f04/resource.go#L51-L53
func (v BaseResource) List(c Context) error { return c.Error(404, errors.New("resource not implemented")) }
https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/mvcc/watcher_group.go#L270-L292
func (wg *watcherGroup) watcherSetByKey(key string) watcherSet { wkeys := wg.keyWatchers[key] wranges := wg.ranges.Stab(adt.NewStringAffinePoint(key)) // zero-copy cases switch { case len(wranges) == 0: // no need to merge ranges or copy; reuse single-key set return wkeys case len(wranges) == 0 && len(wkeys)...
https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/pkg/netutil/routes_linux.go#L189-L224
func GetDefaultInterfaces() (map[string]uint8, error) { interfaces := make(map[string]uint8) rmsgs, rerr := getDefaultRoutes() if rerr != nil { return interfaces, rerr } for family, rmsg := range rmsgs { _, oif, err := parsePREFSRC(rmsg) if err != nil { return interfaces, err } ifmsg, ierr := getIfa...
https://github.com/hashicorp/raft/blob/773bcaa2009bf059c5c06457b9fccd156d5e91e7/net_transport.go#L146-L169
func NewNetworkTransportWithConfig( config *NetworkTransportConfig, ) *NetworkTransport { if config.Logger == nil { config.Logger = log.New(os.Stderr, "", log.LstdFlags) } trans := &NetworkTransport{ connPool: make(map[ServerAddress][]*netConn), consumeCh: make(chan RPC), logger: ...
https://github.com/kubernetes/test-infra/blob/8125fbda10178887be5dff9e901d6a0a519b67bc/prow/cmd/build/controller.go#L607-L614
func injectEnvironment(b *buildv1alpha1.Build, rawEnv map[string]string) { for i := range b.Spec.Steps { // Inject environment variables to each step defaultEnv(&b.Spec.Steps[i], rawEnv) } if b.Spec.Template != nil { // Also add it as template arguments defaultArguments(b.Spec.Template, rawEnv) } }
https://github.com/kubernetes/test-infra/blob/8125fbda10178887be5dff9e901d6a0a519b67bc/prow/githuboauth/githuboauth.go#L93-L115
func (ga *Agent) HandleLogin(client OAuthClient) http.HandlerFunc { return func(w http.ResponseWriter, r *http.Request) { stateToken := xsrftoken.Generate(ga.gc.ClientSecret, "", "") state := hex.EncodeToString([]byte(stateToken)) oauthSession, err := ga.gc.CookieStore.New(r, oauthSessionCookie) oauthSession.O...
https://github.com/kubernetes/test-infra/blob/8125fbda10178887be5dff9e901d6a0a519b67bc/prow/plugins/updateconfig/updateconfig.go#L90-L164
func Update(fg FileGetter, kc corev1.ConfigMapInterface, name, namespace string, updates []ConfigMapUpdate, logger *logrus.Entry) error { cm, getErr := kc.Get(name, metav1.GetOptions{}) isNotFound := errors.IsNotFound(getErr) if getErr != nil && !isNotFound { return fmt.Errorf("failed to fetch current state of con...
https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/pkg/transport/listener.go#L333-L357
func (info TLSInfo) ServerConfig() (*tls.Config, error) { cfg, err := info.baseConfig() if err != nil { return nil, err } cfg.ClientAuth = tls.NoClientCert if info.TrustedCAFile != "" || info.ClientCertAuth { cfg.ClientAuth = tls.RequireAndVerifyClientCert } cs := info.cafiles() if len(cs) > 0 { cp, err...
https://github.com/gobuffalo/buffalo/blob/7f360181f4ccd79dcc9dcea2c904a4801f194f04/cookies.go#L15-L22
func (c *Cookies) Get(name string) (string, error) { ck, err := c.req.Cookie(name) if err != nil { return "", err } return ck.Value, nil }
https://github.com/kubernetes/test-infra/blob/8125fbda10178887be5dff9e901d6a0a519b67bc/prow/external-plugins/cherrypicker/server.go#L484-L499
func (s *Server) getPatch(org, repo, targetBranch string, num int) (string, error) { patch, err := s.ghc.GetPullRequestPatch(org, repo, num) if err != nil { return "", err } localPath := fmt.Sprintf("/tmp/%s_%s_%d_%s.patch", org, repo, num, normalize(targetBranch)) out, err := os.Create(localPath) if err != nil...
https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/clientv3/utils.go#L31-L34
func jitterUp(duration time.Duration, jitter float64) time.Duration { multiplier := jitter * (rand.Float64()*2 - 1) return time.Duration(float64(duration) * (1 + multiplier)) }
https://github.com/kubernetes/test-infra/blob/8125fbda10178887be5dff9e901d6a0a519b67bc/greenhouse/diskutil/diskutil.go#L29-L39
func GetDiskUsage(path string) (percentBlocksFree float64, bytesFree, bytesUsed uint64, err error) { var stat syscall.Statfs_t err = syscall.Statfs(path, &stat) if err != nil { return 0, 0, 0, err } percentBlocksFree = float64(stat.Bfree) / float64(stat.Blocks) * 100 bytesFree = stat.Bfree * uint64(stat.Bsize) ...
https://github.com/kubernetes/test-infra/blob/8125fbda10178887be5dff9e901d6a0a519b67bc/prow/crier/controller.go#L190-L285
func (c *Controller) processNextItem() bool { key, quit := c.queue.Get() if quit { return false } defer c.queue.Done(key) // assert the string out of the key (format `namespace/name`) keyRaw := key.(string) namespace, name, err := cache.SplitMetaNamespaceKey(keyRaw) if err != nil { logrus.WithError(err).W...
https://github.com/hashicorp/raft/blob/773bcaa2009bf059c5c06457b9fccd156d5e91e7/api.go#L938-L996
func (r *Raft) Stats() map[string]string { toString := func(v uint64) string { return strconv.FormatUint(v, 10) } lastLogIndex, lastLogTerm := r.getLastLog() lastSnapIndex, lastSnapTerm := r.getLastSnapshot() s := map[string]string{ "state": r.getState().String(), "term": toStr...
https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/etcdserver/api/snap/db.go#L36-L79
func (s *Snapshotter) SaveDBFrom(r io.Reader, id uint64) (int64, error) { start := time.Now() f, err := ioutil.TempFile(s.dir, "tmp") if err != nil { return 0, err } var n int64 n, err = io.Copy(f, r) if err == nil { fsyncStart := time.Now() err = fileutil.Fsync(f) snapDBFsyncSec.Observe(time.Since(fsyn...
https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/mvcc/kvstore.go#L569-L582
func appendMarkTombstone(lg *zap.Logger, b []byte) []byte { if len(b) != revBytesLen { if lg != nil { lg.Panic( "cannot append tombstone mark to non-normal revision bytes", zap.Int("expected-revision-bytes-size", revBytesLen), zap.Int("given-revision-bytes-size", len(b)), ) } else { plog.Panic...
https://github.com/dgraph-io/badger/blob/6b796b3ebec3ff006fcb1b425836cd784651e9fd/util.go#L117-L120
func (s *levelsController) reserveFileID() uint64 { id := atomic.AddUint64(&s.nextFileID, 1) return id - 1 }
https://github.com/kubernetes/test-infra/blob/8125fbda10178887be5dff9e901d6a0a519b67bc/prow/pluginhelp/pluginhelp.go#L71-L73
func (pluginHelp *PluginHelp) AddCommand(command Command) { pluginHelp.Commands = append(pluginHelp.Commands, command) }
https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/pkg/transport/keepalive_listener.go#L70-L83
func (l *tlsKeepaliveListener) Accept() (c net.Conn, err error) { c, err = l.Listener.Accept() if err != nil { return } kac := c.(keepAliveConn) // detection time: tcp_keepalive_time + tcp_keepalive_probes + tcp_keepalive_intvl // default on linux: 30 + 8 * 30 // default on osx: 30 + 8 * 75 kac.SetKeepAli...
https://github.com/dgraph-io/badger/blob/6b796b3ebec3ff006fcb1b425836cd784651e9fd/util.go#L66-L93
func (s *levelHandler) validate() error { if s.level == 0 { return nil } s.RLock() defer s.RUnlock() numTables := len(s.tables) for j := 1; j < numTables; j++ { if j >= len(s.tables) { return errors.Errorf("Level %d, j=%d numTables=%d", s.level, j, numTables) } if y.CompareKeys(s.tables[j-1].Biggest(...
https://github.com/kubernetes/test-infra/blob/8125fbda10178887be5dff9e901d6a0a519b67bc/ghproxy/ghproxy.go#L158-L172
func diskMonitor(interval time.Duration, diskRoot string) { logger := logrus.WithField("sync-loop", "disk-monitor") ticker := time.NewTicker(interval) for ; true; <-ticker.C { logger.Info("tick") _, bytesFree, bytesUsed, err := diskutil.GetDiskUsage(diskRoot) if err != nil { logger.WithError(err).Error("Fai...
https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/etcdctl/ctlv3/command/check.go#L286-L411
func newCheckDatascaleCommand(cmd *cobra.Command, args []string) { var checkDatascaleAlias = map[string]string{ "s": "s", "small": "s", "m": "m", "medium": "m", "l": "l", "large": "l", "xl": "xl", "xLarge": "xl", } model, ok := checkDatascaleAlias[checkDatascaleLoad] if !ok { ExitWithError(ExitBadFeature...
https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/proxy/grpcproxy/cache/store.go#L44-L51
func keyFunc(req *pb.RangeRequest) string { // TODO: use marshalTo to reduce allocation b, err := req.Marshal() if err != nil { panic(err) } return string(b) }
https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/etcdserver/api/etcdhttp/metrics.go#L94-L123
func checkHealth(srv etcdserver.ServerV2) Health { h := Health{Health: "true"} as := srv.Alarms() if len(as) > 0 { h.Health = "false" } if h.Health == "true" { if uint64(srv.Leader()) == raft.None { h.Health = "false" } } if h.Health == "true" { ctx, cancel := context.WithTimeout(context.Background...
https://github.com/hashicorp/raft/blob/773bcaa2009bf059c5c06457b9fccd156d5e91e7/fuzzy/cluster.go#L369-L388
func assertLogEntryEqual(t *testing.T, node string, exp *raft.Log, act *raft.Log) bool { res := true if exp.Term != act.Term { t.Errorf("Log Entry at Index %d for node %v has mismatched terms %d/%d", exp.Index, node, exp.Term, act.Term) res = false } if exp.Index != act.Index { t.Errorf("Node %v, Log Entry sh...
https://github.com/kubernetes/test-infra/blob/8125fbda10178887be5dff9e901d6a0a519b67bc/prow/plugins/plugins.go#L244-L257
func (pa *ConfigAgent) Start(path string) error { if err := pa.Load(path); err != nil { return err } ticker := time.Tick(1 * time.Minute) go func() { for range ticker { if err := pa.Load(path); err != nil { logrus.WithField("path", path).WithError(err).Error("Error loading plugin config.") } } }() ...
https://github.com/kubernetes/test-infra/blob/8125fbda10178887be5dff9e901d6a0a519b67bc/prow/plugins/require-matching-label/require-matching-label.go#L143-L163
func matchingConfigs(org, repo, branch, label string, allConfigs []plugins.RequireMatchingLabel) []plugins.RequireMatchingLabel { var filtered []plugins.RequireMatchingLabel for _, cfg := range allConfigs { // Check if the config applies to this issue type. if (branch == "" && !cfg.Issues) || (branch != "" && !cf...
https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/pkg/flags/urls.go#L41-L47
func (us *URLsValue) String() string { all := make([]string, len(*us)) for i, u := range *us { all[i] = u.String() } return strings.Join(all, ",") }
https://github.com/kubernetes/test-infra/blob/8125fbda10178887be5dff9e901d6a0a519b67bc/prow/kube/dry_run_client.go#L55-L57
func (c *dryRunProwJobClient) Update(*prowapi.ProwJob) (*prowapi.ProwJob, error) { return nil, nil }
https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/etcdctl/ctlv3/command/make_mirror_command.go#L44-L61
func NewMakeMirrorCommand() *cobra.Command { c := &cobra.Command{ Use: "make-mirror [options] <destination>", Short: "Makes a mirror at the destination etcd cluster", Run: makeMirrorCommandFunc, } c.Flags().StringVar(&mmprefix, "prefix", "", "Key-value prefix to mirror") c.Flags().StringVar(&mmdestprefix...
https://github.com/kubernetes/test-infra/blob/8125fbda10178887be5dff9e901d6a0a519b67bc/prow/tide/search.go#L88-L100
func dateToken(start, end time.Time) string { // GitHub's GraphQL API silently fails if you provide it with an invalid time // string. // Dates before 1970 (unix epoch) are considered invalid. startString, endString := "*", "*" if start.Year() >= 1970 { startString = start.Format(github.SearchTimeFormat) } if ...
https://github.com/kubernetes/test-infra/blob/8125fbda10178887be5dff9e901d6a0a519b67bc/prow/cmd/pipeline/controller.go#L242-L248
func fromKey(key string) (string, string, string, error) { parts := strings.Split(key, "/") if len(parts) != 3 { return "", "", "", fmt.Errorf("bad key: %q", key) } return parts[0], parts[1], parts[2], nil }
https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/contrib/recipes/key.go#L154-L163
func newUniqueEphemeralKV(s *concurrency.Session, prefix, val string) (ek *EphemeralKV, err error) { for { newKey := fmt.Sprintf("%s/%v", prefix, time.Now().UnixNano()) ek, err = newEphemeralKV(s, newKey, val) if err == nil || err != ErrKeyExists { break } } return ek, err }
https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/pkg/logutil/zap_grpc.go#L26-L32
func NewGRPCLoggerV2(lcfg zap.Config) (grpclog.LoggerV2, error) { lg, err := lcfg.Build(zap.AddCallerSkip(1)) // to annotate caller outside of "logutil" if err != nil { return nil, err } return &zapGRPCLogger{lg: lg, sugar: lg.Sugar()}, nil }
https://github.com/kubernetes/test-infra/blob/8125fbda10178887be5dff9e901d6a0a519b67bc/prow/cmd/peribolos/main.go#L520-L530
func findTeam(teams map[string]github.Team, name string, previousNames ...string) *github.Team { if t, ok := teams[name]; ok { return &t } for _, p := range previousNames { if t, ok := teams[p]; ok { return &t } } return nil }
https://github.com/kubernetes/test-infra/blob/8125fbda10178887be5dff9e901d6a0a519b67bc/prow/crier/controller.go#L134-L139
func (c *Controller) runWorker() { c.wg.Add(1) for c.processNextItem() { } c.wg.Done() }
https://github.com/kubernetes/test-infra/blob/8125fbda10178887be5dff9e901d6a0a519b67bc/prow/kube/dry_run_client.go#L177-L179
func (c *dryRunProwJobClient) Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *prowapi.ProwJob, err error) { return nil, nil }
https://github.com/kubernetes/test-infra/blob/8125fbda10178887be5dff9e901d6a0a519b67bc/prow/jenkins/jenkins.go#L483-L491
func (c *Client) JobParameterized(jobInfo *JobInfo) bool { for _, prop := range jobInfo.Property { if prop.ParameterDefinitions != nil && len(prop.ParameterDefinitions) > 0 { return true } } return false }
https://github.com/kubernetes/test-infra/blob/8125fbda10178887be5dff9e901d6a0a519b67bc/prow/spyglass/lenses/lenses.go#L96-L112
func RegisterLens(lens Lens) error { config := lens.Config() _, ok := lensReg[config.Name] if ok { return fmt.Errorf("viewer already registered with name %s", config.Name) } if config.Title == "" { return errors.New("empty title field in view metadata") } if config.Priority < 0 { return errors.New("priori...
https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/proxy/grpcproxy/cache/store.go#L158-L165
func (c *cache) Compact(revision int64) { c.mu.Lock() defer c.mu.Unlock() if revision > c.compactedRev { c.compactedRev = revision } }
https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/pkg/logutil/zap.go#L57-L97
func AddOutputPaths(cfg zap.Config, outputPaths, errorOutputPaths []string) zap.Config { outputs := make(map[string]struct{}) for _, v := range cfg.OutputPaths { outputs[v] = struct{}{} } for _, v := range outputPaths { outputs[v] = struct{}{} } outputSlice := make([]string, 0) if _, ok := outputs["/dev/null...
https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/clientv3/compare.go#L117-L120
func (cmp Cmp) WithPrefix() Cmp { cmp.RangeEnd = getPrefix(cmp.Key) return cmp }
https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/pkg/netutil/routes_linux.go#L36-L65
func GetDefaultHost() (string, error) { rmsgs, rerr := getDefaultRoutes() if rerr != nil { return "", rerr } // prioritize IPv4 if rmsg, ok := rmsgs[syscall.AF_INET]; ok { if host, err := chooseHost(syscall.AF_INET, rmsg); host != "" || err != nil { return host, err } delete(rmsgs, syscall.AF_INET) } ...
https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/etcdserver/etcdserverpb/rpc.pb.go#L690-L697
func (*RequestOp) XXX_OneofFuncs() (func(msg proto.Message, b *proto.Buffer) error, func(msg proto.Message, tag, wire int, b *proto.Buffer) (bool, error), func(msg proto.Message) (n int), []interface{}) { return _RequestOp_OneofMarshaler, _RequestOp_OneofUnmarshaler, _RequestOp_OneofSizer, []interface{}{ (*RequestOp...
https://github.com/kubernetes/test-infra/blob/8125fbda10178887be5dff9e901d6a0a519b67bc/prow/jenkins/jenkins.go#L260-L290
func NewClient( url string, dryRun bool, tlsConfig *tls.Config, authConfig *AuthConfig, logger *logrus.Entry, metrics *ClientMetrics, ) (*Client, error) { if logger == nil { logger = logrus.NewEntry(logrus.StandardLogger()) } c := &Client{ logger: logger.WithField("client", "jenkins"), dryRun: dr...