|
4 | 4 | "context" |
5 | 5 | "encoding/json" |
6 | 6 | "fmt" |
7 | | - "io/ioutil" |
8 | 7 | "os" |
9 | 8 | "os/exec" |
10 | 9 | "path" |
@@ -148,7 +147,7 @@ func (h *GitHubEventsHandler) handleIssueComment(log *logrus.Entry, event *githu |
148 | 147 | if err != nil { |
149 | 148 | log.WithError(err).Errorf("Could not get PR number %d", event.Issue.Number) |
150 | 149 | } |
151 | | - repoClient, err := h.getRebasedRepoClient(log, pr, err, org, repo) |
| 150 | + repoClient, err := h.getRebasedRepoClient(log, pr, org, repo) |
152 | 151 | if err != nil { |
153 | 152 | log.WithError(err).Error("could not get repo client") |
154 | 153 | return |
@@ -309,7 +308,7 @@ func (h *GitHubEventsHandler) handlePullRequestUpdateEvent(log *logrus.Entry, ev |
309 | 308 | if err != nil { |
310 | 309 | log.WithError(err).Errorf("Could not get PR number %d", event.PullRequest.Number) |
311 | 310 | } |
312 | | - repoClient, err := h.getRebasedRepoClient(log, pr, err, org, repo) |
| 311 | + repoClient, err := h.getRebasedRepoClient(log, pr, org, repo) |
313 | 312 | if err != nil { |
314 | 313 | log.WithError(err).Error("could not get repo client") |
315 | 314 | return |
@@ -342,7 +341,7 @@ func (h *GitHubEventsHandler) handleRehearsalForPR(log *logrus.Entry, pr *github |
342 | 341 | log.WithError(err).Errorf("Could not parse repo name: %s", pr.Base.Repo.FullName) |
343 | 342 | return |
344 | 343 | } |
345 | | - repoClient, err := h.getRebasedRepoClient(log, pr, err, org, repo) |
| 344 | + repoClient, err := h.getRebasedRepoClient(log, pr, org, repo) |
346 | 345 | if err != nil { |
347 | 346 | log.WithError(err).Error("could not get repo client") |
348 | 347 | return |
@@ -443,7 +442,7 @@ func (h *GitHubEventsHandler) handleRehearsalForPR(log *logrus.Entry, pr *github |
443 | 442 | } |
444 | 443 | } |
445 | 444 |
|
446 | | -func (h *GitHubEventsHandler) getRebasedRepoClient(log *logrus.Entry, pr *github.PullRequest, err error, org string, repo string) (gitv2.RepoClient, error) { |
| 445 | +func (h *GitHubEventsHandler) getRebasedRepoClient(log *logrus.Entry, pr *github.PullRequest, org string, repo string) (gitv2.RepoClient, error) { |
447 | 446 | log.Debugln("Generating git client") |
448 | 447 | rebasedRepoClient, err := h.gitClientFactory.ClientFor(org, repo) |
449 | 448 | if err != nil { |
@@ -518,7 +517,10 @@ func (h *GitHubEventsHandler) generateProwJobs( |
518 | 517 | var jobs []prowapi.ProwJob |
519 | 518 |
|
520 | 519 | for path, headConfig := range headConfigs { |
521 | | - baseConfig, _ := baseConfigs[path] |
| 520 | + baseConfig, ok := baseConfigs[path] |
| 521 | + if !ok { |
| 522 | + log.Errorf("Path %s not found in base configs", path) |
| 523 | + } |
522 | 524 | jobs = append(jobs, h.generatePresubmits(headConfig, baseConfig, pr, eventGUID)...) |
523 | 525 | } |
524 | 526 |
|
@@ -594,7 +596,7 @@ func (h *GitHubEventsHandler) loadConfigsAtRef( |
594 | 596 | changedJobConfigs []string, git gitv2.RepoClient, ref string) (map[string]*config.Config, error) { |
595 | 597 | configs := map[string]*config.Config{} |
596 | 598 |
|
597 | | - tmpdir, err := ioutil.TempDir("", "prow-configs") |
| 599 | + tmpdir, err := os.MkdirTemp("", "prow-configs") |
598 | 600 | if err != nil { |
599 | 601 | log.WithError(err).Error("Could not create a temp directory to store configs.") |
600 | 602 | return nil, err |
@@ -643,7 +645,7 @@ func (h *GitHubEventsHandler) loadConfigsAtRef( |
643 | 645 | // directories as we do here |
644 | 646 | // thus we need to reset the SourcePath to the original value for each job config |
645 | 647 | for _, presubmits := range pc.PresubmitsStatic { |
646 | | - for index, _ := range presubmits { |
| 648 | + for index := range presubmits { |
647 | 649 | presubmits[index].JobBase.SourcePath = path.Join(git.Directory(), changedJobConfig) |
648 | 650 | } |
649 | 651 | } |
@@ -697,7 +699,7 @@ func catFile(log *logrus.Logger, gitDir, file, refspec string) ([]byte, int) { |
697 | 699 | } |
698 | 700 |
|
699 | 701 | func writeTempFile(log *logrus.Logger, basedir string, content []byte) (string, error) { |
700 | | - tmpfile, err := ioutil.TempFile(basedir, "job-config") |
| 702 | + tmpfile, err := os.CreateTemp(basedir, "job-config") |
701 | 703 | if err != nil { |
702 | 704 | log.WithError(err).Errorf("Could not create temp file for job config.") |
703 | 705 | return "", err |
|
0 commit comments