10000 chore: use template excludes in generation config (#2453) · googleapis/sdk-platform-java@ed21464 · GitHub
[go: up one dir, main page]

Skip to content

Commit ed21464

Browse files
authored
chore: use template excludes in generation config (#2453)
In this PR: - Modify `generate_prerequisite_files` to render `owlbot.py` using template excludes from `GenerationConfig`, rather than hard code the excludes. - Add unit tests to verify `from_yaml` method.
1 parent 33ba423 commit ed21464

20 files changed

+235
-25
lines changed

library_generation/generate_composed_library.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,8 @@ def generate_composed_library(
5454
:param library_path: the path to which the generated file goes
5555
:param library: a LibraryConfig object contained inside config, passed here
5656
for convenience and to prevent all libraries to be processed
57-
:param output_folder:
58-
:param versions_file:
57+
:param output_folder: the folder to where tools go
58+
:param versions_file: the file containing version of libraries
5959
:return None
6060
"""
6161
util.pull_api_definition(
@@ -74,6 +74,7 @@ def generate_composed_library(
7474
# owlbot.py) here because transport is parsed from BUILD.bazel,
7575
# which lives in a versioned proto_path.
7676
util.generate_prerequisite_files(
77+
config=config,
7778
library=library,
7879
proto_path=util.remove_version_from(gapic.proto_path),
7980
transport=gapic_inputs.transport,

library_generation/model/generation_config.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ def __init__(
3131
googleapis_commitish: str,
3232
owlbot_cli_image: str,
3333
synthtool_commitish: str,
34-
template_excludes: str,
34+
template_excludes: List[str],
3535
path_to_yaml: str,
3636
libraries: List[LibraryConfig],
3737
grpc_version: Optional[str] = None,
@@ -48,10 +48,11 @@ def __init__(
4848
self.protobuf_version = protobuf_version
4949

5050

51-
def from_yaml(path_to_yaml: str):
51+
def from_yaml(path_to_yaml: str) -> GenerationConfig:
5252
"""
53-
Parses a yaml located in path_to_yaml. Returns the parsed configuration
54-
represented by the "model" classes
53+
Parses a yaml located in path_to_yaml.
54+
:param path_to_yaml: the path to the configuration file
55+
:return the parsed configuration represented by the "model" classes
5556
"""
5657
with open(path_to_yaml, "r") as file_stream:
5758
config = yaml.safe_load(file_stream)

library_generation/requirements.in

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,4 @@ platformdirs==4.1.0
1515
PyYAML==6.0.1
1616
smmap==5.0.1
1717
typing==3.7.4.3
18+
parameterized==0.9.0 # used in parameterized test

library_generation/test/resources/integration/google-cloud-java/generation_config.yaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ protobuf_version: 25.2
33
googleapis_commitish: 1a45bf7393b52407188c82e63101db7dc9c72026
44
owlbot_cli_image: sha256:623647ee79ac605858d09e60c1382a716c125fb776f69301b72de1cd35d49409
55
synthtool_commitish: 6612ab8f3afcd5e292aecd647f0fa68812c9f5b5
6-
destination_path: google-cloud-java
76
template_excludes:
87
- ".github/*"
98
- ".kokoro/*"

library_generation/test/resources/integration/java-bigtable/generation_config.yaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ protobuf_version: 25.2
44
googleapis_commitish: 40203ca1880849480bbff7b8715491060bbccdf1
55
owlbot_cli_image: sha256:623647ee79ac605858d09e60c1382a716c125fb776f69301b72de1cd35d49409
66
synthtool_commitish: 6612ab8f3afcd5e292aecd647f0fa68812c9f5b5
7-
destination_path: java-bigtable
87
template_excludes:
98
- ".gitignore"
109
- ".kokoro/presubmit/integration.cfg"
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
gapic_generator_version: 2.34.0
2+
libraries:
3+
- api_shortname: apigeeconnect
4+
GAPICs:
5+
- proto_path: google/cloud/apigeeconnect/v1
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
gapic_generator_version: 2.34.0
2+
libraries:
3+
- GAPICs:
4+
- proto_path: google/cloud/apigeeconnect/v1
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
gapic_generator_version: 2.34.0
2+
libraries:
3+
random_key:
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
libraries:
2+
- api_shortname: apigeeconnect
3+
name_pretty: Apigee Connect
4+
api_description: "allows the Apigee hybrid management"
5+
product_documentation: "https://cloud.google.com/apigee/docs/hybrid/v1.3/apigee-connect/"
6+
GAPICs:
7+
- proto_path: google/cloud/apigeeconnect/v1
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
gapic_generator_version: 2.34.0
2+
libraries:
3+
- api_shortname: apigeeconnect
4+
name_pretty: Apigee Connect
5+
api_description: "allows the Apigee hybrid management"
6+
product_documentation: "https://cloud.google.com/apigee/docs/hybrid/v1.3/apigee-connect/"
7+
GAPICs:
8+
- proto_path: google/cloud/apigeeconnect/v1

0 commit comments

Comments
 (0)
0