id
stringlengths
2
7
text
stringlengths
17
51.2k
title
stringclasses
1 value
c176100
return nil } return a[github.NormLogin(alias)] }
c176101
expanded := a.ExpandAlias(login); len(expanded) > 0 { logins.Delete(login) logins = logins.Union(expanded) } } return logins }
c176102
full := new(FullConfig) err := yaml.Unmarshal(b, full) return *full, err }
c176103
simple := new(SimpleConfig) err := yaml.Unmarshal(b, simple) return *simple, err }
c176104
meta := mdStructuredHeaderRegex.FindString(string(fileBytes)) // Unmarshal the yaml header into the config return yaml.Unmarshal([]byte(meta), &config) }
c176105
%q and path.", d) return "" } for re, n := range ownerMap[d] { if re != nil && !re.MatchString(relative) { continue } if len(n) != 0 { return d } } } return "" }
c176106
return findOwnersForFile(o.log, path, o.approvers) }
c176107
return findOwnersForFile(o.log, path, o.reviewers) }
c176108
o.entriesForFile(path, o.labels, false) }
c176109
return o.options[path].NoParentOwners }
c176110
return float32(c.NumCoveredStmts) / float32(c.NumAllStmts) }
c176111
:= json.Unmarshal(data, pe); err != nil { return err } return nil }
c176112
Attributes: map[string]string{ prowEventType: periodicProwJobEvent, }, } return &message, nil }
c176113
fmt.Errorf("bad privacy setting: %s", v) } *p = v return nil }
c176114
are protected" } else { b.explanation = raw.Explanation } for _, str := range raw.ExceptionRegexps { if reg, err := regexp.Compile(str); err != nil { log.WithError(err).Errorf("Failed to compile the blockade regexp '%s'.", str) } else { b.exceptionRegexps = append(b.exceptionRegexps, reg) } } compiled = append(compiled, b) } return compiled }
c176115
range changes { for _, b := range blockades { if b.isBlocked(change.Filename) { sum[b.explanation] = append(sum[b.explanation], change) } } } return sum }
c176116
var err error if result, err = MergeProfiles(result, profile); err != nil { return nil, err } } return result, nil }
c176117
has finished running") fs.StringVar(&o.MetadataFile, "metadata-file", "", "path to the metadata file generated from the job") }
c176118
if workItem.podName == workItem.prowJobId { target = path.Join(ContainerLogDir, fmt.Sprintf("%s.txt", workItem.containerName)) } else { target = path.Join(ContainerLogDir, workItem.podName, fmt.Sprintf("%s.txt", workItem.containerName)) } data := gcs.DataUpload(bytes.NewReader(log)) if err := c.gcsConfig.Run(&spec, map[string]gcs.UploadFunc{target: data}); err != nil { c.handleErr(err, workItem) return true } c.queue.Forget(key) return true }
c176119
key.containerName, key.podName, err) c.queue.AddRateLimited(key) return } c.queue.Forget(key) glog.Infof("Giving up on upload of logs for container %v in pod %v: %v", key.containerName, key.podName, err) }
c176120
shouldRun, forced, defaults := filter(presubmit); shouldRun { return shouldRun, forced, defaults } } return false, false, false } }
c176121
} if shouldRun { toTrigger = append(toTrigger, presubmit) } else { toSkip = append(toSkip, presubmit) } } logger.WithFields(logrus.Fields{"to-trigger": toTrigger, "to-skip": toSkip}).Debugf("Filtered %d jobs, found %d to trigger and %d to skip.", len(presubmits), len(toTrigger), len(toSkip)) return toTrigger, toSkip, nil }
c176122
"If specified at least once, only files with paths matching one of these regexes are included.") cmd.Flags().StringSliceVar(&flags.ExcludePaths, "exclude-path", nil, "Files with paths matching one of these regexes are excluded. Can be used repeatedly.") return cmd }
c176123
append(*t, x.(sql.IssueEvent)) }
c176124
old[n-1] *t = old[0 : n-1] return x }
c176125
plugin, alreadyOpen: map[string]bool{}, } }
c176126
&issue.User, EventCreatedAt: issue.IssueCreatedAt, }) o.alreadyOpen[issue.ID] = true } return o.plugin.ReceiveIssue(issue) }
c176127
return errors.New("sync config for %s/%s provided more than once") } seen[ref.Org].Insert(ref.Repo) } else { seen[ref.Org] = sets.NewString(ref.Repo) } } return nil }
c176128
ref.PathAlias = alias alias, err = o.cloneURI.Execute(OrgRepo{Org: ref.Org, Repo: ref.Repo}) if err != nil { panic(err) } ref.CloneURI = alias } }
c176129
if err != nil { return err } a.raw = value a.format = templ return nil }
c176130
err != nil { return fmt.Errorf("%s: %s", binary, install) } return nil }
c176131
b, err := cmd.Output() return strings.TrimSpace(string(b)), err }
c176132
if err != nil { return nil, err } return strings.Split(out, "\n"), nil }
c176133
} fmt.Printf("Select project [%s]: ", def) fmt.Scanln(&choice) // use default project if choice == "" { return def, nil } } // is this a project from the list? for _, p := range projs { if p == choice { return choice, nil } } fmt.Printf("Ensuring %s has access to %s...", who, choice) fmt.Println() // no, make sure user has access to it if err = exec.Command("gcloud", "projects", "describe", choice).Run(); err != nil { return "", fmt.Errorf("%s cannot describe project: %v", who, err) } return choice, nil }
c176134
!= nil { return nil, fmt.Errorf("describe cluster: %v", err) } parts := strings.Split(out, "\t") if len(parts) != 2 { return nil, fmt.Errorf("bad describe cluster output: %s", out) } return &cluster{name: parts[0], zone: parts[1], project: proj}, nil }
c176135
{ cluster, err := createCluster(proj, create) if err != nil { return "", fmt.Errorf("create cluster in %s: %v", proj, err) } return cluster.context(), nil } cluster, ok := clusters[choice] if !ok { return "", fmt.Errorf("cluster not found: %s", choice) } cmd := exec.Command("gcloud", "container", "clusters", "get-credentials", cluster.name, "--project="+cluster.project, "--zone="+cluster.zone) cmd.Stdin = os.Stdin cmd.Stdout = os.Stdout cmd.Stderr = os.Stderr if err := cmd.Run(); err != nil { return "", fmt.Errorf("get credentials: %v", err) } return cluster.context(), nil }
c176136
fmt.Println(" *", err) if gerr := ensureGcloud(); gerr != nil { fmt.Println(" *", gerr) } return nil, nil, errors.New("missing kubectl") } l := clientcmd.NewDefaultClientConfigLoadingRules() c, err := l.Load() return l, c, err }
c176137
") fmt.Scanln(&choice) } if choice == "create" || choice == "" || choice == "create new" || choice == "new" { ctx, err := createContext(co) if err != nil { return "", fmt.Errorf("create context: %v", err) } return ctx, nil } if _, ok := cfg.Contexts[choice]; ok { return choice, nil } idx, err := strconv.Atoi(choice) if err != nil { return "", fmt.Errorf("invalid context: %q", choice) } if ctx, ok := options[idx]; ok { return ctx, nil } return "", fmt.Errorf("invalid index: %d", idx) }
c176138
err := apply(ctx, obj); err != nil { return fmt.Errorf("apply: %v", err) } if err := create.Wait(); err != nil { return fmt.Errorf("create: %v", err) } return nil }
c176139
{ logger.WithFields(logrus.Fields{"context": presubmit.Context, "job": presubmit.Name}).Debug("Not skipping job as context will be created by a triggered job.") continue } toSkip = append(toSkip, presubmit) } return toSkip }
c176140
case sql.Comment: points = plugin.ReceiveComment(event) default: glog.Fatal("Received invalid object: ", event) } } for _, point := range points { if err := DB.Push(point.Tags, point.Values, point.Date); err != nil { glog.Fatal("Failed to push point: ", err) } } } }
c176141
var result *github.Issue _, err := c.retry( fmt.Sprintf("creating issue '%s'", title), func() (*github.Response, error) { var resp *github.Response var err error result, resp, err = c.issueService.Create(context.Background(), org, repo, issue) return resp, err }, ) return result, err }
c176142
_, err := c.retry(msg, func() (*github.Response, error) { var resp *github.Response var err error result, resp, err = c.repoService.CreateStatus(context.Background(), owner, repo, ref, status) return resp, err }) return result, err }
c176143
if pr.Number == nil { mungeErr = fmt.Errorf("error munging pull request with nil Number field: %v", mungeErr) } else { mungeErr = fmt.Errorf("error munging pull request #%d: %v", *pr.Number, mungeErr) } if !continueOnError { return nil, resp, &retryAbort{mungeErr} } glog.Errorf("%v\n", mungeErr) } } if resp.LastPage > 0 { lastPage = resp.LastPage } glog.Infof("ForEachPR processed page %d/%d\n", opts.ListOptions.Page, lastPage) } return nil, resp, err }, ) return err }
c176144
page { interfaceList = append(interfaceList, user) } } return interfaceList, resp, err }, ) result := make([]*github.User, 0, len(collaborators)) for _, user := range collaborators { result = append(result, user.(*github.User)) } return result, err }
c176145
status := range combined.Statuses { interfaceList = append(interfaceList, status) } } return interfaceList, resp, err }, ) if result != nil { result.Statuses = make([]github.RepoStatus, 0, len(statuses)) for _, status := range statuses { result.Statuses = append(result.Statuses, status.(github.RepoStatus)) } } return result, err }
c176146
page { interfaceList = append(interfaceList, issue) } } return interfaceList, resp, err }, ) result := make([]*github.Issue, 0, len(issues)) for _, issue := range issues { result = append(result, issue.(*github.Issue)) } return result, err }
c176147
page { interfaceList = append(interfaceList, label) } } return interfaceList, resp, err }, ) result := make([]*github.Label, 0, len(labels)) for _, label := range labels { result = append(result, label.(*github.Label)) } return result, err }
c176148
error result, resp, err = c.userService.Get(context.Background(), login) return resp, err }, ) return result, err }
c176149
gcloud service account file: %v", err) } else { glog.Infof("Running gcloud auth activate-service-account --key-file=%s\n", *gcloudAuthFilePath) cmd := exec.Command("gcloud", "auth", "activate-service-account", "--key-file="+*gcloudAuthFilePath) var stderr, stdout bytes.Buffer cmd.Stderr, cmd.Stdout = &stderr, &stdout err = cmd.Run() glog.Infof("Stdout:\n%s\n", stdout.String()) glog.Infof("Stderr:\n%s\n", stderr.String()) if err != nil { return fmt.Errorf("Failed to activate gcloud service account: %v", err) } } return nil }
c176150
command for '%v' service failed: %v", service, err) } logfile := filepath.Join(outputDir, service+".log") if err := ioutil.WriteFile(logfile, output, 0444); err != nil { return fmt.Errorf("Writing to file of journalctl logs for '%v' service failed: %v", service, err) } return nil }
c176151
logfile := filepath.Join(outputDir, "systemd.log") if err := ioutil.WriteFile(logfile, output, 0444); err != nil { return fmt.Errorf("Writing full journalctl logs to file failed: %v", err) } return nil }
c176152
glog.Warningf("Failed to record journalctl logs: %v", err) } } if *dumpSystemdJournal { if err := createFullSystemdLogfile(outputDir); err != nil { glog.Warningf("Failed to record journalctl logs: %v", err) } } }
c176153
logfiles = append(logfiles, kernelLog) logfiles = append(logfiles, initdLogs...) logfiles = append(logfiles, supervisordLogs...) } // Copy all the logfiles that exist, to logDir. for _, logfile := range logfiles { logfileFullPath := filepath.Join(localLogPath, logfile+".log*") // Append .log* to copy rotated logs too. cmd := exec.Command("/bin/sh", "-c", fmt.Sprintf("cp %v %v", logfileFullPath, logDir)) if err := cmd.Run(); err != nil { glog.Warningf("Failed to copy any logfiles with pattern '%v': %v", logfileFullPath, err) } } }
c176154
pipe to write marker file: %v", err) } io.WriteString(stdin, "") stdin.Close() if err = cmd.Run(); err != nil { return fmt.Errorf("Failed to write marker file to GCS: %v", err) } return nil }
c176155
per-file and per-package level. Any coverage below coverage-threshold will be marked with a <failure> tag in the xml produced.`, Run: func(cmd *cobra.Command, args []string) { run(flags, cmd, args) }, } cmd.Flags().StringVarP(&flags.outputFile, "output", "o", "-", "output file") cmd.Flags().Float32VarP(&flags.threshold, "threshold", "t", .8, "code coverage threshold") return cmd }
c176156
recently return } // Warning is stale, will we win the race to warn? warnLock.Lock() defer warnLock.Unlock() now := time.Now() // Recalculate now, we might wait awhile for the lock if now.Sub(*last) <= freq { // Nope, we lost return } *last = now logrus.Warn(msg) }
c176157
} fmt.Fprint(str, "PRs ") } if r.Repo == "" { fmt.Fprintf(str, "in the '%s' GitHub org ", r.Org) } else { fmt.Fprintf(str, "in the '%s/%s' GitHub repo ", r.Org, r.Repo) } fmt.Fprintf(str, "that have no labels matching the regular expression '%s'.", r.Regexp) return str.String() }
c176158
r == fmt.Sprintf("%s/%s", org, repo) { return tr } } } return Trigger{} }
c176159
if strings.Contains(repo, "/") { repos = append(repos, repo) } else { orgs = append(orgs, repo) } } } return }
c176160
found { if strings.Contains(repo, "/") { repos = append(repos, repo) } else { orgs = append(orgs, repo) } } } return }
c176161
map[string]ConfigMapSpec{ cf: { Name: "config", }, pf: { Name: "plugins", }, } } for name, spec := range c.Maps { spec.Namespaces = append([]string{spec.Namespace}, spec.AdditionalNamespaces...) c.Maps[name] = spec } }
c176162
append(errors, fmt.Sprintf("plugins %v are duplicated for %s and %s", dupes, repo, org)) } } } if len(errors) > 0 { return fmt.Errorf("invalid plugin configuration:\n\t%v", strings.Join(errors, "\n\t")) } return nil }
c176163
report when all jobs of the same type on the same revision finished selector := labels.Set{ client.GerritRevision: pj.ObjectMeta.Labels[client.GerritRevision], kube.ProwJobTypeLabel: pj.ObjectMeta.Labels[kube.ProwJobTypeLabel], } if pj.ObjectMeta.Labels[client.GerritReportLabel] == "" { // Shouldn't happen, adapter should already have defaulted to Code-Review logrus.Errorf("Gerrit report label not set for job %s", pj.Spec.Job) } else { selector[client.GerritReportLabel] = pj.ObjectMeta.Labels[client.GerritReportLabel] } pjs, err := c.lister.List(selector.AsSelector()) if err != nil { logrus.WithError(err).Errorf("Cannot list prowjob with selector %v", selector) return false } for _, pjob := range pjs { if pjob.Status.State == v1.TriggeredState || pjob.Status.State == v1.PendingState { // other jobs with same label are still running on this revision, skip report logrus.WithField("prowjob", pjob.ObjectMeta.Name).Info("Other jobs with same label are still running on this revision") return false } } return true }
c176164
} g := gitCtxForRefs(refs, dir, env) if err := runCommands(g.commandsForBaseRef(refs, gitUserName, gitUserEmail, cookiePath)); err != nil { return record } timestamp, err := g.gitHeadTimestamp() if err != nil { timestamp = int(time.Now().Unix()) } if err := runCommands(g.commandsForPullRefs(refs, timestamp)); err != nil { return record } finalSHA, err := g.gitRevParse() if err != nil { logrus.WithError(err).Warnf("Cannot resolve finalSHA for ref %#v", refs) } else { record.FinalSHA = finalSHA } return record }
c176165
clonePath = fmt.Sprintf("github.com/%s/%s", refs.Org, refs.Repo) } return fmt.Sprintf("%s/src/%s", baseDir, clonePath) }
c176166
fmt.Sprintf("https://github.com/%s/%s.git", refs.Org, refs.Repo), } if refs.CloneURI != "" { g.repositoryURI = refs.CloneURI } return g }
c176167
// but we cannot update a branch we are on, so in case we // are on the branch we are syncing, we check out the SHA // first and reset the branch second, then check out the // branch we just reset to be in the correct final state commands = append(commands, g.gitCommand("checkout", target)) commands = append(commands, g.gitCommand("branch", "--force", refs.BaseRef, target)) commands = append(commands, g.gitCommand("checkout", refs.BaseRef)) return commands }
c176168
fmt.Sprintf("GIT_COMMITTER_DATE=%d", timestamp), } }
c176169
logrus.WithError(err).Error("git rev-parse HEAD failed!") return "", err } return strings.TrimSpace(commit), nil }
c176170
prCheckout) gitMergeCommand.env = append(gitMergeCommand.env, gitTimestampEnvs(fakeTimestamp)...) commands = append(commands, gitMergeCommand) } // unless the user specifically asks us not to, init submodules if !refs.SkipSubmodules { commands = append(commands, g.gitCommand("submodule", "update", "--init", "--recursive")) } return commands }
c176171
covList.Group = append(covList.Group, summarizeBlocks(prof)) } return covList }
c176172
:= list[rand.Intn(len(list))] set.Delete(sel) return sel }
c176173
%v", context, err) } clients[context] = client } localCfg := clusterConfigs[kube.InClusterContext] pjClient, err := prow.NewForConfig(&localCfg) if err != nil { return err } o.prowJobClientset = pjClient o.kubernetesClientsByContext = clients o.resolved = true return nil }
c176174
o.dryRun { return nil, errors.New("no dry-run prowjob clientset is supported in dry-run mode") } return o.prowJobClientset, nil }
c176175
if o.dryRun { return kube.NewDryRunProwJobClient(o.DeckURI), nil } return o.prowJobClientset.ProwV1().ProwJobs(namespace), nil }
c176176
return nil, errors.New("no dry-run kubernetes client is supported in dry-run mode") } return o.kubernetesClientsByContext[kube.InClusterContext], nil }
c176177
build clusters in dry-run mode") } buildClients := map[string]corev1.PodInterface{} for context, client := range o.kubernetesClientsByContext { buildClients[context] = client.CoreV1().Pods(namespace) } return buildClients, nil }
c176178
time.Duration { return t.Sub(a.startTime) }
c176179
&InactiveState{ entry: a.exit.Opposite(), }, true } return a, false }
c176180
startTime: t, exit: i.entry.Opposite(), }, true } return i, false }
c176181
range m.states { if !state.Active() { return false } } return true }
c176182
for _, state := range m.states { stateAge := state.Age(t) if stateAge < minAge { minAge = stateAge } } return minAge }
c176183
label, t) if changed { oneChanged = true } m.states[i] = state } return m, oneChanged }
c176184
v.namespace, tweakListOptions: v.tweakListOptions} }
c176185
construct Resource from received object %v", i) } return conf, nil }
c176186
n := TypeToResources{} for k, v := range t { n[k] = v } return n }
c176187
"count" or "atomic" mode, produces a new Go coverage file in the same mode that counts how many of those coverage profiles hit a block at least once.`, Run: func(cmd *cobra.Command, args []string) { run(flags, cmd, args) }, } cmd.Flags().StringVarP(&flags.OutputFile, "output", "o", "-", "output file") return cmd }
c176188
defer c.lock.Unlock() c.pendingJobs[job]++ }
c176189
= map[string]prowapi.ProwJobState{} } latestPJ.Status.PrevReportStates[reporter.GitHubReporterName] = latestPJ.Status.State _, err = c.kc.ReplaceProwJob(latestPJ.ObjectMeta.Name, latestPJ) return err }
c176190
kube.GatherProwJobMetrics(c.pjs) }
c176191
%d\n", profile.FileName, block.StartLine, block.StartCol, block.EndLine, block.EndCol, block.NumStmt, block.Count); err != nil { return err } } } return nil }
c176192
a.EndCol == b.EndCol && a.EndLine == b.EndLine && a.NumStmt == b.NumStmt }
c176193
return NewFilteredProwJobInformer(client, namespace, resyncPeriod, indexers, nil) }
c176194
WatchFunc: func(options metav1.ListOptions) (watch.Interface, error) { if tweakListOptions != nil { tweakListOptions(&options) } return client.ProwV1().ProwJobs(namespace).Watch(options) }, }, &prowjobsv1.ProwJob{}, resyncPeriod, indexers, ) }
c176195
cfg, PodLogArtifactFetcher: NewPodLogArtifactFetcher(ja), GCSArtifactFetcher: NewGCSArtifactFetcher(c), testgrid: &TestGrid{ conf: cfg, client: c, ctx: ctx, }, } }
c176196
j int) bool { iconf := ls[i].Config() jconf := ls[j].Config() iname := iconf.Name jname := jconf.Name pi := iconf.Priority pj := jconf.Priority if pi == pj { return iname < jname } return pi < pj }) return ls }
c176197
from src %q: %v", key, err) } if job.Spec.DecorationConfig == nil { return "", fmt.Errorf("failed to locate GCS upload bucket for %s: job is undecorated", jobName) } if job.Spec.DecorationConfig.GCSConfiguration == nil { return "", fmt.Errorf("failed to locate GCS upload bucket for %s: missing GCS configuration", jobName) } bktName := job.Spec.DecorationConfig.GCSConfiguration.Bucket if job.Spec.Type == prowapi.PresubmitJob { return path.Join(bktName, gcs.PRLogs, "directory", jobName), nil } return path.Join(bktName, gcs.NonPRLogs, jobName), nil default: return "", fmt.Errorf("unrecognized key type for src: %v", src) } }
c176198
key, nil case prowKeyType: return s.prowToGCS(key) default: return "", fmt.Errorf("unrecognized key type for src: %v", src) } }
c176199
if !ok { // This should never happen, because Keys() should only return valid Metas. logrus.Debugf("Got bad link key %q from %s, but that should be impossible.", name, artifacts[0].CanonicalLink()) continue } s := m.Strings() link := ExtraLink{ Name: name, URL: s["url"], Description: s["description"], } if link.URL == "" || link.Name == "" { continue } extraLinks = append(extraLinks, link) } return extraLinks, nil }