summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--cmd/podman/generate_kube.go33
-rw-r--r--cmd/podman/login.go19
-rw-r--r--completions/bash/podman1
-rwxr-xr-xcontrib/python/podman/test/test_runner.sh1
-rw-r--r--docs/podman-generate-kube.1.md56
-rw-r--r--docs/podman-login.1.md4
6 files changed, 89 insertions, 25 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 {
diff --git a/completions/bash/podman b/completions/bash/podman
index 9a8adb502..4702ae0e0 100644
--- a/completions/bash/podman
+++ b/completions/bash/podman
@@ -2217,6 +2217,7 @@ _podman_login() {
--password
-p
--authfile
+ --get-login
"
local boolean_options="
--help
diff --git a/contrib/python/podman/test/test_runner.sh b/contrib/python/podman/test/test_runner.sh
index bf097e2b2..651b2e74f 100755
--- a/contrib/python/podman/test/test_runner.sh
+++ b/contrib/python/podman/test/test_runner.sh
@@ -41,6 +41,7 @@ export TMPDIR=`mktemp -d /tmp/podman.XXXXXXXXXX`
trap "cleanup $TMPDIR" EXIT
function umount {
+ set +xeuo pipefail
# xargs -r always ran once, so write any mount points to file first
mount |awk "/$1/"' { print $3 }' >${TMPDIR}/mounts
if [[ -s ${TMPDIR}/mounts ]]; then
diff --git a/docs/podman-generate-kube.1.md b/docs/podman-generate-kube.1.md
index 59c3353a5..396f69615 100644
--- a/docs/podman-generate-kube.1.md
+++ b/docs/podman-generate-kube.1.md
@@ -22,7 +22,7 @@ random port is assigned by Podman in the specification.
# OPTIONS:
**s** **--service**
-Generate a service file for the resulting Pod YAML.
+Generate a Kubernetes service object in addition to the Pods.
## Examples ##
@@ -82,31 +82,63 @@ spec:
status: {}
```
-Create Kubernetes service YAML for a container called `some-mariabdb`
+Create Kubernetes Pod YAML for a pod called `demoweb` and include a service.
```
-$ sudo podman generate kube -s some-mariadb
-# Generation of Kubenetes YAML is still under development!
+$ sudo podman generate kube -s demoweb
+# Generation of Kubernetes YAML is still under development!
#
# Save the output of this file and use kubectl create -f to import
# it into Kubernetes.
#
-# Created with podman-0.11.2-dev
+# Created with podman-0.12.2-dev
+apiVersion: v1
+kind: Pod
+metadata:
+ creationTimestamp: 2018-12-18T15:16:06Z
+ labels:
+ app: demoweb
+ name: demoweb-libpod
+spec:
+ containers:
+ - command:
+ - python3
+ - /root/code/graph.py
+ env:
+ - name: PATH
+ value: /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
+ - name: TERM
+ value: xterm
+ - name: HOSTNAME
+ - name: container
+ value: podman
+ image: quay.io/baude/demoweb:latest
+ name: practicalarchimedes
+ resources: {}
+ securityContext:
+ allowPrivilegeEscalation: true
+ capabilities: {}
+ privileged: false
+ readOnlyRootFilesystem: false
+ tty: true
+ workingDir: /root/code
+status: {}
+---
apiVersion: v1
kind: Service
metadata:
- creationTimestamp: 2018-12-03T19:08:24Z
+ creationTimestamp: 2018-12-18T15:16:06Z
labels:
- app: some-mariadb
- name: some-mariadb-libpod
+ app: demoweb
+ name: demoweb-libpod
spec:
ports:
- - name: "3306"
- nodePort: 30929
- port: 3306
+ - name: "8050"
+ nodePort: 31269
+ port: 8050
protocol: TCP
targetPort: 0
selector:
- app: some-mariadb
+ app: demoweb
type: NodePort
status:
loadBalancer: {}
diff --git a/docs/podman-login.1.md b/docs/podman-login.1.md
index 7c033d7c5..e72d1deca 100644
--- a/docs/podman-login.1.md
+++ b/docs/podman-login.1.md
@@ -36,6 +36,10 @@ Path of the authentication file. Default is ${XDG_\RUNTIME\_DIR}/containers/auth
Note: You can also override the default path of the authentication file by setting the REGISTRY\_AUTH\_FILE
environment variable. `export REGISTRY_AUTH_FILE=path`
+**--get-login**
+
+Return the logged-in user for the registry. Return error if no login is found.
+
**--cert-dir** *path*
Use certificates at *path* (\*.crt, \*.cert, \*.key) to connect to the registry.