duct

ted 2020-07-18T15:57:52.285300Z

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?

kwrooijen 2020-07-18T16:06:33.285600Z

Hmm.. seems like that's an outdated config

kwrooijen 2020-07-18T16:07:05.285800Z

Have you seen this one? https://github.com/duct-framework/docs/blob/master/GUIDE.rst

ted 2020-07-18T16:09:18.287200Z

Well, I have now. Thanks 🙂 wasn't aware of that but I'll take a stab at it

kwrooijen 2020-07-18T16:11:04.287900Z

I think I'm going to backup / delete the outdated section, and reference the guide I just linked

kwrooijen 2020-07-18T16:11:39.288500Z

Well I don't even need to back it up since it's git

kwrooijen 2020-07-18T16:13:29.289100Z

Also, be sure to update your packages after you generate a new Duct project (with for example lein ancient)

ted 2020-07-18T16:19:49.290100Z

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

kwrooijen 2020-07-18T16:22:33.290900Z

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"

kwrooijen 2020-07-18T16:24:23.292200Z

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

kwrooijen 2020-07-18T16:25:22.293100Z

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))

kwrooijen 2020-07-18T16:26:39.294100Z

Which will make sure that the dev.edn file gets merged into your base config during development

ted 2020-07-18T16:26:58.294600Z

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

kwrooijen 2020-07-18T16:28:23.295100Z

Strange, that should be the case. Do you have your config online / can you share it?

kwrooijen 2020-07-18T16:29:01.295300Z

Oh, I think I know the issue

kwrooijen 2020-07-18T16:30:01.295900Z

All your keys need to be top-level in your dev.edn

kwrooijen 2020-07-18T16:30:32.296800Z

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

ted 2020-07-18T16:30:43.297Z

My dev edn is

{:duct.core/environment :development
 :duct.core/include ["image_service/config"]}

ted 2020-07-18T16:31:46.298500Z

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?

kwrooijen 2020-07-18T16:32:18.299Z

Does your base have the following format?

{:duct.profile/base
 {:duct.core/project-ns my-app
  ,,,}
 :duct.profile/dev #duct/include "dev.edn"}

kwrooijen 2020-07-18T16:32:38.299600Z

Since you're starting off from the old guide, it's probably a bit messed up

ted 2020-07-18T16:32:41.299700Z

No, the includes are in the base

ted 2020-07-18T16:33:03.300400Z

Lemme try moving them out :thinking_face: ?

kwrooijen 2020-07-18T16:33:07.300600Z

I think the best thing you can do is run lein new duct my-app

kwrooijen 2020-07-18T16:33:11.300800Z

And then just restart the guide

kwrooijen 2020-07-18T16:33:31.301200Z

Because generating a new duct app (and updating dependencies) should already be enough

kwrooijen 2020-07-18T16:34:00.301600Z

And yeah, :duct.profile/dev has to be outside of the base config

ted 2020-07-18T16:34:58.303Z

Ah, OK. Yeah, even generated on has it this way

ted 2020-07-18T16:35:02.303300Z

Not sure how I got here

ted 2020-07-18T16:35:29.303700Z

Yup, that did it...

ted 2020-07-18T16:35:33.303900Z

Thank you 🙇

kwrooijen 2020-07-18T16:36:02.304600Z

No problem, a bit of an unfortunate start with that outdated config

kwrooijen 2020-07-18T16:36:26.305200Z

Also, in terms of the difference between keys inside of the base config vs outside of the base config:

kwrooijen 2020-07-18T16:37:14.306200Z

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)

kwrooijen 2020-07-18T16:37:36.306700Z

Might be a bit confusing at first, but I'm not sure if there's any documentation on them either

ted 2020-07-18T16:39:26.307400Z

Gotcha, I'm sure it'll start to make sense as I play around with it more

ted 2020-07-18T16:39:33.307700Z

thanks again for all the help!

kwrooijen 2020-07-18T16:39:43.307900Z

👍

ted 2020-07-18T17:31:37.309200Z

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

kwrooijen 2020-07-18T17:46:53.310500Z

You could add a key to dev.edn with an init-key that's dev only

ted 2020-07-18T18:50:48.311500Z

That's a cool idea! I feel like a real dumb dumb for just now starting to use integrant

kwrooijen 2020-07-18T19:22:18.312200Z

Integrant can be very powerful once you get the hang of it