@@ -144,6 +144,16 @@ func OptCreateWithLaunchScript(s string) CreateOpt {
144
144
}
145
145
}
146
146
147
+ // OptCreateDeterministic sets header/descriptor fields to values that support deterministic
148
+ // creation of images.
149
+ func OptCreateDeterministic () CreateOpt {
150
+ return func (co * createOpts ) error {
151
+ co .id = uuid .Nil
152
+ co .t = time .Unix (0 , 0 )
153
+ return nil
154
+ }
155
+ }
156
+
147
157
// OptCreateWithID specifies id as the unique ID.
148
158
func OptCreateWithID (id string ) CreateOpt {
149
159
return func (co * createOpts ) error {
@@ -239,10 +249,10 @@ func createContainer(rw ReadWriter, co createOpts) (*FileImage, error) {
239
249
// interface. To change this behavior, consider using OptCreateWithCloseOnUnload.
240
250
//
241
251
// By default, the image ID is set to a randomly generated value. To override this, consider using
242
- // OptCreateWithID.
252
+ // OptCreateDeterministic or OptCreateWithID.
243
253
//
244
254
// By default, the image creation time is set to time.Now(). To override this, consider using
245
- // OptCreateWithTime.
255
+ // OptCreateDeterministic or OptCreateWithTime.
246
256
//
247
257
// By default, the image will support a maximum of 48 descriptors. To change this, consider using
248
258
// OptCreateWithDescriptorCapacity.
@@ -284,10 +294,10 @@ func CreateContainer(rw ReadWriter, opts ...CreateOpt) (*FileImage, error) {
284
294
// are released.
285
295
//
286
296
// By default, the image ID is set to a randomly generated value. To override this, consider using
287
- // OptCreateWithID.
297
+ // OptCreateDeterministic or OptCreateWithID.
288
298
//
289
299
// By default, the image creation time is set to time.Now(). To override this, consider using
290
- // OptCreateWithTime.
300
+ // OptCreateDeterministic or OptCreateWithTime.
291
301
//
292
302
// By default, the image will support a maximum of 48 descriptors. To change this, consider using
293
303
// OptCreateWithDescriptorCapacity.
@@ -364,6 +374,15 @@ type addOpts struct {
364
374
// AddOpt are used to specify object add options.
365
375
type AddOpt func (* addOpts ) error
366
376
377
+ // OptAddDeterministic sets header/descriptor fields to values that support deterministic
378
+ // modification of images.
379
+ func OptAddDeterministic () AddOpt {
380
+ return func (ao * addOpts ) error {
381
+ ao .t = time .Unix (0 , 0 )
382
+ return nil
383
+ }
384
+ }
385
+
367
386
// OptAddWithTime specifies t as the image modification time.
368
387
func OptAddWithTime (t time.Time ) AddOpt {
369
388
return func (ao * addOpts ) error {
@@ -375,7 +394,7 @@ func OptAddWithTime(t time.Time) AddOpt {
375
394
// AddObject adds a new data object and its descriptor into the specified SIF file.
376
395
//
377
396
// By default, the image modification time is set to the current time. To override this, consider
378
- // using OptAddWithTime.
397
+ // using OptAddDeterministic or OptAddWithTime.
379
398
func (f * FileImage ) AddObject (di DescriptorInput , opts ... AddOpt ) error {
380
399
ao := addOpts {
381
400
t : time .Now (),
@@ -463,6 +482,15 @@ func OptDeleteCompact(b bool) DeleteOpt {
463
482
}
464
483
}
465
484
485
+ // OptDeleteDeterministic sets header/descriptor fields to values that support deterministic
486
+ // modification of images.
487
+ func OptDeleteDeterministic () DeleteOpt {
488
+ return func (do * deleteOpts ) error {
489
+ do .t = time .Unix (0 , 0 )
490
+ return nil
491
+ }
492
+ }
493
+
466
494
// OptDeleteWithTime specifies t as the image modification time.
467
495
func OptDeleteWithTime (t time.Time ) DeleteOpt {
468
496
return func (do * deleteOpts ) error {
@@ -479,7 +507,7 @@ var errCompactNotImplemented = errors.New("compact not implemented for non-last
479
507
// object deletion, use OptDeleteCompact.
480
508
//
481
509
// By default, the image modification time is set to time.Now(). To override this, consider using
482
- // OptDeleteWithTime.
510
+ // OptDeleteDeterministic or OptDeleteWithTime.
483
511
func (f * FileImage ) DeleteObject (id uint32 , opts ... DeleteOpt ) error {
484
512
do := deleteOpts {
485
513
t : time .Now (),
@@ -544,6 +572,15 @@ type setOpts struct {
544
572
// SetOpt are used to specify object set options.
545
573
type SetOpt func (* setOpts ) error
546
574
575
+ // OptSetDeterministic sets header/descriptor fields to values that support deterministic
576
+ // modification of images.
577
+ func OptSetDeterministic () SetOpt {
578
+ return func (so * setOpts ) error {
579
+ so .t = time .Unix (0 , 0 )
580
+ return nil
581
+ }
582
+ }
583
+
547
584
// OptSetWithTime specifies t as the image/object modification time.
548
585
func OptSetWithTime (t time.Time ) SetOpt {
549
586
return func (so * setOpts ) error {
@@ -560,7 +597,7 @@ var (
560
597
// SetPrimPart sets the specified system partition to be the primary one.
561
598
//
562
599
// By default, the image/object modification times are set to time.Now(). To override this,
563
- // consider using OptSetWithTime.
600
+ // consider using OptSetDeterministic or OptSetWithTime.
564
601
func (f * FileImage ) SetPrimPart (id uint32 , opts ... SetOpt ) error {
565
602
so := setOpts {
566
603
t : time .Now (),
0 commit comments