feat: improve configuration of the plugin #1649
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR is the first of a series that is meant to improve the structure
of the gapic generator. This PR improves how the plugin configuration
flow works, and provides a centralized place for new plugin args to be
mapped to specific configuration options. It also makes it easier to do
validation by moving them into the specific options, rather than having
this all in one big parse function.
There's a couple things called out as TODOs for renaming. The point
here is to keep this PR minimally invasive, as it avoids having to visit
the callsites for all the places which rely on the current names. We
can do the renames individually through a series of small followups.
The main oddity here is the error feedback in the option pattern.
Rather than iterating through the args and collecting opts to apply, we
apply them when encountered which lets us fail immediately. We could
collect errors at apply, but I favored a "fail as early as possible"
approach to avoid risks of silently missing validation opportunities.