Skip to content

Commit

Permalink
refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
jlangch committed Sep 16, 2023
1 parent d034502 commit 93ba4a2
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down
33 changes: 29 additions & 4 deletions src/main/resources/com/github/jlangch/venice/docker.venice
Original file line number Diff line number Diff line change
Expand Up @@ -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?
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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)] }

Expand Down

0 comments on commit 93ba4a2

Please sign in to comment.