GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
GeezerVison is showing github.com — chore(librariangen): languagecontainer package to parse release-init request by suztomo · Pull Request #3965 · googleapis/sdk-platform-java
This repository was archived by the owner on Oct 29, 2026. It is now read-only.
Conversation
|
Summary of ChangesHello @suztomo, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request introduces a significant architectural change by creating a new Highlights
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@ ## main #3965 +/- ## ========================================== - Coverage 88.37% 80.27% -8.11% ========================================== Files 6 8 +2 Lines 370 441 +71 ========================================== + Hits 327 354 +27 - Misses 30 68 +38 - Partials 13 19 +6
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| cmd := args[0] | ||
| flags := args[1:] | ||
| switch cmd { | ||
| case "generate": |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
I'll move the generate command parsing here. Once Mike's generate command work stop having conflict.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
I don't have any outstanding PRs right now. I think it's OK to move it. I can deal with the merge with my WIP.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
I'll change that in a subsequent pull request.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
This pull request introduces a new languagecontainer package to abstract command execution, starting with the release-init command. The refactoring in main.go delegates command handling to this new package, which is a good step towards modularity. My feedback focuses on improving robustness by avoiding panics, adhering to structured logging best practices, enhancing test clarity, and addressing a regression in test coverage in main_test.go.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| "github.com/google/go-cmp/cmp" | ||
| ) | ||
|
|
||
| func TestRun(t *testing.T) { |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
This test is from main_test.go
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| "cloud.google.com/java/internal/librariangen/generate" | ||
| ) | ||
|
|
||
| func TestRun(t *testing.T) { |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
This goes to languagecontainer_test.go.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
2d0b042 to
28cb6cd
Compare
…request The languagecontainer package parses the request JSON file and calls the corresponding implementation method. The user (Java's language container in this case) doesn't have to implement the parsing logic and the tests. I moved the argument parsing tests to languagecontainer/languagecontainer_test.go from main_test.go.
28cb6cd to
75337ca
Compare
|
Thank you Gemini Code Assist. I added that to the PR description. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
I think ideally this would be two separate PRs, one for introducing languagecontainer, and another for adding release-init command support.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| case "configure": | ||
| slog.Warn("librariangen: configure command is not yet implemented") | ||
| return 1 | ||
| case "release-init": |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
I think this is a lot code to put into a switch statement. Do you think it would make sense to move it to a separate function, like it was done for generate?
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Let me work on that.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Added handleReleaseInit here.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| cmd := args[0] | ||
| flags := args[1:] | ||
| switch cmd { | ||
| case "generate": |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
I don't have any outstanding PRs right now. I think it's OK to move it. I can deal with the merge with my WIP.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| ) | ||
|
|
||
| // LanguageContainer defines the functions for language-specific container operations. | ||
| type LanguageContainer struct { |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Why not use an interface here?
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
If this is an interface, then there would be package name conflict of languagecontainer/release package (language agostic) and release package (language-specific. In this case Java-specific). Here is a piece of code when I tried to introduce languagecontainer/release and release packages. The naming conflict happened and I had to rename one of them to release2:
package main
import (
... (omit)...
"cloud.google.com/java/internal/librariangen/generate"
release2 "cloud.google.com/java/internal/librariangen/languagecontainer/release"
"cloud.google.com/java/internal/librariangen/message"
"cloud.google.com/java/internal/librariangen/release"
)
... (omit)...
// javaContainer implements the LanguageContainer interface for Java.
type javaContainer struct{}
// ReleaseInit implements the LanguageContainer interface for Java.
func (c *javaContainer) ReleaseInit(ctx context.Context, cfg *release2.Config) (*message.ReleaseInitResponse, error) {
return release.Init(ctx, cfg)
}
I just added this observation in the description of this pull requests.
CC: @codyoss We talked about interface v.s. a struct with functions. I now think the struct is better because we don't have to rename "languagecontainer/release" package when we use (language-specific) "release" package used in main.go.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
I thought about that too, but I think it's more clear if the introduction of languagecontainer has one usage of the package. Subsequent pull requests will be more fine-grained. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| } | ||
|
|
||
| // Run accepts an implementation of the LanguageContainer. | ||
| func Run(args []string, container LanguageContainer) int { |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Should this be a pointer *LanguageContainer?
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Yes, that's a good catch. Updated to use a pointer.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| cmd := args[0] | ||
| flags := args[1:] | ||
| switch cmd { | ||
| case "generate": |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
I would imagine you would check if the passed in LanguageContainer struct includes the corresponding functions, and if so invoke them, otherwise log the warning.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Yes, that's the plan. In this pull requests, LanguageContainer only has ReleaseInit function.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Added that in #3968.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
I approved it, but then I noticed the code coverage dropping by 8.11%. Can you look into this please?
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
@meltsufin I checked the coverage (
|
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
|
I temporarily removed "build (11)", "build (17)", and "showcase (25)". |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
@meltsufin Created #3968. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
…request (#3965) Introducing languagecontainer package. * **New languagecontainer package**: A new `languagecontainer` package has been introduced to encapsulate language-specific container operations and command execution logic, promoting modularity. This package parses the request JSON file and calls the corresponding implementation method in each language container. The languagecontainer package itself should not have language-specific implementation. * **release-init command parsing**: The `languagecontainer.Run` function now includes robust logic to parse `release-init` requests from JSON files, handle command-line flags, and invoke the `ReleaseInit` function. * Why isn't this providing an interface? It's because if `LanguageContainer` is an interface, then there would be package name conflict of `languagecontainer/release` package (language agostic) and `release` package (language-specific. In this case Java-specific). [Here is a piece of code](googleapis/librarian#2516 (comment)). * **Main command dispatch refactor**: The `librariangen` `main.go` has been refactored to delegate non-`generate` commands to the new `languagecontainer.Run` function, centralizing command execution and wiring up `release.Init` for the `release-init` command. * **message.Change struct update**: The `SourceCommitHash` field in the `message.Change` struct has been renamed to `CommitHash` for improved clarity and consistency. This is due to the recent renaming of the field and [google-cloud-go/internal/librariangen/request.Change](https://github.com/googleapis/google-cloud-go/blob/7a85df39319e3a4870d4ad413f714ae5edd78ac8/internal/librariangen/request/request.go#L60) already has the field. The user (Java's language container in this case) doesn't have to implement the parsing logic and the tests. I moved the argument parsing tests to languagecontainer/languagecontainer_test.go from main_test.go.
There was an error while loading. Please reload this page.
Successfully merging this pull request may close these issues.
There was an error while loading. Please reload this page.