                               :scheduledAt (str (java.util.Date.))
                               :status "sche"})))))))))
 
-(defn watch-resource [rt process]
+(defn watch-resource [cfg rt process]
   (if @stop
     (println "Stop watching " (name rt))
-    (future (process (walk/keywordize-keys (k8s/list k8s/cfg rt)))
+    (future (process (walk/keywordize-keys (k8s/list cfg rt)))
             (Thread/sleep 5000)
             (watch-resource rt process))))
 

(defonce stop (atom nil))

(defn process-build [builds]
  (when-let [items (:items builds)]
    (doseq [i items]
      (when-not (:pod i)
        (let [id (get-in i [:metadata :name])]

        (println "Add webhook " (:url r))
        (spit "/tmp/repl" (str "add web hook" "\n\n\n"))))))

(defn watch []
  (watch-resource cfg :builds process-build))

(comment

  (watch-resource cfg :builds process-build)

  (watch-resource :repositories process-repository)

  ("items")
  (doseq [b (get (k8s/list cfg :builds) "items")]
    (println
     (k8s/delete cfg :builds
                 (get-in b ["metadata" "name"]))))


  (reset! stop true)
  (reset! stop false)

