#Hey guys - just came back to zenith and
1 messages · Page 1 of 1 (latest)
Were you able to aim graphiql at it?
yup!
I have a script but haven’t gotten around to making it a module left. wasn’t possible before 0.9, but with host networking there’s everything needed 🙂
dagger -m github.com/shykes/daggerverse/playground —target YOURMODULE 🙂
it seems the dev loop here falls back into the commit and pray model though? dagger modules can't be run from local directories :/ ?
Installing a local module that's not in git
➜ service-foo git:(stobias/ci-testing) ✗ dagger mod install -m /Users/steven@foo.co/repos/foo/infra/golang-cli/zenith/foo_service
• Engine: 55def26095a8 (version v0.9.3)
⧗ 0.96s ✔ 2
Error: failed to get module: for now, only github.com/ paths are supported: "/Users/me@foo.co/repos/foorides/infra/golang-cli/zenith/foo_service"
Trying to call the module from another dir
➜ service-sidewalkdetection git:(stobias/ci-testing) ✗ dagger call -m /Users/me@foo.co/repos/foorides/infra/golang-cli/zenith/foo_cli bootstrap
✘ load call ERROR [0.00s]
├ [0.00s] loading module
┃ Error: failed to get module config: for now, only github.com/ paths are supported: "/Users/me@foo.co/repos/foorides/infra/golang-cli/zenith/foo_cli"
• Engine: 55def26095a8 (version v0.9.3)
⧗ 1.20s ✔ 3 ✘ 1
steven.tobias@bird.co probably your path parsed as url
ah dag - I'm pretty stuck then lol
This is a dagger json from gale.
{
"name": "gale",
"root": "../..",
"sdk": "go",
"dependencies": [
"../actions/artifacts",
"../actions/artifactcache",
"../ghx",
"github.com/aweris/daggerverse/docker@969bc30a84b48f76a28afab3986144d2e47469df"
]
}
you can modify dagger.json manually and run dagger mod sync
that should work around your issue
ah ok I can try that, the dagger mod install -m ../foo returns an error
yea, it returns parsing error which I always forget to open bug for it. You can use manual edit as workaround
what about calling externally?
from module dir I'm not able to pass in host dir context from another directory
dagger call --workdir /long/path/to/dir func
when I load dag.Host().Dir('.') - I get the directory of the module
and then I cant call the module from the other dir (see above)
cd /long/path/to/dir
dagger call -m /path/to/module func
Just a side note root: "../.." important here to load your dependent module loaded to dagger
What do you want do with working directory?
Just trying to load in host dir like normal and build
I mean the specific function I'm working on right now should load a dir, modify it and export to the host
but all funcs will load from host dir at some level
hmm then you can set -m to load your module
let's say you have ci module in your project. You can run root of your project dagger -m ci foo
if you want to pass specific Directory or file you need to add *Directory or *File as parameter to your function and passit like
dagger -m ci lint --source "." for examp.e
https://github.com/aweris/gale/blob/c0bed86a298782335454b1282ff63d5d06ad26c6/daggerverse/gale/gale.go#L22-L23 like this optional Source parameter
noted re: passing source.
re module dir, I thought the point of modules was to share them across multiple projects?
I've got a central dagger libs repo (private) - so I either need to load my modules from a local dir outside my current dir, or from a private git repo
re module dir, I thought the point of modules was to share them across multiple projects?
Yes, but I guess that's one of the use-case. You can define your ci/cd as code in your repository as well.
It can replace your, magefile or makefiles with simple dagger commands. That depend on your needs and usecase
right but I've got like 50 repositories and I dont want to write this per repo.
just need "dagger.build(src)"
That's okay as well. You can publish one common module and re-use that module in your repo or import it in your ci module per project and wrap it custom parameters
Only issue could be for you, zenith doesn't supports private repos yet. Not sure if it solved or not
yeah exactly it looks like that's not supported yet https://discord.com/channels/707636530424053791/1171809848057401375
not sure how I can exclude dirs with
func example(src *Directory){}
either...
looks like great progress, maybe the full features set just isn't there yet. I can wait 🙂
you’re right. The target argument would be a source directory (so would support both)
@lucid hemlock basically it all works the way you want it to, except for a few bugs & missing features 😁
yes! I actually think I solved all the stuff above I was struggling with
writing up a little summary right now for posterity
Just to sum up a little in case anyone else finds this thread, I had two questions/issues here that are maybe moreso just a change in workflow than anything.
- When I'm developing a module, how do I run it against target directories?
Previously I was using syntax like this:
src := pipeline.Host().Directory(".", dagger.HostDirectoryOpts{
Exclude: ignoreList,
})
Then I could run my custom cobra cli or debug tools to run the build in a target directory. ./cli service build
With modules, I need to pass in the directory as an argument, though filtering out exclude dirs seems limited at this time.
func (m *MyModule) Bootstrap(ctx context.Context, src *Directory) {
// do cool stuff
}
then I can call like so - but noteably, from the module directory, not from my service (target) directory. dagger call --progress plain bootstrap --src "/Users/PATH_TO_DIR/repos/app/service-foo"
- How do I get or work with private modules?
Use local modules by directly editing dagger.json. I also had a really hacky fork where I just inject git http creds
If the dir you want to access is a parent of your submodule (at any level), you can add "root": ".." in dagger.json and also include and exclude patterns (example). Then you can use .Host().Directory(".." in the pipeline, with further excludes if needed. If multiple modules need this, then do it for a common one and use it as a dependency.
We want to be able to set include/exclude patterns from the CLI when providing a directory but there's no design for that yet. No great idea has come to mind.
That’s not safe, I think we need to cut that
I'm assuming that's for a module that's closely tied to a app, committed in the same repo. Not meant to be reused for other purposes.
For more reusability, ideally dir is provided as an arg. It can be filtered in ctr.WithDirectory if that fits, otherwise if it's a specific dir or file, they can be removed with WithoutDirectory and WithoutFile. It won't prevent those files from being uploaded, but can prevent unnecessary cache busts when integrating in pipelines.