summaryrefslogtreecommitdiff
path: root/pkg/bindings/generate
diff options
context:
space:
mode:
authorbaude <bbaude@redhat.com>2020-12-02 16:06:31 -0600
committerbaude <bbaude@redhat.com>2020-12-07 11:34:39 -0600
commit749ee2a10ed689a06da699659c59872c0ed770d7 (patch)
tree496d31fdaa07af5778214d6c22ea0222f50ded9b /pkg/bindings/generate
parente6f80fa61aa082d2226b8258ea247186451d84d3 (diff)
downloadpodman-749ee2a10ed689a06da699659c59872c0ed770d7.tar.gz
podman-749ee2a10ed689a06da699659c59872c0ed770d7.tar.bz2
podman-749ee2a10ed689a06da699659c59872c0ed770d7.zip
generate kube on multiple containers
add the ability to add multiple containers into a single k8s pod instead of just one. also fixed some bugs in the resulting yaml where an empty service description was being added on error causing the k8s validation to fail. Signed-off-by: baude <bbaude@redhat.com>
Diffstat (limited to 'pkg/bindings/generate')
-rw-r--r--pkg/bindings/generate/generate.go11
1 files changed, 9 insertions, 2 deletions
diff --git a/pkg/bindings/generate/generate.go b/pkg/bindings/generate/generate.go
index dde1cc29c..8d0146ec1 100644
--- a/pkg/bindings/generate/generate.go
+++ b/pkg/bindings/generate/generate.go
@@ -2,6 +2,7 @@ package generate
import (
"context"
+ "errors"
"net/http"
"net/url"
"strconv"
@@ -37,15 +38,21 @@ func Systemd(ctx context.Context, nameOrID string, options entities.GenerateSyst
return report, response.Process(&report.Units)
}
-func Kube(ctx context.Context, nameOrID string, options entities.GenerateKubeOptions) (*entities.GenerateKubeReport, error) {
+func Kube(ctx context.Context, nameOrIDs []string, options entities.GenerateKubeOptions) (*entities.GenerateKubeReport, error) {
conn, err := bindings.GetClient(ctx)
if err != nil {
return nil, err
}
+ if len(nameOrIDs) < 1 {
+ return nil, errors.New("must provide the name or ID of one container or pod")
+ }
params := url.Values{}
+ for _, name := range nameOrIDs {
+ params.Add("names", name)
+ }
params.Set("service", strconv.FormatBool(options.Service))
- response, err := conn.DoRequest(nil, http.MethodGet, "/generate/%s/kube", params, nil, nameOrID)
+ response, err := conn.DoRequest(nil, http.MethodGet, "/generate/kube", params, nil)
if err != nil {
return nil, err
}