#Can I call builtin functions without using a module?

1 messages · Page 1 of 1 (latest)

unborn light
#

Calling a module function that returns a builtin type - e.g. Container - I can chain this with its methods - e.g. WithExec.
But, can I also start a chain without calling a module first?
Something like: dagger call container from --address=alpine with-exec --args="echo,hello world"

jade cove
#

In the meantime there are workarounds

#

Thanks to a small bug in the Go SDK, you can use this small bash/zsh function to emulate it: #daggernauts message

#
function core() {
 (
  set -ex
  cd $(mktemp -d)
  echo "{\"name\":\"$1\", \"sdk\":\"go\"}" > dagger.json
  echo 'package main' > main.go
  shift
  dagger call "$@"
 )
}
#

core container from --address=alpine with-exec --args="echo,hello world" stdout

unborn light
#

That is very neat, thanks a bunch!

Something that might be related: #daggernauts message
Did you do anything more with that, or thought about it further?
It seems to me that it could be a way of actually calling the builtins, either directly via CLI or through a she-banged script like your example.
With the current workaround, and possible what comes from the PR you linked, I guess it is the go SDK that is used to interact with the engine, rather than something sh-esque.