Hello, I'm new to duct and was wondering if someone could help me with some project setup. I'm following https://github.com/duct-framework/duct/wiki/Configuration instructiong but based on https://github.com/duct-framework/duct/wiki/Configuration#configedn section is looks like they are a little out of date since the default config doesn't look like that (unless I've gotten a base version). My problem is that following the instructions as they are https://github.com/duct-framework/duct/wiki/Configuration#completed-configuration my completed configuration isn't overwriting :duct.core/environment
with :development
as I would hope. My project is all default stuff except I have replaced {}
with
{:duct.core/environment :development
:duct.core/include ["image_service/config"]}
in dev/resources/dev.edn
per the README. I would assume that when I run (duct/prep-config (read-config) profiles)
(from the default dev namespace) it would merge the dev config and replace the environment config. Does anyone know what I'm missing here?Hmm.. seems like that's an outdated config
Have you seen this one? https://github.com/duct-framework/docs/blob/master/GUIDE.rst
Well, I have now. Thanks 🙂 wasn't aware of that but I'll take a stab at it
I think I'm going to backup / delete the outdated section, and reference the guide I just linked
Well I don't even need to back it up since it's git
Also, be sure to update your packages after you generate a new Duct project (with for example lein ancient)
Hmm, I don't see anything in regards to dev configurations in this guide. I'd be more than willing to write it once I figure it out though
The way dev configuration works is with the profiles system. For example in the config.edn
file there is the following like:
:duct.profile/dev #duct/include "dev"
If the :duct.profile/dev
key is passed in the duct.core/exec-config
or duct.core/prep-config
function, then that profile's EDN file gets merged into your base profile
The following two definitions should be in your dev.clj
file
(def profiles
[:duct.profile/dev :duct.profile/local])
(integrant.repl/set-prep! #(duct/prep-config (read-config) profiles))
Which will make sure that the dev.edn
file gets merged into your base config during development
Yes, those are there. When I run (duct/prep-config (read-config) profiles)
I can see that my dev config has been picked up correctly, but it doesn't seem to be merging it into the base
Strange, that should be the case. Do you have your config online / can you share it?
Oh, I think I know the issue
All your keys need to be top-level in your dev.edn
If you're seeing the keys in the resulting config, but they aren't being merged into your base, then that's probably the issue
My dev edn is
{:duct.core/environment :development
:duct.core/include ["image_service/config"]}
Actually, I may still be operating off of suggestions from that old README. If I want duct.core/environment
to default to :production
would I put that in the base or in the top level?
Does your base have the following format?
{:duct.profile/base
{:duct.core/project-ns my-app
,,,}
:duct.profile/dev #duct/include "dev.edn"}
Since you're starting off from the old guide, it's probably a bit messed up
No, the includes are in the base
Lemme try moving them out :thinking_face: ?
I think the best thing you can do is run lein new duct my-app
And then just restart the guide
Because generating a new duct app (and updating dependencies) should already be enough
And yeah, :duct.profile/dev
has to be outside of the base config
Ah, OK. Yeah, even generated on has it this way
Not sure how I got here
Yup, that did it...
Thank you 🙇
No problem, a bit of an unfortunate start with that outdated config
Also, in terms of the difference between keys inside of the base config vs outside of the base config:
Any keys outside of the base config are "duct module" keys. These are initiated during preperation (`duct/prep-config`), and modify the base config somehow. All module keys' ig/init-key
return a function (fn [config] config)
where the fn
modifies config
(base config)
Might be a bit confusing at first, but I'm not sure if there's any documentation on them either
Gotcha, I'm sure it'll start to make sense as I play around with it more
thanks again for all the help!
👍
Is there an idiomatic way to do local setup tasks? In my case I just want to ensure that a bucket exists in a local minio container
You could add a key to dev.edn with an init-key that's dev only
That's a cool idea! I feel like a real dumb dumb for just now starting to use integrant
Integrant can be very powerful once you get the hang of it