-
Notifications
You must be signed in to change notification settings - Fork 1.8k
feat: add code samples for Connect Gateway API #5299
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
feat: add code samples for Connect Gateway API #5299
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hello @hodaaaaaaaaaa, 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!
Summary of Changes
This pull request introduces a new sample for connecting to the Connect Gateway. It adds a new directory connectgateway
with Go modules and a sample Go program (list_namespaces.go
) that demonstrates how to list namespaces in a Kubernetes cluster using the GKE Connect Gateway. The pull request also updates the .github/CODEOWNERS
file to include codeowners for the new connectgateway
directory.
Highlights
- New Sample: Connect Gateway: A new sample directory
connectgateway
is added, showcasing how to connect to and interact with the GKE Connect Gateway using Go. - Go Modules: The pull request includes
go.mod
andgo.sum
files for managing dependencies required by the new sample. - List Namespaces Implementation: The
list_namespaces.go
file contains the implementation for listing Kubernetes namespaces using the GKE Connect Gateway. - Codeowners Update: The
.github/CODEOWNERS
file is updated to include the appropriate codeowners for the newconnectgateway
directory.
Changelog
Click here to see the changelog
- .github/CODEOWNERS
- Added
/connectgateway/
with codeowners@GoogleCloudPlatform/go-samples-reviewers
,@GoogleCloudPlatform/cloud-samples-reviewers
, and@GoogleCloudPlatform/connect-gateway
.
- Added
- connectgateway/go.mod
- Added a new go.mod file for the connectgateway sample.
- Specifies the module name as
main
. - Declares dependencies on
cloud.google.com/go/gkeconnect
,golang.org/x/oauth2
,k8s.io/api
,k8s.io/apimachinery
, andk8s.io/client-go
.
- connectgateway/go.sum
- Added a new go.sum file for the connectgateway sample.
- Lists the checksums of the dependencies specified in
go.mod
.
- connectgateway/list_namespaces.go
- Added a new Go program to list Kubernetes namespaces using the GKE Connect Gateway.
- Includes functions to get the Gateway URL, configure the Kubernetes client, and call the List Namespaces API.
- Uses
cloud.google.com/go/gkeconnect/gateway/apiv1
to interact with the GKE Connect Gateway. - Uses
k8s.io/client-go/kubernetes
to interact with the Kubernetes API. - Accepts projectID, membershipID, membershipLocation, and serviceAccountKeyPath as command-line arguments.
- go.mod
- Added
cloud.google.com/go/gkeconnect v0.12.1
as a dependency. - Added
k8s.io/apimachinery v0.32.4
andk8s.io/client-go v0.32.4
as dependencies. - Added indirect dependencies related to kubernetes and other google cloud packages.
- Added
- go.sum
- Added checksums for
cloud.google.com/go/gkeconnect v0.12.1
. - Added checksums for
k8s.io/apimachinery v0.32.4
andk8s.io/client-go v0.32.4
. - Added checksums for indirect dependencies related to kubernetes and other google cloud packages.
- Added checksums for
- go.work
- Added
./connectgateway
to theuse
directive to include the new module in the workspace. - Upgraded go version to 1.25
- Added
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 in your pull request via creating an issue comment (i.e. comment on the pull request page) using either /gemini <command>
or @gemini-code-assist <command>
. Below is a summary of the supported commands.
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 issue 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 is currently in preview and 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 to provide feedback.
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.
A gateway to connect,
Kubernetes namespaces inspect,
Go code takes flight,
Listing with all its might,
Cloud samples, quite correct.
Footnotes
-
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. ↩
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code Review
The pull request introduces a new sample for connecting to a gateway using golang. The code appears to be well-structured and follows common Go practices. However, there are a few areas that could be improved for clarity and robustness.
Summary of Findings
- Error Handling: The error handling in
getGatewayURL
could be improved by providing more context to the user about the specific failure. - Argument Validation: The
main
function could benefit from more robust argument validation to ensure that the program is called with the correct number of arguments and that the arguments are valid. - Dependency Versions: The
go.mod
file has a mix of specific versions and some older versions. It would be good to update these to the latest versions.
Merge Readiness
The pull request introduces a new sample and appears to be well-structured. However, there are a few areas that could be improved for clarity and robustness. I would recommend addressing the high severity issues before merging. I am unable to directly approve this pull request, and recommend that others review and approve this code before merging.
Googlers: see internal bug for updates |
67e268f
to
3a3bc4f
Compare
3a3bc4f
to
c876f0c
Compare
Co-authored-by: Katie McLaughlin <[email protected]>
Here is the summary of changes. You are about to add 1 region tag.
This comment is generated by snippet-bot.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @hodaaaaaaaaaa ,
Thank you for contributing this code sample! Please address the comments and I will take another look.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
From my review, this looks very close to being ready. Thank you for addressing that first round of comments.
@glasnt -- please take another look when you get a chance.
Configuration changes look ok, I'm not a go-language code review to check that content. I would ask why the root go.mod/go.sum files need changing for this sample, but if that's okay, then disregard. |
@telpirion not updating the root go.mod/go.sum breaks the build since ./connectgateway is added to the workspace. Can you comment on whether this update is ok? |
I downgraded the version to 1.23 and removed the parent dir changes. All checks are passing now. |
Description
Fixes b/369653672
Note: Before submitting a pull request, please open an issue for discussion if you are not associated with Google.
Checklist
go test -v ./..
(see Testing)Manually tested as the API call requires extensive setup shttps://cloud.google.com/kubernetes-engine/enterprise/multicluster-management/gateway/setup
gofmt
(see Formatting)go vet
(see Formatting)connectgateway.googleapis.com, gkehub.googleapis.com