Merge pull request #8225 from AkihiroSuda/comment-image-created-at
metadata: add comments about `Image.CreatedAt`
This commit is contained in:
		@@ -145,6 +145,10 @@ func (s *imageStore) Create(ctx context.Context, image images.Image) (images.Ima
 | 
			
		||||
			return fmt.Errorf("image %q: %w", image.Name, errdefs.ErrAlreadyExists)
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		// The value of `image.CreatedAt` passed from the caller is discarded here.
 | 
			
		||||
		// Ideally we should return an error when the value is already set.
 | 
			
		||||
		// However, as `image.CreatedAt` is defined as a non-pointer `time.Time`, we can't compare it to nil.
 | 
			
		||||
		// And we can't compare it to `time.Time{}` either, as `time.Time{}` is a proper timestamp (1970-01-01 00:00:00).
 | 
			
		||||
		if tm := epoch.FromContext(ctx); tm != nil {
 | 
			
		||||
			image.CreatedAt = tm.UTC()
 | 
			
		||||
		} else {
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user