feat(storage): add projectNumber field to bucketAttrs. (#4805)
* feat(storage): add projectNumber field to bucketAttrs.
* Added check to integration Test.
* Added check to integration Test.
* added check in creating/deleting with attributes
Co-authored-by: Brenna N Epp <brennae@google.com>
diff --git a/storage/bucket.go b/storage/bucket.go
index 602c851..f2a59f3 100644
--- a/storage/bucket.go
+++ b/storage/bucket.go
@@ -337,6 +337,10 @@
// 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.
+ // This field is read-only.
+ ProjectNumber uint64
}
// BucketPolicyOnly is an alias for UniformBucketLevelAccess.
@@ -597,6 +601,7 @@
PublicAccessPrevention: toPublicAccessPrevention(b.IamConfiguration),
Etag: b.Etag,
LocationType: b.LocationType,
+ ProjectNumber: b.ProjectNumber,
}, nil
}
diff --git a/storage/bucket_test.go b/storage/bucket_test.go
index 4ff5f5c..3919853 100644
--- a/storage/bucket_test.go
+++ b/storage/bucket_test.go
@@ -642,10 +642,11 @@
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,
}
want := &BucketAttrs{
Name: "name",
@@ -695,6 +696,7 @@
ACL: []ACLRule{{Entity: "allUsers", Role: RoleReader, Email: "joe@example.com"}},
DefaultObjectACL: nil,
LocationType: "dual-region",
+ ProjectNumber: 123231313,
}
got, err := newBucket(rb)
if err != nil {
diff --git a/storage/integration_test.go b/storage/integration_test.go
index f90f1532..e608034 100644
--- a/storage/integration_test.go
+++ b/storage/integration_test.go
@@ -265,6 +265,9 @@
if attrs.LocationType == "" {
t.Error("got an empty LocationType")
}
+ if attrs.ProjectNumber == 0 {
+ t.Errorf("got a zero ProjectNumber")
+ }
h.mustDeleteBucket(b)
// Test Create and Delete with attributes.
@@ -331,6 +334,9 @@
if attrs.LocationType == "" {
t.Error("got an empty LocationType")
}
+ if attrs.ProjectNumber == 0 {
+ t.Errorf("got a zero ProjectNumber")
+ }
h.mustDeleteBucket(b)
}