Merge pull request #2237 from dmcgowan/fix-pull-uncompressed-label
client/pull: fix label being put on snapshot instead of content
This commit is contained in:
		
							
								
								
									
										21
									
								
								image.go
									
									
									
									
									
								
							
							
						
						
									
										21
									
								
								image.go
									
									
									
									
									
								
							| @@ -25,7 +25,6 @@ import ( | |||||||
| 	"github.com/containerd/containerd/images" | 	"github.com/containerd/containerd/images" | ||||||
| 	"github.com/containerd/containerd/platforms" | 	"github.com/containerd/containerd/platforms" | ||||||
| 	"github.com/containerd/containerd/rootfs" | 	"github.com/containerd/containerd/rootfs" | ||||||
| 	"github.com/containerd/containerd/snapshots" |  | ||||||
| 	digest "github.com/opencontainers/go-digest" | 	digest "github.com/opencontainers/go-digest" | ||||||
| 	"github.com/opencontainers/image-spec/identity" | 	"github.com/opencontainers/image-spec/identity" | ||||||
| 	ocispec "github.com/opencontainers/image-spec/specs-go/v1" | 	ocispec "github.com/opencontainers/image-spec/specs-go/v1" | ||||||
| @@ -124,15 +123,25 @@ func (i *image) Unpack(ctx context.Context, snapshotterName string) error { | |||||||
| 		unpacked bool | 		unpacked bool | ||||||
| 	) | 	) | ||||||
| 	for _, layer := range layers { | 	for _, layer := range layers { | ||||||
| 		labels := map[string]string{ | 		unpacked, err = rootfs.ApplyLayer(ctx, layer, chain, sn, a) | ||||||
| 			"containerd.io/uncompressed": layer.Diff.Digest.String(), |  | ||||||
| 		} |  | ||||||
|  |  | ||||||
| 		unpacked, err = rootfs.ApplyLayer(ctx, layer, chain, sn, a, snapshots.WithLabels(labels)) |  | ||||||
| 		if err != nil { | 		if err != nil { | ||||||
| 			return err | 			return err | ||||||
| 		} | 		} | ||||||
|  |  | ||||||
|  | 		if unpacked { | ||||||
|  | 			// Set the uncompressed label after the uncompressed | ||||||
|  | 			// digest has been verified through apply. | ||||||
|  | 			cinfo := content.Info{ | ||||||
|  | 				Digest: layer.Blob.Digest, | ||||||
|  | 				Labels: map[string]string{ | ||||||
|  | 					"containerd.io/uncompressed": layer.Diff.Digest.String(), | ||||||
|  | 				}, | ||||||
|  | 			} | ||||||
|  | 			if _, err := cs.Update(ctx, cinfo, "labels.containerd.io/uncompressed"); err != nil { | ||||||
|  | 				return err | ||||||
|  | 			} | ||||||
|  | 		} | ||||||
|  |  | ||||||
| 		chain = append(chain, layer.Diff.Digest) | 		chain = append(chain, layer.Diff.Digest) | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 Phil Estes
					Phil Estes