diff options
author | OpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com> | 2020-12-17 17:22:37 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-12-17 17:22:37 +0000 |
commit | a17afa931d1aa73b8657cf26de3b49841837f66d (patch) | |
tree | 8b3e3408eea4fa15320f5c294d96b8e134bf49c4 /pkg/bindings/generate/generate.go | |
parent | 033336606f8aa9687cbdff5450c691b48d45e8e6 (diff) | |
parent | 86335aa4ae01dadecd36468409d742e68b76925d (diff) | |
download | podman-a17afa931d1aa73b8657cf26de3b49841837f66d.tar.gz podman-a17afa931d1aa73b8657cf26de3b49841837f66d.tar.bz2 podman-a17afa931d1aa73b8657cf26de3b49841837f66d.zip |
Merge pull request #8752 from baude/bindings3volumes
misc bindings to podman v3
Diffstat (limited to 'pkg/bindings/generate/generate.go')
-rw-r--r-- | pkg/bindings/generate/generate.go | 35 |
1 files changed, 16 insertions, 19 deletions
diff --git a/pkg/bindings/generate/generate.go b/pkg/bindings/generate/generate.go index 8d0146ec1..29eb39557 100644 --- a/pkg/bindings/generate/generate.go +++ b/pkg/bindings/generate/generate.go @@ -4,31 +4,23 @@ import ( "context" "errors" "net/http" - "net/url" - "strconv" "github.com/containers/podman/v2/pkg/bindings" "github.com/containers/podman/v2/pkg/domain/entities" ) -func Systemd(ctx context.Context, nameOrID string, options entities.GenerateSystemdOptions) (*entities.GenerateSystemdReport, error) { +func Systemd(ctx context.Context, nameOrID string, options *SystemdOptions) (*entities.GenerateSystemdReport, error) { + if options == nil { + options = new(SystemdOptions) + } conn, err := bindings.GetClient(ctx) if err != nil { return nil, err } - params := url.Values{} - - params.Set("useName", strconv.FormatBool(options.Name)) - params.Set("new", strconv.FormatBool(options.New)) - if options.RestartPolicy != "" { - params.Set("restartPolicy", options.RestartPolicy) - } - if options.StopTimeout != nil { - params.Set("stopTimeout", strconv.FormatUint(uint64(*options.StopTimeout), 10)) + params, err := options.ToParams() + if err != nil { + return nil, err } - params.Set("containerPrefix", options.ContainerPrefix) - params.Set("podPrefix", options.PodPrefix) - params.Set("separator", options.Separator) response, err := conn.DoRequest(nil, http.MethodGet, "/generate/%s/systemd", params, nil, nameOrID) if err != nil { @@ -38,7 +30,10 @@ func Systemd(ctx context.Context, nameOrID string, options entities.GenerateSyst return report, response.Process(&report.Units) } -func Kube(ctx context.Context, nameOrIDs []string, options entities.GenerateKubeOptions) (*entities.GenerateKubeReport, error) { +func Kube(ctx context.Context, nameOrIDs []string, options *KubeOptions) (*entities.GenerateKubeReport, error) { + if options == nil { + options = new(KubeOptions) + } conn, err := bindings.GetClient(ctx) if err != nil { return nil, err @@ -46,12 +41,14 @@ func Kube(ctx context.Context, nameOrIDs []string, options entities.GenerateKube if len(nameOrIDs) < 1 { return nil, errors.New("must provide the name or ID of one container or pod") } - params := url.Values{} + + params, err := options.ToParams() + if err != nil { + return nil, err + } for _, name := range nameOrIDs { params.Add("names", name) } - params.Set("service", strconv.FormatBool(options.Service)) - response, err := conn.DoRequest(nil, http.MethodGet, "/generate/kube", params, nil) if err != nil { return nil, err |