Skip to content

improve experimental configurability of gapic generator #1647

@shollyman

Description

@shollyman

The entrypoint we use for configuring the gapic generator outputs is mediated for the most part via our bazel build definition for go_gapic_library, defined here:

def go_gapic_library(
name,
srcs,
importpath,
deps,
release_level = "",
grpc_service_config = None,
service_yaml = None,
gapic_yaml = None,
metadata = False,
transport = "grpc",
diregapic = False,
rest_numeric_enums = False,
omit_snippets = False,
**kwargs):

The arguments to that rule are currently:

def go_gapic_library(
  name,
  srcs,
  importpath,
  deps,
  release_level = "",
  grpc_service_config = None,
  service_yaml = None,
  gapic_yaml = None,
  metadata = False,
  transport = "grpc",
  diregapic = False,
  rest_numeric_enums = False,
  omit_snippets = False,
  **kwargs):

To enable easier configuration of uncommon/experimental options, I'm proposing the following:

  • accept a list of plugin args directly as part of the bazel rule definition (amended via the other existing options)
  • amend existing BUILD.bazel rules for affected definitions to use new plugin arguments.
  • switch the various hardcoded configs in the generator to use plugin arguments instead
    • ex:
      // keyed by proto package name, e.g. "google.cloud.foo.v1".
      var enableWrapperTypesForPageSize = map[string]bool{
      "google.cloud.bigquery.v2": true,
      }
      // keyed by the API + service name joined by "/", e.g. "storage.googleapis.com/StorageControl".
      var enableDirectPath = map[string]bool{
      "storage.googleapis.com/StorageControl": true,
      // for test purposes.
      "showcase.googleapis.com/Foo": true,
      }
      var enableMtlsHardBoundTokens = map[string]bool{
      "cloudkms.googleapis.com": true,
      "secretmanager.googleapis.com": true,
      "showcase.googleapis.com": true,
      }
    • ex:
      var paginationOverrides = []struct {
      pkgName string
      disallowedMethods []string // methods explicitly denied from pagination
      }{
      {
      pkgName: "google.cloud.talent.v4beta1",
      disallowedMethods: []string{"SearchProfiles", "SearchJobs"},
      },
      {
      pkgName: "google.cloud.bigquery.v2",
      disallowedMethods: []string{"GetQueryResults"},
      },
      }

If we do this in the correct order, we should be able to refactor with a minimal amount of churn.

As options/configs become more standard, we can also hoist them out of the plugin_args and make them first class parts of the bazel definition, or move them into the service config if they're so general that they should be configured through that mechanism.

Metadata

Metadata

Assignees

Labels

priority: p2Moderately-important priority. Fix may not be included in next release.type: feature request‘Nice-to-have’ improvement, new feature or different behavior or design.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions