diff options
Diffstat (limited to 'pkg/bindings')
-rw-r--r-- | pkg/bindings/containers/containers.go | 12 | ||||
-rw-r--r-- | pkg/bindings/containers/types.go | 2 | ||||
-rw-r--r-- | pkg/bindings/containers/types_remove_options.go | 32 |
3 files changed, 44 insertions, 2 deletions
diff --git a/pkg/bindings/containers/containers.go b/pkg/bindings/containers/containers.go index 73e4d1d3d..40fcfbded 100644 --- a/pkg/bindings/containers/containers.go +++ b/pkg/bindings/containers/containers.go @@ -71,8 +71,10 @@ func Prune(ctx context.Context, options *PruneOptions) ([]*reports.PruneReport, } // Remove removes a container from local storage. The force bool designates -// that the container should be removed forcibly (example, even it is running). The volumes -// bool dictates that a container's volumes should also be removed. +// that the container should be removed forcibly (example, even it is running). +// The volumes bool dictates that a container's volumes should also be removed. +// The All option indicates that all containers should be removed +// The Ignore option indicates that if a container did not exist, ignore the error func Remove(ctx context.Context, nameOrID string, options *RemoveOptions) error { if options == nil { options = new(RemoveOptions) @@ -85,9 +87,15 @@ func Remove(ctx context.Context, nameOrID string, options *RemoveOptions) error if v := options.GetVolumes(); options.Changed("Volumes") { params.Set("v", strconv.FormatBool(v)) } + if all := options.GetAll(); options.Changed("All") { + params.Set("all", strconv.FormatBool(all)) + } if force := options.GetForce(); options.Changed("Force") { params.Set("force", strconv.FormatBool(force)) } + if ignore := options.GetIgnore(); options.Changed("Ignore") { + params.Set("ignore", strconv.FormatBool(ignore)) + } response, err := conn.DoRequest(nil, http.MethodDelete, "/containers/%s", params, nil, nameOrID) if err != nil { return err diff --git a/pkg/bindings/containers/types.go b/pkg/bindings/containers/types.go index 43cb58a54..24604fa83 100644 --- a/pkg/bindings/containers/types.go +++ b/pkg/bindings/containers/types.go @@ -122,6 +122,8 @@ type PruneOptions struct { //go:generate go run ../generator/generator.go RemoveOptions // RemoveOptions are optional options for removing containers type RemoveOptions struct { + All *bool + Ignore *bool Force *bool Volumes *bool } diff --git a/pkg/bindings/containers/types_remove_options.go b/pkg/bindings/containers/types_remove_options.go index e21fb41f7..3ef32fa03 100644 --- a/pkg/bindings/containers/types_remove_options.go +++ b/pkg/bindings/containers/types_remove_options.go @@ -87,6 +87,38 @@ func (o *RemoveOptions) ToParams() (url.Values, error) { return params, nil } +// WithAll +func (o *RemoveOptions) WithAll(value bool) *RemoveOptions { + v := &value + o.All = v + return o +} + +// GetAll +func (o *RemoveOptions) GetAll() bool { + var all bool + if o.All == nil { + return all + } + return *o.All +} + +// WithIgnore +func (o *RemoveOptions) WithIgnore(value bool) *RemoveOptions { + v := &value + o.Ignore = v + return o +} + +// GetIgnore +func (o *RemoveOptions) GetIgnore() bool { + var ignore bool + if o.Ignore == nil { + return ignore + } + return *o.Ignore +} + // WithForce func (o *RemoveOptions) WithForce(value bool) *RemoveOptions { v := &value |