-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
feat(storage): add update time in bucketAttrs #10710
Conversation
storage/bucket.go
Outdated
@@ -416,6 +416,10 @@ type BucketAttrs struct { | |||
// This field is read-only. | |||
Created time.Time | |||
|
|||
// Time at which the bucket was last modified. |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
storage/bucket.go
Outdated
@@ -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), |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
storage/bucket_test.go
Outdated
@@ -157,6 +158,7 @@ func TestBucketAttrsToRawBucket(t *testing.T) { | |||
}, | |||
PublicAccessPrevention: "enforced", | |||
}, | |||
Updated: time.Now().Format("2006-01-02T15:04:05Z07:00"), |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
storage/integration_test.go
Outdated
@@ -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") |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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.
01bdeb5
to
67b2c9e
Compare
Add update time field in bucketAttrs struct.
Fixes #9361