_id stringlengths 2 7 | title stringlengths 1 118 | partition stringclasses 3
values | text stringlengths 52 85.5k | language stringclasses 1
value | meta_information dict |
|---|---|---|---|---|---|
q176200 | needDemux | test | func (s *Server) needDemux(eventType, srcRepo string) []plugins.ExternalPlugin {
var matching []plugins.ExternalPlugin
srcOrg := strings.Split(srcRepo, "/")[0]
for repo, plugins := range s.Plugins.Config().ExternalPlugins {
// Make sure the repositories match
if repo != srcRepo && repo != srcOrg {
continue
... | go | {
"resource": ""
} |
q176201 | demuxExternal | test | func (s *Server) demuxExternal(l *logrus.Entry, externalPlugins []plugins.ExternalPlugin, payload []byte, h http.Header) {
h.Set("User-Agent", "ProwHook")
for _, p := range externalPlugins {
s.wg.Add(1)
go func(p plugins.ExternalPlugin) {
defer s.wg.Done()
if err := s.dispatch(p.Endpoint, payload, h); err !... | go | {
"resource": ""
} |
q176202 | dispatch | test | func (s *Server) dispatch(endpoint string, payload []byte, h http.Header) error {
req, err := http.NewRequest(http.MethodPost, endpoint, bytes.NewBuffer(payload))
if err != nil {
return err
}
req.Header = h
resp, err := s.do(req)
if err != nil {
return err
}
defer resp.Body.Close()
rb, err := ioutil.ReadAl... | go | {
"resource": ""
} |
q176203 | AddFlags | test | func (s *StatePlugin) AddFlags(cmd *cobra.Command) {
cmd.Flags().StringVar(&s.desc, "state", "", "Description of the state (eg: `opened,!merged,labeled:cool`)")
cmd.Flags().IntSliceVar(&s.percentiles, "percentiles", []int{}, "Age percentiles for state")
} | go | {
"resource": ""
} |
q176204 | CheckFlags | test | func (s *StatePlugin) CheckFlags() error {
s.states = NewBundledStates(s.desc)
return nil
} | go | {
"resource": ""
} |
q176205 | ReceiveIssueEvent | test | func (s *StatePlugin) ReceiveIssueEvent(event sql.IssueEvent) []Point {
label := ""
if event.Label != nil {
label = *event.Label
}
if !s.states.ReceiveEvent(event.IssueID, event.Event, label, event.EventCreatedAt) {
return nil
}
total, sum := s.states.Total(event.EventCreatedAt)
values := map[string]interf... | go | {
"resource": ""
} |
q176206 | Load | test | func Load(prowConfig, jobConfig string) (c *Config, err error) {
// we never want config loading to take down the prow components
defer func() {
if r := recover(); r != nil {
c, err = nil, fmt.Errorf("panic loading config: %v", r)
}
}()
c, err = loadConfig(prowConfig, jobConfig)
if err != nil {
return nil... | go | {
"resource": ""
} |
q176207 | loadConfig | test | func loadConfig(prowConfig, jobConfig string) (*Config, error) {
stat, err := os.Stat(prowConfig)
if err != nil {
return nil, err
}
if stat.IsDir() {
return nil, fmt.Errorf("prowConfig cannot be a dir - %s", prowConfig)
}
var nc Config
if err := yamlToConfig(prowConfig, &nc); err != nil {
return nil, err... | go | {
"resource": ""
} |
q176208 | yamlToConfig | test | func yamlToConfig(path string, nc interface{}) error {
b, err := ReadFileMaybeGZIP(path)
if err != nil {
return fmt.Errorf("error reading %s: %v", path, err)
}
if err := yaml.Unmarshal(b, nc); err != nil {
return fmt.Errorf("error unmarshaling %s: %v", path, err)
}
var jc *JobConfig
switch v := nc.(type) {
... | go | {
"resource": ""
} |
q176209 | ReadFileMaybeGZIP | test | func ReadFileMaybeGZIP(path string) ([]byte, error) {
b, err := ioutil.ReadFile(path)
if err != nil {
return nil, err
}
// check if file contains gzip header: http://www.zlib.org/rfc-gzip.html
if !bytes.HasPrefix(b, []byte("\x1F\x8B")) {
// go ahead and return the contents if not gzipped
return b, nil
}
//... | go | {
"resource": ""
} |
q176210 | finalizeJobConfig | test | func (c *Config) finalizeJobConfig() error {
if c.decorationRequested() {
if c.Plank.DefaultDecorationConfig == nil {
return errors.New("no default decoration config provided for plank")
}
if c.Plank.DefaultDecorationConfig.UtilityImages == nil {
return errors.New("no default decoration image pull specs pr... | go | {
"resource": ""
} |
q176211 | validateComponentConfig | test | func (c *Config) validateComponentConfig() error {
if c.Plank.JobURLPrefix != "" && c.Plank.JobURLPrefixConfig["*"] != "" {
return errors.New(`Planks job_url_prefix must be unset when job_url_prefix_config["*"] is set. The former is deprecated, use the latter`)
}
for k, v := range c.Plank.JobURLPrefixConfig {
if... | go | {
"resource": ""
} |
q176212 | ConfigPath | test | func ConfigPath(value string) string {
if value != "" {
return value
}
logrus.Warningf("defaulting to %s until 15 July 2019, please migrate", DefaultConfigPath)
return DefaultConfigPath
} | go | {
"resource": ""
} |
q176213 | ValidateController | test | func ValidateController(c *Controller) error {
urlTmpl, err := template.New("JobURL").Parse(c.JobURLTemplateString)
if err != nil {
return fmt.Errorf("parsing template: %v", err)
}
c.JobURLTemplate = urlTmpl
reportTmpl, err := template.New("Report").Parse(c.ReportTemplateString)
if err != nil {
return fmt.Er... | go | {
"resource": ""
} |
q176214 | defaultJobBase | test | func (c *ProwConfig) defaultJobBase(base *JobBase) {
if base.Agent == "" { // Use kubernetes by default
base.Agent = string(prowapi.KubernetesAgent)
}
if base.Namespace == nil || *base.Namespace == "" {
s := c.PodNamespace
base.Namespace = &s
}
if base.Cluster == "" {
base.Cluster = kube.DefaultClusterAlia... | go | {
"resource": ""
} |
q176215 | SetPresubmitRegexes | test | func SetPresubmitRegexes(js []Presubmit) error {
for i, j := range js {
if re, err := regexp.Compile(j.Trigger); err == nil {
js[i].re = re
} else {
return fmt.Errorf("could not compile trigger regex for %s: %v", j.Name, err)
}
if !js[i].re.MatchString(j.RerunCommand) {
return fmt.Errorf("for job %s, ... | go | {
"resource": ""
} |
q176216 | setBrancherRegexes | test | func setBrancherRegexes(br Brancher) (Brancher, error) {
if len(br.Branches) > 0 {
if re, err := regexp.Compile(strings.Join(br.Branches, `|`)); err == nil {
br.re = re
} else {
return br, fmt.Errorf("could not compile positive branch regex: %v", err)
}
}
if len(br.SkipBranches) > 0 {
if re, err := reg... | go | {
"resource": ""
} |
q176217 | SetPostsubmitRegexes | test | func SetPostsubmitRegexes(ps []Postsubmit) error {
for i, j := range ps {
b, err := setBrancherRegexes(j.Brancher)
if err != nil {
return fmt.Errorf("could not set branch regexes for %s: %v", j.Name, err)
}
ps[i].Brancher = b
c, err := setChangeRegexes(j.RegexpChangeMatcher)
if err != nil {
return fm... | go | {
"resource": ""
} |
q176218 | Body | test | func (lens Lens) Body(artifacts []lenses.Artifact, resourceDir string, data string) string {
var buf bytes.Buffer
type MetadataViewData struct {
Status string
StartTime time.Time
FinishedTime time.Time
Elapsed time.Duration
Metadata map[string]string
}
metadataViewData := MetadataViewDat... | go | {
"resource": ""
} |
q176219 | NewBoskosHandler | test | func NewBoskosHandler(r *ranch.Ranch) *http.ServeMux {
mux := http.NewServeMux()
mux.Handle("/", handleDefault(r))
mux.Handle("/acquire", handleAcquire(r))
mux.Handle("/acquirebystate", handleAcquireByState(r))
mux.Handle("/release", handleRelease(r))
mux.Handle("/reset", handleReset(r))
mux.Handle("/update", ha... | go | {
"resource": ""
} |
q176220 | ErrorToStatus | test | func ErrorToStatus(err error) int {
switch err.(type) {
default:
return http.StatusInternalServerError
case *ranch.OwnerNotMatch:
return http.StatusUnauthorized
case *ranch.ResourceNotFound:
return http.StatusNotFound
case *ranch.ResourceTypeNotFound:
return http.StatusNotFound
case *ranch.StateNotMatch:
... | go | {
"resource": ""
} |
q176221 | DumpProfile | test | func DumpProfile(destination string, profile []*cover.Profile) error {
var output io.Writer
if destination == "-" {
output = os.Stdout
} else {
f, err := os.Create(destination)
if err != nil {
return fmt.Errorf("failed to open %s: %v", destination, err)
}
defer f.Close()
output = f
}
err := cov.Dump... | go | {
"resource": ""
} |
q176222 | LoadProfile | test | func LoadProfile(origin string) ([]*cover.Profile, error) {
filename := origin
if origin == "-" {
// Annoyingly, ParseProfiles only accepts a filename, so we have to write the bytes to disk
// so it can read them back.
// We could probably also just give it /dev/stdin, but that'll break on Windows.
tf, err :=... | go | {
"resource": ""
} |
q176223 | NewClient | test | func NewClient() (*Client, error) {
g, err := exec.LookPath("git")
if err != nil {
return nil, err
}
t, err := ioutil.TempDir("", "git")
if err != nil {
return nil, err
}
return &Client{
logger: logrus.WithField("client", "git"),
dir: t,
git: g,
base: fmt.Sprintf("https://%s", git... | go | {
"resource": ""
} |
q176224 | SetCredentials | test | func (c *Client) SetCredentials(user string, tokenGenerator func() []byte) {
c.credLock.Lock()
defer c.credLock.Unlock()
c.user = user
c.tokenGenerator = tokenGenerator
} | go | {
"resource": ""
} |
q176225 | Checkout | test | func (r *Repo) Checkout(commitlike string) error {
r.logger.Infof("Checkout %s.", commitlike)
co := r.gitCommand("checkout", commitlike)
if b, err := co.CombinedOutput(); err != nil {
return fmt.Errorf("error checking out %s: %v. output: %s", commitlike, err, string(b))
}
return nil
} | go | {
"resource": ""
} |
q176226 | CheckoutNewBranch | test | func (r *Repo) CheckoutNewBranch(branch string) error {
r.logger.Infof("Create and checkout %s.", branch)
co := r.gitCommand("checkout", "-b", branch)
if b, err := co.CombinedOutput(); err != nil {
return fmt.Errorf("error checking out %s: %v. output: %s", branch, err, string(b))
}
return nil
} | go | {
"resource": ""
} |
q176227 | Merge | test | func (r *Repo) Merge(commitlike string) (bool, error) {
r.logger.Infof("Merging %s.", commitlike)
co := r.gitCommand("merge", "--no-ff", "--no-stat", "-m merge", commitlike)
b, err := co.CombinedOutput()
if err == nil {
return true, nil
}
r.logger.WithError(err).Infof("Merge failed with output: %s", string(b))... | go | {
"resource": ""
} |
q176228 | CheckoutPullRequest | test | func (r *Repo) CheckoutPullRequest(number int) error {
r.logger.Infof("Fetching and checking out %s#%d.", r.repo, number)
if b, err := retryCmd(r.logger, r.Dir, r.git, "fetch", r.base+"/"+r.repo, fmt.Sprintf("pull/%d/head:pull%d", number, number)); err != nil {
return fmt.Errorf("git fetch failed for PR %d: %v. out... | go | {
"resource": ""
} |
q176229 | Config | test | func (r *Repo) Config(key, value string) error {
r.logger.Infof("Running git config %s %s", key, value)
if b, err := r.gitCommand("config", key, value).CombinedOutput(); err != nil {
return fmt.Errorf("git config %s %s failed: %v. output: %s", key, value, err, string(b))
}
return nil
} | go | {
"resource": ""
} |
q176230 | retryCmd | test | func retryCmd(l *logrus.Entry, dir, cmd string, arg ...string) ([]byte, error) {
var b []byte
var err error
sleepyTime := time.Second
for i := 0; i < 3; i++ {
c := exec.Command(cmd, arg...)
c.Dir = dir
b, err = c.CombinedOutput()
if err != nil {
l.Warningf("Running %s %v returned error %v with output %s.... | go | {
"resource": ""
} |
q176231 | LabelsAndAnnotationsForSpec | test | func LabelsAndAnnotationsForSpec(spec prowapi.ProwJobSpec, extraLabels, extraAnnotations map[string]string) (map[string]string, map[string]string) {
jobNameForLabel := spec.Job
if len(jobNameForLabel) > validation.LabelValueMaxLength {
// TODO(fejta): consider truncating middle rather than end.
jobNameForLabel = ... | go | {
"resource": ""
} |
q176232 | ProwJobToPod | test | func ProwJobToPod(pj prowapi.ProwJob, buildID string) (*coreapi.Pod, error) {
if pj.Spec.PodSpec == nil {
return nil, fmt.Errorf("prowjob %q lacks a pod spec", pj.Name)
}
rawEnv, err := downwardapi.EnvForSpec(downwardapi.NewJobSpec(pj.Spec, buildID, pj.Name))
if err != nil {
return nil, err
}
spec := pj.Spe... | go | {
"resource": ""
} |
q176233 | CloneLogPath | test | func CloneLogPath(logMount coreapi.VolumeMount) string {
return filepath.Join(logMount.MountPath, cloneLogPath)
} | go | {
"resource": ""
} |
q176234 | cloneEnv | test | func cloneEnv(opt clonerefs.Options) ([]coreapi.EnvVar, error) {
// TODO(fejta): use flags
cloneConfigEnv, err := clonerefs.Encode(opt)
if err != nil {
return nil, err
}
return kubeEnv(map[string]string{clonerefs.JSONConfigEnvVar: cloneConfigEnv}), nil
} | go | {
"resource": ""
} |
q176235 | sshVolume | test | func sshVolume(secret string) (coreapi.Volume, coreapi.VolumeMount) {
var sshKeyMode int32 = 0400 // this is octal, so symbolic ref is `u+r`
name := strings.Join([]string{"ssh-keys", secret}, "-")
mountPath := path.Join("/secrets/ssh", secret)
v := coreapi.Volume{
Name: name,
VolumeSource: coreapi.VolumeSource{... | go | {
"resource": ""
} |
q176236 | InjectEntrypoint | test | func InjectEntrypoint(c *coreapi.Container, timeout, gracePeriod time.Duration, prefix, previousMarker string, exitZero bool, log, tools coreapi.VolumeMount) (*wrapper.Options, error) {
wrapperOptions := &wrapper.Options{
Args: append(c.Command, c.Args...),
ProcessLog: processLog(log, prefix),
MarkerFi... | go | {
"resource": ""
} |
q176237 | PlaceEntrypoint | test | func PlaceEntrypoint(image string, toolsMount coreapi.VolumeMount) coreapi.Container {
return coreapi.Container{
Name: "place-entrypoint",
Image: image,
Command: []string{"/bin/cp"},
Args: []string{"/entrypoint", entrypointLocation(toolsMount)},
VolumeMounts: []coreapi.VolumeMount... | go | {
"resource": ""
} |
q176238 | kubeEnv | test | func kubeEnv(environment map[string]string) []coreapi.EnvVar {
var keys []string
for key := range environment {
keys = append(keys, key)
}
sort.Strings(keys)
var kubeEnvironment []coreapi.EnvVar
for _, key := range keys {
kubeEnvironment = append(kubeEnvironment, coreapi.EnvVar{
Name: key,
Value: envi... | go | {
"resource": ""
} |
q176239 | Client | test | func (o *KubernetesOptions) Client(namespace string, dryRun bool) (*kube.Client, error) {
if dryRun {
return kube.NewFakeClient(o.DeckURI), nil
}
if o.cluster == "" {
return kube.NewClientInCluster(namespace)
}
return kube.NewClientFromFile(o.cluster, namespace)
} | go | {
"resource": ""
} |
q176240 | handle | test | func handle(gc githubClient, le *logrus.Entry, e *event) error {
needsLabel := e.draft || titleRegex.MatchString(e.title)
if needsLabel && !e.hasLabel {
if err := gc.AddLabel(e.org, e.repo, e.number, labels.WorkInProgress); err != nil {
le.Warnf("error while adding Label %q: %v", labels.WorkInProgress, err)
... | go | {
"resource": ""
} |
q176241 | SendHook | test | func SendHook(address, eventType string, payload, hmac []byte) error {
req, err := http.NewRequest(http.MethodPost, address, bytes.NewBuffer(payload))
if err != nil {
return err
}
req.Header.Set("X-GitHub-Event", eventType)
req.Header.Set("X-GitHub-Delivery", "GUID")
req.Header.Set("X-Hub-Signature", github.Pay... | go | {
"resource": ""
} |
q176242 | janitorClean | test | func janitorClean(resource *common.Resource, flags []string) error {
args := append([]string{fmt.Sprintf("--%s=%s", format(resource.Type), resource.Name)}, flags...)
logrus.Infof("executing janitor: %s %s", *janitorPath, strings.Join(args, " "))
cmd := exec.Command(*janitorPath, args...)
b, err := cmd.CombinedOutpu... | go | {
"resource": ""
} |
q176243 | janitor | test | func janitor(c boskosClient, buffer <-chan *common.Resource, fn clean, flags []string) {
for {
resource := <-buffer
dest := common.Free
if err := fn(resource, flags); err != nil {
logrus.WithError(err).Errorf("%s failed!", *janitorPath)
dest = common.Dirty
}
if err := c.ReleaseOne(resource.Name, dest... | go | {
"resource": ""
} |
q176244 | Run | test | func (s *PullServer) Run(ctx context.Context) error {
configEvent := make(chan config.Delta, 2)
s.Subscriber.ConfigAgent.Subscribe(configEvent)
var err error
defer func() {
if err != nil {
logrus.WithError(ctx.Err()).Error("Pull server shutting down")
}
logrus.Warn("Pull server shutting down")
}()
curre... | go | {
"resource": ""
} |
q176245 | specToStarted | test | func specToStarted(spec *downwardapi.JobSpec, mainRefSHA string) gcs.Started {
started := gcs.Started{
Timestamp: time.Now().Unix(),
RepoVersion: downwardapi.GetRevisionFromSpec(spec),
}
if mainRefSHA != "" {
started.RepoVersion = mainRefSHA
}
// TODO(fejta): VM name
if spec.Refs != nil && len(spec.Ref... | go | {
"resource": ""
} |
q176246 | Run | test | func (o Options) Run() error {
spec, err := downwardapi.ResolveSpecFromEnv()
if err != nil {
return fmt.Errorf("could not resolve job spec: %v", err)
}
uploadTargets := map[string]gcs.UploadFunc{}
var failed bool
var mainRefSHA string
if o.Log != "" {
if failed, mainRefSHA, err = processCloneLog(o.Log, upl... | go | {
"resource": ""
} |
q176247 | hasPRChanged | test | func hasPRChanged(pr github.PullRequestEvent) bool {
switch pr.Action {
case github.PullRequestActionOpened:
return true
case github.PullRequestActionReopened:
return true
case github.PullRequestActionSynchronize:
return true
default:
return false
}
} | go | {
"resource": ""
} |
q176248 | UpdateIssues | test | func UpdateIssues(db *gorm.DB, client ClientInterface) {
latest, err := findLatestIssueUpdate(db, client.RepositoryName())
if err != nil {
glog.Error("Failed to find last issue update: ", err)
return
}
c := make(chan *github.Issue, 200)
go client.FetchIssues(latest, c)
for issue := range c {
issueOrm, err ... | go | {
"resource": ""
} |
q176249 | handleReviewEvent | test | func handleReviewEvent(pc plugins.Agent, re github.ReviewEvent) error {
return handleReview(
pc.Logger,
pc.GitHubClient,
pc.OwnersClient,
pc.Config.GitHubOptions,
pc.PluginConfig,
&re,
)
} | go | {
"resource": ""
} |
q176250 | findAssociatedIssue | test | func findAssociatedIssue(body, org string) (int, error) {
associatedIssueRegex, err := regexp.Compile(fmt.Sprintf(associatedIssueRegexFormat, org))
if err != nil {
return 0, err
}
match := associatedIssueRegex.FindStringSubmatch(body)
if len(match) == 0 {
return 0, nil
}
v, err := strconv.Atoi(match[1])
if ... | go | {
"resource": ""
} |
q176251 | optionsForRepo | test | func optionsForRepo(config *plugins.Configuration, org, repo string) *plugins.Approve {
fullName := fmt.Sprintf("%s/%s", org, repo)
a := func() *plugins.Approve {
// First search for repo config
for _, c := range config.Approve {
if !strInSlice(fullName, c.Repos) {
continue
}
return &c
}
// If ... | go | {
"resource": ""
} |
q176252 | localOnlyMain | test | func localOnlyMain(cfg config.Getter, o options, mux *http.ServeMux) *http.ServeMux {
mux.Handle("/github-login", gziphandler.GzipHandler(handleSimpleTemplate(o, cfg, "github-login.html", nil)))
if o.spyglass {
initSpyglass(cfg, o, mux, nil)
}
return mux
} | go | {
"resource": ""
} |
q176253 | summarize | test | func (covList *CoverageList) summarize() {
covList.NumCoveredStmts = 0
covList.NumAllStmts = 0
for _, item := range covList.Group {
covList.NumCoveredStmts += item.NumCoveredStmts
covList.NumAllStmts += item.NumAllStmts
}
} | go | {
"resource": ""
} |
q176254 | Subset | test | func (covList *CoverageList) Subset(prefix string) *CoverageList {
s := newCoverageList("Filtered Summary")
for _, c := range covList.Group {
if strings.HasPrefix(c.Name, prefix) {
covList.Group = append(covList.Group, c)
}
}
return s
} | go | {
"resource": ""
} |
q176255 | ListDirectories | test | func (covList CoverageList) ListDirectories() []string {
dirSet := map[string]bool{}
for _, cov := range covList.Group {
dirSet[path.Dir(cov.Name)] = true
}
var result []string
for key := range dirSet {
result = append(result, key)
}
return result
} | go | {
"resource": ""
} |
q176256 | readRequest | test | func readRequest(r io.Reader, contentType string) (*admissionapi.AdmissionRequest, error) {
if contentType != contentTypeJSON {
return nil, fmt.Errorf("Content-Type=%s, expected %s", contentType, contentTypeJSON)
}
// Can we read the body?
if r == nil {
return nil, fmt.Errorf("no body")
}
body, err := ioutil... | go | {
"resource": ""
} |
q176257 | handle | test | func handle(w http.ResponseWriter, r *http.Request) {
req, err := readRequest(r.Body, r.Header.Get("Content-Type"))
if err != nil {
logrus.WithError(err).Error("read")
}
if err := writeResponse(*req, w, onlyUpdateStatus); err != nil {
logrus.WithError(err).Error("write")
}
} | go | {
"resource": ""
} |
q176258 | writeResponse | test | func writeResponse(ar admissionapi.AdmissionRequest, w io.Writer, decide decider) error {
response, err := decide(ar)
if err != nil {
logrus.WithError(err).Error("failed decision")
response = &admissionapi.AdmissionResponse{
Result: &meta.Status{
Message: err.Error(),
},
}
}
var result admissionapi.... | go | {
"resource": ""
} |
q176259 | onlyUpdateStatus | test | func onlyUpdateStatus(req admissionapi.AdmissionRequest) (*admissionapi.AdmissionResponse, error) {
logger := logrus.WithFields(logrus.Fields{
"resource": req.Resource,
"subresource": req.SubResource,
"name": req.Name,
"namespace": req.Namespace,
"operation": req.Operation,
})
// Does this o... | go | {
"resource": ""
} |
q176260 | convertSuiteMeta | test | func convertSuiteMeta(suiteMeta gcs.SuitesMeta) resultstore.Suite {
out := resultstore.Suite{
Name: path.Base(suiteMeta.Path),
Files: []resultstore.File{
{
ContentType: "text/xml",
ID: resultstore.UUID(),
URL: suiteMeta.Path, // ensure the junit.xml file appears in artifacts list
... | go | {
"resource": ""
} |
q176261 | NewHealth | test | func NewHealth() *Health {
healthMux := http.NewServeMux()
healthMux.HandleFunc("/healthz", func(w http.ResponseWriter, r *http.Request) { fmt.Fprint(w, "OK") })
go func() {
logrus.WithError(http.ListenAndServe(":"+strconv.Itoa(healthPort), healthMux)).Fatal("ListenAndServe returned.")
}()
return &Health{
heal... | go | {
"resource": ""
} |
q176262 | ServeReady | test | func (h *Health) ServeReady() {
h.healthMux.HandleFunc("/healthz/ready", func(w http.ResponseWriter, r *http.Request) { fmt.Fprint(w, "OK") })
} | go | {
"resource": ""
} |
q176263 | NewController | test | func NewController(ghcSync, ghcStatus *github.Client, prowJobClient prowv1.ProwJobInterface, cfg config.Getter, gc *git.Client, maxRecordsPerPool int, opener io.Opener, historyURI, statusURI string, logger *logrus.Entry) (*Controller, error) {
if logger == nil {
logger = logrus.NewEntry(logrus.StandardLogger())
}
... | go | {
"resource": ""
} |
q176264 | newExpectedContext | test | func newExpectedContext(c string) Context {
return Context{
Context: githubql.String(c),
State: githubql.StatusStateExpected,
Description: githubql.String(""),
}
} | go | {
"resource": ""
} |
q176265 | contextsToStrings | test | func contextsToStrings(contexts []Context) []string {
var names []string
for _, c := range contexts {
names = append(names, string(c.Context))
}
return names
} | go | {
"resource": ""
} |
q176266 | filterSubpools | test | func (c *Controller) filterSubpools(goroutines int, raw map[string]*subpool) map[string]*subpool {
filtered := make(map[string]*subpool)
var lock sync.Mutex
subpoolsInParallel(
goroutines,
raw,
func(sp *subpool) {
if err := c.initSubpoolData(sp); err != nil {
sp.log.WithError(err).Error("Error initiali... | go | {
"resource": ""
} |
q176267 | filterSubpool | test | func filterSubpool(ghc githubClient, sp *subpool) *subpool {
var toKeep []PullRequest
for _, pr := range sp.prs {
if !filterPR(ghc, sp, &pr) {
toKeep = append(toKeep, pr)
}
}
if len(toKeep) == 0 {
return nil
}
sp.prs = toKeep
return sp
} | go | {
"resource": ""
} |
q176268 | poolPRMap | test | func poolPRMap(subpoolMap map[string]*subpool) map[string]PullRequest {
prs := make(map[string]PullRequest)
for _, sp := range subpoolMap {
for _, pr := range sp.prs {
prs[prKey(&pr)] = pr
}
}
return prs
} | go | {
"resource": ""
} |
q176269 | unsuccessfulContexts | test | func unsuccessfulContexts(contexts []Context, cc contextChecker, log *logrus.Entry) []Context {
var failed []Context
for _, ctx := range contexts {
if string(ctx.Context) == statusContext {
continue
}
if cc.IsOptional(string(ctx.Context)) {
continue
}
if ctx.State != githubql.StatusStateSuccess {
f... | go | {
"resource": ""
} |
q176270 | accumulate | test | func accumulate(presubmits map[int][]config.Presubmit, prs []PullRequest, pjs []prowapi.ProwJob, log *logrus.Entry) (successes, pendings, nones []PullRequest) {
for _, pr := range prs {
// Accumulate the best result for each job.
psStates := make(map[string]simpleState)
for _, pj := range pjs {
if pj.Spec.Typ... | go | {
"resource": ""
} |
q176271 | tryMerge | test | func tryMerge(mergeFunc func() error) (bool, error) {
var err error
const maxRetries = 3
backoff := time.Second * 4
for retry := 0; retry < maxRetries; retry++ {
if err = mergeFunc(); err == nil {
// Successful merge!
return true, nil
}
// TODO: Add a config option to abort batches if a PR in the batch
... | go | {
"resource": ""
} |
q176272 | prChanges | test | func (c *changedFilesAgent) prChanges(pr *PullRequest) config.ChangedFilesProvider {
return func() ([]string, error) {
cacheKey := changeCacheKey{
org: string(pr.Repository.Owner.Login),
repo: string(pr.Repository.Name),
number: int(pr.Number),
sha: string(pr.HeadRefOID),
}
c.RLock()
chang... | go | {
"resource": ""
} |
q176273 | prune | test | func (c *changedFilesAgent) prune() {
c.Lock()
defer c.Unlock()
c.changeCache = c.nextChangeCache
c.nextChangeCache = make(map[changeCacheKey][]string)
} | go | {
"resource": ""
} |
q176274 | dividePool | test | func (c *Controller) dividePool(pool map[string]PullRequest, pjs []prowapi.ProwJob) (map[string]*subpool, error) {
sps := make(map[string]*subpool)
for _, pr := range pool {
org := string(pr.Repository.Owner.Login)
repo := string(pr.Repository.Name)
branch := string(pr.BaseRef.Name)
branchRef := string(pr.Bas... | go | {
"resource": ""
} |
q176275 | AggregateProfiles | test | func AggregateProfiles(profiles [][]*cover.Profile) ([]*cover.Profile, error) {
setProfiles := make([][]*cover.Profile, 0, len(profiles))
for _, p := range profiles {
c := countToBoolean(p)
setProfiles = append(setProfiles, c)
}
aggregateProfiles, err := MergeMultipleProfiles(setProfiles)
if err != nil {
ret... | go | {
"resource": ""
} |
q176276 | countToBoolean | test | func countToBoolean(profile []*cover.Profile) []*cover.Profile {
setProfile := make([]*cover.Profile, 0, len(profile))
for _, p := range profile {
pc := deepCopyProfile(*p)
for i := range pc.Blocks {
if pc.Blocks[i].Count > 0 {
pc.Blocks[i].Count = 1
}
}
setProfile = append(setProfile, &pc)
}
retu... | go | {
"resource": ""
} |
q176277 | NewStorage | test | func NewStorage(r storage.PersistenceLayer, storage string) (*Storage, error) {
s := &Storage{
resources: r,
}
if storage != "" {
var data struct {
Resources []common.Resource
}
buf, err := ioutil.ReadFile(storage)
if err == nil {
logrus.Infof("Current state: %s.", string(buf))
err = json.Unmarsh... | go | {
"resource": ""
} |
q176278 | AddResource | test | func (s *Storage) AddResource(resource common.Resource) error {
return s.resources.Add(resource)
} | go | {
"resource": ""
} |
q176279 | DeleteResource | test | func (s *Storage) DeleteResource(name string) error {
return s.resources.Delete(name)
} | go | {
"resource": ""
} |
q176280 | UpdateResource | test | func (s *Storage) UpdateResource(resource common.Resource) error {
return s.resources.Update(resource)
} | go | {
"resource": ""
} |
q176281 | GetResource | test | func (s *Storage) GetResource(name string) (common.Resource, error) {
i, err := s.resources.Get(name)
if err != nil {
return common.Resource{}, err
}
var res common.Resource
res, err = common.ItemToResource(i)
if err != nil {
return common.Resource{}, err
}
return res, nil
} | go | {
"resource": ""
} |
q176282 | GetResources | test | func (s *Storage) GetResources() ([]common.Resource, error) {
var resources []common.Resource
items, err := s.resources.List()
if err != nil {
return resources, err
}
for _, i := range items {
var res common.Resource
res, err = common.ItemToResource(i)
if err != nil {
return nil, err
}
resources = a... | go | {
"resource": ""
} |
q176283 | SyncResources | test | func (s *Storage) SyncResources(data []common.Resource) error {
s.resourcesLock.Lock()
defer s.resourcesLock.Unlock()
resources, err := s.GetResources()
if err != nil {
logrus.WithError(err).Error("cannot find resources")
return err
}
var finalError error
// delete non-exist resource
valid := 0
for _, r... | go | {
"resource": ""
} |
q176284 | ParseConfig | test | func ParseConfig(configPath string) ([]common.Resource, error) {
file, err := ioutil.ReadFile(configPath)
if err != nil {
return nil, err
}
var data common.BoskosConfig
err = yaml.Unmarshal(file, &data)
if err != nil {
return nil, err
}
var resources []common.Resource
for _, entry := range data.Resources... | go | {
"resource": ""
} |
q176285 | problemsInFiles | test | func problemsInFiles(r *git.Repo, files map[string]string) (map[string][]string, error) {
problems := make(map[string][]string)
for f := range files {
src, err := ioutil.ReadFile(filepath.Join(r.Dir, f))
if err != nil {
return nil, err
}
// This is modeled after the logic from buildifier:
// https://gith... | go | {
"resource": ""
} |
q176286 | NewPodLogArtifact | test | func NewPodLogArtifact(jobName string, buildID string, sizeLimit int64, ja jobAgent) (*PodLogArtifact, error) {
if jobName == "" {
return nil, errInsufficientJobInfo
}
if buildID == "" {
return nil, errInsufficientJobInfo
}
if sizeLimit < 0 {
return nil, errInvalidSizeLimit
}
return &PodLogArtifact{
name... | go | {
"resource": ""
} |
q176287 | CanonicalLink | test | func (a *PodLogArtifact) CanonicalLink() string {
q := url.Values{
"job": []string{a.name},
"id": []string{a.buildID},
}
u := url.URL{
Path: "/log",
RawQuery: q.Encode(),
}
return u.String()
} | go | {
"resource": ""
} |
q176288 | ReadAt | test | func (a *PodLogArtifact) ReadAt(p []byte, off int64) (n int, err error) {
logs, err := a.jobAgent.GetJobLog(a.name, a.buildID)
if err != nil {
return 0, fmt.Errorf("error getting pod log: %v", err)
}
r := bytes.NewReader(logs)
readBytes, err := r.ReadAt(p, off)
if err == io.EOF {
return readBytes, io.EOF
}
... | go | {
"resource": ""
} |
q176289 | ReadAll | test | func (a *PodLogArtifact) ReadAll() ([]byte, error) {
size, err := a.Size()
if err != nil {
return nil, fmt.Errorf("error getting pod log size: %v", err)
}
if size > a.sizeLimit {
return nil, lenses.ErrFileTooLarge
}
logs, err := a.jobAgent.GetJobLog(a.name, a.buildID)
if err != nil {
return nil, fmt.Errorf... | go | {
"resource": ""
} |
q176290 | ReadAtMost | test | func (a *PodLogArtifact) ReadAtMost(n int64) ([]byte, error) {
logs, err := a.jobAgent.GetJobLog(a.name, a.buildID)
if err != nil {
return nil, fmt.Errorf("error getting pod log: %v", err)
}
reader := bytes.NewReader(logs)
var byteCount int64
var p []byte
for byteCount < n {
b, err := reader.ReadByte()
if ... | go | {
"resource": ""
} |
q176291 | ReadTail | test | func (a *PodLogArtifact) ReadTail(n int64) ([]byte, error) {
logs, err := a.jobAgent.GetJobLog(a.name, a.buildID)
if err != nil {
return nil, fmt.Errorf("error getting pod log tail: %v", err)
}
size := int64(len(logs))
var off int64
if n > size {
off = 0
} else {
off = size - n
}
p := make([]byte, n)
re... | go | {
"resource": ""
} |
q176292 | newProblems | test | func newProblems(cs []github.ReviewComment, ps map[string]map[int]lint.Problem) map[string]map[int]lint.Problem {
// Make a copy, then remove the old elements.
res := make(map[string]map[int]lint.Problem)
for f, ls := range ps {
res[f] = make(map[int]lint.Problem)
for l, p := range ls {
res[f][l] = p
}
}
... | go | {
"resource": ""
} |
q176293 | problemsInFiles | test | func problemsInFiles(r *git.Repo, files map[string]string) (map[string]map[int]lint.Problem, []github.DraftReviewComment) {
problems := make(map[string]map[int]lint.Problem)
var lintErrorComments []github.DraftReviewComment
l := new(lint.Linter)
for f, patch := range files {
problems[f] = make(map[int]lint.Proble... | go | {
"resource": ""
} |
q176294 | undoPreset | test | func undoPreset(preset *config.Preset, labels map[string]string, pod *coreapi.PodSpec) {
// skip presets that do not match the job labels
for l, v := range preset.Labels {
if v2, ok := labels[l]; !ok || v2 != v {
return
}
}
// collect up preset created keys
removeEnvNames := sets.NewString()
for _, e1 := ... | go | {
"resource": ""
} |
q176295 | undoPresubmitPresets | test | func undoPresubmitPresets(presets []config.Preset, presubmit *config.Presubmit) {
if presubmit.Spec == nil {
return
}
for _, preset := range presets {
undoPreset(&preset, presubmit.Labels, presubmit.Spec)
}
} | go | {
"resource": ""
} |
q176296 | yamlBytesStripNulls | test | func yamlBytesStripNulls(yamlBytes []byte) []byte {
nullRE := regexp.MustCompile("(?m)[\n]+^[^\n]+: null$")
return nullRE.ReplaceAll(yamlBytes, []byte{})
} | go | {
"resource": ""
} |
q176297 | monitorDiskAndEvict | test | func monitorDiskAndEvict(
c *diskcache.Cache,
interval time.Duration,
minPercentBlocksFree, evictUntilPercentBlocksFree float64,
) {
diskRoot := c.DiskRoot()
// forever check if usage is past thresholds and evict
ticker := time.NewTicker(interval)
for ; true; <-ticker.C {
blocksFree, _, _, err := diskutil.GetD... | go | {
"resource": ""
} |
q176298 | difference | test | func (c *orgRepoConfig) difference(c2 *orgRepoConfig) *orgRepoConfig {
res := &orgRepoConfig{
orgExceptions: make(map[string]sets.String),
repos: sets.NewString().Union(c.repos),
}
for org, excepts1 := range c.orgExceptions {
if excepts2, ok := c2.orgExceptions[org]; ok {
res.repos.Insert(excepts2.D... | go | {
"resource": ""
} |
q176299 | union | test | func (c *orgRepoConfig) union(c2 *orgRepoConfig) *orgRepoConfig {
res := &orgRepoConfig{
orgExceptions: make(map[string]sets.String),
repos: sets.NewString(),
}
for org, excepts1 := range c.orgExceptions {
// keep only items in both blacklists that are not in the
// explicit repo whitelists for the ... | go | {
"resource": ""
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.