Skip to content

Commit

Permalink
Merge pull request kubernetes#27634 from AlexNPavel/bz-disable-cherry…
Browse files Browse the repository at this point in the history
…picking

plugins/bugzilla: add EnableBackporting branch option
  • Loading branch information
k8s-ci-robot authored Jan 6, 2023
2 parents 7615b60 + 31d1296 commit 0de7d15
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 21 deletions.
32 changes: 19 additions & 13 deletions prow/plugins/bugzilla/bugzilla.go
Original file line number Diff line number Diff line change
Expand Up @@ -544,18 +544,20 @@ type querySearch struct {
Edges []queryEdge
}

/* emailToLoginQuery is a graphql query struct that should result in this graphql query:
{
search(type: USER, query: "email", first: 5) {
edges {
node {
... on User {
login
}
}
}
}
}
/*
emailToLoginQuery is a graphql query struct that should result in this graphql query:
{
search(type: USER, query: "email", first: 5) {
edges {
node {
... on User {
login
}
}
}
}
}
*/
type emailToLoginQuery struct {
Search querySearch `graphql:"search(type:USER query:$email first:5)"`
Expand Down Expand Up @@ -612,7 +614,11 @@ func handle(e event, gc githubClient, bc bugzilla.Client, options plugins.Bugzil
}
// cherrypicks follow a different pattern than normal validation
if e.cherrypick {
return handleCherrypick(e, gc, bc, options, log)
if *options.EnableBackporting {
return handleCherrypick(e, gc, bc, options, log)
} else {
return nil
}
}

var needsValidLabel, needsInvalidLabel bool
Expand Down
16 changes: 8 additions & 8 deletions prow/plugins/bugzilla/bugzilla_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1433,7 +1433,7 @@ Instructions for interacting with me using PR comments are available [here](http
cherryPick: true,
cherryPickFromPRNum: 1,
cherryPickTo: "v1",
options: plugins.BugzillaBranchOptions{TargetRelease: &v1},
options: plugins.BugzillaBranchOptions{TargetRelease: &v1, EnableBackporting: &yes},
expectedComment: `org/repo#1:@user: [Bugzilla bug 123](www.bugzilla/show_bug.cgi?id=123) has been cloned as [Bugzilla bug 124](www.bugzilla/show_bug.cgi?id=124). Retitling PR to link against new bug.
/retitle [v1] Bug 124: fixed it!
Expand All @@ -1457,7 +1457,7 @@ Instructions for interacting with me using PR comments are available [here](http
cherryPick: true,
cherryPickFromPRNum: 1,
cherryPickTo: "v1",
options: plugins.BugzillaBranchOptions{TargetRelease: &v1},
options: plugins.BugzillaBranchOptions{TargetRelease: &v1, EnableBackporting: &yes},
expectedComment: `org/repo#1:@user: Error creating a cherry-pick bug in Bugzilla: failed to check the state of cherrypicked pull request at https://github.com/org/repo/pull/1: pull request number 1 does not exist.
Please contact an administrator to resolve this issue, then request a bug refresh with <code>/bugzilla refresh</code>.
Expand All @@ -1481,7 +1481,7 @@ Instructions for interacting with me using PR comments are available [here](http
cherryPick: true,
cherryPickFromPRNum: 1,
cherryPickTo: "v1",
options: plugins.BugzillaBranchOptions{TargetRelease: &v1},
options: plugins.BugzillaBranchOptions{TargetRelease: &v1, EnableBackporting: &yes},
expectedComment: `org/repo#1:@user: An error was encountered searching for bug 123 on the Bugzilla server at www.bugzilla. No known errors were detected, please see the full error message for details.
<details><summary>Full error message.</summary>
Expand Down Expand Up @@ -1513,7 +1513,7 @@ Instructions for interacting with me using PR comments are available [here](http
cherryPick: true,
cherryPickFromPRNum: 1,
cherryPickTo: "v1",
options: plugins.BugzillaBranchOptions{TargetRelease: &v1},
options: plugins.BugzillaBranchOptions{TargetRelease: &v1, EnableBackporting: &yes},
expectedComment: `org/repo#1:@user: An error was encountered cloning bug for cherrypick for bug 123 on the Bugzilla server at www.bugzilla. No known errors were detected, please see the full error message for details.
<details><summary>Full error message.</summary>
Expand Down Expand Up @@ -1547,7 +1547,7 @@ Instructions for interacting with me using PR comments are available [here](http
cherryPick: true,
cherryPickFromPRNum: 1,
cherryPickTo: "v1",
options: plugins.BugzillaBranchOptions{TargetRelease: &v1},
options: plugins.BugzillaBranchOptions{TargetRelease: &v1, EnableBackporting: &yes},
expectedComment: `org/repo#1:@user: An error was encountered cloning bug for cherrypick for bug 123 on the Bugzilla server at www.bugzilla. No known errors were detected, please see the full error message for details.
<details><summary>Full error message.</summary>
Expand Down Expand Up @@ -1581,7 +1581,7 @@ Instructions for interacting with me using PR comments are available [here](http
cherryPick: true,
cherryPickFromPRNum: 1,
cherryPickTo: "v1",
options: plugins.BugzillaBranchOptions{TargetRelease: &v1},
options: plugins.BugzillaBranchOptions{TargetRelease: &v1, EnableBackporting: &yes},
expectedComment: `org/repo#1:@user: Detected clone of [Bugzilla bug 123](www.bugzilla/show_bug.cgi?id=123) with correct target release. Retitling PR to link to clone:
/retitle [v1] Bug 124: fixed it!
Expand All @@ -1606,7 +1606,7 @@ Instructions for interacting with me using PR comments are available [here](http
cherryPick: true,
cherryPickFromPRNum: 1,
cherryPickTo: "v1",
options: plugins.BugzillaBranchOptions{TargetRelease: &v1},
options: plugins.BugzillaBranchOptions{TargetRelease: &v1, EnableBackporting: &yes},
expectedComment: `org/repo#1:@user: [Bugzilla bug 123](www.bugzilla/show_bug.cgi?id=123) has been cloned as [Bugzilla bug 125](www.bugzilla/show_bug.cgi?id=125). Retitling PR to link against new bug.
/retitle [v1] Bug 125: fixed it!
Expand Down Expand Up @@ -1635,7 +1635,7 @@ Instructions for interacting with me using PR comments are available [here](http
cherryPick: true,
cherryPickFromPRNum: 1,
cherryPickTo: "v1",
options: plugins.BugzillaBranchOptions{TargetRelease: &v1},
options: plugins.BugzillaBranchOptions{TargetRelease: &v1, EnableBackporting: &yes},
expectedSubComponents: map[int]map[string][]string{
123: {
"TestComponent": {
Expand Down
4 changes: 4 additions & 0 deletions prow/plugins/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -1478,6 +1478,10 @@ type BugzillaBranchOptions struct {
// ExcludeDefaults excludes defaults from more generic Bugzilla configurations.
ExcludeDefaults *bool `json:"exclude_defaults,omitempty"`

// EnableBackporting enables functionality to create new backport bugs for
// cherrypick PRs created by the cherrypick plugin that reference bugzilla bugs.
EnableBackporting *bool

// ValidateByDefault determines whether a validation check is run for all pull
// requests by default
ValidateByDefault *bool `json:"validate_by_default,omitempty"`
Expand Down
12 changes: 12 additions & 0 deletions prow/plugins/plugin-config-documented.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,10 @@ bugzilla:
# The `*` wildcard will apply to all branches.
default:
"":
# EnableBackporting enables functionality to create new backport bugs for
# cherrypick PRs created by the cherrypick plugin that reference bugzilla bugs.
EnableBackporting: false

# AddExternalLink determines whether the pull request will be added to the Bugzilla
# bug using the ExternalBug tracker API after being validated
add_external_link: false
Expand Down Expand Up @@ -180,6 +184,10 @@ bugzilla:
# The `*` wildcard will apply to all branches.
default:
"":
# EnableBackporting enables functionality to create new backport bugs for
# cherrypick PRs created by the cherrypick plugin that reference bugzilla bugs.
EnableBackporting: false

# AddExternalLink determines whether the pull request will be added to the Bugzilla
# bug using the ExternalBug tracker API after being validated
add_external_link: false
Expand Down Expand Up @@ -267,6 +275,10 @@ bugzilla:
# The `*` wildcard will apply to all branches.
branches:
"":
# EnableBackporting enables functionality to create new backport bugs for
# cherrypick PRs created by the cherrypick plugin that reference bugzilla bugs.
EnableBackporting: false

# AddExternalLink determines whether the pull request will be added to the Bugzilla
# bug using the ExternalBug tracker API after being validated
add_external_link: false
Expand Down

0 comments on commit 0de7d15

Please sign in to comment.