#Dagger functions showing a function called "with"

1 messages · Page 1 of 1 (latest)

jaunty oar
#

Hello, I've started to use Dagger with Go for a project and I noticed a function called with is listed whenever I use dagger functions. I assume it comes from my constructor but I'm not sure why. How can I hide it? Thanks in advance!

dagger functions
▶ ✔ connect 0.3s
✔ load workspace: . 5.1s

Name   Description
with   Configure the homelab constructor arguments.

The code:

type Homelab struct {
    // +private
    Src *dagger.Directory
}

func New(
    // +optional
    // +defaultPath="."
    src *dagger.Directory,
) *Homelab {
    return &Homelab{
        Src: src,
    }
}
lyric girder
#

cc @red girder

red girder
#

I don't think that's a regression, it's a new feature.
See https://github.com/dagger/dagger/blob/6e6a18036e4ed31f0488c697ecebc667971cfe3f/core/object.go#L1157-L1166

It allows to have a function just for the constructor args.
So before: dagger call --src my-dir my-func and with it dagger call with --src my-dir my-func

And especially with modules v2, for modules that are not set as an entrypoint (or for toolchains currently) it means you'll write something like:

dagger call go with --limit=1 check-tidy

This is coming from the workspace: plumbing & compat PR:

  • switched constructor-arg flow to with instead of flattening constructor args into each proxy
  • hid entrypoint constructors from the outer schema; clients are expected to use with plus proxy methods
tacit lark
jaunty oar
#

Oh wow, I thought I was doing something wrong I didn't expect it to be an actual feature 😅
Tbh, I also think it's a bit confusing being displayed like this in functions. At first, I even tried to run it without arguments to see what it would do and it just printed Query which didn't help me much.

lyric girder
red girder
red girder