Skip to content
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 projectNumber field to bucketAttrs. #4805

Merged
merged 8 commits into from Sep 28, 2021
4 changes: 4 additions & 0 deletions storage/bucket.go
Expand Up @@ -337,6 +337,9 @@ type BucketAttrs struct {
// Typical values are "multi-region", "region" and "dual-region".
// This field is read-only.
LocationType string

// The project number of the project the bucket belongs to.
anrajitha marked this conversation as resolved.
Show resolved Hide resolved
ProjectNumber uint64
}

// BucketPolicyOnly is an alias for UniformBucketLevelAccess.
Expand Down Expand Up @@ -597,6 +600,7 @@ func newBucket(b *raw.Bucket) (*BucketAttrs, error) {
PublicAccessPrevention: toPublicAccessPrevention(b.IamConfiguration),
Etag: b.Etag,
LocationType: b.LocationType,
ProjectNumber: b.ProjectNumber,
}, nil
}

Expand Down
10 changes: 6 additions & 4 deletions storage/bucket_test.go
Expand Up @@ -642,10 +642,11 @@ func TestNewBucket(t *testing.T) {
Acl: []*raw.BucketAccessControl{
{Bucket: "name", Role: "READER", Email: "joe@example.com", Entity: "allUsers"},
},
LocationType: "dual-region",
Encryption: &raw.BucketEncryption{DefaultKmsKeyName: "key"},
Logging: &raw.BucketLogging{LogBucket: "lb", LogObjectPrefix: "p"},
Website: &raw.BucketWebsite{MainPageSuffix: "mps", NotFoundPage: "404"},
LocationType: "dual-region",
Encryption: &raw.BucketEncryption{DefaultKmsKeyName: "key"},
Logging: &raw.BucketLogging{LogBucket: "lb", LogObjectPrefix: "p"},
Website: &raw.BucketWebsite{MainPageSuffix: "mps", NotFoundPage: "404"},
ProjectNumber: 123231313,
anrajitha marked this conversation as resolved.
Show resolved Hide resolved
}
want := &BucketAttrs{
Name: "name",
Expand Down Expand Up @@ -695,6 +696,7 @@ func TestNewBucket(t *testing.T) {
ACL: []ACLRule{{Entity: "allUsers", Role: RoleReader, Email: "joe@example.com"}},
DefaultObjectACL: nil,
LocationType: "dual-region",
ProjectNumber: 123231313,
}
got, err := newBucket(rb)
if err != nil {
Expand Down