Skip to content

Commit

Permalink
fix(bazel): use None when no service_yaml (#54)
Browse files Browse the repository at this point in the history
When there is no `service_yaml` in the directory, we should generate `None` so that we don't generate garbage like `"{{service_yaml}}"` instead. `None` builds, the latter does not.
  • Loading branch information
noahdietz committed Jun 29, 2021
1 parent 03d2e09 commit 7bdaf87
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ java_gapic_library(
name = "{{name}}_java_gapic",
srcs = [":{{name}}_proto_with_info"],
grpc_service_config = {{grpc_service_config}},
service_yaml = "{{service_yaml}}",
service_yaml = {{service_yaml}},
test_deps = [
":{{name}}_java_grpc",{{java_gapic_test_deps}}
],
Expand Down Expand Up @@ -117,7 +117,7 @@ go_gapic_library(
srcs = [":{{name}}_proto_with_info"],
grpc_service_config = {{grpc_service_config}},
importpath = "{{go_gapic_importpath}}",
service_yaml = "{{service_yaml}}",
service_yaml = {{service_yaml}},
metadata = True,
deps = [
":{{name}}_go_proto",{{go_gapic_deps}}
Expand Down Expand Up @@ -191,7 +191,7 @@ php_gapic_library(
name = "{{name}}_php_gapic",
srcs = [":{{name}}_proto_with_info"],
grpc_service_config = {{grpc_service_config}},
service_yaml = "{{service_yaml}}",
service_yaml = {{service_yaml}},
deps = [
":{{name}}_php_grpc",
":{{name}}_php_proto",
Expand Down Expand Up @@ -224,7 +224,7 @@ nodejs_gapic_library(
extra_protoc_parameters = ["metadata"],
grpc_service_config = {{grpc_service_config}},
package = "{{package}}",
service_yaml = "{{service_yaml}}",
service_yaml = {{service_yaml}},
deps = [],
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,12 @@ class BazelBuildFileView {
"\"" + convertPathToLabel(bp.getProtoPackage(), bp.getServiceConfigJsonPath()) + "\"");
}

tokens.put("service_yaml", convertPathToLabel(bp.getProtoPackage(), bp.getServiceYamlPath()));
String serviceYaml = "None";
if (bp.getServiceYamlPath() != null) {
// Wrap the label in quotations, because None doesn't need them, so they can't be in the template.
serviceYaml = "\""+convertPathToLabel(bp.getProtoPackage(), bp.getServiceYamlPath())+"\"";
}
tokens.put("service_yaml", serviceYaml);

Set<String> javaTests = new TreeSet<>();
for (String service : bp.getServices()) {
Expand Down

0 comments on commit 7bdaf87

Please sign in to comment.