...

Source file src/github.com/Microsoft/hcsshim/pkg/go-runhcs/runhcs_delete.go

Documentation: github.com/Microsoft/hcsshim/pkg/go-runhcs

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

View as plain text