-
Notifications
You must be signed in to change notification settings - Fork 0
/
containers.clj
43 lines (34 loc) · 1.27 KB
/
containers.clj
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
(ns monkey.ci.containers
"Generic functionality for running containers"
(:require [medley.core :as mc]
[monkey.ci
[config :as c]
[runtime :as rt]]))
;; TODO Rework to use a container runner fn instead
(defmulti run-container (comp :type :containers))
(defn- update-env [cc]
(mc/update-existing cc :env (partial map (fn [[k v]]
(str k "=" v)))))
(defn rt->container-config
"Extracts all keys from the context step that have the `container` namespace,
and drops that namespace."
[rt]
(->> rt
:job
(mc/filter-keys (comp (partial = "container") namespace))
(mc/map-keys (comp keyword name))
(update-env)))
;;; Configuration handling
(defmulti normalize-containers-config (comp :type :containers))
(defmethod normalize-containers-config :default [conf]
conf)
(defmethod c/normalize-key :containers [k conf]
(c/normalize-typed k conf normalize-containers-config))
(defmethod rt/setup-runtime :containers [conf _]
;; Just return the config, will be reworked later to be more consistent with other runtimes
(get conf :containers))
(def image :image)
(def env :container/env)
(def cmd :container/cmd)
(def mounts :container/mounts)
(def entrypoint :container/entrypoint)