1package runhcs 2 3import ( 4 "context" 5) 6 7// DeleteOpts is set of options that can be used with the Delete command. 8type DeleteOpts struct { 9 // Force forcibly deletes the container if it is still running (uses SIGKILL). 10 Force bool 11} 12 13func (opt *DeleteOpts) args() ([]string, error) { 14 var out []string 15 if opt.Force { 16 out = append(out, "--force") 17 } 18 return out, nil 19} 20 21// Delete any resources held by the container often used with detached 22// containers. 23func (r *Runhcs) Delete(context context.Context, id string, opts *DeleteOpts) error { 24 args := []string{"delete"} 25 if opts != nil { 26 oargs, err := opts.args() 27 if err != nil { 28 return err 29 } 30 args = append(args, oargs...) 31 } 32 return r.runOrError(r.command(context, append(args, id)...)) 33} 34