#Bikeshed: default module source dir?
1 messages Β· Page 1 of 1 (latest)
π§΅
Bikeshed: default module source dir?
Suggestions so far:
-
./functions(where the code goes for your module's functions. If you don't set this directory, your module has no functions) -
./dagger_src(source code for your dagger stuff) -
./dagger(your dagger stuff)
./dag(your subgraph of the :onedag: π€)
Is there further reading for this change? Curious what use case it's optimized for (or is that part of the question?)
e.g. is this for Dagger module authors creating repos with the express purpose of module publishing, or is this for Dagger module consumers who are using Dagger within an existing repo (i.e. the product they build)?
It came out of a bunch of threads related to the CLI polish
no good paper trail I'm afraid, sorry
@river heart asked this question recently too, will dig up the thread (https://discord.com/channels/707636530424053791/1199495113747988480)
To summarize:
dagger initis for everyone now: consumers and producers of modules.
dagger initby default creates a codeless module, ie. a receptacle for dependencies. It allows todagger install LONGanddagger call -m SHORT
- Later the consumer graduates to writing their own "main" module, when gluing
dagger callin a shell scripts becomes too much. At that point theydagger developtheir first functions. At this point the module now has source code for functions of its own.
- Of course sometimes you intend to publish the module from the start, in which case you would either
dagger init && dagger developright away, or as @golden jewel proposed it:dagger init --sdkas a convenience so you don't have to run 2 commands
- In the case of the consumer: the question is where should I call
dagger init? The answer is: the root of your repo. That way you get, finally, a standardized entrypoint πgit clone && dagger call
- Finally: when a consumer upgrades to developing their first functions, with
dagger develop: where should the source code go? Today the answer is: the root of the module! In other words:"source": ".". But that tends to pollute your app repo. Most people will want something like"source": "./ci". So maybe we should default to that? Except"ci"maybe isn't the right path to default to. Hence the current bikeshedding.
- Due to how
"source":works, no matter where the module's source lives, it can still be at the root of the repo. So you still get togit clone && dagger call
Ha, it's kind of funny that we ended up with dagger.json in the root of your repo after all, but it makes sense (and is still not required, just a sane default)
Right, you can still have sub-modules anywhere you want, and local imports in any layout you wish
What if we had a .dagger directory instead, and put the dagger.json + source code there?
I think @fresh imp suggested that in one of our office hours
For cosmetic reasons you mean?
I say we reserve the right to support that as an alternative form, in the future. We could just decide to check for both. It seems a bit late to break the current layout
Supporting it as an alternative form, would also help writing a dagger.json to the user's home directory by default (like npm -f). I prefer having ~/.dagger/dagger.json than ~/dagger.json. Instead of making a special case just for home, it kind of makes sense to support both everywhere
Oh interesting. Yeah I don't remember the original motivation, but I mentioned it this time because then we just have to decide on one toplevel name in someone's repo (.dagger), rather than naming two (dagger.json + ???)
you mean like DAGGER_MODULES=$HOME/ci ?
Oh one important detail: we discussed defaulting to <dir>/<sdk> in other words, namespace source code by sdk by default. This makes it easier to handle things like switching SDKs without figuring out which files to wipe.
Yeah going to do that whichever name we choose for <dir>
This is fortunately very easy to adjust (and/or support in the future backwards compatibly)
@severe fog one downside of .dagger is that it's weird to store source code in a hidden directory. I know because we did this in (some old cue-based version, can't remember how old) and that feedback came up
Yeah it does feel weird especially if the modules are the focal point of the repo
On the plus side, it would appear above .github in repos on github π
I agree itβs weird but feels like thatβs how GHA and circleci do it, so seems like there is at least some normalization of this (recognizing itβs yaml and not code)
Is this a convention forming, to put tool-specific configs in dotfiles in a repo? I see we also have .changes in our own repo for Changie. It kinda makes sense I guess, wonder how people feel about it generally. People probably spend a lot of time editing .github at least.
(Yielding the floor to further bikeshedding)
FTR my vote is dagger/, but no problem with dagger_src/ or dag/ either. My gut feeling is that putting actual code in a . prefixed dir is odd and surprising, but can't really justify it fully. The fact that we use code is sufficiently different from yaml configs to differ from that loose convention. But I also wouldn't strongly object to it either, just a gut feeling.
trying hard to form an opinion
I can always see what copilot autocompletes it to if nothing else π
I'm good with dagger/ too, only slightly dreading getting it mixed up with all my other dagger dirs, but that's a me problem
I generally dislike directories with underscores, but I canβt really reason why
dag may overlap with an actual dag package in the software, ao it should be a setting that can be changed
Yeah this is just a default but you can specify whatever you want with --source <path> too
I hope DAGGER_SOURCE env var will work as well.
That would not make sense IMO, it's always an implementation detail of the module
Why is there a default then?
Env vars are for changing defaults in a lot of cases (eg. I wanna use mydaggerstuff, because dag and dagger are taken by my software packages)
As far as I understood, this is similar to setting DAGGER_MODULE=ci , so I donβt have to pass it to dagger every single time. Thatβs my new default. I can still override it with -mod if I want to.
Anyway, this is a little off topic now I guess.
it's just that env variables are for settings exposed to the caller. But source is not exposed to the caller as a setting. It's part of the module's layout, like its dependencies. It would be like having a DAGGER_DEPENDENCIES env var.
that particular default is for module authors not consumers
I don't think I am clear why source needs to be defaulted. I feel like there will be a myriad of ways people will name their source directory. Would enforcing it for dagger develop be an option? If you type dagger develop without a --source kindly ask to provide one.
Or make it a TUI question if source doesn't exist
"Where do you want your module source code to be?" for eg
but most devs won't know what to answer. "you tell me", they will think in frustration π
we default to . currently. It's just not the best default now, with the new best practice of rooting main module in your git root
agree with that. So in the TUI question we set the default to whatever we decide here. Instead of ".". That way, the user is aware and has a chance to modify it. Implicitly creating the folder doesn't feel right to me. Although it can become the dagger convention later on.
I may have misunderstood what this is about. I reacted to Erik's --source flag. If there is one thing I hate, it's passing the same parameters to the same command over and over again. π (and writing a script to make that easier is a very close second on that list) (so I guess it's at least two things I don't like very much)
--source is a flag to init or develop which are one-time commands.
Once the source value is written to dagger.json, you never have to type it again
FYI, for now the implementation went with dagger/<sdk> as the default value of --source: https://github.com/dagger/dagger/pull/6575
Hm, could we revisit this? I'm really unsure as to why this is a common use case.
Surely the case of using multiple SDKs like this isn't the general use case? Surely, if the modules are different, we'd want to have actually different names.
I don't generally understand why https://github.com/dagger/dagger/issues/6607 is a feature we want - surely, if we've already set an SDK for a module, then it should be in that language. If you've set it accidentally and want to change it, we should require that users force that option (with something like --force). like hugo new site ./dir/ or git clone ... ./dir works, if ./dir exists and has contents.
Part of that issue is just support for renaming, which I think comes up in common cases where you change your mind about what you want the name to be. Currently that's a fairly painful manual process but could be automated.
I agree that changing SDK is gonna be more obscure and probably only something that would come up fairly early in the development process, e.g. I started writing a module in go but then remembered I hate go and switched to python instead π But it does feel reasonable to support (eventually, not a top priority in my mind) in one way or another.
Having <sdk> in the default source path just slightly eases things in that it would result in the new source not overwriting the previous source. It only applies in that case where the default was used though, so not a general solution. In my mind, it was otherwise harmless, so may as well go with it even if the benefits are marginal. What's the concern with having it there?
it's just another layer of directories - even though github and lots of tools will collapse this into one, not everything does this.
i just don't really like the extra directory level, if it feels very unlikely that it's actually gonna get committed and used
tbf, i am having trouble coming up with reasons that aren't "i just don't like how it looks and would want to clean it up all the time"
I don't feel strongly attached to it. It just seemed like it might help keep things simpler by not mixing files from different SDKs. But I don't feel strongly about it.
Yeah, agree that it's unnecessary. If I wanted to change the SDK I'd just rename dagger dir to dagger_go or dagger/go (manually) before new dagger init.
@fringe rivet you like dagger/ best?
Yeah, just dagger or .dagger.
That's fair, and what a lot of these choices come down to, which is unfortunate because it's hard to measure the aesthetics of paths in an objective way π Like I said I viewed the benefits as marginal, so I'm not attached either
i can still see myself often overriding it, e.g. for my daggerverse
but i think, for the case of using dagger modules in a monorepo, the dagger default makes sense
Probably with source=. then?
Yeah, me too... using --source. But I get why.
exactly yeah
same sentiment here. dagger/ is better
This was a bit strange: dagger init --sdk=go --source=. some/subdir π Makes sense if you know source is relative to PATH, but you think intuitively it's relative to your workdir, so I almost tried this first: dagger init --sdk=go --source=some/subdir some/subdir.
yeah.. Not sure what's the least bad there TBH
my remaining worry (maybe needs a separate thread) is in making the decoupling between init & develop really work.
The goal of decoupling is to make it easy and natural to initialize a module, install and call dependencies before you're ready to choose an SDK answer write code.
How to design this decoupling to make it work great, I don't have strong opinions on
Ah yeah that's actually something I'll fix actually. The rest of the path arguments in the CLI are always relative to your cwd (i.e. dagger install), with the CLI/engine doing the path arithmetic to make them relative to the source root as needed, so that should be too for consistency if nothing else
I really like not having to make two commands π Replacing mkdir ... && cd ... && dagger init .... with dagger init ... && dagger develop.
I've been thinking about grouping flags like we group commands. Lots of CLIs do this.
So the flags to develop could be separate in --help. Same with global flags for TUI for example.
Not following sorry. What would I run for:
-
Initializing a module without code
-
Adding code to an existing module
-
As a convenience: combining the two when that's what you need
init in all three cases?
dagger initdagger develop ...dagger init --sdk ...
I think that's the current design π So you're saying you like it the way it is?
Yes, I'm saying I like it how it is π Not to require init + develop when authoring.
Initializing a module without code
Dumb question probably. Why is this a common usecase?
is it to support dagger install externalModule?
yes, and calling them from CLI and shell scripts
Can't dagger install externalModle initialize if not already initialized?
as an additional convenience, maybe. As the only way to initialize a module without code, I'd say no.
I can see the parallel with git init so it's something devs are used to doing
right, we're betting on that familiarity