github.com/containerd/containerd@v22.0.0-20200918172823-438c87b8e050+incompatible/cmd/ctr/commands/oci/oci.go (about) 1 /* 2 Copyright The containerd Authors. 3 4 Licensed under the Apache License, Version 2.0 (the "License"); 5 you may not use this file except in compliance with the License. 6 You may obtain a copy of the License at 7 8 http://www.apache.org/licenses/LICENSE-2.0 9 10 Unless required by applicable law or agreed to in writing, software 11 distributed under the License is distributed on an "AS IS" BASIS, 12 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 See the License for the specific language governing permissions and 14 limitations under the License. 15 */ 16 17 package oci 18 19 import ( 20 "github.com/pkg/errors" 21 "github.com/urfave/cli" 22 23 "github.com/containerd/containerd/cmd/ctr/commands" 24 "github.com/containerd/containerd/containers" 25 "github.com/containerd/containerd/oci" 26 ) 27 28 var Command = cli.Command{ 29 Name: "oci", 30 Usage: "OCI tools", 31 Subcommands: []cli.Command{ 32 defaultSpecCommand, 33 }, 34 } 35 36 var defaultSpecCommand = cli.Command{ 37 Name: "spec", 38 Usage: "see the output of the default OCI spec", 39 Action: func(context *cli.Context) error { 40 ctx, cancel := commands.AppContext(context) 41 defer cancel() 42 43 spec, err := oci.GenerateSpec(ctx, nil, &containers.Container{}) 44 if err != nil { 45 return errors.Wrap(err, "failed to generate spec") 46 } 47 48 commands.PrintAsJSON(spec) 49 return nil 50 }, 51 }