-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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(storage): add gRPC quickstart sample #4438
Conversation
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.
Few minor comments, otherwise lgtm
|
||
stdOut, stdErr, err := m.Run(nil, time.Minute, "--project", tc.ProjectID, "--bucket", bucketName) | ||
|
||
if err != nil { |
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.
Should we also specifically check for the error about directPath not being enabled or metrics not being enabled? Do we want to try to ensure that these things work properly for the test?
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.
Warning wasn't implemented into the new auth code path introduced in recent releases and didn't see that until now. filed issue: googleapis/google-cloud-go#11001
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.
My point was that we probably don't want to be getting these warnings, right? We want to quickstart to be able to run without warnings if the project has the correct permissions.
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.
Failed to enable client metrics isn't logged with existing tests. However, current implementation is emitting a warning that the Resource Detector detected a different project compared to the project used by the Go client. Can talk through this with you when you're back on.
) | ||
|
||
const ( | ||
testPrefix = "test-gcs-grpc-team" |
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.
Do we still need an allowlisted prefix now that this is GA? Let's just say storage-grpc-quickstart-test maybe?
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.
Yes it's still required; fails otherwise.
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.
Hmm when is the allowlist dropped?
Let's use the same prefix we use in the storage client integration tests ("golang-grpc-test").
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.
Updated as it's not longer required.
defer client.Close() | ||
|
||
// Creates a Bucket instance. | ||
bucket := client.Bucket(*bucketName) |
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.
This doesn't need to be a separate line of code and comment; can just do client.Bucket(*bucketName).Create() on L52 instead.
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.
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.
Package names need to match if stored in the same directory which means we can't use main() for both. I need to put it into a different directory at least in Golang.
https://pkg.go.dev/golang.org/x/tools/internal/typesinternal#MismatchedPkgName
Moving into separate directory to unblock PR.
ctx := context.Background() | ||
|
||
// Expects Google Cloud Platform project ID and Cloud Storage bucket | ||
projectID := flag.String("project", "", "Cloud Platform project id") |
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.
issue: current best practice for samples is to forego a CLI.
See the Sample Style Guide:
https://googlecloudplatform.github.io/samples-style-guide/#no-cli
In the case of Go quickstarts, we've typically just not included tests (not great, I know) so as to have a "main" method.
@@ -0,0 +1,67 @@ | |||
// Copyright 2024 Google LLC |
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.
See previous comment about testing quickstarts.
Description
Fixes b/373643411
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)gofmt
(see Formatting)go vet
(see Formatting)