From 93ba4a272db07ab1e8e7aa1778d99b25f5cd21b4 Mon Sep 17 00:00:00 2001 From: Juerg Lang Date: Sat, 16 Sep 2023 22:16:20 +0200 Subject: [PATCH] refactoring --- .../modules/ModuleDockerSection.java | 1 + .../com/github/jlangch/venice/docker.venice | 33 ++++++++++++++++--- 2 files changed, 30 insertions(+), 4 deletions(-) diff --git a/src/main/java/com/github/jlangch/venice/impl/docgen/cheatsheet/modules/ModuleDockerSection.java b/src/main/java/com/github/jlangch/venice/impl/docgen/cheatsheet/modules/ModuleDockerSection.java index a17a62427..f7c198c5b 100644 --- a/src/main/java/com/github/jlangch/venice/impl/docgen/cheatsheet/modules/ModuleDockerSection.java +++ b/src/main/java/com/github/jlangch/venice/impl/docgen/cheatsheet/modules/ModuleDockerSection.java @@ -79,6 +79,7 @@ public DocSection section() { final DocSection utils = new DocSection("Utils", id()); all.addSection(utils); utils.addItem(diBuilder.getDocItem("docker/images-query-by-repo", false)); + utils.addItem(diBuilder.getDocItem("docker/image-ready?", false)); utils.addItem(diBuilder.getDocItem("docker/container-find-by-name", false)); utils.addItem(diBuilder.getDocItem("docker/container-exists-with-name?", false)); utils.addItem(diBuilder.getDocItem("docker/container-running-with-name?", false)); diff --git a/src/main/resources/com/github/jlangch/venice/docker.venice b/src/main/resources/com/github/jlangch/venice/docker.venice index 5e8752f3a..001977f95 100644 --- a/src/main/resources/com/github/jlangch/venice/docker.venice +++ b/src/main/resources/com/github/jlangch/venice/docker.venice @@ -1015,6 +1015,7 @@ ;; ----------------------------------------------------------------------------- ;; Utility functions ;; - docker/images-query-by-repo +;; - docker/image-ready? ;; - docker/container-find-by-name ;; - docker/container-find-by-name ;; - docker/container-exists-with-name? @@ -1042,14 +1043,38 @@ (map #(get % "ID"))) """ ) :see-also '( - "docker/images" ) } + "docker/images", + "docker/image-ready?" ) } images-query-by-repo [repo] - { :pre [(string? name)] } + { :pre [(string? repo)] } (->> (docker/images :format :json) - (filter #(== repor (get % "Repository"))))) + (filter #(== repo (get % "Repository"))))) + + +(defn + ^{ :arglists '("(docker/image-ready? repo tag)") + :doc """ + Returns true if the image is ready for use else false. + """ + :examples '( + """ + (docker/image-ready? "arangodb/arangodb" "3.10.10") + """ ) + :see-also '( + "docker/images" + "docker/images-query-by-repo" ) } + + image-ready? [repo tag] + + { :pre [(string? repo) (string? tag)] } + + (->> (docker/images-query-by-repo repo) + (filter #(== tag (get % "Tag"))) + (count) + (pos?))) (defn @@ -1253,7 +1278,7 @@ "docker/container-stop-by-name" "docker/container-status-by-name" ) } - container-exec-by-name [name] + container-exec-by-name [name] { :pre [(string? name)] }