@@ -34,6 +34,7 @@ import (
34
34
"github.com/moby/buildkit/session"
35
35
"github.com/moby/buildkit/util/bklog"
36
36
"github.com/moby/buildkit/util/disk"
37
+ "github.com/moby/buildkit/util/estargz"
37
38
"github.com/moby/buildkit/util/network/cniprovider"
38
39
"github.com/moby/buildkit/util/network/netproviders"
39
40
"github.com/moby/buildkit/util/resolver"
@@ -461,22 +462,6 @@ func validOCIBinary() bool {
461
462
return true
462
463
}
463
464
464
- const (
465
- // targetRefLabel is a label which contains image reference.
466
- targetRefLabel = "containerd.io/snapshot/remote/stargz.reference"
467
-
468
- // targetDigestLabel is a label which contains layer digest.
469
- targetDigestLabel = "containerd.io/snapshot/remote/stargz.digest"
470
-
471
- // targetImageLayersLabel is a label which contains layer digests contained in
472
- // the target image.
473
- targetImageLayersLabel = "containerd.io/snapshot/remote/stargz.layers"
474
-
475
- // targetSessionLabel is a labeld which contains session IDs usable for
476
- // authenticating the target snapshot.
477
- targetSessionLabel = "containerd.io/snapshot/remote/stargz.session"
478
- )
479
-
480
465
// sourceWithSession returns a callback which implements a converter from labels to the
481
466
// typed snapshot source info. This callback is called everytime the snapshotter resolves a
482
467
// snapshot. This callback returns configuration that is based on buildkitd's registry config
@@ -487,15 +472,15 @@ func sourceWithSession(hosts docker.RegistryHosts, sm *session.Manager) sgzsourc
487
472
// to the snapshotter API. So, first, get all these IDs
488
473
var ids []string
489
474
for k := range labels {
490
- if strings .HasPrefix (k , targetRefLabel + "." ) {
491
- ids = append (ids , strings .TrimPrefix (k , targetRefLabel + "." ))
475
+ if strings .HasPrefix (k , estargz . TargetRefLabel + "." ) {
476
+ ids = append (ids , strings .TrimPrefix (k , estargz . TargetRefLabel + "." ))
492
477
}
493
478
}
494
479
495
480
// Parse all labels
496
481
for _ , id := range ids {
497
482
// Parse session labels
498
- ref , ok := labels [targetRefLabel + "." + id ]
483
+ ref , ok := labels [estargz . TargetRefLabel + "." + id ]
499
484
if ! ok {
500
485
continue
501
486
}
@@ -505,7 +490,7 @@ func sourceWithSession(hosts docker.RegistryHosts, sm *session.Manager) sgzsourc
505
490
}
506
491
var sids []string
507
492
for i := 0 ; ; i ++ {
508
- sidKey := targetSessionLabel + "." + fmt .Sprintf ("%d" , i ) + "." + id
493
+ sidKey := estargz . TargetSessionLabel + "." + fmt .Sprintf ("%d" , i ) + "." + id
509
494
sid , ok := labels [sidKey ]
510
495
if ! ok {
511
496
break
@@ -520,9 +505,9 @@ func sourceWithSession(hosts docker.RegistryHosts, sm *session.Manager) sgzsourc
520
505
HostsFunc (ref .Hostname ())
521
506
})
522
507
if s , err := parse (map [string ]string {
523
- targetRefLabel : ref ,
524
- targetDigestLabel : labels [targetDigestLabel + "." + id ],
525
- targetImageLayersLabel : labels [targetImageLayersLabel + "." + id ],
508
+ estargz . TargetRefLabel : ref ,
509
+ estargz . TargetDigestLabel : labels [estargz . TargetDigestLabel + "." + id ],
510
+ estargz . TargetImageLayersLabel : labels [estargz . TargetImageLayersLabel + "." + id ],
526
511
}); err == nil {
527
512
src = append (src , s ... )
528
513
}
0 commit comments