Add a new flag to images pull for printing out the pulled image's chainID
Signed-off-by: Kathryn Baldauf <kabaldau@microsoft.com>
This commit is contained in:
@@ -25,6 +25,7 @@ import (
|
||||
"github.com/containerd/containerd/images"
|
||||
"github.com/containerd/containerd/log"
|
||||
"github.com/containerd/containerd/platforms"
|
||||
"github.com/opencontainers/image-spec/identity"
|
||||
ocispec "github.com/opencontainers/image-spec/specs-go/v1"
|
||||
"github.com/pkg/errors"
|
||||
"github.com/urfave/cli"
|
||||
@@ -57,6 +58,10 @@ command. As part of this process, we do the following:
|
||||
Name: "all-metadata",
|
||||
Usage: "Pull metadata for all platforms",
|
||||
},
|
||||
cli.BoolFlag{
|
||||
Name: "print-chainid",
|
||||
Usage: "Print the resulting image's chain ID",
|
||||
},
|
||||
),
|
||||
Action: func(context *cli.Context) error {
|
||||
var (
|
||||
@@ -118,6 +123,14 @@ command. As part of this process, we do the following:
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if context.Bool("print-chainid") {
|
||||
diffIDs, err := i.RootFS(ctx)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
chainID := identity.ChainID(diffIDs).String()
|
||||
fmt.Printf("image chain ID: %s\n", chainID)
|
||||
}
|
||||
}
|
||||
|
||||
fmt.Println("done")
|
||||
|
Reference in New Issue
Block a user