Skip to content

Commit 2a744a3

Browse files
authored
[ggj][engx] feat: prevent non-allowlisted APIs from supplying service.yaml (#483)
* fix: swap assertEquals args in JavaWriterVisitorTest to match (expected, actusl) order * fix: swap assertEquals args in ImportWriterVisitorTest to match (expected, actusl) order * fix: add node validator to refactor/centralize null element checks * test: update logging integration goldens with gapic.yaml * feat!: remove gapic.yaml from Bazel and input interface * feat!: remove all per-RPC batching codegen logic * fix: update tests * fix: handle wildcard-only resource_reference * fix: make service.yaml optional * fix: remove iam, longrunning from codegen for all non-iam,longrunning APIs * feat: handle IAM RPCs in pubsub and KMS APIs * feat: prevent non-allowlisted APIs from supplying service.yaml * fix: update goldens
1 parent e1b0a66 commit 2a744a3

5 files changed

Lines changed: 15 additions & 14 deletions

File tree

rules_java_gapic/java_gapic.bzl

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414

1515
load("@com_google_api_codegen//rules_gapic:gapic.bzl", "proto_custom_library", "unzipped_srcjar")
1616

17+
SERVICE_YAML_ALLOWLIST = ["googleads"]
18+
1719
def _java_gapic_postprocess_srcjar_impl(ctx):
1820
gapic_srcjar = ctx.file.gapic_srcjar
1921
output_srcjar_name = ctx.label.name
@@ -91,9 +93,17 @@ def java_gapic_library(
9193
if grpc_service_config:
9294
file_args_dict[grpc_service_config] = "grpc-service-config"
9395

94-
# Currently a no-op.
96+
# Check the allow-list.
9597
if service_yaml:
96-
file_args_dict[service_yaml] = "gapic-service-config"
98+
service_yaml_in_allowlist = False
99+
for keyword in SERVICE_YAML_ALLOWLIST:
100+
if keyword in service_yaml:
101+
service_yaml_in_allowlist = True
102+
break
103+
if service_yaml_in_allowlist:
104+
file_args_dict[service_yaml] = "gapic-service-config"
105+
else:
106+
fail("Service.yaml is no longer supported in the Java microgenerator")
97107

98108
srcjar_name = name + "_srcjar"
99109
raw_srcjar_name = srcjar_name + "_raw"

test/integration/BUILD.bazel

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,6 @@ java_gapic_library(
4646
srcs = ["@com_google_googleapis//google/cloud/asset/v1:asset_proto_with_info"],
4747
grpc_service_config = "@com_google_googleapis//google/cloud/asset/v1:cloudasset_grpc_service_config.json",
4848
package = "google.cloud.asset.v1",
49-
service_yaml = "@com_google_googleapis//google/cloud/asset/v1:cloudasset_v1.yaml",
5049
test_deps = [
5150
"@com_google_googleapis//google/cloud/asset/v1:asset_java_grpc",
5251
"@com_google_googleapis//google/iam/v1:iam_java_grpc",
@@ -88,7 +87,6 @@ java_gapic_library(
8887
srcs = ["redis_proto_with_info"],
8988
grpc_service_config = "@com_google_googleapis//google/cloud/redis/v1:redis_grpc_service_config.json",
9089
package = "google.cloud.redis.v1",
91-
service_yaml = "@com_google_googleapis//google/cloud/redis/v1:redis_v1.yaml",
9290
test_deps = [
9391
"@com_google_googleapis//google/cloud/redis/v1:redis_java_grpc",
9492
],
@@ -113,7 +111,6 @@ java_gapic_library(
113111
srcs = ["@com_google_googleapis//google/logging/v2:logging_proto_with_info"],
114112
grpc_service_config = "@com_google_googleapis//google/logging/v2:logging_grpc_service_config.json",
115113
package = "google.logging.v2",
116-
service_yaml = "@com_google_googleapis//google/logging/v2:logging.yaml",
117114
test_deps = [
118115
"@com_google_googleapis//google/logging/v2:logging_java_grpc",
119116
],

test/integration/goldens/asset/package-info.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,7 @@
1515
*/
1616

1717
/**
18-
* A client to Cloud Asset API
19-
*
20-
* <p>The interfaces provided are listed below, along with usage samples.
18+
* The interfaces provided are listed below, along with usage samples.
2119
*
2220
* <p>======================= AssetServiceClient =======================
2321
*

test/integration/goldens/logging/package-info.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,7 @@
1515
*/
1616

1717
/**
18-
* A client to Cloud Logging API
19-
*
20-
* <p>The interfaces provided are listed below, along with usage samples.
18+
* The interfaces provided are listed below, along with usage samples.
2119
*
2220
* <p>======================= LoggingServiceV2Client =======================
2321
*

test/integration/goldens/redis/package-info.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,7 @@
1515
*/
1616

1717
/**
18-
* A client to Google Cloud Memorystore for Redis API
19-
*
20-
* <p>The interfaces provided are listed below, along with usage samples.
18+
* The interfaces provided are listed below, along with usage samples.
2119
*
2220
* <p>======================= CloudRedisClient =======================
2321
*

0 commit comments

Comments
 (0)