diff --git a/cli/cmd/run/run.go b/cli/cmd/run/run.go index 24f415ce7..d25779b10 100644 --- a/cli/cmd/run/run.go +++ b/cli/cmd/run/run.go @@ -18,6 +18,7 @@ package run import ( "context" + "errors" "fmt" "io" "os" @@ -43,7 +44,7 @@ func Command(contextType string) *cobra.Command { if len(args) > 1 { opts.Command = args[1:] } - return runRun(cmd.Context(), args[0], opts) + return runRun(cmd.Context(), args[0], contextType, opts) }, } cmd.Flags().SetInterspersed(false) @@ -58,15 +59,22 @@ func Command(contextType string) *cobra.Command { cmd.Flags().StringArrayVarP(&opts.Environment, "env", "e", []string{}, "Set environment variables") cmd.Flags().StringArrayVar(&opts.EnvironmentFiles, "env-file", []string{}, "Path to environment files to be translated as environment variables") cmd.Flags().StringVarP(&opts.RestartPolicyCondition, "restart", "", containers.RestartPolicyNone, "Restart policy to apply when a container exits") + cmd.Flags().BoolVar(&opts.Rm, "rm", false, "Automatically remove the container when it exits") if contextType == store.AciContextType { cmd.Flags().StringVar(&opts.DomainName, "domainname", "", "Container NIS domain name") } + _ = cmd.Flags().MarkHidden("rm") + return cmd } -func runRun(ctx context.Context, image string, opts run.Opts) error { +func runRun(ctx context.Context, image string, contextType string, opts run.Opts) error { + if opts.Rm { + return errors.New(`Option "rm" is not yet implemented for context type: ` + contextType) + } + c, err := client.New(ctx) if err != nil { return err diff --git a/cli/options/run/opts.go b/cli/options/run/opts.go index 9a3130aac..35475d75c 100644 --- a/cli/options/run/opts.go +++ b/cli/options/run/opts.go @@ -46,6 +46,7 @@ type Opts struct { EnvironmentFiles []string RestartPolicyCondition string DomainName string + Rm bool } // ToContainerConfig convert run options to a container configuration