Skip to content

Commit 0c1f1ed

Browse files
authored
Merge branch 'kubevirt:main' into add-charts-repo
2 parents 1d88cf4 + 5b43015 commit 0c1f1ed

File tree

194 files changed

+2290
-3471
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

194 files changed

+2290
-3471
lines changed

.golangci.yaml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,11 @@ linters:
88
disable-all: true
99
enable:
1010
- gocyclo
11-
# - staticcheck
11+
- staticcheck
1212
- unused
13-
# - ineffassign
14-
# - govet
15-
# - gosimple
13+
- govet
14+
- ineffassign
15+
- gosimple
1616
# - errcheck
1717
#linters-settings:
1818
# gocyclo:

Makefile

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,6 @@ flake-issue-creator := robots/cmd/flake-issue-creator
44
querier := robots/cmd/release-querier
55
kubevirtci := robots/cmd/kubevirtci-bumper
66

7-
ifndef GOLANGCI_LINT_VERSION
8-
GOLANGCI_LINT_VERSION=v1.62.2
9-
export GOLANGCI_LINT_VERSION
10-
endif
117
ifndef ARTIFACTS
128
ARTIFACTS=/tmp/artifacts
139
export ARTIFACTS

docs/labels.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,7 @@ larger set of contributors to apply/remove them.
123123
| <a id="release-note" href="#release-note">`release-note`</a> | Denotes a PR that will be considered when it comes time to generate release notes.| prow | [release-note](https://prow.ci.kubevirt.io/command-help#release-note) |
124124
| <a id="release-note-action-required" href="#release-note-action-required">`release-note-action-required`</a> | Denotes a PR that introduces potentially breaking changes that require user action.| prow | [releasenote](https://prow.ci.kubevirt.io/command-help#releasenote) |
125125
| <a id="release-note-none" href="#release-note-none">`release-note-none`</a> | Denotes a PR that doesn't merit a release note.| prow | [release-note](https://prow.ci.kubevirt.io/command-help#release-note) |
126+
| <a id="approved-vep" href="#approved-vep">`approved-vep`</a> | Indicates that a PR is tied to an approved VEP and is prioritized.| approvers | [label](https://prow.ci.kubevirt.io/command-help#label) |
126127

127128
## Labels that apply to kubevirt/containerized-data-importer, only for PRs
128129

external-plugins/botreview/review/result.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -77,14 +77,14 @@ func (r *BasicReviewResult) String() string {
7777
return r.approveComment
7878
} else {
7979
comment := r.disapproveComment
80-
comment += fmt.Sprintf("\n\n<details>\n")
80+
comment += "\n\n<details>\n"
8181
for fileName, hunks := range r.notMatchingHunks {
8282
comment += fmt.Sprintf("\n_%s_", fileName)
8383
for _, hunk := range hunks {
8484
comment += fmt.Sprintf("\n\n~~~diff\n%s\n~~~", string(hunk.Body))
8585
}
8686
}
87-
comment += fmt.Sprintf("\n\n</details>\n")
87+
comment += "\n\n</details>\n"
8888
return comment
8989
}
9090
}
@@ -113,11 +113,11 @@ func (r *BasicReviewResult) ShortString() string {
113113
return r.approveComment
114114
} else {
115115
comment := r.disapproveComment
116-
comment += fmt.Sprintf("\n <details>")
116+
comment += "\n <details>"
117117
for fileName := range r.notMatchingHunks {
118118
comment += fmt.Sprintf("\n * `%s`", fileName)
119119
}
120-
comment += fmt.Sprintf("\n </details>")
120+
comment += "\n </details>"
121121
return comment
122122
}
123123
}

external-plugins/botreview/review/review.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -169,8 +169,8 @@ func (r *Reviewer) AttachReviewComments(botReviewResults []BotReviewResult, gith
169169
if reviewResult.ShouldNotMergeReason() != "" {
170170
shouldNotMergeReasons = append(shouldNotMergeReasons, reviewResult.ShouldNotMergeReason())
171171
}
172-
botReviewComments = append(botReviewComments, fmt.Sprintf("%s", reviewResult))
173-
shortBotReviewComments = append(shortBotReviewComments, fmt.Sprintf(reviewResult.ShortString()))
172+
botReviewComments = append(botReviewComments, reviewResult.String())
173+
shortBotReviewComments = append(shortBotReviewComments, reviewResult.ShortString())
174174
}
175175
approveLabels := unapprovePRComment
176176
if isApproved {

external-plugins/phased/plugin/handler/handler.go

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,14 @@ package handler
33
import (
44
"encoding/json"
55
"fmt"
6-
"io/ioutil"
7-
pi_github "kubevirt.io/project-infra/robots/pkg/github"
8-
kubeVirtLabels "kubevirt.io/project-infra/robots/pkg/github/labels"
6+
"io"
97
"net/http"
108
"os"
119
"os/exec"
1210

11+
pi_github "kubevirt.io/project-infra/robots/pkg/github"
12+
kubeVirtLabels "kubevirt.io/project-infra/robots/pkg/github/labels"
13+
1314
"github.com/sirupsen/logrus"
1415
"sigs.k8s.io/prow/pkg/config"
1516
gitv2 "sigs.k8s.io/prow/pkg/git/v2"
@@ -166,9 +167,7 @@ func (h *GitHubEventsHandler) loadPresubmits(pr github.PullRequest) ([]config.Pr
166167
if index != orgRepo {
167168
continue
168169
}
169-
for _, job := range jobs {
170-
presubmits = append(presubmits, job)
171-
}
170+
presubmits = append(presubmits, jobs...)
172171
}
173172

174173
return presubmits, nil
@@ -203,7 +202,7 @@ func catFile(log *logrus.Logger, gitDir, file, refspec string) ([]byte, int) {
203202
}
204203

205204
func writeTempFile(log *logrus.Logger, basedir string, content []byte) (string, error) {
206-
tmpfile, err := ioutil.TempFile(basedir, "job-config")
205+
tmpfile, err := os.CreateTemp(basedir, "job-config")
207206
if err != nil {
208207
log.WithError(err).Errorf("Could not create temp file for job config.")
209208
return "", err
@@ -229,7 +228,7 @@ func fetchRemoteFile(url string) ([]byte, error) {
229228
return nil, fmt.Errorf("HTTP request failed with status: %v", resp.Status)
230229
}
231230

232-
body, err := ioutil.ReadAll(resp.Body)
231+
body, err := io.ReadAll(resp.Body)
233232
if err != nil {
234233
return nil, err
235234
}
@@ -338,7 +337,7 @@ func loadConfigBytes(h *GitHubEventsHandler, org, repo string) ([]byte, []byte,
338337
}
339338

340339
func (h *GitHubEventsHandler) loadProwConfig(prFullName string) (*config.Config, error) {
341-
tmpdir, err := ioutil.TempDir("", "prow-configs")
340+
tmpdir, err := os.MkdirTemp("", "prow-configs")
342341
if err != nil {
343342
log.WithError(err).Error("Could not create a temp directory to store configs.")
344343
return nil, err

external-plugins/rehearse/plugin/handler/handler.go

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import (
44
"context"
55
"encoding/json"
66
"fmt"
7-
"io/ioutil"
87
"os"
98
"os/exec"
109
"path"
@@ -148,7 +147,7 @@ func (h *GitHubEventsHandler) handleIssueComment(log *logrus.Entry, event *githu
148147
if err != nil {
149148
log.WithError(err).Errorf("Could not get PR number %d", event.Issue.Number)
150149
}
151-
repoClient, err := h.getRebasedRepoClient(log, pr, err, org, repo)
150+
repoClient, err := h.getRebasedRepoClient(log, pr, org, repo)
152151
if err != nil {
153152
log.WithError(err).Error("could not get repo client")
154153
return
@@ -309,7 +308,7 @@ func (h *GitHubEventsHandler) handlePullRequestUpdateEvent(log *logrus.Entry, ev
309308
if err != nil {
310309
log.WithError(err).Errorf("Could not get PR number %d", event.PullRequest.Number)
311310
}
312-
repoClient, err := h.getRebasedRepoClient(log, pr, err, org, repo)
311+
repoClient, err := h.getRebasedRepoClient(log, pr, org, repo)
313312
if err != nil {
314313
log.WithError(err).Error("could not get repo client")
315314
return
@@ -342,7 +341,7 @@ func (h *GitHubEventsHandler) handleRehearsalForPR(log *logrus.Entry, pr *github
342341
log.WithError(err).Errorf("Could not parse repo name: %s", pr.Base.Repo.FullName)
343342
return
344343
}
345-
repoClient, err := h.getRebasedRepoClient(log, pr, err, org, repo)
344+
repoClient, err := h.getRebasedRepoClient(log, pr, org, repo)
346345
if err != nil {
347346
log.WithError(err).Error("could not get repo client")
348347
return
@@ -443,7 +442,7 @@ func (h *GitHubEventsHandler) handleRehearsalForPR(log *logrus.Entry, pr *github
443442
}
444443
}
445444

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) {
447446
log.Debugln("Generating git client")
448447
rebasedRepoClient, err := h.gitClientFactory.ClientFor(org, repo)
449448
if err != nil {
@@ -518,7 +517,10 @@ func (h *GitHubEventsHandler) generateProwJobs(
518517
var jobs []prowapi.ProwJob
519518

520519
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+
}
522524
jobs = append(jobs, h.generatePresubmits(headConfig, baseConfig, pr, eventGUID)...)
523525
}
524526

@@ -594,7 +596,7 @@ func (h *GitHubEventsHandler) loadConfigsAtRef(
594596
changedJobConfigs []string, git gitv2.RepoClient, ref string) (map[string]*config.Config, error) {
595597
configs := map[string]*config.Config{}
596598

597-
tmpdir, err := ioutil.TempDir("", "prow-configs")
599+
tmpdir, err := os.MkdirTemp("", "prow-configs")
598600
if err != nil {
599601
log.WithError(err).Error("Could not create a temp directory to store configs.")
600602
return nil, err
@@ -643,7 +645,7 @@ func (h *GitHubEventsHandler) loadConfigsAtRef(
643645
// directories as we do here
644646
// thus we need to reset the SourcePath to the original value for each job config
645647
for _, presubmits := range pc.PresubmitsStatic {
646-
for index, _ := range presubmits {
648+
for index := range presubmits {
647649
presubmits[index].JobBase.SourcePath = path.Join(git.Directory(), changedJobConfig)
648650
}
649651
}
@@ -697,7 +699,7 @@ func catFile(log *logrus.Logger, gitDir, file, refspec string) ([]byte, int) {
697699
}
698700

699701
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")
701703
if err != nil {
702704
log.WithError(err).Errorf("Could not create temp file for job config.")
703705
return "", err

external-plugins/rehearse/plugin/rehearse_test.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,7 @@ var _ = Describe("Rehearse", func() {
138138
},
139139
},
140140
})
141+
Expect(err).ShouldNot(HaveOccurred())
141142
err = gitrepo.AddCommit("foo", "bar", map[string][]byte{
142143
"jobs-config.yaml": headConfig,
143144
})
@@ -618,6 +619,7 @@ var _ = Describe("Rehearse", func() {
618619
},
619620
},
620621
})
622+
Expect(err).ShouldNot(HaveOccurred())
621623
err = gitrepo.AddCommit("foo", "bar", map[string][]byte{
622624
"jobs-config.yaml": headConfig,
623625
})
@@ -798,6 +800,7 @@ var _ = Describe("Rehearse", func() {
798800
},
799801
},
800802
})
803+
Expect(err).ShouldNot(HaveOccurred())
801804
err = gitrepo.AddCommit("foo", "bar", map[string][]byte{
802805
"jobs-config.yaml": headConfig,
803806
})
@@ -1014,6 +1017,7 @@ var _ = Describe("Rehearse", func() {
10141017
},
10151018
},
10161019
})
1020+
Expect(err).ShouldNot(HaveOccurred())
10171021
err = gitrepo.AddCommit("foo", "bar", map[string][]byte{
10181022
"jobs-config.yaml": headConfig,
10191023
})
@@ -1311,6 +1315,7 @@ var _ = Describe("Rehearse", func() {
13111315
},
13121316
},
13131317
})
1318+
Expect(err).ShouldNot(HaveOccurred())
13141319
err = gitrepo.AddCommit("foo", "bar", map[string][]byte{
13151320
"jobs-config.yaml": headConfig,
13161321
})
@@ -1457,6 +1462,7 @@ var _ = Describe("Rehearse", func() {
14571462
},
14581463
},
14591464
})
1465+
Expect(err).ShouldNot(HaveOccurred())
14601466
err = gitrepo.AddCommit("foo", "bar", map[string][]byte{
14611467
"jobs-config.yaml": headConfig,
14621468
})
@@ -1628,6 +1634,7 @@ var _ = Describe("Rehearse", func() {
16281634
},
16291635
},
16301636
})
1637+
Expect(err).ShouldNot(HaveOccurred())
16311638
err = gitrepo.AddCommit("foo", "bar", map[string][]byte{
16321639
"jobs-config.yaml": headConfig,
16331640
})

external-plugins/release-blocker/server.go

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -284,13 +284,11 @@ func (s *Server) handleIssueComment(l *logrus.Entry, ic github.IssueCommentEvent
284284
if ic.Action != github.IssueCommentActionCreated {
285285
return nil
286286
}
287-
288287
org := ic.Repo.Owner.Login
289288
repo := ic.Repo.Name
290289
num := ic.Issue.Number
291290
commentAuthor := ic.Comment.User.Login
292291

293-
needsLabel := true
294292
targetBranch := ""
295293

296294
l = l.WithFields(logrus.Fields{
@@ -303,10 +301,8 @@ func (s *Server) handleIssueComment(l *logrus.Entry, ic github.IssueCommentEvent
303301
matches := releaseBlockRe.FindAllStringSubmatch(ic.Comment.Body, -1)
304302

305303
if len(cancelMatches) == 1 && len(cancelMatches[0]) == 2 {
306-
needsLabel = false
307304
targetBranch = strings.TrimSpace(cancelMatches[0][1])
308305
} else if len(matches) == 1 && len(matches[0]) == 2 {
309-
needsLabel = true
310306
targetBranch = strings.TrimSpace(matches[0][1])
311307
} else {
312308
// no matches
@@ -333,6 +329,7 @@ func (s *Server) handleIssueComment(l *logrus.Entry, ic github.IssueCommentEvent
333329
WithField("target_branch", targetBranch).
334330
Debug("release-blocker request.")
335331

332+
needsLabel := len(cancelMatches) != 1 || len(cancelMatches[0]) != 2
336333
resp, err := s.handleLabel(targetBranch, org, repo, num, needsLabel)
337334
if err != nil {
338335
s.log.WithFields(l.Data).WithError(err)

external-plugins/test-subset/plugin/handler/handler.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ func init() {
3030
log = logrus.New()
3131
log.SetOutput(os.Stdout)
3232
log.SetFormatter(&logrus.JSONFormatter{})
33+
log.SetLevel(logrus.DebugLevel)
3334
}
3435

3536
type GitHubEvent struct {

0 commit comments

Comments
 (0)