From 2273214c59794ca6fca59b08ed0f4b298520d307 Mon Sep 17 00:00:00 2001 From: Brian Cully Date: Tue, 4 Oct 2022 09:57:35 -0400 Subject: [PATCH] Provide Podman containers on their own method. * tramp-docker.el (tramp-podman-program): New defcustom. (tramp-podman-method): New defconst. (tramp-docker-program): Remove "podman" from option list. (top): update comments to refer to Docker-alike where necessary. Add description for how to use the podman method. --- lisp/tramp-docker.el | 39 ++++++++++++++++++++++++++++++++++----- 1 file changed, 34 insertions(+), 5 deletions(-) diff --git a/lisp/tramp-docker.el b/lisp/tramp-docker.el index 12fabfe7..e7657414 100644 --- a/lisp/tramp-docker.el +++ b/lisp/tramp-docker.el @@ -1,4 +1,4 @@ -;;; tramp-docker.el --- Tramp integration for Docker containers -*- lexical-binding: t; -*- +;;; tramp-docker.el --- Tramp integration for Docker-like containers -*- lexical-binding: t; -*- ;; Copyright © 2022 Free Software Foundation, Inc. @@ -24,14 +24,18 @@ ;;; Commentary: ;; ‘tramp-docker’ allows Tramp access to environments provided by -;; Docker. +;; Docker and similar programs. ;; ;; ## Usage ;; -;; Open a file on a running systemd-docker container: +;; Open a file on a running Docker container: ;; ;; C-x C-f /docker:USER@CONTAINER:/path/to/file ;; +;; or Podman: +;; +;; C-x C-f /podman:USER@CONTAINER:/path/to/file +;; ;; Where: ;; USER is the user on the container to connect as (optional) ;; CONTAINER is the container to connect to @@ -46,16 +50,27 @@ :group 'tramp :version "29.1" :type '(choice (const "docker") - (const "podman") + (string))) + +;;;###tramp-autoload +(defcustom tramp-podman-program "podman" + "Name of the Podman client program." + :group 'tramp + :version "29.1" + :type '(choice (const "podman") (string))) ;;;###tramp-autoload (defconst tramp-docker-method "docker" "Tramp method name to use to connect to Docker containers.") +;;;###tramp-autoload +(defconst tramp-podman-method "podman" + "Tramp method name to use to connect to Podman containers.") + ;;;###tramp-autoload (defun tramp-docker--completion-function (&rest _args) - "List Docker containers available for connection. + "List Docker-like containers available for connection. This function is used by `tramp-set-completion-function', please see its function help for a description of the format." @@ -89,9 +104,23 @@ see its function help for a description of the format." (tramp-remote-shell-login ("-l")) (tramp-remote-shell-args ("-i" "-c"))) tramp-methods) + (push `(,tramp-podman-method + (tramp-login-program ,tramp-podman-program) + (tramp-login-args (("exec") + ("-it") + ("-u" "%u") + ("%h") + ("%l"))) + (tramp-remote-shell ,tramp-default-remote-shell) + (tramp-remote-shell-login ("-l")) + (tramp-remote-shell-args ("-i" "-c"))) + tramp-methods) (tramp-set-completion-function tramp-docker-method + '((tramp-docker--completion-function ""))) + (tramp-set-completion-function + tramp-podman-method '((tramp-docker--completion-function "")))) (add-hook 'tramp-unload-hook -- 2.37.3