Fix rootfs digest computation
Compute digest from uncompressed archive. Properly propagate error on unpack. Rename dist cmd commands to match command name. Signed-off-by: Derek McGowan <derek@mcgstyle.net> (github: dmcgowan)
This commit is contained in:
parent
82a2d766ec
commit
4492a2cee3
3 changed files with 7 additions and 6 deletions
6
cmd/dist/rootfs.go
vendored
6
cmd/dist/rootfs.go
vendored
|
@ -23,12 +23,12 @@ var rootfsCommand = cli.Command{
|
||||||
Name: "rootfs",
|
Name: "rootfs",
|
||||||
Usage: "rootfs setups a rootfs",
|
Usage: "rootfs setups a rootfs",
|
||||||
Subcommands: []cli.Command{
|
Subcommands: []cli.Command{
|
||||||
|
rootfsUnpackCommand,
|
||||||
rootfsPrepareCommand,
|
rootfsPrepareCommand,
|
||||||
rootfsInitCommand,
|
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
var rootfsPrepareCommand = cli.Command{
|
var rootfsUnpackCommand = cli.Command{
|
||||||
Name: "unpack",
|
Name: "unpack",
|
||||||
Usage: "unpack applies layers from a manifest to a snapshot",
|
Usage: "unpack applies layers from a manifest to a snapshot",
|
||||||
ArgsUsage: "[flags] <digest>",
|
ArgsUsage: "[flags] <digest>",
|
||||||
|
@ -68,7 +68,7 @@ var rootfsPrepareCommand = cli.Command{
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
var rootfsInitCommand = cli.Command{
|
var rootfsPrepareCommand = cli.Command{
|
||||||
Name: "prepare",
|
Name: "prepare",
|
||||||
Usage: "prepare gets mount commands for digest",
|
Usage: "prepare gets mount commands for digest",
|
||||||
ArgsUsage: "[flags] <digest> <target>",
|
ArgsUsage: "[flags] <digest> <target>",
|
||||||
|
|
|
@ -32,8 +32,6 @@ type Mounter interface {
|
||||||
//
|
//
|
||||||
// The returned digest is the diffID for the applied layer.
|
// The returned digest is the diffID for the applied layer.
|
||||||
func ApplyLayer(snapshots snapshot.Snapshotter, mounter Mounter, rd io.Reader, parent digest.Digest) (digest.Digest, error) {
|
func ApplyLayer(snapshots snapshot.Snapshotter, mounter Mounter, rd io.Reader, parent digest.Digest) (digest.Digest, error) {
|
||||||
digester := digest.Canonical.Digester() // used to calculate diffID.
|
|
||||||
rd = io.TeeReader(rd, digester.Hash())
|
|
||||||
ctx := context.TODO()
|
ctx := context.TODO()
|
||||||
|
|
||||||
// create a temporary directory to work from, needs to be on same
|
// create a temporary directory to work from, needs to be on same
|
||||||
|
@ -68,6 +66,9 @@ func ApplyLayer(snapshots snapshot.Snapshotter, mounter Mounter, rd io.Reader, p
|
||||||
return "", err
|
return "", err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
digester := digest.Canonical.Digester() // used to calculate diffID.
|
||||||
|
rd = io.TeeReader(rd, digester.Hash())
|
||||||
|
|
||||||
if _, err := archive.Apply(context.Background(), key, rd); err != nil {
|
if _, err := archive.Apply(context.Background(), key, rd); err != nil {
|
||||||
return "", err
|
return "", err
|
||||||
}
|
}
|
||||||
|
|
|
@ -33,7 +33,7 @@ func (rp remoteUnpacker) Unpack(ctx context.Context, layers []ocispec.Descriptor
|
||||||
}
|
}
|
||||||
resp, err := rp.client.Unpack(ctx, &pr)
|
resp, err := rp.client.Unpack(ctx, &pr)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", nil
|
return "", err
|
||||||
}
|
}
|
||||||
return resp.ChainID, nil
|
return resp.ChainID, nil
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue