#9 - Use {:keys [...]} for map destructuring
This commit is contained in:
parent
9511f82dfe
commit
a5a78008ba
1 changed files with 6 additions and 18 deletions
|
|
@ -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))
|
||||||
|
|
||||||
|
|
@ -19,7 +15,7 @@
|
||||||
(if (some? env-vars)
|
(if (some? env-vars)
|
||||||
(doseq [pair env-vars]
|
(doseq [pair env-vars]
|
||||||
(.addEnv container (first pair) (second pair))))
|
(.addEnv container (first pair) (second pair))))
|
||||||
|
|
||||||
(if (some? command)
|
(if (some? command)
|
||||||
(.setCommand container command))
|
(.setCommand container command))
|
||||||
|
|
||||||
|
|
@ -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)
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue