diff options
author | OpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com> | 2018-12-18 12:13:59 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-12-18 12:13:59 -0800 |
commit | 08eeef8a8531568a4b652761c71ad6604902eddc (patch) | |
tree | b13b5efde62809ec939003a41d6d4976ed21f25b /cmd/podman/generate_kube.go | |
parent | 51d80ed01b95dc9f96ec7fae48eab4453e9475d7 (diff) | |
parent | 0702e71ca5440c6cf801a05cff616eafc6454220 (diff) | |
download | podman-08eeef8a8531568a4b652761c71ad6604902eddc.tar.gz podman-08eeef8a8531568a4b652761c71ad6604902eddc.tar.bz2 podman-08eeef8a8531568a4b652761c71ad6604902eddc.zip |
Merge pull request #2019 from baude/kubeserviceinline
generate service object inline
Diffstat (limited to 'cmd/podman/generate_kube.go')
-rw-r--r-- | cmd/podman/generate_kube.go | 33 |
1 files changed, 20 insertions, 13 deletions
diff --git a/cmd/podman/generate_kube.go b/cmd/podman/generate_kube.go index 6483ffd72..8f2f0de32 100644 --- a/cmd/podman/generate_kube.go +++ b/cmd/podman/generate_kube.go @@ -17,7 +17,7 @@ var ( containerKubeFlags = []cli.Flag{ cli.BoolFlag{ Name: "service, s", - Usage: "only generate YAML for kubernetes service object", + Usage: "generate YAML for kubernetes service object", }, } containerKubeDescription = "Generate Kubernetes Pod YAML" @@ -36,13 +36,14 @@ var ( // generateKubeYAMLCmdgenerates or replays kube func generateKubeYAMLCmd(c *cli.Context) error { var ( - podYAML *v1.Pod - container *libpod.Container - err error - output []byte - pod *libpod.Pod - mashalledBytes []byte - servicePorts []v1.ServicePort + podYAML *v1.Pod + container *libpod.Container + err error + output []byte + pod *libpod.Pod + marshalledPod []byte + marshalledService []byte + servicePorts []v1.ServicePort ) if rootless.IsRootless() { @@ -79,11 +80,13 @@ func generateKubeYAMLCmd(c *cli.Context) error { if c.Bool("service") { serviceYAML := libpod.GenerateKubeServiceFromV1Pod(podYAML, servicePorts) - mashalledBytes, err = yaml.Marshal(serviceYAML) - } else { - // Marshall the results - mashalledBytes, err = yaml.Marshal(podYAML) + marshalledService, err = yaml.Marshal(serviceYAML) + if err != nil { + return err + } } + // Marshall the results + marshalledPod, err = yaml.Marshal(podYAML) if err != nil { return err } @@ -96,7 +99,11 @@ func generateKubeYAMLCmd(c *cli.Context) error { # Created with podman-%s ` output = append(output, []byte(fmt.Sprintf(header, podmanVersion.Version))...) - output = append(output, mashalledBytes...) + output = append(output, marshalledPod...) + if c.Bool("service") { + output = append(output, []byte("---\n")...) + output = append(output, marshalledService...) + } // Output the v1.Pod with the v1.Container fmt.Println(string(output)) |