id
stringlengths
2
7
text
stringlengths
17
51.2k
title
stringclasses
1 value
c175900
== failure || *jb.Result == unstable) }
c175901
nil && *jb.Result == aborted }
c175902
logrus.Errorf("Cannot determine %s value for %#v", p.Name, jb) continue } return value } } } return "" }
c175903
== prowJobID if p.Name == statusBuildID { value, ok := p.Value.(string) if !ok { logrus.Errorf("Cannot determine %s value for %#v", p.Name, jb) continue } buildID = value } } } if !hasProwJobID { return "" } return buildID }
c175904
&crumbResp); err != nil { return fmt.Errorf("cannot unmarshal crumb response: %v", err) } c.authConfig.csrfToken = crumbResp.Crumb c.authConfig.csrfRequestField = crumbResp.CrumbRequestField return nil }
c175905
path).Observe(time.Since(start).Seconds()) c.metrics.Requests.WithLabelValues(method, path, fmt.Sprintf("%d", code)).Inc() }
c175906
:= c.request(http.MethodGet, path, nil, false) if err != nil { return nil, err } return readResp(resp) }
c175907
path, nil, true) if err != nil { return nil, err } return readResp(resp) }
c175908
if err == nil && retries+1 < maxRetries { resp.Body.Close() } // Capture the retry in a metric. if measure && c.metrics != nil { c.metrics.RequestRetries.Inc() } time.Sleep(backoff) backoff *= 2 } if measure && resp != nil { c.measure(method, path, resp.StatusCode, start) } return resp, err }
c175909
} if c.authConfig.CSRFProtect && c.authConfig.csrfRequestField != "" && c.authConfig.csrfToken != "" { req.Header.Set(c.authConfig.csrfRequestField, c.authConfig.csrfToken) } } return c.client.Do(req) }
c175910
return fmt.Sprintf("%s/view/change-requests/job/PR-%d", spec.Job, spec.Refs.Pulls[0].Number) } return fmt.Sprintf("%s/job/%s", spec.Job, spec.Refs.BaseRef) } return spec.Job }
c175911
:= fmt.Sprintf("/job/%s/build", jenkinsJobName) return jenkinsPath }
c175912
JobInfo if err := json.Unmarshal(data, &jobInfo); err != nil { return nil, fmt.Errorf("Cannot unmarshal job info from API: %v", err) } c.logger.Tracef("JobInfo: %+v", jobInfo) return &jobInfo, nil }
c175913
{ if prop.ParameterDefinitions != nil && len(prop.ParameterDefinitions) > 0 { return true } } return false }
c175914
return wait.ExponentialBackoff(backoff, func() (bool, error) { c.logger.Debugf("Waiting for job %v to become parameterized", spec.Job) jobInfo, _ := c.GetJobInfo(spec) isParameterized := false if jobInfo != nil { isParameterized = c.JobParameterized(jobInfo) if isParameterized && jobInfo.LastBuild != nil { c.logger.Debugf("Job %v is now parameterized, aborting the build", spec.Job) err := c.Abort(getJobName(spec), jobInfo.LastBuild) if err != nil { c.logger.Infof("Couldn't abort build #%v for job %v: %v", jobInfo.LastBuild.Number, spec.Job, err) } } } // don't stop on (possibly) intermittent errors return isParameterized, nil }) }
c175915
if err != nil { return err } defer resp.Body.Close() if resp.StatusCode != 201 { return fmt.Errorf("response not 201: %s", resp.Status) } return nil }
c175916
return c.BuildFromSpec(&pj.Spec, buildID, pj.ObjectMeta.Name) }
c175917
c.EnsureBuildableJob(spec); err != nil { return fmt.Errorf("Job %v cannot be build: %v", spec.Job, err) } return c.LaunchBuild(spec, params) }
c175918
// Ignore builds with missing buildID parameters. if prowJobID == "" { continue } // Ignore builds for jobs we didn't ask for. var exists bool for _, job := range jobs { if prowJobID == job.ProwJobID { exists = true break } } if !exists { continue } jb.enqueued = true jenkinsBuilds[prowJobID] = jb } return jenkinsBuilds, nil }
c175919
defer resp.Body.Close() if resp.StatusCode < 200 || resp.StatusCode >= 300 { return fmt.Errorf("response not 2XX: %s", resp.Status) } return nil }
c175920
Type: prowapi.PresubmitJob, Job: pre.Name, } }
c175921
{ return &downwardapi.JobSpec{ Type: prowapi.PostsubmitJob, Job: post.Name, } }
c175922
{ return &downwardapi.JobSpec{ Type: prowapi.PeriodicJob, Job: periodic.Name, } }
c175923
resp, err = http.Get(url.String()) if err != nil { continue } defer resp.Body.Close() if resp.StatusCode != 200 { err = fmt.Errorf("got unexpected response from tot: %v", resp.Status) continue } var buf []byte buf, err = ioutil.ReadAll(resp.Body) if err == nil { return string(buf), nil } return "", err } return "", err }
c175924
{ return objects, fmt.Errorf("error iterating: %v", err) } if attrs.Prefix != "" { objects = append(objects, path.Base(attrs.Prefix)) } } logrus.Info("end of listGcsObjects(...)") return objects, nil }
c175925
} else if isBuildSucceeded(statusText) { artifactsDirPath := path.Join(buildDirPath, artifactsDirName) profilePath = path.Join(artifactsDirPath, covProfileName) break } } if profilePath == "" { return nil, fmt.Errorf("no healthy build found for job '%s' in bucket '%s'; total # builds = %v", dirOfJob, bucket, len(builds)) } return readGcsObject(ctx, client, bucket, profilePath) }
c175926
} else { res = append(res, num) } } sort.Sort(sort.Reverse(sort.IntSlice(res))) return res }
c175927
for _, region := range resp.Regions { regions = append(regions, *region.RegionName) } return regions, nil }
c175928
*EventClient { return &EventClient{ org: org, repo: repo, number: number, ghc: ghc, log: log, } }
c175929
removed := false if shouldPrune(comment) { if err := c.ghc.DeleteComment(c.org, c.repo, comment.ID); err != nil { c.log.WithError(err).Errorf("failed to delete stale comment with ID '%d'", comment.ID) } else { removed = true } } if !removed { remaining = append(remaining, comment) } } c.comments = remaining }
c175930
return fmt.Sprintf(format, to, message, reason, AboutThisBotWithoutCommands) }
c175931
fmt.Sprintf(format, to, message, AboutThisBotWithoutCommands) }
c175932
FormatResponseRaw(ic.Body, ic.HTMLURL, ic.User.Login, s) }
c175933
quoted = append(quoted, ">"+l) } return FormatResponse(login, reply, fmt.Sprintf(format, bodyURL, strings.Join(quoted, "\n"))) }
c175934
if o.GcsCredentialsFile == "" { return errors.New("GCS upload was requested but no GCS credentials file was provided") } } return o.GCSConfiguration.Validate() }
c175935
json.Marshal(options) return string(encoded), err }
c175936
pluginHelp[name] = help issueHandlers[name] = fn }
c175937
pluginHelp[name] = help issueCommentHandlers[name] = fn }
c175938
pluginHelp[name] = help pullRequestHandlers[name] = fn }
c175939
pluginHelp[name] = help statusEventHandlers[name] = fn }
c175940
pluginHelp[name] = help pushEventHandlers[name] = fn }
c175941
pluginHelp[name] = help reviewEventHandlers[name] = fn }
c175942
pluginHelp[name] = help reviewCommentEventHandlers[name] = fn }
c175943
pluginHelp[name] = help genericCommentHandlers[name] = fn }
c175944
GitClient: clientAgent.GitClient, SlackClient: clientAgent.SlackClient, OwnersClient: clientAgent.OwnersClient, Config: prowConfig, PluginConfig: pluginConfig, Logger: logger, } }
c175945
a.GitHubClient, a.Logger.WithField("client", "commentpruner"), org, repo, pr, ) }
c175946
client never initialized") } return a.commentPruner, nil }
c175947
} if err := np.Validate(); err != nil { return err } pa.Set(np) return nil }
c175948
defer pa.mut.Unlock() return pa.configuration }
c175949
defer pa.mut.Unlock() pa.configuration = pc }
c175950
!= nil { logrus.WithField("path", path).WithError(err).Error("Error loading plugin config.") } } }() return nil }
c175951
:= range pa.getPlugins(owner, repo) { if h, ok := genericCommentHandlers[p]; ok { hs[p] = h } } return hs }
c175952
:= range pa.getPlugins(owner, repo) { if h, ok := issueHandlers[p]; ok { hs[p] = h } } return hs }
c175953
:= range pa.getPlugins(owner, repo) { if h, ok := issueCommentHandlers[p]; ok { hs[p] = h } } return hs }
c175954
:= range pa.getPlugins(owner, repo) { if h, ok := pullRequestHandlers[p]; ok { hs[p] = h } } return hs }
c175955
:= range pa.getPlugins(owner, repo) { if h, ok := reviewEventHandlers[p]; ok { hs[p] = h } } return hs }
c175956
p := range pa.getPlugins(owner, repo) { if h, ok := reviewCommentEventHandlers[p]; ok { hs[p] = h } } return hs }
c175957
:= range pa.getPlugins(owner, repo) { if h, ok := statusEventHandlers[p]; ok { hs[p] = h } } return hs }
c175958
:= range pa.getPlugins(owner, repo) { if h, ok := pushEventHandlers[p]; ok { hs[p] = h } } return hs }
c175959
events = append(events, "pull_request_review_comment") } if _, ok := statusEventHandlers[name]; ok { events = append(events, "status") } if _, ok := genericCommentHandlers[name]; ok { events = append(events, "GenericCommentEvent (any event for user text)") } return events }
c175960
links = &metadata.Metadata{} changed = true } resultstoreMeta, present := links.Meta(resultstoreKey) if present && resultstoreMeta == nil { return false, fmt.Errorf("metadata.links.resultstore is not a Metadata value: %v", (*links)[resultstoreKey]) } if resultstoreMeta == nil { resultstoreMeta = &metadata.Metadata{} changed = true } val, present := resultstoreMeta.String(urlKey) if present && val == nil { return false, fmt.Errorf("metadata.links.resultstore.url is not a string value: %v", (*resultstoreMeta)[urlKey]) } if !changed && val != nil && *val == viewURL { return false, nil } (*resultstoreMeta)[urlKey] = viewURL (*links)[resultstoreKey] = *resultstoreMeta meta[linksKey] = *links return true, nil }
c175961
PR is opened immediately) and open PRs (the cherrypick PR opens as soon as the original PR merges).", Featured: true, // depends on how the cherrypick server runs; needs auth by default (--allow-all=false) WhoCanUse: "Members of the trusted organization for the repo.", Examples: []string{"/cherrypick release-3.9"}, }) return pluginHelp, nil }
c175962
return "", err } defer out.Close() if _, err := io.Copy(out, bytes.NewBuffer(patch)); err != nil { return "", err } return localPath, nil }
c175963
"" } return fmt.Sprintf("```release-note\n%s\n```", strings.TrimSpace(potentialMatch[1])) }
c175964
} mac := hmac.New(sha1.New, key) mac.Write(payload) expected := mac.Sum(nil) return hmac.Equal(sb, expected) }
c175965
sum := mac.Sum(nil) return "sha1=" + hex.EncodeToString(sum) }
c175966
*want: return false // already have it } *have = *want // update value return true }
c175967
*want: return false //already have it } *have = *want // update value return true }
c175968
want.Description) || change change = updateString(&cur.Location, want.Location) || change if want.DefaultRepositoryPermission != nil { w := string(*want.DefaultRepositoryPermission) change = updateString(&cur.DefaultRepositoryPermission, &w) } change = updateBool(&cur.HasOrganizationProjects, want.HasOrganizationProjects) || change change = updateBool(&cur.HasRepositoryProjects, want.HasRepositoryProjects) || change change = updateBool(&cur.MembersCanCreateRepositories, want.MembersCanCreateRepositories) || change if change { if _, err := client.EditOrg(orgName, *cur); err != nil { return fmt.Errorf("failed to edit %s metadata: %v", orgName, err) } } return nil }
c175969
these permissions actions[haveRepo] = github.None } } var updateErrors []error for repo, permission := range actions { var err error if permission == github.None { err = client.RemoveTeamRepo(gt.ID, orgName, repo) } else { err = client.UpdateTeamRepo(gt.ID, orgName, repo, permission) } if err != nil { updateErrors = append(updateErrors, fmt.Errorf("failed to update team %d(%s) permissions on repo %s to %s: %v", gt.ID, name, repo, permission, err)) } } return errorutil.NewAggregate(updateErrors...) }
c175970
pubSubMap[PubSubProjectLabel] != "" && pubSubMap[PubSubTopicLabel] != "" }
c175971
return fmt.Errorf("failed to upload to GCS: %v", err) } } else { for destination := range uploadTargets { logrus.WithField("dest", destination).Info("Would upload") } } logrus.Info("Finished upload to GCS") return nil }
c175972
data[k] = v } return d.WrappedFormatter.Format(&logrus.Entry{ Logger: entry.Logger, Data: data, Time: entry.Time, Level: entry.Level, Message: entry.Message, }) }
c175973
regex.MatchString(label.Name) { labels = append(labels, label) } } return labels }
c175974
the clone records log") o.Options.AddFlags(flags) }
c175975
return &Agent{ gc: config, logger: logger, } }
c175976
60 oauthSession.Values[stateKey] = state if err := oauthSession.Save(r, w); err != nil { ga.serverError(w, "Save oauth session", err) return } redirectURL := client.AuthCodeURL(state, oauth2.ApprovalForce, oauth2.AccessTypeOnline) http.Redirect(w, r, redirectURL, http.StatusFound) } }
c175977
:= r.Cookie(loginSession) if err == nil { loginCookie.MaxAge = -1 loginCookie.Expires = time.Now().Add(-time.Hour * 24) http.SetCookie(w, loginCookie) } http.Redirect(w, r, ga.gc.FinalRedirectURL, http.StatusFound) } }
c175978
%s.", action) msg := fmt.Sprintf("500 Internal server error %s: %v", action, err) http.Error(w, msg, http.StatusInternalServerError) }
c175979
:= common.ItemToResourcesConfig(i) if err == nil { in.fromConfig(c) } }
c175980
{ items = append(items, i) } return items }
c175981
items = append(items, b.(*ResourcesConfigObject)) } in.Items = items }
c175982
fmt.Errorf("bad repo permission: %s not in %v", v, repoPermissionLevels) } *l = v return nil }
c175983
i.Assignees { if NormLogin(login) == NormLogin(assignee.Login) { return true } } return false }
c175984
{ return NormLogin(i.User.Login) == NormLogin(login) }
c175985
strings.ToLower(label.Name) == strings.ToLower(labelToFind) { return true } } return false }
c175986
strings.TrimPrefix(ref, "refs/tags/") // if Ref is a tag return ref }
c175987
{ return in } return in[:half] + elide + in[len(in)-half:] }
c175988
Description: truncate(pj.Status.Description), Context: pj.Spec.Context, // consider truncating this too TargetURL: pj.Status.URL, }); err != nil { return err } } return nil }
c175989
j > i && f2[0] == f1[0] { keep = false } } // Use the current result if there is an old one. if pj.Spec.Context == f1[0] { keep = false } if keep { newEntries = append(newEntries, entries[i]) } } var createNewComment bool if string(pj.Status.State) == github.StatusFailure { newEntries = append(newEntries, createEntry(pj)) createNewComment = true } delete = append(delete, previousComments...) if (createNewComment || len(newEntries) == 0) && latestComment != 0 { delete = append(delete, latestComment) latestComment = 0 } return delete, newEntries, latestComment }
c175990
} lines = append(lines, entries...) if reportTemplate != nil { lines = append(lines, "", b.String()) } lines = append(lines, []string{ "", "<details>", "", plugins.AboutThisBot, "</details>", commentTag, }...) return strings.Join(lines, "\n"), nil }
c175991
Title: title, Priority: priority, } }
c175992
data string) string { return "" }
c175993
fmt.Fprintf(&output, "(%s)", pull.SHA) } fmt.Fprint(&output, "\n") } } for _, command := range record.Commands { fmt.Fprintf(&output, "$ %s\n", command.Command) fmt.Fprint(&output, command.Output) if command.Error != "" { fmt.Fprintf(&output, "# Error: %s\n", command.Error) } } return output.String() }
c175994
*Client { nc := *c nc.namespace = ns return &nc }
c175995
client: &http.Client{}, fake: true, } }
c175996
RootCAs: cp, }, } return &Client{ logger: logrus.WithField("client", "kube"), baseURL: inClusterBaseURL, client: &http.Client{Transport: tr, Timeout: requestTimeout}, token: string(token), namespace: namespace, }, nil }
c175997
if err := yaml.Unmarshal(data, &c); err != nil { return nil, err } return NewClient(&c, namespace) }
c175998
[]tls.Certificate{cert}, RootCAs: cp, }, } return &Client{ logger: logrus.WithField("client", "kube"), baseURL: c.Endpoint, client: &http.Client{Transport: tr, Timeout: requestTimeout}, namespace: namespace, }, nil }
c175999
} var retConfigMap ConfigMap err := c.request(&request{ method: http.MethodPut, path: fmt.Sprintf("/api/v1/namespaces/%s/configmaps/%s", namespace, name), requestBody: &config, }, &retConfigMap) return retConfigMap, err }