in pkg/plugin/cloudlogging/client.go [229:253]
func (c *Client) ListProjectBuckets(ctx context.Context, projectId string) ([]string, error) {
buckets := []string{""}
req := &loggingpb.ListBucketsRequest{
// Request struct fields. Using '-' to get the full list
// See https://pkg.go.dev/cloud.google.com/go/logging/apiv2/loggingpb#ListBucketsRequest
Parent: fmt.Sprintf("projects/%s/locations/-", projectId),
}
it := c.configClient.ListBuckets(ctx, req)
for {
resp, err := it.Next()
if err == iterator.Done {
break
}
if err != nil {
return nil, err
}
// See response format: https://cloud.google.com/logging/docs/reference/v2/rest/v2/billingAccounts.locations.buckets#LogBucket
bucket := strings.Split(resp.Name, "/")
// Get `global/buckets/my-bucket` for `projects/my-project/locations/global/buckets/my-bucket`
buckets = append(buckets, strings.Join(bucket[3:], "/"))
}
return buckets, nil
}