Skip to content

Commit

Permalink
feat: remove single repo settings (#4)
Browse files Browse the repository at this point in the history
* Revert "feat: allow enable needs-retitle like a non external plugin (#3)"

This reverts commit e5619c5.

* fix: updated npm dependencies
  • Loading branch information
belitre authored Jul 8, 2020
1 parent e5619c5 commit c667db9
Show file tree
Hide file tree
Showing 9 changed files with 269 additions and 1,151 deletions.
69 changes: 0 additions & 69 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

- [Overview](#overview)
- [Configuration](#configuration)
- [Enable only in some repositories of an organization](#enable-only-in-some-repositories-of-an-organization)
- [Build](#build)
- [Deploy](#deploy)

Expand Down Expand Up @@ -78,74 +77,6 @@ You'll need to add new things to your prow `plugins.yaml` file:
- needs-retitle
```
### Enable only in some repositories of an organization
To enable the plugin only in some repositories of the same organization you have two options:
* You can add to the `external_plugins` options all the repositories you want like:
```
external_plugins:
org-foo/repo-bar:
- name: needs-retitle
events:
- pull_request
org-foo/repo-bar-2:
- name: needs-retitle
events:
- pull_request
org-foo/repo-bar-3:
- name: needs-retitle
events:
- pull_request
...
```
* You can use `require_enable_as_not_external`, this way you can enable the plugin for the whole organization at the `external_plugins` config level, and then just add the plugin to each repo like any other plugin, example:
* First we enable the `require_enable_as_not_external` setting for the plugin:
```
needs_retitle:
regexp: "^(fix:|feat:|major:).*$"
require_enable_as_not_external: true
error_message: |
Invalid title for the PR, the title needs to be like:
fix: this is a fix commit
feat: this is a feature commit
major: this is a major commit
```
* Then we enable the plugin for the whole organization in `external_plugins`:
```
external_plugins:
org-foo:
- name: needs-retitle
events:
- pull_request
```
* And now we enable it like any other plugin for the repositories:
```
plugins:
org-foo/test-infra:
- approve
- assign
- config-updater
- needs-retitle
org-foo/my-repo:
- approve
- assign
- lgtm
- needs-retitle
org-foo/another-repo:
- trigger
- needs-retitle
```
## Build
* To make just the binary run: `make build`
Expand Down
6 changes: 2 additions & 4 deletions cmd/needs-retitle/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,9 +99,7 @@ func main() {
log.WithError(err).Fatalf("Error loading plugin config from %q.", o.pluginConfig)
}

p := plugin.NewPlugin(pa)

pca := config.NewPluginConfigAgent(p)
pca := config.NewPluginConfigAgent()
if err := pca.Start(o.pluginConfig); err != nil {
log.WithError(err).Fatalf("Error loading %s config from %q.", plugin.PluginName, o.pluginConfig)
}
Expand All @@ -118,7 +116,7 @@ func main() {

interrupts.TickLiteral(func() {
start := time.Now()
if err := pca.GetPlugin().HandleAll(log, githubClient); err != nil {
if err := pca.GetPlugin().HandleAll(log, githubClient, pa.Config()); err != nil {
log.WithError(err).Error("Error during periodic update of all PRs.")
}
log.WithField("duration", fmt.Sprintf("%v", time.Since(start))).Info("Periodic update complete.")
Expand Down
1 change: 0 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ require (
google.golang.org/genproto v0.0.0-20191108220845-16a3f7862a1a // indirect
gopkg.in/yaml.v2 v2.3.0 // indirect
gopkg.in/yaml.v3 v3.0.0-20200615113413-eeeca48fe776 // indirect
gotest.tools v2.2.0+incompatible
honnef.co/go/tools v0.0.1-2020.1.4 // indirect
k8s.io/test-infra v0.0.0-20200702033203-1e71b3526aef
sigs.k8s.io/yaml v1.2.0
Expand Down
Loading

0 comments on commit c667db9

Please sign in to comment.