Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make dependencies explicit #12

Merged
merged 1 commit into from
Sep 12, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading