diff options
author | baude <bbaude@redhat.com> | 2020-12-14 11:33:25 -0600 |
---|---|---|
committer | baude <bbaude@redhat.com> | 2020-12-17 09:40:51 -0600 |
commit | 86335aa4ae01dadecd36468409d742e68b76925d (patch) | |
tree | fd6e5bfeb924db9020073685d0133b2fa38622c1 /pkg/bindings/system/system.go | |
parent | c38ae47a1adf3235d8b01d724e7327e608dd8078 (diff) | |
download | podman-86335aa4ae01dadecd36468409d742e68b76925d.tar.gz podman-86335aa4ae01dadecd36468409d742e68b76925d.tar.bz2 podman-86335aa4ae01dadecd36468409d742e68b76925d.zip |
misc bindings to podman v3
manifest, system, info, volumes, play, and generate bindings are
updated to always have binding options.
Signed-off-by: baude <bbaude@redhat.com>
Diffstat (limited to 'pkg/bindings/system/system.go')
-rw-r--r-- | pkg/bindings/system/system.go | 53 |
1 files changed, 22 insertions, 31 deletions
diff --git a/pkg/bindings/system/system.go b/pkg/bindings/system/system.go index 1203f5c3c..815c967f1 100644 --- a/pkg/bindings/system/system.go +++ b/pkg/bindings/system/system.go @@ -6,8 +6,6 @@ import ( "fmt" "io" "net/http" - "net/url" - "strconv" "time" "github.com/containers/podman/v2/libpod/define" @@ -20,27 +18,14 @@ import ( // Events allows you to monitor libdpod related events like container creation and // removal. The events are then passed to the eventChan provided. The optional cancelChan // can be used to cancel the read of events and close down the HTTP connection. -func Events(ctx context.Context, eventChan chan entities.Event, cancelChan chan bool, since, until *string, filters map[string][]string, stream *bool) error { +func Events(ctx context.Context, eventChan chan entities.Event, cancelChan chan bool, options *EventsOptions) error { conn, err := bindings.GetClient(ctx) if err != nil { return err } - params := url.Values{} - if since != nil { - params.Set("since", *since) - } - if until != nil { - params.Set("until", *until) - } - if stream != nil { - params.Set("stream", strconv.FormatBool(*stream)) - } - if filters != nil { - filterString, err := bindings.FiltersToString(filters) - if err != nil { - return errors.Wrap(err, "invalid filters") - } - params.Set("filters", filterString) + params, err := options.ToParams() + if err != nil { + return err } response, err := conn.DoRequest(nil, http.MethodGet, "/events", params, nil) if err != nil { @@ -74,7 +59,7 @@ func Events(ctx context.Context, eventChan chan entities.Event, cancelChan chan } // Prune removes all unused system data. -func Prune(ctx context.Context, all, volumes *bool) (*entities.SystemPruneReport, error) { +func Prune(ctx context.Context, options *PruneOptions) (*entities.SystemPruneReport, error) { var ( report entities.SystemPruneReport ) @@ -82,12 +67,9 @@ func Prune(ctx context.Context, all, volumes *bool) (*entities.SystemPruneReport if err != nil { return nil, err } - params := url.Values{} - if all != nil { - params.Set("All", strconv.FormatBool(*all)) - } - if volumes != nil { - params.Set("Volumes", strconv.FormatBool(*volumes)) + params, err := options.ToParams() + if err != nil { + return nil, err } response, err := conn.DoRequest(nil, http.MethodPost, "/system/prune", params, nil) if err != nil { @@ -96,10 +78,15 @@ func Prune(ctx context.Context, all, volumes *bool) (*entities.SystemPruneReport return &report, response.Process(&report) } -func Version(ctx context.Context) (*entities.SystemVersionReport, error) { - var report entities.SystemVersionReport - var component entities.ComponentVersion - +func Version(ctx context.Context, options *VersionOptions) (*entities.SystemVersionReport, error) { + var ( + component entities.ComponentVersion + report entities.SystemVersionReport + ) + if options == nil { + options = new(VersionOptions) + } + _ = options version, err := define.GetVersion() if err != nil { return nil, err @@ -140,8 +127,12 @@ func Version(ctx context.Context) (*entities.SystemVersionReport, error) { // DiskUsage returns information about image, container, and volume disk // consumption -func DiskUsage(ctx context.Context) (*entities.SystemDfReport, error) { +func DiskUsage(ctx context.Context, options *DiskOptions) (*entities.SystemDfReport, error) { var report entities.SystemDfReport + if options == nil { + options = new(DiskOptions) + } + _ = options conn, err := bindings.GetClient(ctx) if err != nil { return nil, err |