Skip to content

Merge #290 related changes from main to epic/issue-285-client-v2 - #293

Merged
kyasbal merged 2 commits into
epic/issue-285-api-client-v2from
main
Oct 6, 2025
Merged

Merge #290 related changes from main to epic/issue-285-client-v2#293
kyasbal merged 2 commits into
epic/issue-285-api-client-v2from
main

Conversation

@kyasbal

@kyasbal kyasbal commented Oct 6, 2025

Copy link
Copy Markdown
Member

This is already reviewed on main branch. I'll merge them on epic/issue-285-api-client-v2 just after creating this PR.

@kyasbal
kyasbal merged commit fcc756c into epic/issue-285-api-client-v2 Oct 6, 2025
11 of 12 checks passed
@gemini-code-assist

Copy link
Copy Markdown
Contributor

Summary of Changes

Hello @kyasbal, 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 merges a set of already reviewed changes from the main branch into the epic/issue-285-client-v2 feature branch. The primary change involves a significant refactoring effort to rename the PreviousTaskResult struct to CacheableTaskResult across the codebase. This change aims to enhance the semantic clarity and maintainability of the caching mechanism within the inspection task base and related Google Cloud autocomplete tasks.

Highlights

  • Struct Renaming: The PreviousTaskResult struct has been renamed to CacheableTaskResult to better reflect its purpose and improve code clarity within the caching mechanism.
  • Consistent Type Updates: All references to the PreviousTaskResult struct, including its usage in NewCachedTask functions and various Google Cloud autocomplete tasks, have been updated to use the new CacheableTaskResult name, ensuring consistency across the codebase.
Using Gemini Code Assist

The 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 /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

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 .gemini/ folder in the base of the repository. Detailed instructions can be found here.

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

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Code Review

This pull request primarily renames PreviousTaskResult to CacheableTaskResult across the codebase, which improves clarity. The changes are mostly straightforward refactoring. However, I've identified a couple of issues where errors from NewClient() are being swallowed instead of propagated, which could mask underlying problems. I've also pointed out a minor typo in a function parameter. Please address these points to ensure robustness and maintainability.

client, err := googlecloudapi.DefaultGCPClientFactory.NewClient()
if err != nil {
return inspectiontaskbase.PreviousTaskResult[*googlecloudk8scommon_contract.AutocompleteClusterNameList]{}, nil
return inspectiontaskbase.CacheableTaskResult[*googlecloudk8scommon_contract.AutocompleteClusterNameList]{}, nil

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

high

The error from googlecloudapi.DefaultGCPClientFactory.NewClient() is being swallowed. It should be propagated. This can hide important issues like authentication or configuration problems.

		return inspectiontaskbase.CacheableTaskResult[*googlecloudk8scommon_contract.AutocompleteClusterNameList]{}, err

client, err := googlecloudapi.DefaultGCPClientFactory.NewClient()
if err != nil {
return inspectiontaskbase.PreviousTaskResult[*googlecloudk8scommon_contract.AutocompleteClusterNameList]{}, nil
return inspectiontaskbase.CacheableTaskResult[*googlecloudk8scommon_contract.AutocompleteClusterNameList]{}, nil

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

high

The error from googlecloudapi.DefaultGCPClientFactory.NewClient() is being swallowed. It should be propagated. This can hide important issues like authentication or configuration problems.

		return inspectiontaskbase.CacheableTaskResult[*googlecloudk8scommon_contract.AutocompleteClusterNameList]{}, err

Comment on lines +38 to 39
func NewCachedTask[T any](taskID taskid.TaskImplementationID[T], depdendencies []taskid.UntypedTaskReference, f func(ctx context.Context, prevValue CacheableTaskResult[T]) (CacheableTaskResult[T], error), labelOpt ...coretask.LabelOpt) coretask.Task[T] {
return coretask.NewTask(taskID, depdendencies, func(ctx context.Context) (T, error) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

There's a typo in the parameter name depdendencies. It should be dependencies.

Suggested change
func NewCachedTask[T any](taskID taskid.TaskImplementationID[T], depdendencies []taskid.UntypedTaskReference, f func(ctx context.Context, prevValue CacheableTaskResult[T]) (CacheableTaskResult[T], error), labelOpt ...coretask.LabelOpt) coretask.Task[T] {
return coretask.NewTask(taskID, depdendencies, func(ctx context.Context) (T, error) {
func NewCachedTask[T any](taskID taskid.TaskImplementationID[T], dependencies []taskid.UntypedTaskReference, f func(ctx context.Context, prevValue CacheableTaskResult[T]) (CacheableTaskResult[T], error), labelOpt ...coretask.LabelOpt) coretask.Task[T] {
return coretask.NewTask(taskID, dependencies, func(ctx context.Context) (T, error) {

kyasbal added a commit that referenced this pull request Oct 21, 2025
…using official SDK (#324)

* [fix#285 1/N] feat(api): introduce v2 client factory (#286)

* feat(api): introduce v2 client factory

Introduces a new, more flexible factory for creating Google Cloud service clients eventually replacing the current clients calling REST endpoint for Google Cloud API.

Key features include:
- A `ClientFactory` to centralize client creation for services like Container, GKE Hub, Composer, and Logging.
- A `ResourceContainer` interface to represent different resource scopes (e.g., a project, an organization ...etc)
- A set of `ClientFactoryOptions` to configure authentication using service account keys or token sources, with the ability to apply them per-project.

* fix problems pointed by gemini-code-assist

* Merge #290 related changes from main to epic/issue-285-client-v2 (#293)

* Rename inspectiontaskbase.PreviousTaskResult to CachableTaskResult (#290)

* Fix typo on #290 (#292)

* [fix#285 2/N] feat(api): implement OAuth server for api client v2 (#287)

* [fix#285 2/N] feat(api): added oauth server implementation for client v2

* Fix issues pointed out by gemini-code-assist

* [feat #285 3/N] Implemented a function to convert loggingpb.LogEntry to structured.Node (#289)

* [fix #285 3/N] feat(api): Implement converter function from the log client to KHI's log type

* fixed issues pointed by gemini-code-assist

* Merge main change into epic/issue-285-api-cleint-v2 (#304)

* Rename inspectiontaskbase.PreviousTaskResult to CachableTaskResult (#290)

* Fix typo on #290 (#292)

* feat(server): Add ServerFactory type to configure the gin.Engine (#288)

* feat(server): Add ServerFactory type to configure the gin.Engine instance easier in the initialization phase

Several KHI feature sometimes needs to register API handler on gin.Engine but it was difficult before.
This makes the initialization code under cmd/kubernetes-history-inspector harder. This change introduced a new type ServerFactory used for instancing a new gin.Engine instance.
This type receives Option parameters to extend the server instance. This allows user to extend its behavior just by adding new init() function on cmd/kubernetes-history-inspector or each task package folders.

* fix points pointed out by gemini-code-review

* [feat #285 5-7-1/N] Adding a progress reportable log client with the v2 API client (#301)

* [feat #285 4/N] Add google cloud common task injecting Google Cloud API client (#294)

* [feat #285 4/N] Add google cloud common task injecting Google Cloud API client

* fixed issues pointed out by gemini-code-assist

* Rewrite document about authentication method using ADC (#306)

* Rewrite document about authentication method using ADC

* Fix issues pointed out by gemini-code-assist

* Removed unused part

* Format the command to be multi lined for better readability

* [feat #285 5-1/N] Replace API client to v2 for GKE cluster name auto completion (#295)

* [feat #285 5-1/N] Replace API client to v2 for GKE cluster name auto completion

* fix issues pointed out by gemini-code-assist

* [feat #285 5-2/N] Replace API client to v2 for Cloud Composer cluster name auto completion (#296)

* [feat #285 5-2/N] Replace API client to v2 for CloudComposer cluster name auto completion

* fix issues pointed out by gemini-code-assist

* [feat #285 5-3/N] Replace API client to v2 for GDC baremetal cluster name auto completion (#297)

* [feat #285 5-3/N] Replace API client to v2 for GDC Baremetal cluster name auto completion

* fix issues pointed out by gemini-code-assist

* Added tests for clusterlistfetcher

* [feat #285 5-4/N] Replace API client to v2 for GDC VMware cluster name auto completion (#298)

* [feat #285 5-4/N] Replace API client to v2 for GDC VMWare cluster name auto completion

* fix issues pointed out by gemini-code-assist

* added tests for clusterlistfetcher

* [feat #285 5-5/N] Replace API client to v2 for GKE on AWS cluster name auto completion (#299)

* [feat #285 5-5/N] Replace API client to v2 for GKE on AWS cluster name auto completion

* fix issues pointed out by gemini-code-assist

* [feat #285 5-6/N] Replace API client to v2 for GKE on Azure cluster name auto completion (#300)

* [feat #285 5-6/N] Replace API client to v2 for GKE on Azure cluster name auto completion

* fix issues pointed out by gemini-code-assist

* Make ClientFactory extensible for adding caller options to specific client (#307)

* Merge main branch into epic/issue-285-api-client-v2 (#313)

* Rename inspectiontaskbase.PreviousTaskResult to CachableTaskResult (#290)

* Fix typo on #290 (#292)

* feat(server): Add ServerFactory type to configure the gin.Engine (#288)

* feat(server): Add ServerFactory type to configure the gin.Engine instance easier in the initialization phase

Several KHI feature sometimes needs to register API handler on gin.Engine but it was difficult before.
This makes the initialization code under cmd/kubernetes-history-inspector harder. This change introduced a new type ServerFactory used for instancing a new gin.Engine instance.
This type receives Option parameters to extend the server instance. This allows user to extend its behavior just by adding new init() function on cmd/kubernetes-history-inspector or each task package folders.

* fix points pointed out by gemini-code-review

* fix lint related minor issues (#309)

* fix lint related minor issues

* exclude *.go files under `**/test` folder to be evaluated by "no-testutil-in-non-test-files" rule.
* Use non containerlized golangci-lint when it's available to run them faster.

* fix issues pointed by gemini-code-assist

* [feat #285 5-7-2/N] Adding a progress reportable log client with partitioning time duration (#302)

* [feat #285 5-7-2/N] Adding a progress reportable log client with partitioning time duration

* fix issues pointed out by gemini-code-assist

* Use compute API client to get the list of available regions (#311)

* Use compute API client to get the list of available regions

* fix issues pointed out by gemini-cloud-assist

* [feat #285 5-7-3] Migrate current query_base task implementation to use the api client v2 (#308)

* [feat #285 5-7-3/N] Replace current log fetch base task to use the new types using SDK based client

* fixed issues pointed by gemini-code-assist

* Update epic/issue-285-api-client-v2 to track the latest main branch (#314)

* Rename inspectiontaskbase.PreviousTaskResult to CachableTaskResult (#290)

* Fix typo on #290 (#292)

* feat(server): Add ServerFactory type to configure the gin.Engine (#288)

* feat(server): Add ServerFactory type to configure the gin.Engine instance easier in the initialization phase

Several KHI feature sometimes needs to register API handler on gin.Engine but it was difficult before.
This makes the initialization code under cmd/kubernetes-history-inspector harder. This change introduced a new type ServerFactory used for instancing a new gin.Engine instance.
This type receives Option parameters to extend the server instance. This allows user to extend its behavior just by adding new init() function on cmd/kubernetes-history-inspector or each task package folders.

* fix points pointed out by gemini-code-review

* fix lint related minor issues (#309)

* fix lint related minor issues

* exclude *.go files under `**/test` folder to be evaluated by "no-testutil-in-non-test-files" rule.
* Use non containerlized golangci-lint when it's available to run them faster.

* fix issues pointed by gemini-code-assist

* Made context used in inspection graph extensible from InspectionServer type (#305)

* Made context used in inspection graph extensible from InspectionServer type

* fix issues pointed out by gemini-code-assist

* Enabled OAuth option with the client v2 (#315)

* Enabled OAuth option with the client v2

* fix issues pointed by gemini-code-review

* Complete replacement of API client (#316)

* Complete replacement of API client

* fix issue pointed out by gemini-code-assist

* Rename API package name from `googlecloudv2` to `googlecloud` (#320)

* Implemented CallOptionInjector to inject options required for both clients commonly (#322)

* Add a type to inject options for each API calls

Added CallOptionInjector to provide an option before calling API.
This is implemented for providing header or grpc.Header not supported by gax.

* fix the CI failing issue due to lack of ADC cred

* Merge main into epic/issue-285-api-client-v2 (#323)

* Implemented `--access-token` parameter again just for keeping compatibility with the older versions (#325)

* Implemented `--access-token` parameter again just for keeping compatibility with the older versions

The parameter `--access-token` is now deprecated after we started supporting Application Default Credentials(ADC),
but we wrote many external documents using the parameter. We are going to keep this parameter just only for near future to make our users to migrate their authetication method to ADC.

* fix problems pointed by gemini-code-assist

---------

Signed-off-by: kyasbal <ikakeru@google.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant