#How to prevent leaf functions from being automatically synced?

1 messages · Page 1 of 1 (latest)

inland pewter
#

Hello!

Since v0.12.0 the CLI finds all functions without required arguments that return a scalar/primitive value, and prints them (https://github.com/dagger/dagger/pull/7479).

I really like the feature which is super useful most of the time. However, some of my modules have leaf functions that I do not want to automatically execute.

There are leaf functions that I do not want to execute every time as it might create artifacts somewhere, take a long time to execute, ...
e.g.

func (m *MyModule) Publish(ctx context.Context) (string, error) { ... }

There are functions that will fail the whole execution as they do not have required arguments defined when they actually need some.
e.g.

func (m *MyModule) Test(ctx context.Context,
    // SSH Auth Socket to access internal repositories
    // +optional
    sshSocket *dagger.Socket,
    // GitHub Token to access internal repositories
    // +optional
    ghToken *dagger.Secret,
) (string, error) { 
    if sshSocket == nil && ghToken == nil {
        return "", errors.New("either SSH or token authentication is required")
    }
    ...
}

Is there a way to exclude functions from being resolved automatically?

heady totem
#

I really like the feature which is super useful most of the time. However, some of my modules have leaf functions that I do not want to automatically execute.

#

👋 if you don't want your function to be callable through the CLI you can make it private and then nobody will be able to call it

twin dove
#

This is an open topic @inland pewter ... there's an issue somewhere for it, will try to find it.

#

One option we discussed is to change the selection filter to print the object state, in other words the actual fields in your object. There's typically a lot of overlap between the two possible selections, but it's not 100% overlap. One benefit of selecting fields is that your problem would go away (those problematic functions would not be selected). One possible downside is that you may have false negatives: accessor functions that are safe to print, but won't be selected.

What are your thoughts on this option @inland pewter ?

inland pewter
inland pewter
# twin dove One option we discussed is to change the selection filter to *print the object s...

It seems like the leaf functions are more useful, I normally do not have anything in the module struct apart from a base container and a source directory.
For instance its super nice to have all kinds of tests run in parallel in my golang module and see this kind of output:

_type: Golang
check: ""
fmt: ""
test: |
    ?           github.com/vincent/example/cmd/hello    [no test files]
    ok          github.com/vincent/example/internal/reverse     (cached)
vet: ""
inland pewter