@@ -34,6 +34,7 @@ import (
3434	"github.com/moby/buildkit/session" 
3535	"github.com/moby/buildkit/util/bklog" 
3636	"github.com/moby/buildkit/util/disk" 
37+ 	"github.com/moby/buildkit/util/estargz" 
3738	"github.com/moby/buildkit/util/network/cniprovider" 
3839	"github.com/moby/buildkit/util/network/netproviders" 
3940	"github.com/moby/buildkit/util/resolver" 
@@ -461,22 +462,6 @@ func validOCIBinary() bool {
461462	return  true 
462463}
463464
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- 
480465// sourceWithSession returns a callback which implements a converter from labels to the 
481466// typed snapshot source info. This callback is called everytime the snapshotter resolves a 
482467// 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
487472		// to the snapshotter API. So, first, get all these IDs 
488473		var  ids  []string 
489474		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 + "." ))
492477			}
493478		}
494479
495480		// Parse all labels 
496481		for  _ , id  :=  range  ids  {
497482			// Parse session labels 
498- 			ref , ok  :=  labels [targetRefLabel + "." + id ]
483+ 			ref , ok  :=  labels [estargz . TargetRefLabel + "." + id ]
499484			if  ! ok  {
500485				continue 
501486			}
@@ -505,7 +490,7 @@ func sourceWithSession(hosts docker.RegistryHosts, sm *session.Manager) sgzsourc
505490			}
506491			var  sids  []string 
507492			for  i  :=  0 ; ; i ++  {
508- 				sidKey  :=  targetSessionLabel  +  "."  +  fmt .Sprintf ("%d" , i ) +  "."  +  id 
493+ 				sidKey  :=  estargz . TargetSessionLabel  +  "."  +  fmt .Sprintf ("%d" , i ) +  "."  +  id 
509494				sid , ok  :=  labels [sidKey ]
510495				if  ! ok  {
511496					break 
@@ -520,9 +505,9 @@ func sourceWithSession(hosts docker.RegistryHosts, sm *session.Manager) sgzsourc
520505					HostsFunc (ref .Hostname ())
521506			})
522507			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 ],
526511			}); err  ==  nil  {
527512				src  =  append (src , s ... )
528513			}
0 commit comments