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 update time in bucketAttrs #10710

Merged
merged 4 commits into from
Aug 22, 2024

Conversation

shubham-diwakar
Copy link
Contributor

Add update time field in bucketAttrs struct.

Fixes #9361

@shubham-diwakar shubham-diwakar requested review from a team as code owners August 20, 2024 07:29
@product-auto-label product-auto-label bot added the api: storage Issues related to the Cloud Storage API. label Aug 20, 2024
@@ -416,6 +416,10 @@ type BucketAttrs struct {
// This field is read-only.
Created time.Time

// Time at which the bucket was last modified.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: godocs should start with the name of the field; ie Updated is the time at which the bucket was last modified. The linter will complain about this.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

@@ -922,6 +928,7 @@ func (b *BucketAttrs) toRawBucket() *raw.Bucket {
Name: b.Name,
Location: b.Location,
StorageClass: b.StorageClass,
Updated: b.Updated.Format(time.RFC3339),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since the field is read-only, it doesn't have to be included in toRawBucket or toProtoBucket I believe.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

@@ -157,6 +158,7 @@ func TestBucketAttrsToRawBucket(t *testing.T) {
},
PublicAccessPrevention: "enforced",
},
Updated: time.Now().Format("2006-01-02T15:04:05Z07:00"),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this actually work? Wouldn't time.Now() be later when the comparison is made?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Given that this was BucketAttrs to RawBucket Test hence i have removed this.
Although a nice catch, but it was working somehow. Will check why.

@@ -589,6 +589,9 @@ func TestIntegration_BucketUpdate(t *testing.T) {
if !testutil.Equal(attrs.Labels, wantLabels) {
t.Fatalf("add labels: got %v, want %v", attrs.Labels, wantLabels)
}
if !attrs.Created.Before(attrs.Updated) {
t.Fatal("attrs.Updated should be newer than attrs.Created")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: These checks should be Errorf rather than Fatalf because they don't need to stop the execution of the remainder of the test.

Also, include both timestamps in the error for debugging purposes, something like:
got attrs.Updated %v before attrs.Created %v, want Attrs.Updated to be after

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Have changed up.

Reason behind picking Fatalf was that Bucket Attributes should update given that this was not done hence i thought tests should stop. Also all other checks where fatalf only.

@tritone tritone added the kokoro:run Add this label to force Kokoro to re-run the tests. label Aug 21, 2024
@kokoro-team kokoro-team removed the kokoro:run Add this label to force Kokoro to re-run the tests. label Aug 21, 2024
@tritone tritone added kokoro:run Add this label to force Kokoro to re-run the tests. automerge Merge the pull request once unit tests and other checks pass. labels Aug 22, 2024
@gcf-merge-on-green gcf-merge-on-green bot merged commit 5f06ae1 into googleapis:main Aug 22, 2024
8 checks passed
@gcf-merge-on-green gcf-merge-on-green bot removed the automerge Merge the pull request once unit tests and other checks pass. label Aug 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api: storage Issues related to the Cloud Storage API. kokoro:run Add this label to force Kokoro to re-run the tests.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

storage: bucketAttrs class in bucket.go does not have Updated field for last modification time for bucket
3 participants