Skip to content

Commit

Permalink
Merge branch 'master' into regen_gocloud
Browse files Browse the repository at this point in the history
  • Loading branch information
codyoss committed Jan 22, 2021
2 parents 160164a + 9b9c3dc commit e5ad229
Show file tree
Hide file tree
Showing 9 changed files with 93 additions and 8 deletions.
6 changes: 3 additions & 3 deletions .github/CODEOWNERS
Validating CODEOWNERS rules …
@@ -1,10 +1,10 @@
# Default owner for all directories not owned by others
* @googleapis/yoshi-go-admins

/bigtable/ @tritone @googleapis/yoshi-go-admins
/bigtable/ @crwilcox @tritone @googleapis/yoshi-go-admins
/bigquery/ @googleapis/api-bigquery @googleapis/yoshi-go-admins
/datastore/ @tritone @googleapis/yoshi-go-admins
/firestore/ @tritone @googleapis/yoshi-go-admins
/datastore/ @crwilcox @tritone @googleapis/yoshi-go-admins
/firestore/ @crwilcox @tritone @googleapis/yoshi-go-admins
/pubsub/ @googleapis/api-pubsub @googleapis/yoshi-go-admins
/pubsublite/ @googleapis/api-pubsub @googleapis/yoshi-go-admins
/spanner/ @skuruppu @googleapis/yoshi-go-admins
Expand Down
3 changes: 3 additions & 0 deletions .github/blunderbuss.yml
Expand Up @@ -3,6 +3,9 @@ assign_issues_by:
- 'api: bigtable'
- 'api: datastore'
- 'api: firestore'
to:
- crwilcox
- labels:
- 'api: storage'
to:
- tritone
Expand Down
4 changes: 2 additions & 2 deletions internal/gapicgen/cmd/genbot/github.go
Expand Up @@ -36,7 +36,7 @@ import (

const (
gocloudBranchName = "regen_gocloud"
gocloudCommitTitle = "feat(all): auto-regenerate gapics"
gocloudCommitTitle = "chore(all): auto-regenerate gapics"
gocloudCommitBody = `
This is an auto-generated regeneration of the gapic clients by
cloud.google.com/go/internal/gapicgen. Once the corresponding genproto PR is
Expand All @@ -51,7 +51,7 @@ If you have been assigned to review this PR, please:
`

genprotoBranchName = "regen_genproto"
genprotoCommitTitle = "feat(all): auto-regenerate .pb.go files"
genprotoCommitTitle = "chore(all): auto-regenerate .pb.go files"
genprotoCommitBody = `
This is an auto-generated regeneration of the .pb.go files by
cloud.google.com/go/internal/gapicgen. Once this PR is submitted, genbot will
Expand Down
9 changes: 8 additions & 1 deletion internal/godocfx/parse.go
Expand Up @@ -339,9 +339,16 @@ func buildTOC(mod string, pis []pkgInfo, extraFiles []extraFile) tableOfContents
toc := tableOfContents{}

modTOC := &tocItem{
UID: mod, // Assume the module root has a package.
UID: mod,
Name: mod,
}

// Assume the module root has a package.
modTOC.addItem(&tocItem{
UID: mod,
Name: mod,
})

for _, ef := range extraFiles {
modTOC.addItem(&tocItem{
Href: ef.dstRelativePath,
Expand Down
2 changes: 2 additions & 0 deletions internal/godocfx/testdata/golden/toc.yml
Expand Up @@ -2,5 +2,7 @@
- uid: cloud.google.com/go/storage
name: cloud.google.com/go/storage
items:
- uid: cloud.google.com/go/storage
name: cloud.google.com/go/storage
- name: README
href: pkg-readme.md
4 changes: 3 additions & 1 deletion pubsublite/internal/wire/publish_batcher_test.go
Expand Up @@ -253,7 +253,9 @@ func TestPublishBatcherBundlerBatchingDelay(t *testing.T) {
if err := batcher.AddMessage(msg1, nil); err != nil {
t.Errorf("AddMessage(%v) got err: %v", msg1, err)
}
time.Sleep(settings.DelayThreshold * 2)
// Wait much longer than DelayThreshold to prevent test flakiness, as the
// Bundler may place the messages in the same batch.
time.Sleep(settings.DelayThreshold * 5)
if err := batcher.AddMessage(msg2, nil); err != nil {
t.Errorf("AddMessage(%v) got err: %v", msg2, err)
}
Expand Down
6 changes: 5 additions & 1 deletion storage/bucket.go
Expand Up @@ -1204,7 +1204,11 @@ func (it *ObjectIterator) Next() (*ObjectAttrs, error) {
func (it *ObjectIterator) fetch(pageSize int, pageToken string) (string, error) {
req := it.bucket.c.raw.Objects.List(it.bucket.name)
setClientHeader(req.Header())
req.Projection("full")
projection := it.query.Projection
if projection == ProjectionDefault {
projection = ProjectionFull
}
req.Projection(projection.String())
req.Delimiter(it.query.Delimiter)
req.Prefix(it.query.Prefix)
req.StartOffset(it.query.StartOffset)
Expand Down
37 changes: 37 additions & 0 deletions storage/integration_test.go
Expand Up @@ -698,6 +698,7 @@ func TestIntegration_Objects(t *testing.T) {
testObjectsIterateSelectedAttrs(t, bkt, objects)
testObjectsIterateAllSelectedAttrs(t, bkt, objects)
testObjectIteratorWithOffset(t, bkt, objects)
testObjectsIterateWithProjection(t, bkt)
t.Run("testObjectsIterateSelectedAttrsDelimiter", func(t *testing.T) {
query := &Query{Prefix: "", Delimiter: "/"}
if err := query.SetAttrSelection([]string{"Name"}); err != nil {
Expand Down Expand Up @@ -1236,6 +1237,42 @@ func testObjectsIterateAllSelectedAttrs(t *testing.T, bkt *BucketHandle, objects
}
}

func testObjectsIterateWithProjection(t *testing.T, bkt *BucketHandle) {
projections := map[Projection]bool{
ProjectionDefault: true,
ProjectionFull: true,
ProjectionNoACL: false,
}

for projection, expectACL := range projections {
query := &Query{Projection: projection}
it := bkt.Objects(context.Background(), query)
attrs, err := it.Next()
if err == iterator.Done {
t.Fatalf("iterator: no objects")
}
if err != nil {
t.Fatalf("iterator.Next: %v", err)
}

if expectACL {
if attrs.Owner == "" {
t.Errorf("projection %q: Owner is empty, want nonempty Owner", projection)
}
if len(attrs.ACL) == 0 {
t.Errorf("projection %q: ACL is empty, want at least one ACL rule", projection)
}
} else {
if attrs.Owner != "" {
t.Errorf("projection %q: got Owner = %q, want empty Owner", projection, attrs.Owner)
}
if len(attrs.ACL) != 0 {
t.Errorf("projection %q: got %d ACL rules, want empty ACL", projection, len(attrs.ACL))
}
}
}
}

func TestIntegration_SignedURL(t *testing.T) {
if testing.Short() { // do not test during replay
t.Skip("Integration tests skipped in short mode")
Expand Down
30 changes: 30 additions & 0 deletions storage/storage.go
Expand Up @@ -1306,6 +1306,31 @@ func encodeUint32(u uint32) string {
return base64.StdEncoding.EncodeToString(b)
}

// Projection is enumerated type for Query.Projection.
type Projection int

const (
// ProjectionDefault returns all fields of objects.
ProjectionDefault Projection = iota

// ProjectionFull returns all fields of objects.
ProjectionFull

// ProjectionNoACL returns all fields of objects except for Owner and ACL.
ProjectionNoACL
)

func (p Projection) String() string {
switch p {
case ProjectionFull:
return "full"
case ProjectionNoACL:
return "noAcl"
default:
return ""
}
}

// Query represents a query to filter objects from a bucket.
type Query struct {
// Delimiter returns results in a directory-like fashion.
Expand Down Expand Up @@ -1341,6 +1366,11 @@ type Query struct {
// lexicographically before endOffset. If startOffset is also set, the objects
// listed will have names between startOffset (inclusive) and endOffset (exclusive).
EndOffset string

// Projection defines the set of properties to return. It will default to ProjectionFull,
// which returns all properties. Passing ProjectionNoACL will omit Owner and ACL,
// which may improve performance when listing many objects.
Projection Projection
}

// attrToFieldMap maps the field names of ObjectAttrs to the underlying field
Expand Down

0 comments on commit e5ad229

Please sign in to comment.