#9 - Use {:keys [...]} for map destructuring

This commit is contained in:
Tim Zöller 2020-06-13 14:49:07 +02:00
parent 9511f82dfe
commit a5a78008ba

View file

@ -7,11 +7,7 @@
(defn create (defn create
"Sets the properties for a testcontainer instance" "Sets the properties for a testcontainer instance"
[{image-name :image-name [{:keys [image-name exposed-ports env-vars command]}]
exposed-ports :exposed-ports
env-vars :env-vars
command :command}]
(let [container (org.testcontainers.containers.GenericContainer. image-name)] (let [container (org.testcontainers.containers.GenericContainer. image-name)]
(.setExposedPorts container (map int exposed-ports)) (.setExposedPorts container (map int exposed-ports))
@ -32,10 +28,7 @@
(defn map-classpath-resource! (defn map-classpath-resource!
"Maps a resource in the classpath to the given container path. Should be called before starting the container!" "Maps a resource in the classpath to the given container path. Should be called before starting the container!"
[container-config [container-config
{resource-path :resource-path {:keys [resource-path container-path mode]}]
container-path :container-path
mode :mode}]
(assoc container-config :container (.withClasspathResourceMapping (:container container-config) (assoc container-config :container (.withClasspathResourceMapping (:container container-config)
resource-path resource-path
container-path container-path
@ -44,10 +37,7 @@
(defn bind-filesystem! (defn bind-filesystem!
"Binds a source from the filesystem to the given container path. Should be called before starting the container!" "Binds a source from the filesystem to the given container path. Should be called before starting the container!"
[container-config [container-config
{host-path :host-path {:keys [host-path container-path mode]}]
container-path :container-path
mode :mode}]
(assoc container-config :container (.withFileSystemBind (:container container-config) (assoc container-config :container (.withFileSystemBind (:container container-config)
host-path host-path
container-path container-path
@ -55,10 +45,8 @@
(defn copy-file-to-container! (defn copy-file-to-container!
"Copies a file into the running container" "Copies a file into the running container"
[container-conf {container-path :container-path [container-conf
path :path {:keys [container-path path type]}]
type :type}]
(let [mountable-file (cond (let [mountable-file (cond
(= :classpath-resource type) (org.testcontainers.utility.MountableFile/forClasspathResource path) (= :classpath-resource type) (org.testcontainers.utility.MountableFile/forClasspathResource path)
(= :host-path type) (org.testcontainers.utility.MountableFile/forHostPath path) (= :host-path type) (org.testcontainers.utility.MountableFile/forHostPath path)