Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: update generate-library-list.sh for duplicate api_shortnames #2873

Merged
merged 4 commits into from
May 15, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/generateAutoConfigs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ on:
branch_name:
description: PR branch name
required: true
default: "renovate/main-gcp-libraries-bom.version"
default: "renovate/gcp-libraries-bom.version"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this change intentional?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep - it's intentional. You can see the correct branch name here:
image
on #2866

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, I see that main-gcp-libraries-bom is still referenced on line 20 below, which I think probably needs to be updated as well. Do you mind updating it too?

forked_repo:
description: Fork name (enter none if repo branch)
required: true
Expand Down
27 changes: 16 additions & 11 deletions spring-cloud-generator/scripts/generate-library-list.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,16 +23,21 @@ cd ${SPRING_GENERATOR_DIR}
filename=${SPRING_GENERATOR_DIR}/scripts/resources/library_list.txt
echo "# api_shortname, googleapis-folder, distribution_name:version, monorepo_folder" > "$filename"

# loop through folders
# loop through configs for the monorepo (google-cloud-java)
count=0
for d in ./google-cloud-java/*java-*/; do
# parse variables from .repo-metadata.json
language=$(cat $d/.repo-metadata.json | jq -r .language)
api_shortname=$(cat $d/.repo-metadata.json | jq -r .api_shortname)
distribution_name=$(cat $d/.repo-metadata.json | jq -r .distribution_name)
library_type=$(cat $d/.repo-metadata.json | jq -r .library_type)
release_level=$(cat $d/.repo-metadata.json | jq -r .release_level)
monorepo_folder=$(basename $d)
configs=$(yq e '.libraries[]' ./google-cloud-java/generate_config.yaml)
for config_str in $configs; do
# parse variables from generation_config.yaml
config=$(echo "$config_str" | yq e '.') # Parse config_str back to YAML format
unique_module_name=$(echo "$config" | jq -r '.library_name // .api_shortname')
# Determine distribution_name
distribution_name=$(echo "$config" | jq -r '.distribution_name' // "")
if [ -z "$distribution_name" ]; then
distribution_name="com.google.cloud:google-cloud-${unique_module_name}"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did we get the logic from here? It will not work for non-cloud apis, but I think we are not publishing SpringCodeGen for them anyway, so we should be fine.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep, that's correct. And yeah I assumed as much, but I've added an explicit comment about that now

fi
library_type=$(echo "$config" | jq -r '.library_type // "GAPIC_AUTO"') # default to GAPIC_AUTO per https://github.com/googleapis/sdk-platform-java/blob/v2.40.0/library_generation/model/library_config.py#L57
release_level=$(echo "$config" | jq -r '.release_level // "preview"') # default to preview per https://github.com/googleapis/sdk-platform-java/blob/v2.40.0/library_generation/model/library_config.py#L58
monorepo_folder="java/${unique_module_name}"

group_id=$(echo $distribution_name | cut -f1 -d:)
artifact_id=$(echo $distribution_name | cut -f2 -d:)
Expand All @@ -55,9 +60,9 @@ for d in ./google-cloud-java/*java-*/; do
continue
fi

# parse proto path from generation_config.yaml, find by api_shortname
# parse proto path from generation_config.yaml, find by unique_module_name, which will match library_name if it exists, or api_shortname if library_name does not exist
# then sort and keep latest stable version
library=$(yq -r '.libraries[] | select(.api_shortname == "'"$api_shortname"'")' ./google-cloud-java/generation_config.yaml)
library=$(yq -r '.libraries[] | select(.library_name == "'"$unique_module_name"'" or .api_shortname == "'"$unique_module_name"'" )' ./google-cloud-java/generation_config.yaml)
proto_paths_stable=$(echo "$library" | yq -r '.GAPICs[] | select(.proto_path | test("/v[0-9]+$")) | .proto_path')
proto_paths_latest=$(echo "$proto_paths_stable" | sort -d -r | head -n 1)

Expand Down
Loading