#Consuming function modules from custom applications (SDK)?

1 messages · Page 1 of 1 (latest)

lyric maple
#

Is there currently no story for consuming Dagger Functions style modules from a custom application that uses the Dagger SDK?

The gist of my problem is:

  • I like using functions and modules to organize various platform components and building blocks (verbose, flexible)
  • I don't prefer functions (in their current state) as a user-facing interface, as in this case I care about a zero-config principle, which needs host access (default access to various env vars, local files, docker credentials, exporting files, etc)

So ideally, I would want to use the SDK to build a custom CLI which (thanks to host access) can handle all my UX needs, before calling a module function.
But judging by the docs, it's not clear to me whether this is at all possible ? The table says "No" to "Direct" access to 3rd party modules. Is there any "Indirect" workaround ? I don't mind maintaining a dagger.json and having to code gen in the custom application etc.

feral tusk
#

It has rough edges but it does work

#

cc @inland torrent who is working on that

lyric maple
#

😮 awesome, will give it a try

lyric maple
#

What are the limitations as of 0.18.8? I don't think I'm able to properly generate client with a dependency module. Might be doing it wrong. I did a dagger init (local dir/module is called dagger-sdk) -> dagger install <mydependency> (dependency name is deliver). I can see dag.Deliver() has been generated and also a bunch of things around the types that the deliver module has. But a bunch of types seem to be missing:

dagger/dag/dag.gen.go:83:26: undefined: dagger.DaggerSDK
dagger/dag/dag.gen.go:94:24: undefined: dagger.Deliver
dagger/dag/dag.gen.go:188:36: undefined: dagger.DaggerSDKID
dagger/dag/dag.gen.go:188:57: undefined: dagger.DaggerSDK
dagger/dag/dag.gen.go:194:45: undefined: dagger.DeliverEnvironmentID
dagger/dag/dag.gen.go:194:75: undefined: dagger.DeliverEnvironment
dagger/dag/dag.gen.go:200:34: undefined: dagger.DeliverID
dagger/dag/dag.gen.go:200:53: undefined: dagger.Deliver
dagger/dag/dag.gen.go:206:48: undefined: dagger.DeliverManifestBundleID
dagger/dag/dag.gen.go:206:81: undefined: dagger.DeliverManifestBundle
dagger/dag/dag.gen.go:206:81: too many errors
#

Or here's the same thing just with a reproducible public module:

{
  "name": "dagger-sdk",
  "engineVersion": "v0.18.8",
  "sdk": {
    "source": "go"
  },
  "dependencies": [
    {
      "name": "go",
      "source": "github.com/sagikazarmark/daggerverse/go",
      "pin": "ceffda4aebd349a24fc00e591b4ed9b801535b65"
    }
  ],
  "source": ".dagger",
  "clients": [
    {
      "generator": "go",
      "directory": "dagger"
    }
  ]
}
func main() {
    dag.Go()
}
dagger/dag/dag.gen.go:83:26: undefined: dagger.DaggerSDK
dagger/dag/dag.gen.go:85:16: client.DaggerSDK undefined (type *dagger.Client has no field or method DaggerSDK)
dagger/dag/dag.gen.go:138:24: undefined: dagger.GoOpts
dagger/dag/dag.gen.go:138:40: undefined: dagger.Go
dagger/dag/dag.gen.go:188:36: undefined: dagger.DaggerSDKID
dagger/dag/dag.gen.go:188:57: undefined: dagger.DaggerSDK
dagger/dag/dag.gen.go:290:29: undefined: dagger.GoID
dagger/dag/dag.gen.go:290:43: undefined: dagger.Go
dagger/dag/dag.gen.go:296:39: undefined: dagger.GoWithSourceID
dagger/dag/dag.gen.go:296:63: undefined: dagger.GoWithSource
dagger/dag/dag.gen.go:85:16: too many errors
inland torrent
# lyric maple What are the limitations as of 0.18.8? I don't think I'm able to properly genera...

Hey!

I fixed that problem in https://github.com/dagger/dagger/pull/10393

It will be fixed by the release including this pr

GitHub

Part of #9582
Pass the moduleSourceID instead of a JSON file so it simplifies SDK implementation and let it rely on the codegen.
If a moduleSourceID is passed to the codegen CLI,
it will fetch its ...

lyric maple
#

Also.. minor but am curious, are there plans to suport "source-less" dagger modules ? For this use case I basically only need a dagger.json for dagger client without generating local module code boilerplate into source (e.g. .dagger) .

turbid bloom
lyric maple
#

yeah should have clarified that... I'm talking about the fact that the source dir is always generated even though I'm not using it for anything. Tried removing it but dagger client install --generator go brings it back

turbid bloom
#

and that way it won't generate the src dir anymore

lyric maple
#

oh, I've missed the part where you can dagger init without --sdk, that works great, thanks!