diff options
Diffstat (limited to 'cmd/podman')
-rw-r--r-- | cmd/podman/generate_kube.go | 33 | ||||
-rw-r--r-- | cmd/podman/login.go | 19 |
2 files changed, 39 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)) diff --git a/cmd/podman/login.go b/cmd/podman/login.go index cfdd8005b..4452651f8 100644 --- a/cmd/podman/login.go +++ b/cmd/podman/login.go @@ -34,6 +34,10 @@ var ( Usage: "Pathname of a directory containing TLS certificates and keys used to connect to the registry", }, cli.BoolTFlag{ + Name: "get-login", + Usage: "Return the current login user for the registry", + }, + cli.BoolTFlag{ Name: "tls-verify", Usage: "Require HTTPS and verify certificates when contacting registries (default: true)", }, @@ -65,6 +69,21 @@ func loginCmd(c *cli.Context) error { sc := common.GetSystemContext("", authfile, false) + if c.IsSet("get-login") { + user, err := config.GetUserLoggedIn(sc, server) + + if err != nil { + return errors.Wrapf(err, "unable to check for login user") + } + + if user == "" { + return errors.Errorf("not logged into %s", server) + } + + fmt.Printf("%s\n", user) + return nil + } + // username of user logged in to server (if one exists) userFromAuthFile, passFromAuthFile, err := config.GetAuthentication(sc, server) if err != nil { |