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 e5d3e6662..9c7245b00 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 @@ -45,7 +45,6 @@ public DocSection section() { all.addSection(docker); docker.addItem(diBuilder.getDocItem("docker/version", false)); docker.addItem(diBuilder.getDocItem("docker/cmd", false)); - docker.addItem(diBuilder.getDocItem("docker/volume-list", false)); docker.addItem(diBuilder.getDocItem("docker/debug", false)); final DocSection images = new DocSection("Images", id()); @@ -71,6 +70,13 @@ public DocSection section() { containers.addItem(diBuilder.getDocItem("docker/unpause", false)); containers.addItem(diBuilder.getDocItem("docker/wait", false)); + final DocSection volume = new DocSection("Volumes", id()); + all.addSection(volume); + volume.addItem(diBuilder.getDocItem("docker/volume-list", false)); + volume.addItem(diBuilder.getDocItem("docker/volume-create", false)); + volume.addItem(diBuilder.getDocItem("docker/volume-rm", false)); + volume.addItem(diBuilder.getDocItem("docker/volume-exist?", false)); + final DocSection utils = new DocSection("Utils", id()); all.addSection(utils); utils.addItem(diBuilder.getDocItem("docker/container-find-by-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 47c5604ca..a127feae0 100644 --- a/src/main/resources/com/github/jlangch/venice/docker.venice +++ b/src/main/resources/com/github/jlangch/venice/docker.venice @@ -713,6 +713,15 @@ (:out (apply docker/cmd cmdargs*)))) + +;; ----------------------------------------------------------------------------- +;; Volume functions +;; - docker/volume-list +;; - docker/volume-create +;; - docker/volume-rm +;; - docker/volume-exists? +;; ----------------------------------------------------------------------------- + (defn ^{ :arglists '("(docker/volume-list & options)") :doc """ @@ -728,10 +737,13 @@ (docker/volume-list) """ ) :see-also '( + "docker/volume-create" + "docker/volume-rm" + "docker/volume-exists?" "docker/images" "docker/run" ) } - volume-list [] + volume-list [& options] (let [opts (apply hash-map options) quiet (:quiet opts false) @@ -744,6 +756,67 @@ (parse-output-list format)))) +(defn + ^{ :arglists '("(docker/volume-create name)") + :doc """ + Create a volume. + """ + :examples '( + """ + (docker/volume-create "hello") + """ ) + :see-also '( + "docker/volume-list" + "docker/volume-rm" + "docker/volume-exists?" ) } + + volume-create [name] + + (->> (apply docker/cmd ["volume" "create" name]) + (:out))) + + +(defn + ^{ :arglists '("(docker/volume-rm name)") + :doc """ + Remove a volume. + """ + :examples '( + """ + (docker/volume-remove "hello") + """ ) + :see-also '( + "docker/volume-list" + "docker/volume-create" + "docker/volume-exists?" ) } + + volume-rm [name] + + (->> (apply docker/cmd ["volume" "rm" name]) + (:out))) + + +(defn + ^{ :arglists '("(docker/volume-exists? name)") + :doc """ + Returns true if the volume with the specified name exists. + """ + :examples '( + """ + (docker/volume-exists? "hello") + """ ) + :see-also '( + "docker/volume-list" ) } + + volume-exists? [name] + + (->> (docker/volume-list ":format" ":json") + (filter #(if (== name (get % name)))) + (count) + (pos?))) + + + ;; ----------------------------------------------------------------------------- ;; Generic docker command