Update layer apply to use containerd archive
Signed-off-by: Derek McGowan <derek@mcgstyle.net> (github: dmcgowan)
This commit is contained in:
		
							
								
								
									
										11
									
								
								cmd/dist/apply.go
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										11
									
								
								cmd/dist/apply.go
									
									
									
									
										vendored
									
									
								
							| @@ -4,8 +4,9 @@ import ( | |||||||
| 	contextpkg "context" | 	contextpkg "context" | ||||||
| 	"os" | 	"os" | ||||||
|  |  | ||||||
|  | 	"github.com/docker/containerd/archive" | ||||||
| 	"github.com/docker/containerd/log" | 	"github.com/docker/containerd/log" | ||||||
| 	"github.com/docker/docker/pkg/archive" | 	dockerarchive "github.com/docker/docker/pkg/archive" | ||||||
| 	"github.com/urfave/cli" | 	"github.com/urfave/cli" | ||||||
| ) | ) | ||||||
|  |  | ||||||
| @@ -21,7 +22,13 @@ var applyCommand = cli.Command{ | |||||||
| 		) | 		) | ||||||
|  |  | ||||||
| 		log.G(ctx).Info("applying layer from stdin") | 		log.G(ctx).Info("applying layer from stdin") | ||||||
| 		if _, err := archive.ApplyLayer(dir, os.Stdin); err != nil { |  | ||||||
|  | 		rd, err := dockerarchive.DecompressStream(os.Stdin) | ||||||
|  | 		if err != nil { | ||||||
|  | 			return err | ||||||
|  | 		} | ||||||
|  |  | ||||||
|  | 		if _, err := archive.ApplyDiffTar(ctx, dir, rd); err != nil { | ||||||
| 			return err | 			return err | ||||||
| 		} | 		} | ||||||
|  |  | ||||||
|   | |||||||
| @@ -1,13 +1,15 @@ | |||||||
| package rootfs | package rootfs | ||||||
|  |  | ||||||
| import ( | import ( | ||||||
|  | 	"context" | ||||||
| 	"io" | 	"io" | ||||||
| 	"io/ioutil" | 	"io/ioutil" | ||||||
|  |  | ||||||
| 	"github.com/docker/containerd" | 	"github.com/docker/containerd" | ||||||
|  | 	"github.com/docker/containerd/archive" | ||||||
| 	"github.com/docker/containerd/log" | 	"github.com/docker/containerd/log" | ||||||
| 	"github.com/docker/containerd/snapshot" | 	"github.com/docker/containerd/snapshot" | ||||||
| 	"github.com/docker/docker/pkg/archive" | 	dockerarchive "github.com/docker/docker/pkg/archive" | ||||||
| 	"github.com/opencontainers/go-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" | ||||||
| @@ -56,7 +58,12 @@ func ApplyLayer(snapshots snapshot.Snapshotter, mounter Mounter, rd io.Reader, p | |||||||
| 	} | 	} | ||||||
| 	defer mounter.Unmount(mounts...) | 	defer mounter.Unmount(mounts...) | ||||||
|  |  | ||||||
| 	if _, err := archive.ApplyLayer(key, rd); err != nil { | 	rd, err = dockerarchive.DecompressStream(rd) | ||||||
|  | 	if err != nil { | ||||||
|  | 		return "", err | ||||||
|  | 	} | ||||||
|  |  | ||||||
|  | 	if _, err := archive.ApplyDiffTar(context.Background(), key, rd); err != nil { | ||||||
| 		return "", err | 		return "", err | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 Derek McGowan
					Derek McGowan