Skip to content

Commit

Permalink
fix: nodejs build_gen uses grpc_service_config (#3206)
Browse files Browse the repository at this point in the history
fix: ignore grpc_service_config unless using gapic_v2

fix: use None instead of "" when grpc_service_config is not present
  • Loading branch information
noahdietz committed May 29, 2020
1 parent 23856a0 commit d433cc0
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ go_proto_library(
go_gapic_library(
name = "{{name}}_go_gapic",
srcs = [":{{name}}_proto_with_info"],
grpc_service_config = "{{grpc_service_config}}",
grpc_service_config = {{grpc_service_config}},
importpath = "{{go_gapic_importpath}}",
service_yaml = "{{service_yaml}}",
deps = [
Expand Down Expand Up @@ -242,7 +242,7 @@ load(
nodejs_gapic_library(
name = "{{name}}_nodejs_gapic",
src = ":{{name}}_proto_with_info",
gapic_yaml = "{{gapic_yaml}}",
grpc_service_config = {{grpc_service_config}},
package = "{{package}}",
service_yaml = "{{service_yaml}}",
deps = [],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,12 +49,16 @@ class BazelBuildFileView {
return;
}

String serviceConfigJson = bp.getServiceConfigJsonPath();
if (serviceConfigJson == null) {
serviceConfigJson = "";
// Default grpc_service_config to None, unless there is one present.
tokens.put("grpc_service_config", "None");
if (bp.getServiceConfigJsonPath() != null) {
// Wrap the label in quotes, because the template doesn't supply them
// in case that None is supplied, which is a built-in value.
tokens.put(
"grpc_service_config",
"\"" + convertPathToLabel(bp.getProtoPackage(), bp.getServiceConfigJsonPath()) + "\"");
}

tokens.put("grpc_service_config", convertPathToLabel(bp.getProtoPackage(), serviceConfigJson));
tokens.put("gapic_yaml", convertPathToLabel(bp.getProtoPackage(), bp.getGapicYamlPath()));
tokens.put("service_yaml", convertPathToLabel(bp.getProtoPackage(), bp.getServiceYamlPath()));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@ load(
nodejs_gapic_library(
name = "library_nodejs_gapic",
src = ":library_proto_with_info",
gapic_yaml = "library_example_gapic.yaml",
grpc_service_config = "library_example_grpc_service_config.json",
package = "google.example.library.v1",
service_yaml = "//google/example/library:library_example_v1.yaml",
deps = [],
Expand Down

0 comments on commit d433cc0

Please sign in to comment.