changelog shortlog graph tags branches changeset files revisions annotate raw help

Mercurial > core / lisp/lib/pod/api.lisp

changeset 165: fbab9b24fbe6
parent: 9326f9e5778f
author: ellis <ellis@rwest.io>
date: Thu, 04 Jan 2024 23:07:59 -0500
permissions: -rw-r--r--
description: pod types
1 ;;; lib/pod/api.lisp --- Libpod API model
2 
3 ;;
4 #|
5 'podman info'
6 
7 curl --unix-socket /run/podman/podman.sock http://d/v4.0.0/libpod/info
8 
9 'podman pull quay.io/containers/podman'
10 
11 curl -XPOST --unix-socket /run/podman/podman.sock -v 'http://d/v4.0.0/images/create?fromImage=quay.io%2Fcontainers%2Fpodman'
12 
13 'podman list images'
14 
15 curl --unix-socket /run/podman/podman.sock -v 'http://d/v4.0.0/libpod/images/json' | jq
16 |#
17 ;;; Code:
18 (in-package :pod)
19 
20 (eval-always
21  (defvar *libpod-params* (make-hash-table :test #'equal))
22  (defvar *libpod-paths* (make-hash-table :test #'equal))
23  (defun register-libpod-param (name prototype)
24  (setf (gethash name *libpod-params*) prototype))
25  (defun register-libpod-path (name prototype)
26  (setf (gethash name *libpod-params*) prototype)))
27 
28 (defmacro register-libpod-params (&rest forms)
29  (dolist (f forms)
30  (register-libpod-param (car f) (cdr f))))
31 
32 (defmacro register-libpod-paths (&rest forms)
33  (dolist (f forms)
34  (register-libpod-path (car f) (cdr f))))
35 
36 ;; we should really group these better
37 (register-libpod-params ("caCertFile" string)
38  ("file" string)
39  ("kubeConfig" string)
40  ("namespace" string)
41  ("service" string)
42  ("detachKeys" string)
43  ("logs" boolean)
44  ("stderr" boolean)
45  ("stdin" boolean)
46  ("stdout" boolean)
47  ("stream" boolean)
48  ("name" string)
49  ("export" boolean)
50  ("fileLocks" boolean)
51  ("ignoreRootFS" boolean)
52  ("ignoreVolumes" boolean)
53  ("keep" boolean)
54  ("leaveRunning" boolean)
55  ("preCheckpoint" boolean)
56  ("printStats" boolean)
57  ("tcpEstablished" boolean)
58  ("withPrevious" boolean)
59  ("author" string)
60  ("changes" (vector string))
61  ("comment" string)
62  ("container" string)
63  ("format" string)
64  ("pause" boolean)
65  ("repo" string)
66  ("squash" boolean)
67  ("stream" boolean)
68  ("tag" string)
69  ("path" string)
70  ("depend" boolean)
71  ("force" boolean)
72  ("ignore" boolean)
73  ("timeout" int)
74  ("v" boolean)
75  ("until" time)
76  ("label" string)
77  ("label!" string)
78  ("names" (vector string))
79  ("noTrunc" boolean)
80  ("podmanOnly" boolean)
81  ("replicas" int)
82  ("service" boolean)
83  ("type" string)
84  ("additionalEnvVariables" (vector string)))
85 
86 (register-libpod-paths
87  ;; system
88  ("libpod/info" (:get))
89  ("libpod/_ping" (:get))
90  ("libpod/system/df" (:get))
91  ;; container
92  ("libpod/containers/json" (:get (all filters limit namespace pod size sync)))
93  ;; image
94  ("libpod/images/json" (:get (all filters)))
95  ;; pod
96  ("libpod/pods/json" (:get (filters)))
97  ;; volume
98  ("libpod/volumes/json" (:get (filters)))
99  ;; secret
100  ("libpod/secrets/json" (:get (filters)))
101  ;; network
102  ("libpod networks/json" (:get (filters))))
103 
104 (defstruct libpod-param
105  (name "" :type string)
106  (val nil))
107 
108 (defstruct (libpod-request (:conc-name "REQUEST-"))
109  (path "" :type string)
110  (method :get :type keyword)
111  (params (make-array 0 :element-type 'libpod-param :fill-pointer 0 :adjustable t) :type (vector libpod-param))
112  (body nil))
113 
114 (defmethod push-param ((param libpod-param) (request libpod-request))
115  (vector-push param (request-params request)))
116 
117 (defmethod build-request ((self libpod-request))
118  "Return a function that calls DEX:REQUEST with args filled in from
119 SELF. Holes are left open and exposed as arguments to the returned
120 function as in the below lambda-list:
121 
122 (SOCKET ENDPOINT &OPTIONAL CALLBACK)."
123  (compile nil
124  (lambda (socket endpoint &optional callback)
125  (declare (ignorable socket endpoint callback)))))
126 
127 (defstruct libpod-response
128  (status)
129  (headers)
130  (body nil :type (or null vector)))
131 
132 ;; (defmacro define-libpod-request (path))
133 ;; (defmacro define-libpod-response (name))