-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Try harder to auth the pulls for missing images
- Loading branch information
1 parent
2be104a
commit 4b4ea7c
Showing
6 changed files
with
184 additions
and
41 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
(ns clean-local-images | ||
(:require [docker] | ||
[clojure.pprint :refer [pprint]])) | ||
|
||
(def images | ||
#{"vonwig/prompts" | ||
"vonwig/function_write_file" | ||
"vonwig/docker_scout_tag_recommendation" | ||
"vonwig/extractor-node" | ||
"vonwig/go-linguist" | ||
"vonwig/codescope" | ||
"vonwig/pre-commit" | ||
"markdownlint/markdownlint" | ||
"hadolint/hadolint" | ||
"docker/lsp"}) | ||
|
||
(comment | ||
(docker/delete-image {:image "vonwig/function_write_files"})) | ||
|
||
(defn repo? [images] | ||
(fn [tag-or-digest] | ||
(some (fn [image] (.startsWith tag-or-digest image)) images))) | ||
|
||
(defn -main [] | ||
(->> (docker/images {}) | ||
#_(map #(concat (:RepoTags %) (:RepoDigests %))) | ||
(filter #(some (repo? images) (concat (:RepoTags %) (:RepoDigests %)))) | ||
(map :Id) | ||
(map #(docker/delete-image {:image %})))) | ||
|
||
(-main) | ||
|
||
(comment | ||
(pprint (docker/images {})) | ||
) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
(ns creds | ||
(:require [babashka.fs :as fs] | ||
[babashka.process :as process] | ||
[cheshire.core :as json])) | ||
|
||
(defn credential-helper | ||
"doesn't work without a HOME and docker desktop install" | ||
[key] | ||
(let [path (fs/file (.get (System/getenv) "HOME") ".docker" "config.json")] | ||
(when (.exists path) | ||
(when-let [cred-store (-> (slurp path) (json/parse-string keyword) :credsStore)] | ||
(try | ||
(-> | ||
(process/process [(format "docker-credential-%s" cred-store) "get"] | ||
{:out :string :in key}) | ||
(deref) | ||
:out | ||
(json/parse-string keyword)) | ||
(catch Throwable _)))))) | ||
|
||
(defn credential-helper->jwt | ||
"doesn't work without a HOME and docker desktop install" | ||
[] | ||
(:Secret (credential-helper "https://index.docker.io/v1//access-token"))) | ||
|
||
(comment | ||
(credential-helper->jwt)) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters