Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

checkconfig: fix plugin name in verifyLabelPlugin #24244

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions prow/cmd/checkconfig/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ go_library(
"//prow/plugins/bugzilla:go_default_library",
"//prow/plugins/cherrypickunapproved:go_default_library",
"//prow/plugins/hold:go_default_library",
"//prow/plugins/label:go_default_library",
"//prow/plugins/lgtm:go_default_library",
"//prow/plugins/owners-label:go_default_library",
"//prow/plugins/releasenote:go_default_library",
Expand Down
3 changes: 2 additions & 1 deletion prow/cmd/checkconfig/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ import (
"k8s.io/test-infra/prow/plugins/bugzilla"
"k8s.io/test-infra/prow/plugins/cherrypickunapproved"
"k8s.io/test-infra/prow/plugins/hold"
labelplugin "k8s.io/test-infra/prow/plugins/label"
"k8s.io/test-infra/prow/plugins/lgtm"
ownerslabel "k8s.io/test-infra/prow/plugins/owners-label"
"k8s.io/test-infra/prow/plugins/releasenote"
Expand Down Expand Up @@ -1064,7 +1065,7 @@ func verifyLabelPlugin(label plugins.Label) error {
if len(orgRepos) > 0 {
sort.Strings(orgRepos)
return fmt.Errorf("the following orgs or repos have configuration of %s plugin using the empty string as label name in restricted labels: %s",
verifyowners.PluginName, strings.Join(orgRepos, ", "),
labelplugin.PluginName, strings.Join(orgRepos, ", "),
)
}
return nil
Expand Down
10 changes: 5 additions & 5 deletions prow/cmd/checkconfig/main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -462,19 +462,19 @@ triggers:
// kube/kube:
// - size
// - config-updater
//config_updater:
// config_updater:
// maps:
// # Update the plugins configmap whenever plugins.yaml changes
// kube/plugins.yaml:
// name: plugins
// kube/config.yaml:
// validation: config
//size:
// size:
// s: 1`),
// expectedErr: "validation",
// },
{
//only one invalid element is printed in the error
// only one invalid element is printed in the error
name: "multiple invalid elements",
filename: "multiple.yaml",
cfg: &plugins.Configuration{},
Expand Down Expand Up @@ -2246,7 +2246,7 @@ func TestVerifyLabelPlugin(t *testing.T) {
},
},
},
expectedErrorMsg: "the following orgs or repos have configuration of verify-owners plugin using the empty string as label name in restricted labels: openshift/machine-config-operator",
expectedErrorMsg: "the following orgs or repos have configuration of label plugin using the empty string as label name in restricted labels: openshift/machine-config-operator",
},
{
name: "valid after removing the restricted labels for the empty string",
Expand Down Expand Up @@ -2279,7 +2279,7 @@ func TestVerifyLabelPlugin(t *testing.T) {
},
},
},
expectedErrorMsg: "the following orgs or repos have configuration of verify-owners plugin using the empty string as label name in restricted labels: orgRepo1, orgRepo2",
expectedErrorMsg: "the following orgs or repos have configuration of label plugin using the empty string as label name in restricted labels: orgRepo1, orgRepo2",
},
}

Expand Down
8 changes: 5 additions & 3 deletions prow/plugins/label/label.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,9 @@ import (
"k8s.io/test-infra/prow/plugins"
)

const pluginName = "label"
const (
PluginName = "label"
)

var (
defaultLabels = []string{"kind", "priority", "area"}
Expand All @@ -43,7 +45,7 @@ var (
)

func init() {
plugins.RegisterGenericCommentHandler(pluginName, handleGenericComment, helpProvider)
plugins.RegisterGenericCommentHandler(PluginName, handleGenericComment, helpProvider)
}

func configString(labels []string) string {
Expand All @@ -64,7 +66,7 @@ func helpProvider(config *plugins.Configuration, _ []config.OrgRepo) (*pluginhel
},
})
if err != nil {
logrus.WithError(err).Warnf("cannot generate comments for %s plugin", pluginName)
logrus.WithError(err).Warnf("cannot generate comments for %s plugin", PluginName)
}
pluginHelp := &pluginhelp.PluginHelp{
Description: "The label plugin provides commands that add or remove certain types of labels. Labels of the following types can be manipulated: 'area/*', 'committee/*', 'kind/*', 'language/*', 'priority/*', 'sig/*', 'triage/*', and 'wg/*'. More labels can be configured to be used via the /label command.",
Expand Down
2 changes: 1 addition & 1 deletion prow/plugins/label/label_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -762,7 +762,7 @@ func TestLabel(t *testing.T) {
Repo: github.Repo{Owner: github.User{Login: "org"}, Name: "repo"},
User: github.User{Login: tc.commenter},
}
err := handle(fakeClient, logrus.WithField("plugin", pluginName), plugins.Label{AdditionalLabels: tc.extraLabels, RestrictedLabels: tc.restrictedLabels}, e)
err := handle(fakeClient, logrus.WithField("plugin", PluginName), plugins.Label{AdditionalLabels: tc.extraLabels, RestrictedLabels: tc.restrictedLabels}, e)
if err != nil {
t.Fatalf("didn't expect error from label test: %v", err)
}
Expand Down