|
25 | 25 | (defn pull-image [{:keys [image identity-token creds]}]
|
26 | 26 | (curl/post
|
27 | 27 | (format "http://localhost/images/create?fromImage=%s" image)
|
28 |
| - {:raw-args ["--unix-socket" "/var/run/docker.sock"] |
29 |
| - :throw false |
30 |
| - :headers {"X-Registry-Auth" |
31 |
| - ;; I don't think we'll be pulling images |
32 |
| - ;; from registries that support identity tokens |
33 |
| - (-> (cond |
34 |
| - identity-token {:identitytoken identity-token} |
35 |
| - creds creds) |
36 |
| - (json/generate-string) |
37 |
| - (encode))}})) |
| 28 | + (merge |
| 29 | + {:raw-args ["--unix-socket" "/var/run/docker.sock"] |
| 30 | + :throw false} |
| 31 | + (when (or creds identity-token) |
| 32 | + {:headers {"X-Registry-Auth" |
| 33 | + ;; I don't think we'll be pulling images |
| 34 | + ;; from registries that support identity tokens |
| 35 | + (-> (cond |
| 36 | + identity-token {:identitytoken identity-token} |
| 37 | + creds creds) |
| 38 | + (json/generate-string) |
| 39 | + (encode))}})))) |
38 | 40 |
|
39 | 41 | (comment
|
40 | 42 | (let [pat (string/trim (slurp "/Users/slim/.secrets/dockerhub-pat-ai-tools-for-devs.txt"))]
|
|
100 | 102 |
|
101 | 103 | (defn remove-volume [{:keys [Name]}]
|
102 | 104 | (curl/delete (format "http://localhost/volumes/%s" Name)
|
103 |
| - {:raw-args ["--unix-socket" "/var/run/docker.sock"] |
104 |
| - :throw false})) |
| 105 | + {:raw-args ["--unix-socket" "/var/run/docker.sock"] |
| 106 | + :throw false})) |
105 | 107 |
|
106 | 108 | (defn inspect-container [{:keys [Id]}]
|
107 | 109 | (curl/get
|
|
174 | 176 | :req-un [::image]))
|
175 | 177 |
|
176 | 178 | (defn run-function [m]
|
177 |
| - (when (and (:user m) (and (not (:offline m)) (or (:pat m) (creds/credential-helper->jwt)))) |
178 |
| - (pull (assoc m :creds {:username (:user m) |
179 |
| - :password (or (:pat m) (creds/credential-helper->jwt)) |
180 |
| - :serveraddress "https://index.docker.io/v1/"}))) |
| 179 | + (pull (merge m |
| 180 | + {:serveraddress "https://index.docker.io/v1/"} |
| 181 | + (let [jwt (creds/credential-helper->jwt)] |
| 182 | + (when (and (:user m) |
| 183 | + (or (:pat m) jwt)) |
| 184 | + {:creds {:username (:user m) |
| 185 | + :password (or (:pat m) jwt)}})))) |
181 | 186 | (let [x (create m)]
|
182 | 187 | (start x)
|
183 | 188 | (wait x)
|
|
0 commit comments