Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Podman support #1

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,13 @@ By default the rendering is set to happen in an external viewer (such as
`xviewer`) and can be changed to any other binary or set to render within Emacs
itself via inserting an image into a new buffer.

In order to use Podman instead of Docker as container engine, set it as follows:

```
(setq-default mermaid-docker-engine "podman")
(setq mermaid-mmdc-location "podman")
```

Make sure to check related `defconst` parts of the file to customize.

[melpa-badge]: http://melpa.org/packages/mermaid-docker-mode-badge.svg
Expand Down
21 changes: 14 additions & 7 deletions mermaid-docker-mode.el
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,13 @@
:group 'mermaid-docker
:type 'boolean)

(defcustom mermaid-docker-engine
"docker"
"Container engine."
:group 'mermaid-docker
:type '(string :options ("docker" "podman"))
:set 'set-default)

(define-error 'mermaid-docker-error "Generic mermaid-docker-mode error")

(define-error 'mermaid-docker-render-error
Expand Down Expand Up @@ -143,7 +150,7 @@ Argument CMD-LIST list of strings as a command+args to execute."
(mermaid-docker--log "Checking deps for mermaid-docker"))
(let ((buff-name "*mermaid-docker deps*")
(failed nil)
(deps '("docker")))
(deps (list mermaid-docker-engine)))
(unless (eq window-system 'ns)
(push "wmctrl" deps))
;; clean first
Expand All @@ -156,8 +163,8 @@ Argument CMD-LIST list of strings as a command+args to execute."
;; permissions, network, etc
(dolist
(item (list
(list nil "docker" "run" "--rm" "hello-world:latest")
(list nil "docker" "run" "--rm" "--network=none"
(list nil mermaid-docker-engine "run" "--rm" "hello-world:latest")
(list nil mermaid-docker-engine "run" "--rm" "--network=none"
"hello-world:latest")))
(let ((tmp nil))
(setq tmp (pop item))
Expand All @@ -179,7 +186,7 @@ Argument CMD-LIST list of strings as a command+args to execute."

(when (mermaid-docker--call-cmd
(get-buffer-create buff-name)
(list "docker" "run" "--rm" "--interactive"
(list mermaid-docker-engine "run" "--rm" "--interactive"
(format "%s:%s"
mermaid-docker-image-name
mermaid-docker-image-tag)
Expand Down Expand Up @@ -214,7 +221,7 @@ Argument FILENAME Diagram file."
(with-temp-file out-file
(when (mermaid-docker--call-cmd
(current-buffer)
(list "docker" "run" "--rm" "--interactive"
(list mermaid-docker-engine "run" "--rm" "--interactive"
"--network=none"
(format "%s:%s"
mermaid-docker-image-name
Expand Down Expand Up @@ -249,7 +256,7 @@ Argument FILENAME Diagram file."

(when (mermaid-docker--call-cmd
tmp-buff
(list "docker" "run" "--rm" "--interactive"
(list mermaid-docker-engine "run" "--rm" "--interactive"
"--network=none"
(format "%s:%s"
mermaid-docker-image-name
Expand Down Expand Up @@ -314,7 +321,7 @@ Argument FILENAME =mermaid-compile-file= input arg."
(with-temp-file out-file
(when (mermaid-docker--call-cmd
(current-buffer)
(list "docker" "run" "--rm" "--interactive"
(list mermaid-docker-engine "run" "--rm" "--interactive"
"--network=none"
(format "%s:%s"
mermaid-docker-image-name
Expand Down