Merge pull request #8413 from dcantah/sb_ctr_run
ctr: Add sandbox flag to ctr run
This commit is contained in:
		| @@ -141,6 +141,10 @@ var ( | |||||||
| 			Usage: "Runtime name or absolute path to runtime binary", | 			Usage: "Runtime name or absolute path to runtime binary", | ||||||
| 			Value: defaults.DefaultRuntime, | 			Value: defaults.DefaultRuntime, | ||||||
| 		}, | 		}, | ||||||
|  | 		cli.StringFlag{ | ||||||
|  | 			Name:  "sandbox", | ||||||
|  | 			Usage: "Create the container in the given sandbox", | ||||||
|  | 		}, | ||||||
| 		cli.StringFlag{ | 		cli.StringFlag{ | ||||||
| 			Name:  "runtime-config-path", | 			Name:  "runtime-config-path", | ||||||
| 			Usage: "Optional runtime config path", | 			Usage: "Optional runtime config path", | ||||||
|   | |||||||
| @@ -164,6 +164,7 @@ var Command = cli.Command{ | |||||||
| 			return err | 			return err | ||||||
| 		} | 		} | ||||||
| 		defer cancel() | 		defer cancel() | ||||||
|  |  | ||||||
| 		container, err := NewContainer(ctx, client, context) | 		container, err := NewContainer(ctx, client, context) | ||||||
| 		if err != nil { | 		if err != nil { | ||||||
| 			return err | 			return err | ||||||
|   | |||||||
| @@ -102,6 +102,10 @@ func NewContainer(ctx gocontext.Context, client *containerd.Client, context *cli | |||||||
| 		spec  containerd.NewContainerOpts | 		spec  containerd.NewContainerOpts | ||||||
| 	) | 	) | ||||||
|  |  | ||||||
|  | 	if sandbox := context.String("sandbox"); sandbox != "" { | ||||||
|  | 		cOpts = append(cOpts, containerd.WithSandbox(sandbox)) | ||||||
|  | 	} | ||||||
|  |  | ||||||
| 	if config { | 	if config { | ||||||
| 		cOpts = append(cOpts, containerd.WithContainerLabels(commands.LabelArgs(context.StringSlice("label")))) | 		cOpts = append(cOpts, containerd.WithContainerLabels(commands.LabelArgs(context.StringSlice("label")))) | ||||||
| 		opts = append(opts, oci.WithSpecFromFile(context.String("config"))) | 		opts = append(opts, oci.WithSpecFromFile(context.String("config"))) | ||||||
|   | |||||||
| @@ -51,6 +51,10 @@ func NewContainer(ctx gocontext.Context, client *containerd.Client, context *cli | |||||||
| 		config = context.IsSet("config") | 		config = context.IsSet("config") | ||||||
| 	) | 	) | ||||||
|  |  | ||||||
|  | 	if sandbox := context.String("sandbox"); sandbox != "" { | ||||||
|  | 		cOpts = append(cOpts, containerd.WithSandbox(sandbox)) | ||||||
|  | 	} | ||||||
|  |  | ||||||
| 	if config { | 	if config { | ||||||
| 		id = context.Args().First() | 		id = context.Args().First() | ||||||
| 		opts = append(opts, oci.WithSpecFromFile(context.String("config"))) | 		opts = append(opts, oci.WithSpecFromFile(context.String("config"))) | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 Fu Wei
					Fu Wei