metadata: add comments about Image.CreatedAt

Signed-off-by: Akihiro Suda <akihiro.suda.cz@hco.ntt.co.jp>
This commit is contained in:
Akihiro Suda 2023-03-08 02:39:34 +09:00
parent 94cf2f5099
commit ff4acdc42e
No known key found for this signature in database
GPG Key ID: 49524C6F9F638F1A

View File

@ -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 {