chore: update Authorized() function in all tools#2182
Conversation
Summary of ChangesHello @Yuan325, 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 focuses on a significant refactoring effort to standardize the 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
|
There was a problem hiding this comment.
Code Review
This pull request primarily updates the GetAuthTokenHeaderName function signature across a large number of tools to include a resourceMgr parameter and return an error, aligning with a new interface definition. This is a significant and necessary refactoring.
While the PR description mentions updating the Authorized function, the main change is to GetAuthTokenHeaderName. The only change to an Authorized function is a bug fix in postgresreplicationstats/postgresreplicationstats.go which is a good correction.
However, a critical issue has been introduced: the tests for the cloudmonitoring tool are now broken. The refactoring removed fields from the Tool struct, but the tests were not updated to provide the necessary dependencies through the new SourceProvider mechanism, which will cause a panic. Please see the specific comments for details on fixing these tests.
I am having trouble creating individual review comments. Click here to see my feedback.
tests/cloudmonitoring/cloud_monitoring_integration_test.go (56-57)
By removing BaseURL and Client from the Tool struct, the Invoke method now relies on a SourceProvider to get these dependencies. However, the test calls Invoke with a nil SourceProvider (on line 65), which will cause a panic. The test needs to be updated to provide a mock SourceProvider and Source that returns the test server's URL and client.
tests/cloudmonitoring/cloud_monitoring_integration_test.go (102-103)
Similar to the TestTool_Invoke test, removing BaseURL and Client here breaks this test. The Invoke call on line 109 passes nil for the SourceProvider, which will lead to a panic. Please update this test to use a mock SourceProvider.
Update `Authorized()` function in all tools to take a new input parameter -- resourceManager. This was updated for looker tool previously since that tool require access to the source. When running lint and unit tests, this PR also updates the following: * Remove unit tests that checks for Source compatibility or missing Source during initialization. These tests are not relevant since most of the tools only check for source compatibility when it is needed (e.g. during `Invoke()`) * Update sources configs to be exported (specifically alloydbadmin and cloudsqladmin).
Update `Authorized()` function in all tools to take a new input parameter -- resourceManager. This was updated for looker tool previously since that tool require access to the source. When running lint and unit tests, this PR also updates the following: * Remove unit tests that checks for Source compatibility or missing Source during initialization. These tests are not relevant since most of the tools only check for source compatibility when it is needed (e.g. during `Invoke()`) * Update sources configs to be exported (specifically alloydbadmin and cloudsqladmin).
Update `Authorized()` function in all tools to take a new input parameter -- resourceManager. This was updated for looker tool previously since that tool require access to the source. When running lint and unit tests, this PR also updates the following: * Remove unit tests that checks for Source compatibility or missing Source during initialization. These tests are not relevant since most of the tools only check for source compatibility when it is needed (e.g. during `Invoke()`) * Update sources configs to be exported (specifically alloydbadmin and cloudsqladmin).
Update `Authorized()` function in all tools to take a new input parameter -- resourceManager. This was updated for looker tool previously since that tool require access to the source. When running lint and unit tests, this PR also updates the following: * Remove unit tests that checks for Source compatibility or missing Source during initialization. These tests are not relevant since most of the tools only check for source compatibility when it is needed (e.g. during `Invoke()`) * Update sources configs to be exported (specifically alloydbadmin and cloudsqladmin).
Update
Authorized()function in all tools to take a new input parameter -- resourceManager. This was updated for looker tool previously since that tool require access to the source.When running lint and unit tests, this PR also updates the following:
Invoke())