Merge pull request #7905 from dcantah/ctr-ocispec-plat
This commit is contained in:
		| @@ -24,6 +24,7 @@ import ( | |||||||
| 	"github.com/containerd/containerd/cmd/ctr/commands" | 	"github.com/containerd/containerd/cmd/ctr/commands" | ||||||
| 	"github.com/containerd/containerd/containers" | 	"github.com/containerd/containerd/containers" | ||||||
| 	"github.com/containerd/containerd/oci" | 	"github.com/containerd/containerd/oci" | ||||||
|  | 	"github.com/containerd/containerd/platforms" | ||||||
| ) | ) | ||||||
|  |  | ||||||
| // Command is the parent for all OCI related tools under 'oci' | // Command is the parent for all OCI related tools under 'oci' | ||||||
| @@ -38,11 +39,22 @@ var Command = cli.Command{ | |||||||
| var defaultSpecCommand = cli.Command{ | var defaultSpecCommand = cli.Command{ | ||||||
| 	Name:  "spec", | 	Name:  "spec", | ||||||
| 	Usage: "see the output of the default OCI spec", | 	Usage: "see the output of the default OCI spec", | ||||||
|  | 	Flags: []cli.Flag{ | ||||||
|  | 		cli.StringFlag{ | ||||||
|  | 			Name:  "platform", | ||||||
|  | 			Usage: "platform of the spec to print (Examples: 'linux/arm64', 'windows/amd64')", | ||||||
|  | 		}, | ||||||
|  | 	}, | ||||||
| 	Action: func(context *cli.Context) error { | 	Action: func(context *cli.Context) error { | ||||||
| 		ctx, cancel := commands.AppContext(context) | 		ctx, cancel := commands.AppContext(context) | ||||||
| 		defer cancel() | 		defer cancel() | ||||||
|  |  | ||||||
| 		spec, err := oci.GenerateSpec(ctx, nil, &containers.Container{}) | 		platform := platforms.DefaultString() | ||||||
|  | 		if plat := context.String("platform"); plat != "" { | ||||||
|  | 			platform = plat | ||||||
|  | 		} | ||||||
|  |  | ||||||
|  | 		spec, err := oci.GenerateSpecWithPlatform(ctx, nil, platform, &containers.Container{}) | ||||||
| 		if err != nil { | 		if err != nil { | ||||||
| 			return fmt.Errorf("failed to generate spec: %w", err) | 			return fmt.Errorf("failed to generate spec: %w", err) | ||||||
| 		} | 		} | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 Samuel Karp
					Samuel Karp