summaryrefslogtreecommitdiff
path: root/cmd
diff options
context:
space:
mode:
authorbaude <bbaude@redhat.com>2018-12-17 13:19:05 -0600
committerbaude <bbaude@redhat.com>2018-12-18 09:17:30 -0600
commit0702e71ca5440c6cf801a05cff616eafc6454220 (patch)
treec937c8b919fd76f7c51e67dfc36b448124a80033 /cmd
parent510b5a81dcea7df4c95388db0b66df17a691cb1c (diff)
downloadpodman-0702e71ca5440c6cf801a05cff616eafc6454220.tar.gz
podman-0702e71ca5440c6cf801a05cff616eafc6454220.tar.bz2
podman-0702e71ca5440c6cf801a05cff616eafc6454220.zip
generate service object inline
no longer require the service object be output to a different file; we should be doing this inline with the pods for user convenience. Signed-off-by: baude <bbaude@redhat.com>
Diffstat (limited to 'cmd')
-rw-r--r--cmd/podman/generate_kube.go33
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))