summaryrefslogtreecommitdiff
path: root/pkg/bindings/generate/generate.go
diff options
context:
space:
mode:
Diffstat (limited to 'pkg/bindings/generate/generate.go')
-rw-r--r--pkg/bindings/generate/generate.go35
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