Skip to content

Commit

Permalink
Make dependencies explicit
Browse files Browse the repository at this point in the history
  • Loading branch information
l4e21 committed Sep 12, 2023
1 parent 659d05b commit 620c795
Show file tree
Hide file tree
Showing 18 changed files with 242 additions and 108 deletions.
69 changes: 30 additions & 39 deletions installer-graph/src/juxt/site/install/common_install_util.clj
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,8 @@
:concrete-id concrete-id
:dependency dependency
;;:graph (keys graph)
})))))
}
)))))

;; installer-seq

Expand All @@ -130,24 +131,18 @@
templates."
[graph user-parameters installer-specs]
(->> installer-specs
(mapcat
(map
(fn [installer-spec]
(let [installer-parameters (:juxt.site/parameters installer-spec)
expanded-installer-parameters (render-form-templates installer-parameters user-parameters)
combined-parameters (merge user-parameters expanded-installer-parameters)
root (lookup-root installer-spec graph combined-parameters)]

(reverse
(tree-seq
some?
(fn [parent]
(assert parent)
(for [dep (:deps parent)
:let [child (lookup-dependency dep graph combined-parameters parent)]]
(-> child
(assoc :juxt.site/ultimate-dependant installer-spec)
(assoc :deps (:deps child)))))
(assoc root :juxt.site/parameters combined-parameters))))))))

(assoc root
:juxt.site/parameters combined-parameters
:juxt.site/dependencies
(for [dep (:deps root)]
(render-with-required-check dep combined-parameters))))))))

(defn installer-seq
"Given a graph of installer templates indexed by a (possibly templated) uri,
Expand All @@ -158,32 +153,28 @@
(->> installer-specs
(installer-seq-pt1 graph user-parameters)
(reduce
(fn [{:keys [seen-uri-set] :as acc}
(fn [acc
{:keys [juxt.site/uri install juxt.site/parameters] :as installer}]
(if-not (contains? seen-uri-set uri)
(let [init-data
(try
(render-form-templates install (assoc (merge user-parameters parameters) "$id" uri))
(catch clojure.lang.ExceptionInfo cause
(throw
(ex-info
(format "Failed to render init-data for '%s'" uri)
{:juxt.site/uri uri
:installer installer
:installer-parameters parameters
:user-parameters user-parameters
:cause cause}
cause))))]
(when (nil? init-data)
(throw (ex-info "Nil init data" {:juxt.site/uri uri})))
(-> acc
(update :installers conj (-> installer
(assoc :juxt.site/init-data init-data)
(dissoc :install)))
(update :seen-uri-set conj uri)))
acc))
{:seen-uri-set #{}
:installers []})
(let [init-data
(try
(render-form-templates install (assoc (merge user-parameters parameters) "$id" uri))
(catch clojure.lang.ExceptionInfo cause
(throw
(ex-info
(format "Failed to render init-data for '%s'" uri)
{:juxt.site/uri uri
:installer installer
:installer-parameters parameters
:user-parameters user-parameters
:cause cause}
cause))))]
(when (nil? init-data)
(throw (ex-info "Nil init data" {:juxt.site/uri uri})))
(-> acc
(update :installers conj (-> installer
(assoc :juxt.site/init-data init-data)
(dissoc :install))))))
{:installers []})
:installers))


Expand Down
17 changes: 1 addition & 16 deletions installers/auth.example.org/operations/install-resources.edn
Original file line number Diff line number Diff line change
Expand Up @@ -26,22 +26,7 @@
tx-ops (juxt.site/installer-seq->tx-ops installer-seq)]

{:juxt.site/tx-ops tx-ops})}

:juxt.site/transact
{:juxt.site.sci/program
#juxt.pprint
(let [tx-ops (:juxt.site/tx-ops *prepare*)
put-ids (map :xt/id (map second (filter (fn [x] (= (first x) :xtdb.api/put)) tx-ops)))
#_#_body (pr-str put-ids) #_(clojure.string/join "\r\n"
(cons
(format "Successful application of %d tx-ops\r\n" (count tx-ops))
put-ids)
)]

(-> tx-ops
#_(conj
[:ring.response/body (pr-str tx-ops)])))}


:juxt.site/scope
#{"https://auth.example.org/scopes/system/write"}

Expand Down
Loading

0 comments on commit 620c795

Please sign in to comment.