#`dagger call` "cannot return external type from dependency", why ?

1 messages · Page 1 of 1 (latest)

tepid sapphire
#

I'm curious why we cannot re-use dependent modules' generated types. Is this something that is potentially going to work in the future?
I'm exploring a monorepo use case where a module provides a find-projects function that returns []Project, with Project having further chainable methods, so you can do e.g. dagger call -m my-module find-projects --source . build publish --token=env:TOKEN.

I was pleasantly surprised that dagger call would see that find-project returns a list, and therefore execute the build -> publish chain for each Project. However, then I noticed it doesn't seem to do so in parallel, so I thought I'll just do a PublishAll in my source code (parent) module where I parallelize it, e.g.:

projects := dag.MyModule().Projects(dagger.MyModuleProjectsOpts { Source: source })
published := make([]dagger.MyModuleProject, len(projects))
wg := sync.WaitGroup{}
for i, p := range projects {
  wg.Add(1)
  go func() {
    published[i] = p.Build().Publish(token)
    wg.Done()
  }
}
wg.Wait()

But there are still some useful getters on dagger.MyModuleProject (e.g. the ref of the image that was just published), so ideally I'd want to just return published in this local-module function and be able to dagger call publish-all ref (with ref being a function on dagger.MyModuleProject for example. The only way to do that right now is to make my own local copy of the type and map to it.

tawdry cradle
tepid sapphire
# tawdry cradle Ongoing discussion: https://github.com/dagger/dagger/issues/8529

Thanks! Ok I see, haven't even considered the general implications of this. FWIW, so far I only needed this composition 1 level deep, with the parent module being the composition root of a specific app, only ever used there and never installed anywhere else. So for me the name-sprawl would be fairly limited and not a huge UX wart for the value it'd provide.