id stringlengths 2 7 | text stringlengths 17 51.2k | title stringclasses 1 value |
|---|---|---|
c176200 | {
if len(p.Events) == 0 {
matching = append(matching, p)
} else {
for _, et := range p.Events {
if et != eventType {
continue
}
matching = append(matching, p)
break
}
}
}
}
return matching
} | |
c176201 | {
l.WithError(err).WithField("external-plugin", p.Name).Error("Error dispatching event to external plugin.")
} else {
l.WithField("external-plugin", p.Name).Info("Dispatched event to external plugin")
}
}(p)
}
} | |
c176202 | err
}
if resp.StatusCode < 200 || resp.StatusCode > 299 {
return fmt.Errorf("response has status %q and body %q", resp.Status, string(rb))
}
return nil
} | |
c176203 | `opened,!merged,labeled:cool`)")
cmd.Flags().IntSliceVar(&s.percentiles, "percentiles", []int{}, "Age percentiles for state")
} | |
c176204 | NewBundledStates(s.desc)
return nil
} | |
c176205 |
}
for _, percentile := range s.percentiles {
values[fmt.Sprintf("%d%%", percentile)] = int(s.states.Percentile(event.EventCreatedAt, percentile))
}
return []Point{
{
Values: values,
Date: event.EventCreatedAt,
},
}
} | |
c176206 | return nil, err
}
if err := c.validateComponentConfig(); err != nil {
return nil, err
}
if err := c.validateJobConfig(); err != nil {
return nil, err
}
return c, nil
} | |
c176207 | logrus.WithError(err).Errorf("walking path %q.", path)
// bad file should not stop us from parsing the directory
return nil
}
if strings.HasPrefix(info.Name(), "..") {
// kubernetes volumes also include files we
// should not look be looking into for keys
if info.IsDir() {
return filepath.SkipDir
}
return nil
}
if filepath.Ext(path) != ".yaml" && filepath.Ext(path) != ".yml" {
return nil
}
if info.IsDir() {
return nil
}
base := filepath.Base(path)
if uniqueBasenames.Has(base) {
return fmt.Errorf("duplicated basename is not allowed: %s", base)
}
uniqueBasenames.Insert(base)
var subConfig JobConfig
if err := yamlToConfig(path, &subConfig); err != nil {
return err
}
return nc.mergeJobConfig(subConfig)
})
if err != nil {
return nil, err
}
return &nc, nil
} | |
c176208 | rep := range jc.Presubmits {
var fix func(*Presubmit)
fix = func(job *Presubmit) {
job.SourcePath = path
}
for i := range jc.Presubmits[rep] {
fix(&jc.Presubmits[rep][i])
}
}
for rep := range jc.Postsubmits {
var fix func(*Postsubmit)
fix = func(job *Postsubmit) {
job.SourcePath = path
}
for i := range jc.Postsubmits[rep] {
fix(&jc.Postsubmits[rep][i])
}
}
var fix func(*Periodic)
fix = func(job *Periodic) {
job.SourcePath = path
}
for i := range jc.Periodics {
fix(&jc.Periodics[i])
}
return nil
} | |
c176209 | return b, nil
}
// otherwise decode
gzipReader, err := gzip.NewReader(bytes.NewBuffer(b))
if err != nil {
return nil, err
}
return ioutil.ReadAll(gzipReader)
} | |
c176210 | := SetPresubmitRegexes(vs); err != nil {
return fmt.Errorf("could not set regex: %v", err)
}
}
for _, js := range c.Postsubmits {
c.defaultPostsubmitFields(js)
if err := SetPostsubmitRegexes(js); err != nil {
return fmt.Errorf("could not set regex: %v", err)
}
}
c.defaultPeriodicFields(c.Periodics)
for _, v := range c.AllPresubmits(nil) {
if err := resolvePresets(v.Name, v.Labels, v.Spec, v.BuildSpec, c.Presets); err != nil {
return err
}
}
for _, v := range c.AllPostsubmits(nil) {
if err := resolvePresets(v.Name, v.Labels, v.Spec, v.BuildSpec, c.Presets); err != nil {
return err
}
}
for _, v := range c.AllPeriodics() {
if err := resolvePresets(v.Name, v.Labels, v.Spec, v.BuildSpec, c.Presets); err != nil {
return err
}
}
return nil
} | |
c176211 |
for k, v := range c.Plank.JobURLPrefixConfig {
if _, err := url.Parse(v); err != nil {
return fmt.Errorf(`Invalid value for Planks job_url_prefix_config["%s"]: %v`, k, err)
}
}
if c.SlackReporter != nil {
if err := c.SlackReporter.DefaultAndValidate(); err != nil {
return fmt.Errorf("failed to validate slackreporter config: %v", err)
}
}
return nil
} | |
c176212 | July 2019, please migrate", DefaultConfigPath)
return DefaultConfigPath
} | |
c176213 | return fmt.Errorf("parsing template: %v", err)
}
c.ReportTemplate = reportTmpl
if c.MaxConcurrency < 0 {
return fmt.Errorf("controller has invalid max_concurrency (%d), it needs to be a non-negative number", c.MaxConcurrency)
}
if c.MaxGoroutines == 0 {
c.MaxGoroutines = 20
}
if c.MaxGoroutines <= 0 {
return fmt.Errorf("controller has invalid max_goroutines (%d), it needs to be a positive number", c.MaxGoroutines)
}
return nil
} | |
c176214 | }
if base.Namespace == nil || *base.Namespace == "" {
s := c.PodNamespace
base.Namespace = &s
}
if base.Cluster == "" {
base.Cluster = kube.DefaultClusterAlias
}
} | |
c176215 | branch regexes for %s: %v", j.Name, err)
}
js[i].Brancher = b
c, err := setChangeRegexes(j.RegexpChangeMatcher)
if err != nil {
return fmt.Errorf("could not set change regexes for %s: %v", j.Name, err)
}
js[i].RegexpChangeMatcher = c
}
return nil
} | |
c176216 |
if re, err := regexp.Compile(strings.Join(br.SkipBranches, `|`)); err == nil {
br.reSkip = re
} else {
return br, fmt.Errorf("could not compile negative branch regex: %v", err)
}
}
return br, nil
} | |
c176217 | := setChangeRegexes(j.RegexpChangeMatcher)
if err != nil {
return fmt.Errorf("could not set change regexes for %s: %v", j.Name, err)
}
ps[i].RegexpChangeMatcher = c
}
return nil
} | |
c176218 |
metadataViewData.FinishedTime.Sub(metadataViewData.StartTime)
}
metadataViewData.Elapsed = metadataViewData.Elapsed.Round(time.Second)
}
metadataViewData.Metadata = map[string]string{"node": started.Node}
metadatas := []metadata.Metadata{started.Metadata, finished.Metadata}
for _, m := range metadatas {
for k, v := range m {
if s, ok := v.(string); ok && v != "" {
metadataViewData.Metadata[k] = s
}
}
}
metadataTemplate, err := template.ParseFiles(filepath.Join(resourceDir, "template.html"))
if err != nil {
return fmt.Sprintf("Failed to load template: %v", err)
}
if err := metadataTemplate.ExecuteTemplate(&buf, "body", metadataViewData); err != nil {
logrus.WithError(err).Error("Error executing template.")
}
return buf.String()
} | |
c176219 |
mux.Handle("/acquirebystate", handleAcquireByState(r))
mux.Handle("/release", handleRelease(r))
mux.Handle("/reset", handleReset(r))
mux.Handle("/update", handleUpdate(r))
mux.Handle("/metric", handleMetric(r))
return mux
} | |
c176220 | case *ranch.ResourceTypeNotFound:
return http.StatusNotFound
case *ranch.StateNotMatch:
return http.StatusConflict
}
} | |
c176221 | if err != nil {
return fmt.Errorf("failed to open %s: %v", destination, err)
}
defer f.Close()
output = f
}
err := cov.DumpProfile(profile, output)
if err != nil {
return fmt.Errorf("failed to dump profile: %v", err)
}
return nil
} | |
c176222 | defer tf.Close()
defer os.Remove(tf.Name())
if _, err := io.Copy(tf, os.Stdin); err != nil {
return nil, fmt.Errorf("failed to copy stdin to temp file: %v", err)
}
filename = tf.Name()
}
return cover.ParseProfiles(filename)
} | |
c176223 |
return nil, err
}
return &Client{
logger: logrus.WithField("client", "git"),
dir: t,
git: g,
base: fmt.Sprintf("https://%s", github),
repoLocks: make(map[string]*sync.Mutex),
}, nil
} | |
c176224 | defer c.credLock.Unlock()
c.user = user
c.tokenGenerator = tokenGenerator
} | |
c176225 | nil {
return fmt.Errorf("error checking out %s: %v. output: %s", commitlike, err, string(b))
}
return nil
} | |
c176226 | branch)
if b, err := co.CombinedOutput(); err != nil {
return fmt.Errorf("error checking out %s: %v. output: %s", branch, err, string(b))
}
return nil
} | |
c176227 |
if b, err := r.gitCommand("merge", "--abort").CombinedOutput(); err != nil {
return false, fmt.Errorf("error aborting merge for commitlike %s: %v. output: %s", commitlike, err, string(b))
}
return false, nil
} | |
c176228 | number, err, string(b))
}
co := r.gitCommand("checkout", fmt.Sprintf("pull%d", number))
if b, err := co.CombinedOutput(); err != nil {
return fmt.Errorf("git checkout failed for PR %d: %v. output: %s", number, err, string(b))
}
return nil
} | |
c176229 | return fmt.Errorf("git config %s %s failed: %v. output: %s", key, value, err, string(b))
}
return nil
} | |
c176230 | {
l.Warningf("Running %s %v returned error %v with output %s.", cmd, arg, err, string(b))
time.Sleep(sleepyTime)
sleepyTime *= 2
continue
}
break
}
return b, err
} | |
c176231 | range labels {
if errs := validation.IsValidLabelValue(value); len(errs) > 0 {
// try to use basename of a path, if path contains invalid //
base := filepath.Base(value)
if errs := validation.IsValidLabelValue(base); len(errs) == 0 {
labels[key] = base
continue
}
logrus.WithFields(logrus.Fields{
"key": key,
"value": value,
"errors": errs,
}).Warn("Removing invalid label")
delete(labels, key)
}
}
annotations := map[string]string{
kube.ProwJobAnnotation: spec.Job,
}
for k, v := range extraAnnotations {
annotations[k] = v
}
return labels, annotations
} | |
c176232 | the unset value as
// false, while kubernetes treats it as true if it is unset because
// it was added in v1.6
if spec.AutomountServiceAccountToken == nil && spec.ServiceAccountName == "" {
myFalse := false
spec.AutomountServiceAccountToken = &myFalse
}
if pj.Spec.DecorationConfig == nil {
spec.Containers[0].Env = append(spec.Containers[0].Env, kubeEnv(rawEnv)...)
} else {
if err := decorate(spec, &pj, rawEnv); err != nil {
return nil, fmt.Errorf("error decorating podspec: %v", err)
}
}
podLabels, annotations := LabelsAndAnnotationsForJob(pj)
return &coreapi.Pod{
ObjectMeta: metav1.ObjectMeta{
Name: pj.ObjectMeta.Name,
Labels: podLabels,
Annotations: annotations,
},
Spec: *spec,
}, nil
} | |
c176233 | filepath.Join(logMount.MountPath, cloneLogPath)
} | |
c176234 | := clonerefs.Encode(opt)
if err != nil {
return nil, err
}
return kubeEnv(map[string]string{clonerefs.JSONConfigEnvVar: cloneConfigEnv}), nil
} | |
c176235 |
SecretName: secret,
DefaultMode: &sshKeyMode,
},
},
}
vm := coreapi.VolumeMount{
Name: name,
MountPath: mountPath,
ReadOnly: true,
}
return v, vm
} | |
c176236 | wrapperOptions,
Timeout: timeout,
AlwaysZero: exitZero,
PreviousMarker: previousMarker,
})
if err != nil {
return nil, err
}
c.Command = []string{entrypointLocation(tools)}
c.Args = nil
c.Env = append(c.Env, kubeEnv(map[string]string{entrypoint.JSONConfigEnvVar: entrypointConfigEnv})...)
c.VolumeMounts = append(c.VolumeMounts, log, tools)
return wrapperOptions, nil
} | |
c176237 | Image: image,
Command: []string{"/bin/cp"},
Args: []string{"/entrypoint", entrypointLocation(toolsMount)},
VolumeMounts: []coreapi.VolumeMount{toolsMount},
}
} | |
c176238 |
var kubeEnvironment []coreapi.EnvVar
for _, key := range keys {
kubeEnvironment = append(kubeEnvironment, coreapi.EnvVar{
Name: key,
Value: environment[key],
})
}
return kubeEnvironment
} | |
c176239 | "" {
return kube.NewClientInCluster(namespace)
}
return kube.NewClientFromFile(o.cluster, namespace)
} | |
c176240 | {
le.Warnf("error while adding Label %q: %v", labels.WorkInProgress, err)
return err
}
} else if !needsLabel && e.hasLabel {
if err := gc.RemoveLabel(e.org, e.repo, e.number, labels.WorkInProgress); err != nil {
le.Warnf("error while removing Label %q: %v", labels.WorkInProgress, err)
return err
}
}
return nil
} | |
c176241 |
req.Header.Set("content-type", "application/json")
c := &http.Client{}
resp, err := c.Do(req)
if err != nil {
return err
}
defer resp.Body.Close()
rb, err := ioutil.ReadAll(resp.Body)
if err != nil {
return err
}
if resp.StatusCode != 200 {
return fmt.Errorf("response from hook has status %d and body %s", resp.StatusCode, string(bytes.TrimSpace(rb)))
}
return nil
} | |
c176242 |
logrus.WithError(err).Errorf("failed to clean up project %s, error info: %s", resource.Name, string(b))
} else {
logrus.Tracef("output from janitor: %s", string(b))
logrus.Infof("successfully cleaned up resource %s", resource.Name)
}
return err
} | |
c176243 | }
if err := c.ReleaseOne(resource.Name, dest); err != nil {
logrus.WithError(err).Error("boskos release failed!")
}
}
} | |
c176244 | Parent context. Shutdown
case <-ctx.Done():
return ctx.Err()
// Current thread context, it may be failing already
case <-derivedCtx.Done():
err = errGroup.Wait()
return err
// Checking for update config
case event := <-configEvent:
newConfig := event.After.PubSubSubscriptions
logrus.Info("Received new config")
if !reflect.DeepEqual(currentConfig, newConfig) {
logrus.Warn("New config found, reloading pull Server")
// Making sure the current thread finishes before starting a new one.
errGroup.Wait()
// Starting a new thread with new config
errGroup, derivedCtx, err = s.handlePulls(ctx, newConfig)
if err != nil {
return err
}
currentConfig = newConfig
}
}
}
} | |
c176245 | TODO(fejta): VM name
if spec.Refs != nil && len(spec.Refs.Pulls) > 0 {
started.Pull = strconv.Itoa(spec.Refs.Pulls[0].Number)
}
started.Repos = map[string]string{}
if spec.Refs != nil {
started.Repos[spec.Refs.Org+"/"+spec.Refs.Repo] = spec.Refs.String()
}
for _, ref := range spec.ExtraRefs {
started.Repos[ref.Org+"/"+ref.Repo] = ref.String()
}
return started
} | |
c176246 | not marshal starting data: %v", err)
}
uploadTargets["started.json"] = gcs.DataUpload(bytes.NewReader(startedData))
if err := o.Options.Run(spec, uploadTargets); err != nil {
return fmt.Errorf("failed to upload to GCS: %v", err)
}
if failed {
return errors.New("cloning the appropriate refs failed")
}
return nil
} | |
c176247 | return true
case github.PullRequestActionSynchronize:
return true
default:
return false
}
} | |
c176248 | repository = ?",
issueOrm.ID, client.RepositoryName())
if err := db.Save(issueOrm).Error; err != nil {
glog.Error("Failed to update database issue: ", err)
}
}
// Issue is updated, find if we have new comments
UpdateComments(*issue.Number, issueOrm.IsPR, db, client)
// and find if we have new events
UpdateIssueEvents(*issue.Number, db, client)
}
} | |
c176249 |
pc.Logger,
pc.GitHubClient,
pc.OwnersClient,
pc.Config.GitHubOptions,
pc.PluginConfig,
&re,
)
} | |
c176250 | if len(match) == 0 {
return 0, nil
}
v, err := strconv.Atoi(match[1])
if err != nil {
return 0, err
}
return v, nil
} | |
c176251 |
// Return an empty config, and use plugin defaults
return &plugins.Approve{}
}()
if a.DeprecatedImplicitSelfApprove == nil && a.RequireSelfApproval == nil && config.UseDeprecatedSelfApprove {
no := false
a.DeprecatedImplicitSelfApprove = &no
}
if a.DeprecatedReviewActsAsApprove == nil && a.IgnoreReviewState == nil && config.UseDeprecatedReviewApprove {
no := false
a.DeprecatedReviewActsAsApprove = &no
}
return a
} | |
c176252 | "github-login.html", nil)))
if o.spyglass {
initSpyglass(cfg, o, mux, nil)
}
return mux
} | |
c176253 | {
covList.NumCoveredStmts += item.NumCoveredStmts
covList.NumAllStmts += item.NumAllStmts
}
} | |
c176254 |
if strings.HasPrefix(c.Name, prefix) {
covList.Group = append(covList.Group, c)
}
}
return s
} | |
c176255 |
var result []string
for key := range dirSet {
result = append(result, key)
}
return result
} | |
c176256 |
var ar admissionapi.AdmissionReview
deserializer := codecs.UniversalDeserializer()
if _, _, err := deserializer.Decode(body, nil, &ar); err != nil {
return nil, fmt.Errorf("decode body: %v", err)
}
return ar.Request, nil
} | |
c176257 | if err != nil {
logrus.WithError(err).Error("read")
}
if err := writeResponse(*req, w, onlyUpdateStatus); err != nil {
logrus.WithError(err).Error("write")
}
} | |
c176258 | Message: err.Error(),
},
}
}
var result admissionapi.AdmissionReview
result.Response = response
result.Response.UID = ar.UID
out, err := json.Marshal(result)
if err != nil {
return fmt.Errorf("encode response: %v", err)
}
if _, err := w.Write(out); err != nil {
return fmt.Errorf("write response: %v", err)
}
return nil
} | |
c176259 | fmt.Errorf("decode new: %v", err)
}
var old prowjobv1.ProwJob
if _, _, err := codecs.UniversalDeserializer().Decode(req.OldObject.Raw, nil, &old); err != nil {
return nil, fmt.Errorf("decode old: %v", err)
}
if equality.Semantic.DeepEqual(old.Spec, new.Spec) {
logrus.Info("accept update with equivalent spec")
return &allow, nil // yes
}
logger.Info("reject") // no
return &reject, nil
} | |
c176260 | case result.Failure != nil:
// failing tests have a completed result with an error
if msg == "" {
msg = "unknown failure"
}
c.Failures = append(c.Failures, resultstore.Failure{
Message: msg,
})
case result.Skipped != nil:
c.Result = resultstore.Skipped
if msg != "" { // skipped results do not require an error, but may.
c.Errors = append(c.Errors, resultstore.Error{
Message: msg,
})
}
}
child.Cases = append(child.Cases, c)
if c.Duration > child.Duration {
child.Duration = c.Duration
}
}
if child.Duration > out.Duration {
// Assume suites run in parallel, so choose max
out.Duration = child.Duration
}
out.Suites = append(out.Suites, child)
}
return out
} | |
c176261 | logrus.WithError(http.ListenAndServe(":"+strconv.Itoa(healthPort), healthMux)).Fatal("ListenAndServe returned.")
}()
return &Health{
healthMux: healthMux,
}
} | |
c176262 | r *http.Request) { fmt.Fprint(w, "OK") })
} | |
c176263 | opener,
path: statusURI,
}
go sc.run()
return &Controller{
logger: logger.WithField("controller", "sync"),
ghc: ghcSync,
prowJobClient: prowJobClient,
config: cfg,
gc: gc,
sc: sc,
changedFiles: &changedFilesAgent{
ghc: ghcSync,
nextChangeCache: make(map[changeCacheKey][]string),
},
History: hist,
}, nil
} | |
c176264 | githubql.StatusStateExpected,
Description: githubql.String(""),
}
} | |
c176265 | names = append(names, string(c.Context))
}
return names
} | |
c176266 | key).WithField("pool", spFiltered).Debug("filtered sub-pool")
lock.Lock()
filtered[key] = spFiltered
lock.Unlock()
} else {
sp.log.WithField("key", key).WithField("pool", spFiltered).Debug("filtering sub-pool removed all PRs")
}
},
)
return filtered
} | |
c176267 | {
if !filterPR(ghc, sp, &pr) {
toKeep = append(toKeep, pr)
}
}
if len(toKeep) == 0 {
return nil
}
sp.prs = toKeep
return sp
} | |
c176268 | for _, pr := range sp.prs {
prs[prKey(&pr)] = pr
}
}
return prs
} | |
c176269 | }
if ctx.State != githubql.StatusStateSuccess {
failed = append(failed, ctx)
}
}
for _, c := range cc.MissingRequiredContexts(contextsToStrings(contexts)) {
failed = append(failed, newExpectedContext(c))
}
log.Debugf("from %d total contexts (%v) found %d failing contexts: %v", len(contexts), contextsToStrings(contexts), len(failed), contextsToStrings(failed))
return failed
} | |
c176270 | psStates[ps.Context]; !ok {
overallState = failureState
log.WithFields(pr.logFields()).Debugf("missing presubmit %s", ps.Context)
break
} else if s == failureState {
overallState = failureState
log.WithFields(pr.logFields()).Debugf("presubmit %s not passing", ps.Context)
break
} else if s == pendingState {
log.WithFields(pr.logFields()).Debugf("presubmit %s pending", ps.Context)
overallState = pendingState
}
}
if overallState == successState {
successes = append(successes, pr)
} else if overallState == pendingState {
pendings = append(pendings, pr)
} else {
nones = append(nones, pr)
}
}
return
} | |
c176271 | the token used cannot push to the branch.
// Even if the robot is set up to have write access to the repo, an
// overzealous branch protection setting will not allow the robot to
// push to a specific branch.
// We won't be able to merge the other PRs.
return false, fmt.Errorf("branch needs to be configured to allow this robot to push: %v", err)
} else if _, ok = err.(github.MergeCommitsForbiddenError); ok {
// GitHub let us know that the merge method configured for this repo
// is not allowed by other repo settings, so we should let the admins
// know that the configuration needs to be updated.
// We won't be able to merge the other PRs.
return false, fmt.Errorf("Tide needs to be configured to use the 'rebase' merge method for this repo or the repo needs to allow merge commits: %v", err)
} else if _, ok = err.(github.UnmergablePRError); ok {
return true, fmt.Errorf("PR is unmergable. Do the Tide merge requirements match the GitHub settings for the repo? %v", err)
} else {
return true, err
}
}
// We ran out of retries. Return the last transient error.
return true, err
} | |
c176272 | }
if changedFiles, ok = c.nextChangeCache[cacheKey]; ok {
c.RUnlock()
return changedFiles, nil
}
c.RUnlock()
// We need to query the changes from GitHub.
changes, err := c.ghc.GetPullRequestChanges(
string(pr.Repository.Owner.Login),
string(pr.Repository.Name),
int(pr.Number),
)
if err != nil {
return nil, fmt.Errorf("error getting PR changes for #%d: %v", int(pr.Number), err)
}
changedFiles = make([]string, 0, len(changes))
for _, change := range changes {
changedFiles = append(changedFiles, change.Filename)
}
c.Lock()
c.nextChangeCache[cacheKey] = changedFiles
c.Unlock()
return changedFiles, nil
}
} | |
c176273 |
c.nextChangeCache = make(map[changeCacheKey][]string)
} | |
c176274 | }),
org: org,
repo: repo,
branch: branch,
sha: sha,
}
}
sps[fn].prs = append(sps[fn].prs, pr)
}
for _, pj := range pjs {
if pj.Spec.Type != prowapi.PresubmitJob && pj.Spec.Type != prowapi.BatchJob {
continue
}
fn := poolKey(pj.Spec.Refs.Org, pj.Spec.Refs.Repo, pj.Spec.Refs.BaseRef)
if sps[fn] == nil || pj.Spec.Refs.BaseSHA != sps[fn].sha {
continue
}
sps[fn].pjs = append(sps[fn].pjs, pj)
}
return sps, nil
} | |
c176275 | aggregateProfiles, err := MergeMultipleProfiles(setProfiles)
if err != nil {
return nil, err
}
return aggregateProfiles, nil
} | |
c176276 | if pc.Blocks[i].Count > 0 {
pc.Blocks[i].Count = 1
}
}
setProfile = append(setProfile, &pc)
}
return setProfile
} | |
c176277 | }
logrus.Info("Before adding resource loop")
for _, res := range data.Resources {
if err := s.AddResource(res); err != nil {
logrus.WithError(err).Errorf("Failed Adding Resources: %s - %s.", res.Name, res.State)
}
logrus.Infof("Successfully Added Resources: %s - %s.", res.Name, res.State)
}
}
return s, nil
} | |
c176278 | error {
return s.resources.Add(resource)
} | |
c176279 | return s.resources.Delete(name)
} | |
c176280 | error {
return s.resources.Update(resource)
} | |
c176281 |
return common.Resource{}, err
}
var res common.Resource
res, err = common.ItemToResource(i)
if err != nil {
return common.Resource{}, err
}
return res, nil
} | |
c176282 |
for _, i := range items {
var res common.Resource
res, err = common.ItemToResource(i)
if err != nil {
return nil, err
}
resources = append(resources, res)
}
sort.Stable(common.ResourceByUpdateTime(resources))
return resources, nil
} | |
c176283 | resource
for _, p := range data {
found := false
for idx := range resources {
exist := resources[idx]
if p.Name == exist.Name {
found = true
logrus.Infof("Keeping resource %s", p.Name)
break
}
}
if !found {
if p.State == "" {
p.State = common.Free
}
logrus.Infof("Adding resource %s", p.Name)
resources = append(resources, p)
if err := s.AddResource(p); err != nil {
logrus.WithError(err).Errorf("unable to add resource %s", p.Name)
finalError = multierror.Append(finalError, err)
}
}
}
return finalError
} | |
c176284 |
var resources []common.Resource
for _, entry := range data.Resources {
resources = append(resources, common.NewResourcesFromConfig(entry)...)
}
return resources, nil
} | |
c176285 | info build.RewriteInfo
build.Rewrite(content, &info)
ndata := build.Format(content)
if !bytes.Equal(src, ndata) && !bytes.Equal(src, beforeRewrite) {
// TODO(mattmoor): This always seems to be empty?
problems[f] = uniqProblems(info.Log)
}
}
return problems, nil
} | |
c176286 | < 0 {
return nil, errInvalidSizeLimit
}
return &PodLogArtifact{
name: jobName,
buildID: buildID,
sizeLimit: sizeLimit,
jobAgent: ja,
}, nil
} | |
c176287 | := url.URL{
Path: "/log",
RawQuery: q.Encode(),
}
return u.String()
} | |
c176288 | if err == io.EOF {
return readBytes, io.EOF
}
if err != nil {
return 0, fmt.Errorf("error reading pod logs: %v", err)
}
return readBytes, nil
} | |
c176289 | err := a.jobAgent.GetJobLog(a.name, a.buildID)
if err != nil {
return nil, fmt.Errorf("error getting pod log: %v", err)
}
return logs, nil
} | |
c176290 |
var byteCount int64
var p []byte
for byteCount < n {
b, err := reader.ReadByte()
if err == io.EOF {
return p, io.EOF
}
if err != nil {
return nil, fmt.Errorf("error reading pod log: %v", err)
}
p = append(p, b)
byteCount++
}
return p, nil
} | |
c176291 | readBytes, err := bytes.NewReader(logs).ReadAt(p, off)
if err != nil && err != io.EOF {
return nil, fmt.Errorf("error reading pod log tail: %v", err)
}
return p[:readBytes], nil
} | |
c176292 | c := range cs {
if c.Position == nil {
continue
}
if !strings.Contains(c.Body, commentTag) {
continue
}
delete(res[c.Path], *c.Position)
}
return res
} | |
c176293 |
// Trim error message to after the line and column numbers
reTrimError := regexp.MustCompile(`(:[0-9]+:[0-9]+: )`)
matches = reTrimError.FindStringSubmatch(err.Error())
if len(matches) > 0 {
newComment.Body = err.Error()[len(matches[0])+errLineIndexStart:]
}
}
lintErrorComments = append(lintErrorComments, newComment)
}
al, err := AddedLines(patch)
if err != nil {
lintErrorComments = append(lintErrorComments,
github.DraftReviewComment{
Path: f,
Body: fmt.Sprintf("computing added lines in %s: %v", f, err),
})
}
for _, p := range ps {
if pl, ok := al[p.Position.Line]; ok {
problems[f][pl] = p
}
}
}
return problems, lintErrorComments
} | |
c176294 | := range pod.Containers[i].Env {
if !removeEnvNames.Has(env.Name) {
filteredEnv = append(filteredEnv, env)
}
}
pod.Containers[i].Env = filteredEnv
filteredVolumeMounts := []coreapi.VolumeMount{}
for _, mount := range pod.Containers[i].VolumeMounts {
if !removeVolumeMountNames.Has(mount.Name) {
filteredVolumeMounts = append(filteredVolumeMounts, mount)
}
}
pod.Containers[i].VolumeMounts = filteredVolumeMounts
}
} | |
c176295 | for _, preset := range presets {
undoPreset(&preset, presubmit.Labels, presubmit.Spec)
}
} | |
c176296 | regexp.MustCompile("(?m)[\n]+^[^\n]+: null$")
return nullRE.ReplaceAll(yamlBytes, []byte{})
} | |
c176297 |
files := c.GetEntries()
sort.Slice(files, func(i, j int) bool {
return files[i].LastAccess.Before(files[j].LastAccess)
})
// evict until we pass the safe threshold so we don't thrash at the eviction trigger
for blocksFree < evictUntilPercentBlocksFree {
if len(files) < 1 {
logger.Fatal("Failed to find entries to evict!")
}
// pop entry and delete
var entry diskcache.EntryInfo
entry, files = files[0], files[1:]
err = c.Delete(c.PathToKey(entry.Path))
if err != nil {
logger.WithError(err).Errorf("Error deleting entry at path: %v", entry.Path)
} else {
promMetrics.FilesEvicted.Inc()
promMetrics.LastEvictedAccessAge.Set(time.Now().Sub(entry.LastAccess).Hours())
}
// get new disk usage
blocksFree, _, _, err = diskutil.GetDiskUsage(diskRoot)
logger = logrus.WithFields(logrus.Fields{
"sync-loop": "MonitorDiskAndEvict",
"blocks-free": blocksFree,
})
if err != nil {
logrus.WithError(err).Error("Failed to get disk usage!")
continue
}
}
logger.Info("Done evicting")
}
}
} | |
c176298 | Add any applicable repos in repos2 to excepts
for _, repo := range c2.repos.UnsortedList() {
if parts := strings.SplitN(repo, "/", 2); len(parts) == 2 && parts[0] == org {
excepts.Insert(repo)
}
}
res.orgExceptions[org] = excepts
}
}
res.repos = res.repos.Difference(c2.repos)
for _, repo := range res.repos.UnsortedList() {
if parts := strings.SplitN(repo, "/", 2); len(parts) == 2 {
if excepts2, ok := c2.orgExceptions[parts[0]]; ok && !excepts2.Has(repo) {
res.repos.Delete(repo)
}
}
}
return res
} | |
c176299 | are
// covered by an org already; we know from above that no
// org blacklist in the result will contain a repo whitelist
for _, repo := range c.repos.Union(c2.repos).UnsortedList() {
parts := strings.SplitN(repo, "/", 2)
if len(parts) != 2 {
logrus.Warnf("org/repo %q is formatted incorrectly", repo)
continue
}
if _, exists := res.orgExceptions[parts[0]]; !exists {
res.repos.Insert(repo)
}
}
return res
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.