#Hey guys - just came back to zenith and

1 messages · Page 1 of 1 (latest)

lucid hemlock
#

found dagger listen in an old thread! good to go!

crisp pollen
lucid hemlock
#

yup!

crisp pollen
#

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 🙂

lucid hemlock
#

it seems the dev loop here falls back into the commit and pray model though? dagger modules can't be run from local directories :/ ?

sturdy raptor
#

Yes you can run modules from local directories

#

dagger -m ci lint for example

lucid hemlock
#

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
sturdy raptor
#

steven.tobias@bird.co probably your path parsed as url

lucid hemlock
#

ah dag - I'm pretty stuck then lol

sturdy raptor
#

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

lucid hemlock
#

ah ok I can try that, the dagger mod install -m ../foo returns an error

sturdy raptor
#

yea, it returns parsing error which I always forget to open bug for it. You can use manual edit as workaround

lucid hemlock
#

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
sturdy raptor
#

Just a side note root: "../.." important here to load your dependent module loaded to dagger

#

What do you want do with working directory?

lucid hemlock
#

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

sturdy raptor
#

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

lucid hemlock
#

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

sturdy raptor
#

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

lucid hemlock
#

right but I've got like 50 repositories and I dont want to write this per repo.

just need "dagger.build(src)"

sturdy raptor
#

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

lucid hemlock
#

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 🙂

crisp pollen
crisp pollen
#

@lucid hemlock basically it all works the way you want it to, except for a few bugs & missing features 😁

lucid hemlock
#

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.

  1. 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"

  1. 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

ripe dew
#

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.

crisp pollen
ripe dew
#

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.