Skip to content

Commit f6706de

Browse files
authored
feat: improve configuration of the plugin (#1649)
* feat: improve configuration of the plugin 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.
1 parent d506312 commit f6706de

File tree

3 files changed

+386
-125
lines changed

3 files changed

+386
-125
lines changed

internal/gengapic/generator.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ func newGenerator(req *pluginpb.CodeGeneratorRequest) (*generator, error) {
121121
},
122122
}
123123

124-
opts, err := parseOptions(req.Parameter)
124+
opts, err := newOptionsFromParams(req.Parameter)
125125
if err != nil {
126126
return nil, err
127127
}

0 commit comments

Comments
 (0)