Refactor config reading as preparation to reduce plugin config loads

Loading a plugin config with inheritance via
pluginConfigFactory#getProjectPluginConfigWithInheritance(projectName,
pluginName) is not free as it needs to overlay the config with the
configs of the parent projects. All configs are cached in the project
cache but doing the overlaying too often can still get expensive. At the
moment we do the overlaying each time a config parameter is read and
since we have a lot of config parameters that get read all over the
code this sums up.

At the moment to read a config parameter we do:
1. get CodeOwnersPluginConfiguration injected
2. call getFoo(Project.NameKey) or getFoo(BranchNameKey) on the
   CodeOwnersPluginConfiguration

Each codeOwnersPluginConfiguration.getFoo(...) call
invokes pluginConfigFactory#getProjectPluginConfigWithInheritance(projectName,
pluginName).

With this change we refactor these calls to:
codeOwnersPluginConfiguration.getProjectConfig(Project.NameKey).getFoo()
and codeOwnersPluginConfiguration.getProjectConfig(Project.NameKey).getFoo(branchName).

codeOwnersPluginConfiguration.getProjectConfig(Project.NameKey) returns
a CodeOwnersPluginConfigSnapshot.

The advantage of the new CodeOwnersPluginConfigSnapshot class is that it
can cache the loaded plugin config and reuse it for subsequent get
calls. With this change we do not benefit from this yet, since all
places that read a config call
codeOwnersPluginConfiguration.getProjectConfig(Project.NameKey) newly
which each time creates a new CodeOwnersPluginConfigSnapshot instance.
However this will change with the follow-up changes. It's not done in
this change yet, so that the refactoring (this change) is separated from
doing improvements (follow-up changes) and hence is hopefully easier to
review.

Signed-off-by: Edwin Kempin <ekempin@google.com>
Change-Id: I3ac34367fdbcdaac299f2c76725e48415683b82b
30 files changed
tree: 1f05d1fb55d546762f01c4c0a20f1be51503f87f
  1. java/
  2. javatests/
  3. proto/
  4. resources/
  5. test/
  6. ui/
  7. .eslintrc.json
  8. .gitignore
  9. .gitreview
  10. bower.json
  11. BUILD
  12. LICENSE
  13. package-lock.json
  14. package.json
  15. README.md
README.md

Gerrit Code Review code-owners plugin

This plugin provides support for defining code owners for files in a repository.

If the code-owners plugin is enabled, changes can only be submitted if all touched files are covered by approvals from code owners.

Also see resources/Documentation/about.md.

IMPORTANT: Before installing/enabling the plugin follow the instructions from the setup guide, see resources/Documentation/setup-guide.md.