Coverage report: /home/ellis/comp/core/lib/pod/buildah.lisp

KindCoveredAll%
expression070 0.0
branch02 0.0
Key
Not instrumented
Conditionalized out
Executed
Not executed
 
Both branches taken
One branch taken
Neither branch taken
1
 ;;; buildah.lisp --- Buildah Lisp Utils
2
 
3
 ;; 
4
 
5
 ;;; Code:
6
 (in-package :pod)
7
 
8
 (defvar *buildah-container*)
9
 (defun buildah-from (img)
10
   (trim 
11
    (with-output-to-string (s)
12
      (run-buildah (list "from" img) :output s))))
13
 
14
 (defun buildah-add (src dst) 
15
   (run-buildah 
16
    (list "add" *buildah-container* (namestring src) (namestring dst)) 
17
    :output t))
18
 
19
 (defun buildah-run (args &key dir env)
20
   (run-buildah 
21
    `("run" ,@(when dir `("--workingdir" ,(namestring dir)))
22
            ,@(when env (flatten
23
                         (mapcar (lambda (e) 
24
                                   (if-let ((val (cdr e)))
25
                                     `("--env" ,(format nil "~A=~A" (car e) val))
26
                                     `("--unsetenv" ,(car e))))
27
                                 env)))
28
            ,*buildah-container* ,@(if (stringp args)
29
                                       (ssplit #\space args)
30
                                       (mapcar 'string args)))
31
    :output t))
32
 
33
 (defun buildah-copy (&rest args)
34
   (run-buildah `("copy" ,*buildah-container* ,@args) :output t))
35
 
36
 (defun buildah-config (&rest args)
37
   (run-buildah `("config" ,@args ,*buildah-container*) :output t))
38
 
39
 (defmacro with-buildah ((sym from &key commit (rm t)) &body body)
40
   `(let ((,sym (buildah-from ,from)))
41
      (setf *buildah-container* ,sym)
42
      ,@body
43
      ,@(when commit `((run-buildah (list "commit" ,sym ,commit))))
44
      ,@(when rm `((run-buildah (list "rm" ,sym))))))
45
 
46
 ;; (with-buildah (c "o0") (buildah-run '("ls" "-la") :dir "/root/"))