id
stringlengths
95
167
text
stringlengths
69
15.9k
title
stringclasses
1 value
https://github.com/kubernetes/test-infra/blob/8125fbda10178887be5dff9e901d6a0a519b67bc/prow/external-plugins/cherrypicker/server.go#L58-L71
func HelpProvider(enabledRepos []string) (*pluginhelp.PluginHelp, error) { pluginHelp := &pluginhelp.PluginHelp{ Description: `The cherrypick plugin is used for cherrypicking PRs across branches. For every successful cherrypick invocation a new PR is opened against the target branch and assigned to the requester. If...
https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/pkg/flags/unique_strings.go#L32-L38
func (us *UniqueStringsValue) Set(s string) error { us.Values = make(map[string]struct{}) for _, v := range strings.Split(s, ",") { us.Values[v] = struct{}{} } return nil }
https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/etcdctl/ctlv3/command/lease_command.go#L88-L101
func leaseRevokeCommandFunc(cmd *cobra.Command, args []string) { if len(args) != 1 { ExitWithError(ExitBadArgs, fmt.Errorf("lease revoke command needs 1 argument")) } id := leaseFromArgs(args[0]) ctx, cancel := commandCtx(cmd) resp, err := mustClientFromCmd(cmd).Revoke(ctx, id) cancel() if err != nil { Exit...
https://github.com/dgraph-io/badger/blob/6b796b3ebec3ff006fcb1b425836cd784651e9fd/y/mmap_unix.go#L31-L37
func Mmap(fd *os.File, writable bool, size int64) ([]byte, error) { mtype := unix.PROT_READ if writable { mtype |= unix.PROT_WRITE } return unix.Mmap(int(fd.Fd()), 0, int(size), mtype, unix.MAP_SHARED) }
https://github.com/kubernetes/test-infra/blob/8125fbda10178887be5dff9e901d6a0a519b67bc/prow/githuboauth/githuboauth.go#L119-L140
func (ga *Agent) HandleLogout(client OAuthClient) http.HandlerFunc { return func(w http.ResponseWriter, r *http.Request) { accessTokenSession, err := ga.gc.CookieStore.Get(r, tokenSession) if err != nil { ga.serverError(w, "get cookie", err) return } // Clear session accessTokenSession.Options.MaxAge =...
https://github.com/kubernetes/test-infra/blob/8125fbda10178887be5dff9e901d6a0a519b67bc/prow/plugins/requiresig/requiresig.go#L146-L179
func handle(log *logrus.Entry, ghc githubClient, cp commentPruner, ie *github.IssueEvent, mentionRe *regexp.Regexp) error { // Ignore PRs, closed issues, and events that aren't new issues or sig label // changes. if !shouldReact(mentionRe, ie) { return nil } org := ie.Repo.Owner.Login repo := ie.Repo.Name num...
https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/etcdctl/ctlv3/command/watch_command.go#L46-L59
func NewWatchCommand() *cobra.Command { cmd := &cobra.Command{ Use: "watch [options] [key or prefix] [range_end] [--] [exec-command arg1 arg2 ...]", Short: "Watches events stream on keys or prefixes", Run: watchCommandFunc, } cmd.Flags().BoolVarP(&watchInteractive, "interactive", "i", false, "Interactive ...
https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/functional/agent/handler.go#L140-L175
func (srv *Server) runEtcd() error { errc := make(chan error) go func() { time.Sleep(5 * time.Second) // server advertise client/peer listener had to start first // before setting up proxy listener errc <- srv.startProxy() }() if srv.etcdCmd != nil { srv.lg.Info( "starting etcd command", zap.String...
https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/clientv3/client.go#L164-L175
func (c *Client) Sync(ctx context.Context) error { mresp, err := c.MemberList(ctx) if err != nil { return err } var eps []string for _, m := range mresp.Members { eps = append(eps, m.ClientURLs...) } c.SetEndpoints(eps...) return nil }
https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/etcdserver/api/v3compactor/periodic.go#L206-L210
func (pc *Periodic) Pause() { pc.mu.Lock() pc.paused = true pc.mu.Unlock() }
https://github.com/kubernetes/test-infra/blob/8125fbda10178887be5dff9e901d6a0a519b67bc/velodrome/transform/plugins/events.go#L100-L102
func (l LabelEvent) Match(eventName, label string) bool { return eventName == "labeled" && label == l.Label }
https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/etcdserver/api/rafthttp/http.go#L78-L86
func newPipelineHandler(t *Transport, r Raft, cid types.ID) http.Handler { return &pipelineHandler{ lg: t.Logger, localID: t.ID, tr: t, r: r, cid: cid, } }
https://github.com/kubernetes/test-infra/blob/8125fbda10178887be5dff9e901d6a0a519b67bc/boskos/mason/mason.go#L513-L520
func (m *Mason) UpdateConfigs(storagePath string) error { configs, err := ParseConfig(storagePath) if err != nil { logrus.WithError(err).Error("unable to parse config") return err } return m.storage.SyncConfigs(configs) }
https://github.com/kubernetes/test-infra/blob/8125fbda10178887be5dff9e901d6a0a519b67bc/ghproxy/ghcache/ghcache.go#L176-L185
func NewDiskCache(delegate http.RoundTripper, cacheDir string, cacheSizeGB, maxConcurrency int) http.RoundTripper { return NewFromCache(delegate, diskcache.NewWithDiskv( diskv.New(diskv.Options{ BasePath: path.Join(cacheDir, "data"), TempDir: path.Join(cacheDir, "temp"), CacheSizeMax: uint64(cacheS...
https://github.com/kubernetes/test-infra/blob/8125fbda10178887be5dff9e901d6a0a519b67bc/prow/cmd/pipeline/controller.go#L349-L442
func reconcile(c reconciler, key string) error { logrus.Debugf("reconcile: %s\n", key) ctx, namespace, name, err := fromKey(key) if err != nil { runtime.HandleError(err) return nil } var wantPipelineRun bool pj, err := c.getProwJob(name) switch { case apierrors.IsNotFound(err): // Do not want pipeline ...
https://github.com/kubernetes/test-infra/blob/8125fbda10178887be5dff9e901d6a0a519b67bc/prow/plugins/approve/approvers/owners.go#L140-L155
func (o Owners) KeepCoveringApprovers(reverseMap map[string]sets.String, knownApprovers sets.String, potentialApprovers []string) sets.String { if len(potentialApprovers) == 0 { o.log.Debug("No potential approvers exist to filter for relevance. Does this repo have OWNERS files?") } keptApprovers := sets.NewString(...
https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/etcdctl/ctlv2/command/get_command.go#L44-L66
func getCommandFunc(c *cli.Context, ki client.KeysAPI) { if len(c.Args()) == 0 { handleError(c, ExitBadArgs, errors.New("key required")) } key := c.Args()[0] sorted := c.Bool("sort") quorum := c.Bool("quorum") ctx, cancel := contextWithTotalTimeout(c) resp, err := ki.Get(ctx, key, &client.GetOptions{Sort: so...
https://github.com/kubernetes/test-infra/blob/8125fbda10178887be5dff9e901d6a0a519b67bc/prow/pod-utils/gcs/upload.go#L98-L107
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, clo...
https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/pkg/adt/interval_tree.go#L415-L417
func (ivt *IntervalTree) Visit(ivl Interval, ivv IntervalVisitor) { ivt.root.visit(&ivl, func(n *intervalNode) bool { return ivv(&n.iv) }) }
https://github.com/kubernetes/test-infra/blob/8125fbda10178887be5dff9e901d6a0a519b67bc/prow/config/branch_protection.go#L167-L175
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 }
https://github.com/dgraph-io/badger/blob/6b796b3ebec3ff006fcb1b425836cd784651e9fd/db.go#L820-L869
func (db *DB) handleFlushTask(ft flushTask) error { if !ft.mt.Empty() { // Store badger head even if vptr is zero, need it for readTs db.opt.Debugf("Storing value log head: %+v\n", ft.vptr) db.elog.Printf("Storing offset: %+v\n", ft.vptr) offset := make([]byte, vptrSize) ft.vptr.Encode(offset) // Pick the...
https://github.com/kubernetes/test-infra/blob/8125fbda10178887be5dff9e901d6a0a519b67bc/prow/jenkins/jenkins.go#L403-L420
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.authCo...
https://github.com/kubernetes/test-infra/blob/8125fbda10178887be5dff9e901d6a0a519b67bc/boskos/client/client.go#L286-L298
func (c *Client) UpdateOne(name, state string, userData *common.UserData) error { c.lock.Lock() defer c.lock.Unlock() r, err := c.storage.Get(name) if err != nil { return fmt.Errorf("no resource name %v", name) } if err := c.update(r.GetName(), state, userData); err != nil { return err } return c.updateLoc...
https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/integration/cluster.go#L1030-L1047
func (m *member) Stop(t testing.TB) { lg.Info( "stopping a member", zap.String("name", m.Name), zap.Strings("advertise-peer-urls", m.PeerURLs.StringSlice()), zap.Strings("listen-client-urls", m.ClientURLs.StringSlice()), zap.String("grpc-address", m.grpcAddr), ) m.Close() m.serverClosers = nil lg.Info( ...
https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/pkg/adt/interval_tree.go#L138-L161
func (x *intervalNode) visit(iv *Interval, nv nodeVisitor) bool { if x == nil { return true } v := iv.Compare(&x.iv.Ivl) switch { case v < 0: if !x.left.visit(iv, nv) { return false } case v > 0: maxiv := Interval{x.iv.Ivl.Begin, x.max} if maxiv.Compare(iv) == 0 { if !x.left.visit(iv, nv) || !x.ri...
https://github.com/kubernetes/test-infra/blob/8125fbda10178887be5dff9e901d6a0a519b67bc/velodrome/fetcher/conversion.go#L133-L149
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 fie...
https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/etcdctl/ctlv3/command/get_command.go#L58-L75
func getCommandFunc(cmd *cobra.Command, args []string) { key, opts := getGetOp(args) ctx, cancel := commandCtx(cmd) resp, err := mustClientFromCmd(cmd).Get(ctx, key, opts...) cancel() if err != nil { ExitWithError(ExitError, err) } if printValueOnly { dp, simple := (display).(*simplePrinter) if !simple { ...
https://github.com/kubernetes/test-infra/blob/8125fbda10178887be5dff9e901d6a0a519b67bc/boskos/crds/resources_config_crd.go#L116-L121
func (in *ResourcesConfigObject) FromItem(i common.Item) { c, err := common.ItemToResourcesConfig(i) if err == nil { in.fromConfig(c) } }
https://github.com/kubernetes/test-infra/blob/8125fbda10178887be5dff9e901d6a0a519b67bc/prow/plugins/respond.go#L36-L47
func FormatResponse(to, message, reason string) string { format := `@%s: %s <details> %s %s </details>` return fmt.Sprintf(format, to, message, reason, AboutThisBotWithoutCommands) }
https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/etcdctl/ctlv3/command/member_command.go#L84-L96
func NewMemberListCommand() *cobra.Command { cc := &cobra.Command{ Use: "list", Short: "Lists all members in the cluster", Long: `When --write-out is set to simple, this command prints out comma-separated member lists for each endpoint. The items in the lists are ID, Status, Name, Peer Addrs, Client Addrs. `, ...
https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/etcdctl/ctlv3/command/check.go#L136-L266
func newCheckPerfCommand(cmd *cobra.Command, args []string) { var checkPerfAlias = map[string]string{ "s": "s", "small": "s", "m": "m", "medium": "m", "l": "l", "large": "l", "xl": "xl", "xLarge": "xl", } model, ok := checkPerfAlias[checkPerfLoad] if !ok { ExitWithError(ExitBadFeature, fmt.Errorf("unknow...
https://github.com/hashicorp/raft/blob/773bcaa2009bf059c5c06457b9fccd156d5e91e7/state.go#L156-L160
func (r *raftState) getLastIndex() uint64 { r.lastLock.Lock() defer r.lastLock.Unlock() return max(r.lastLogIndex, r.lastSnapshotIndex) }
https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/pkg/adt/interval_tree.go#L442-L452
func (ivt *IntervalTree) Intersects(iv Interval) bool { x := ivt.root for x != nil && iv.Compare(&x.iv.Ivl) != 0 { if x.left != nil && x.left.max.Compare(iv.Begin) > 0 { x = x.left } else { x = x.right } } return x != nil }
https://github.com/hashicorp/raft/blob/773bcaa2009bf059c5c06457b9fccd156d5e91e7/util.go#L56-L68
func generateUUID() string { buf := make([]byte, 16) if _, err := crand.Read(buf); err != nil { panic(fmt.Errorf("failed to read random bytes: %v", err)) } return fmt.Sprintf("%08x-%04x-%04x-%04x-%12x", buf[0:4], buf[4:6], buf[6:8], buf[8:10], buf[10:16]) }
https://github.com/kubernetes/test-infra/blob/8125fbda10178887be5dff9e901d6a0a519b67bc/prow/githuboauth/githuboauth.go#L227-L231
func (ga *Agent) serverError(w http.ResponseWriter, action string, err error) { ga.logger.WithError(err).Errorf("Error %s.", action) msg := fmt.Sprintf("500 Internal server error %s: %v", action, err) http.Error(w, msg, http.StatusInternalServerError) }
https://github.com/hashicorp/raft/blob/773bcaa2009bf059c5c06457b9fccd156d5e91e7/net_transport.go#L175-L187
func NewNetworkTransport( stream StreamLayer, maxPool int, timeout time.Duration, logOutput io.Writer, ) *NetworkTransport { if logOutput == nil { logOutput = os.Stderr } logger := log.New(logOutput, "", log.LstdFlags) config := &NetworkTransportConfig{Stream: stream, MaxPool: maxPool, Timeout: timeout, Logge...
https://github.com/kubernetes/test-infra/blob/8125fbda10178887be5dff9e901d6a0a519b67bc/prow/plugins/plugins.go#L208-L223
func (pa *ConfigAgent) Load(path string) error { b, err := ioutil.ReadFile(path) if err != nil { return err } np := &Configuration{} if err := yaml.Unmarshal(b, np); err != nil { return err } if err := np.Validate(); err != nil { return err } pa.Set(np) return nil }
https://github.com/kubernetes/test-infra/blob/8125fbda10178887be5dff9e901d6a0a519b67bc/prow/github/fakegithub/fakegithub.go#L204-L210
func (f *FakeClient) GetPullRequest(owner, repo string, number int) (*github.PullRequest, error) { val, exists := f.PullRequests[number] if !exists { return nil, fmt.Errorf("Pull request number %d does not exit", number) } return val, nil }
https://github.com/hashicorp/raft/blob/773bcaa2009bf059c5c06457b9fccd156d5e91e7/api.go#L681-L691
func (r *Raft) GetConfiguration() ConfigurationFuture { configReq := &configurationsFuture{} configReq.init() select { case <-r.shutdownCh: configReq.respond(ErrRaftShutdown) return configReq case r.configurationsCh <- configReq: return configReq } }
https://github.com/kubernetes/test-infra/blob/8125fbda10178887be5dff9e901d6a0a519b67bc/prow/config/agent.go#L123-L144
func (ca *Agent) Set(c *Config) { ca.mut.Lock() defer ca.mut.Unlock() var oldConfig Config if ca.c != nil { oldConfig = *ca.c } delta := Delta{oldConfig, *c} ca.c = c for _, subscription := range ca.subscriptions { go func(sub DeltaChan) { // wait a minute to send each event end := time.NewTimer(time.Min...
https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/etcdserver/api/v2auth/auth.go#L601-L638
func (rw RWPermission) Revoke(lg *zap.Logger, n RWPermission) (RWPermission, error) { var out RWPermission currentRead := types.NewUnsafeSet(rw.Read...) for _, r := range n.Read { if !currentRead.Contains(r) { if lg != nil { lg.Info( "revoking ungranted read permission", zap.String("read-permissio...
https://github.com/kubernetes/test-infra/blob/8125fbda10178887be5dff9e901d6a0a519b67bc/velodrome/transform/plugins/comment_counter.go#L62-L75
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, }) } }...
https://github.com/dgraph-io/badger/blob/6b796b3ebec3ff006fcb1b425836cd784651e9fd/y/y.go#L70-L76
func CreateSyncedFile(filename string, sync bool) (*os.File, error) { flags := os.O_RDWR | os.O_CREATE | os.O_EXCL if sync { flags |= datasyncFileFlag } return os.OpenFile(filename, flags, 0666) }
https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/etcdserver/raft.go#L685-L734
func createConfigChangeEnts(lg *zap.Logger, ids []uint64, self uint64, term, index uint64) []raftpb.Entry { ents := make([]raftpb.Entry, 0) next := index + 1 found := false for _, id := range ids { if id == self { found = true continue } cc := &raftpb.ConfChange{ Type: raftpb.ConfChangeRemoveNode, ...
https://github.com/kubernetes/test-infra/blob/8125fbda10178887be5dff9e901d6a0a519b67bc/prow/jenkins/jenkins.go#L329-L335
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) }
https://github.com/kubernetes/test-infra/blob/8125fbda10178887be5dff9e901d6a0a519b67bc/prow/pjutil/tot.go#L80-L114
func GetBuildID(name, totURL string) (string, error) { if totURL == "" { return node.Generate().String(), nil } var err error url, err := url.Parse(totURL) if err != nil { return "", fmt.Errorf("invalid tot url: %v", err) } url.Path = path.Join(url.Path, "vend", name) sleepDuration := 100 * time.Millisecond...
https://github.com/kubernetes/test-infra/blob/8125fbda10178887be5dff9e901d6a0a519b67bc/prow/plugins/label/label.go#L99-L116
func getLabelsFromGenericMatches(matches [][]string, additionalLabels []string) []string { if len(additionalLabels) == 0 { return nil } var labels []string for _, match := range matches { parts := strings.Split(match[0], " ") if ((parts[0] != "/label") && (parts[0] != "/remove-label")) || len(parts) != 2 { ...
https://github.com/kubernetes/test-infra/blob/8125fbda10178887be5dff9e901d6a0a519b67bc/prow/gerrit/adapter/adapter.go#L122-L147
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 { retur...
https://github.com/gobuffalo/buffalo/blob/7f360181f4ccd79dcc9dcea2c904a4801f194f04/worker/simple.go#L68-L72
func (w Simple) Stop() error { w.Logger.Info("Stopping Simple Background Worker") w.cancel() return nil }
https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/etcdserver/api/rafthttp/util.go#L134-L141
func serverVersion(h http.Header) *semver.Version { verStr := h.Get("X-Server-Version") // backward compatibility with etcd 2.0 if verStr == "" { verStr = "2.0.0" } return semver.Must(semver.NewVersion(verStr)) }
https://github.com/kubernetes/test-infra/blob/8125fbda10178887be5dff9e901d6a0a519b67bc/prow/tide/history/history.go#L196-L205
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 }
https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/clientv3/concurrency/session.go#L95-L102
func (s *Session) Close() error { s.Orphan() // if revoke takes longer than the ttl, lease is expired anyway ctx, cancel := context.WithTimeout(s.opts.ctx, time.Duration(s.opts.ttl)*time.Second) _, err := s.client.Revoke(ctx, s.id) cancel() return err }
https://github.com/kubernetes/test-infra/blob/8125fbda10178887be5dff9e901d6a0a519b67bc/prow/config/branch_protection.go#L148-L156
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: ...
https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/etcdctl/ctlv3/command/ep_command.go#L87-L149
func epHealthCommandFunc(cmd *cobra.Command, args []string) { flags.SetPflagsFromEnv("ETCDCTL", cmd.InheritedFlags()) initDisplayFromCmd(cmd) sec := secureCfgFromCmd(cmd) dt := dialTimeoutFromCmd(cmd) ka := keepAliveTimeFromCmd(cmd) kat := keepAliveTimeoutFromCmd(cmd) auth := authCfgFromCmd(cmd) cfgs := []*v3....
https://github.com/kubernetes/test-infra/blob/8125fbda10178887be5dff9e901d6a0a519b67bc/robots/coverage/downloader/downloader.go#L41-L65
func listGcsObjects(ctx context.Context, client *storage.Client, bucketName, prefix, delim string) ( []string, error) { var objects []string it := client.Bucket(bucketName).Objects(ctx, &storage.Query{ Prefix: prefix, Delimiter: delim, }) for { attrs, err := it.Next() if err == iterator.Done { brea...
https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/clientv3/concurrency/key.go#L50-L65
func waitDeletes(ctx context.Context, client *v3.Client, pfx string, maxCreateRev int64) (*pb.ResponseHeader, error) { getOpts := append(v3.WithLastCreate(), v3.WithMaxCreateRev(maxCreateRev)) for { resp, err := client.Get(ctx, pfx, getOpts...) if err != nil { return nil, err } if len(resp.Kvs) == 0 { r...
https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/pkg/types/set.go#L78-L84
func (us *unsafeSet) Equals(other Set) bool { v1 := sort.StringSlice(us.Values()) v2 := sort.StringSlice(other.Values()) v1.Sort() v2.Sort() return reflect.DeepEqual(v1, v2) }
https://github.com/kubernetes/test-infra/blob/8125fbda10178887be5dff9e901d6a0a519b67bc/prow/plugins/plugins.go#L101-L104
func RegisterPushEventHandler(name string, fn PushEventHandler, help HelpProvider) { pluginHelp[name] = help pushEventHandlers[name] = fn }
https://github.com/gobuffalo/buffalo/blob/7f360181f4ccd79dcc9dcea2c904a4801f194f04/middleware.go#L61-L64
func (ms *MiddlewareStack) Clear() { ms.stack = []MiddlewareFunc{} ms.skips = map[string]bool{} }
https://github.com/kubernetes/test-infra/blob/8125fbda10178887be5dff9e901d6a0a519b67bc/prow/plugins/approve/approvers/owners.go#L174-L181
func (o Owners) GetOwnersSet() sets.String { owners := sets.NewString() for _, fn := range o.filenames { owners.Insert(o.repo.FindApproverOwnersForFile(fn)) } o.removeSubdirs(owners) return owners }
https://github.com/kubernetes/test-infra/blob/8125fbda10178887be5dff9e901d6a0a519b67bc/prow/kube/dry_run_client.go#L70-L72
func (c *dryRunProwJobClient) DeleteCollection(options *metav1.DeleteOptions, listOptions metav1.ListOptions) error { return nil }
https://github.com/hashicorp/raft/blob/773bcaa2009bf059c5c06457b9fccd156d5e91e7/replication.go#L456-L485
func (r *Raft) pipelineDecode(s *followerReplication, p AppendPipeline, stopCh, finishCh chan struct{}) { defer close(finishCh) respCh := p.Consumer() for { select { case ready := <-respCh: req, resp := ready.Request(), ready.Response() appendStats(string(s.peer.ID), ready.Start(), float32(len(req.Entries)...
https://github.com/kubernetes/test-infra/blob/8125fbda10178887be5dff9e901d6a0a519b67bc/prow/config/tide.go#L189-L219
func (tq *TideQuery) Query() string { toks := []string{"is:pr", "state:open"} for _, o := range tq.Orgs { toks = append(toks, fmt.Sprintf("org:\"%s\"", o)) } for _, r := range tq.Repos { toks = append(toks, fmt.Sprintf("repo:\"%s\"", r)) } for _, r := range tq.ExcludedRepos { toks = append(toks, fmt.Sprintf...
https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/etcdctl/ctlv3/command/lease_command.go#L56-L73
func leaseGrantCommandFunc(cmd *cobra.Command, args []string) { if len(args) != 1 { ExitWithError(ExitBadArgs, fmt.Errorf("lease grant command needs TTL argument")) } ttl, err := strconv.ParseInt(args[0], 10, 64) if err != nil { ExitWithError(ExitBadArgs, fmt.Errorf("bad TTL (%v)", err)) } ctx, cancel := co...
https://github.com/kubernetes/test-infra/blob/8125fbda10178887be5dff9e901d6a0a519b67bc/prow/plugins/plugins.go#L389-L416
func EventsForPlugin(name string) []string { var events []string if _, ok := issueHandlers[name]; ok { events = append(events, "issue") } if _, ok := issueCommentHandlers[name]; ok { events = append(events, "issue_comment") } if _, ok := pullRequestHandlers[name]; ok { events = append(events, "pull_request"...
https://github.com/kubernetes/test-infra/blob/8125fbda10178887be5dff9e901d6a0a519b67bc/prow/cmd/peribolos/main.go#L904-L951
func configureTeamRepos(client teamRepoClient, githubTeams map[string]github.Team, name, orgName string, team org.Team) error { gt, ok := githubTeams[name] if !ok { // configureTeams is buggy if this is the case return fmt.Errorf("%s not found in id list", name) } want := team.Repos have := map[string]github.Re...
https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/pkg/types/urlsmap.go#L71-L80
func (c URLsMap) URLs() []string { var urls []string for _, us := range c { for _, u := range us { urls = append(urls, u.String()) } } sort.Strings(urls) return urls }
https://github.com/kubernetes/test-infra/blob/8125fbda10178887be5dff9e901d6a0a519b67bc/prow/cmd/pipeline/controller.go#L561-L587
func makePipelineGitResource(pj prowjobv1.ProwJob) *pipelinev1alpha1.PipelineResource { var revision string if pj.Spec.Refs != nil { if len(pj.Spec.Refs.Pulls) > 0 { revision = pj.Spec.Refs.Pulls[0].SHA } else { revision = pj.Spec.Refs.BaseSHA } } pr := pipelinev1alpha1.PipelineResource{ ObjectMeta: p...
https://github.com/kubernetes/test-infra/blob/8125fbda10178887be5dff9e901d6a0a519b67bc/prow/jenkins/jenkins.go#L598-L601
func (c *Client) Build(pj *prowapi.ProwJob, buildID string) error { c.logger.WithFields(pjutil.ProwJobFields(pj)).Info("Build") return c.BuildFromSpec(&pj.Spec, buildID, pj.ObjectMeta.Name) }
https://github.com/kubernetes/test-infra/blob/8125fbda10178887be5dff9e901d6a0a519b67bc/prow/kube/client.go#L557-L567
func (c *Client) GetLogTail(pod, container string, n int64) ([]byte, error) { c.log("GetLogTail", pod, n) return c.requestRetry(&request{ path: fmt.Sprintf("/api/v1/namespaces/%s/pods/%s/log", c.namespace, pod), query: map[string]string{ // Because we want last n bytes, we fetch all lines and then limit to n byte...
https://github.com/gobuffalo/buffalo/blob/7f360181f4ccd79dcc9dcea2c904a4801f194f04/route_mappings.go#L59-L63
func (a *App) Redirect(status int, from, to string) *RouteInfo { return a.GET(from, func(c Context) error { return c.Redirect(status, to) }) }
https://github.com/kubernetes/test-infra/blob/8125fbda10178887be5dff9e901d6a0a519b67bc/prow/plugins/approve/approvers/owners.go#L584-L592
func GenerateTemplate(templ, name string, data interface{}) (string, error) { buf := bytes.NewBufferString("") if messageTempl, err := template.New(name).Parse(templ); err != nil { return "", fmt.Errorf("failed to parse template for %s: %v", name, err) } else if err := messageTempl.Execute(buf, data); err != nil {...
https://github.com/kubernetes/test-infra/blob/8125fbda10178887be5dff9e901d6a0a519b67bc/prow/tide/blockers/blockers.go#L61-L70
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 }) r...
https://github.com/kubernetes/test-infra/blob/8125fbda10178887be5dff9e901d6a0a519b67bc/label_sync/main.go#L408-L411
func change(repo string, label Label) Update { logrus.WithField("repo", repo).WithField("label", label.Name).WithField("color", label.Color).Info("change") return Update{Why: "change", Current: &label, Wanted: &label, repo: repo} }
https://github.com/kubernetes/test-infra/blob/8125fbda10178887be5dff9e901d6a0a519b67bc/prow/plugins/plugins.go#L236-L240
func (pa *ConfigAgent) Set(pc *Configuration) { pa.mut.Lock() defer pa.mut.Unlock() pa.configuration = pc }
https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/etcdctl/ctlv3/command/lease_command.go#L172-L199
func leaseKeepAliveCommandFunc(cmd *cobra.Command, args []string) { if len(args) != 1 { ExitWithError(ExitBadArgs, fmt.Errorf("lease keep-alive command needs lease ID as argument")) } id := leaseFromArgs(args[0]) if leaseKeepAliveOnce { respc, kerr := mustClientFromCmd(cmd).KeepAliveOnce(context.TODO(), id) ...
https://github.com/kubernetes/test-infra/blob/8125fbda10178887be5dff9e901d6a0a519b67bc/prow/gcsupload/run.go#L117-L131
func PathsForJob(options *prowapi.GCSConfiguration, spec *downwardapi.JobSpec, subdir string) (string, string, gcs.RepoPathBuilder) { builder := builderForStrategy(options.PathStrategy, options.DefaultOrg, options.DefaultRepo) jobBasePath := gcs.PathForSpec(spec, builder) if options.PathPrefix != "" { jobBasePath ...
https://github.com/kubernetes/test-infra/blob/8125fbda10178887be5dff9e901d6a0a519b67bc/prow/plugins/approve/approvers/owners.go#L421-L429
func (ap Approvers) UnapprovedFiles() sets.String { unapproved := sets.NewString() for fn, approvers := range ap.GetFilesApprovers() { if len(approvers) == 0 { unapproved.Insert(fn) } } return unapproved }
https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/raft/util.go#L59-L68
func voteRespMsgType(msgt pb.MessageType) pb.MessageType { switch msgt { case pb.MsgVote: return pb.MsgVoteResp case pb.MsgPreVote: return pb.MsgPreVoteResp default: panic(fmt.Sprintf("not a vote message: %s", msgt)) } }
https://github.com/hashicorp/raft/blob/773bcaa2009bf059c5c06457b9fccd156d5e91e7/inmem_transport.go#L213-L223
func (i *InmemTransport) DisconnectAll() { i.Lock() defer i.Unlock() i.peers = make(map[ServerAddress]*InmemTransport) // Handle pipelines for _, pipeline := range i.pipelines { pipeline.Close() } i.pipelines = nil }
https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/wal/wal.go#L743-L771
func (w *WAL) Close() error { w.mu.Lock() defer w.mu.Unlock() if w.fp != nil { w.fp.Close() w.fp = nil } if w.tail() != nil { if err := w.sync(); err != nil { return err } } for _, l := range w.locks { if l == nil { continue } if err := l.Close(); err != nil { if w.lg != nil { w.lg.W...
https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/mvcc/backend/batch_tx.go#L129-L142
func (t *batchTx) UnsafeRange(bucketName, key, endKey []byte, limit int64) ([][]byte, [][]byte) { bucket := t.tx.Bucket(bucketName) if bucket == nil { if t.backend.lg != nil { t.backend.lg.Fatal( "failed to find a bucket", zap.String("bucket-name", string(bucketName)), ) } else { plog.Fatalf("buc...
https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/etcdserver/api/etcdhttp/metrics.go#L48-L64
func NewHealthHandler(hfunc func() Health) http.HandlerFunc { return func(w http.ResponseWriter, r *http.Request) { if r.Method != http.MethodGet { w.Header().Set("Allow", http.MethodGet) http.Error(w, "Method Not Allowed", http.StatusMethodNotAllowed) return } h := hfunc() d, _ := json.Marshal(h) i...
https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/client/util.go#L48-L53
func IsUserNotFound(err error) bool { if ae, ok := err.(authError); ok { return userNotFoundRegExp.MatchString(ae.Message) } return false }
https://github.com/gobuffalo/buffalo/blob/7f360181f4ccd79dcc9dcea2c904a4801f194f04/genny/newapp/web/options.go#L19-L51
func (opts *Options) Validate() error { if opts.Options == nil { opts.Options = &core.Options{} } if err := opts.Options.Validate(); err != nil { return err } if opts.Docker != nil { if opts.Docker.App.IsZero() { opts.Docker.App = opts.App } if err := opts.Docker.Validate(); err != nil { return e...
https://github.com/kubernetes/test-infra/blob/8125fbda10178887be5dff9e901d6a0a519b67bc/prow/flagutil/github.go#L114-L116
func (o *GitHubOptions) GitHubClient(secretAgent *secret.Agent, dryRun bool) (client *github.Client, err error) { return o.GitHubClientWithLogFields(secretAgent, dryRun, logrus.Fields{}) }
https://github.com/kubernetes/test-infra/blob/8125fbda10178887be5dff9e901d6a0a519b67bc/prow/plugins/approve/approvers/owners.go#L64-L72
func (o Owners) GetApprovers() map[string]sets.String { ownersToApprovers := map[string]sets.String{} for fn := range o.GetOwnersSet() { ownersToApprovers[fn] = o.repo.Approvers(fn) } return ownersToApprovers }
https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/etcdserver/server.go#L871-L873
func (s *EtcdServer) ReportSnapshot(id uint64, status raft.SnapshotStatus) { s.r.ReportSnapshot(id, status) }
https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/pkg/adt/interval_tree.go#L104-L114
func (x *intervalNode) successor() *intervalNode { if x.right != nil { return x.right.min() } y := x.parent for y != nil && x == y.right { x = y y = y.parent } return y }
https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/client/curl.go#L41-L70
func printcURL(req *http.Request) error { if !cURLDebug { return nil } var ( command string b []byte err error ) if req.URL != nil { command = fmt.Sprintf("curl -X %s %s", req.Method, req.URL.String()) } if req.Body != nil { b, err = ioutil.ReadAll(req.Body) if err != nil { return er...
https://github.com/hashicorp/raft/blob/773bcaa2009bf059c5c06457b9fccd156d5e91e7/configuration.go#L158-L185
func checkConfiguration(configuration Configuration) error { idSet := make(map[ServerID]bool) addressSet := make(map[ServerAddress]bool) var voters int for _, server := range configuration.Servers { if server.ID == "" { return fmt.Errorf("Empty ID in configuration: %v", configuration) } if server.Address =...
https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/etcdctl/ctlv2/command/rm_command.go#L25-L41
func NewRemoveCommand() cli.Command { return cli.Command{ Name: "rm", Usage: "remove a key or a directory", ArgsUsage: "<key>", Flags: []cli.Flag{ cli.BoolFlag{Name: "dir", Usage: "removes the key if it is an empty directory or a key-value pair"}, cli.BoolFlag{Name: "recursive, r", Usage: "remov...
https://github.com/gobuffalo/buffalo/blob/7f360181f4ccd79dcc9dcea2c904a4801f194f04/render/js.go#L23-L33
func (e *Engine) JavaScript(names ...string) Renderer { if e.JavaScriptLayout != "" && len(names) == 1 { names = append(names, e.JavaScriptLayout) } hr := &templateRenderer{ Engine: e, contentType: "application/javascript", names: names, } return hr }
https://github.com/kubernetes/test-infra/blob/8125fbda10178887be5dff9e901d6a0a519b67bc/prow/initupload/options.go#L59-L62
func (o *Options) AddFlags(flags *flag.FlagSet) { flags.StringVar(&o.Log, "clone-log", "", "Path to the clone records log") o.Options.AddFlags(flags) }
https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/etcdserver/util.go#L65-L88
func longestConnected(tp rafthttp.Transporter, membs []types.ID) (types.ID, bool) { var longest types.ID var oldest time.Time for _, id := range membs { tm := tp.ActiveSince(id) if tm.IsZero() { // inactive continue } if oldest.IsZero() { // first longest candidate oldest = tm longest = id } i...
https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/etcdctl/ctlv3/command/util.go#L145-L154
func defrag(c *v3.Client, ep string) { fmt.Printf("Defragmenting %q\n", ep) ctx, cancel := context.WithTimeout(context.Background(), 30*time.Second) _, err := c.Defragment(ctx, ep) cancel() if err != nil { ExitWithError(ExitError, err) } fmt.Printf("Defragmented %q\n", ep) }
https://github.com/dgraph-io/badger/blob/6b796b3ebec3ff006fcb1b425836cd784651e9fd/dir_windows.go#L103-L106
func (g *directoryLockGuard) release() error { g.path = "" return syscall.CloseHandle(g.h) }
https://github.com/kubernetes/test-infra/blob/8125fbda10178887be5dff9e901d6a0a519b67bc/experiment/resultstore/main.go#L487-L526
func insertLink(started *gcs.Started, viewURL string) (bool, error) { if started.Metadata == nil { started.Metadata = metadata.Metadata{} } meta := started.Metadata var changed bool top, present := meta.String(resultstoreKey) if !present || top == nil || *top != viewURL { changed = true meta[resultstoreKey]...
https://github.com/kubernetes/test-infra/blob/8125fbda10178887be5dff9e901d6a0a519b67bc/prow/plugins/plugins.go#L226-L230
func (pa *ConfigAgent) Config() *Configuration { pa.mut.Lock() defer pa.mut.Unlock() return pa.configuration }
https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/clientv3/naming/grpc.go#L71-L109
func (gw *gRPCWatcher) Next() ([]*naming.Update, error) { if gw.wch == nil { // first Next() returns all addresses return gw.firstNext() } if gw.err != nil { return nil, gw.err } // process new events on target/* wr, ok := <-gw.wch if !ok { gw.err = status.Error(codes.Unavailable, ErrWatcherClosed.Error...