Skip to main content
Version: 1.0-beta

Calling functions

dagger check, dagger generate, and dagger start are conveniences built on top of the underlying primitive: calling a module's functions. When you need something those verbs don't cover, call functions directly.

dagger api call go module --path=. test

Discover functions​

List the functions available in your workspace:

dagger api functions

List the functions on a specific module:

dagger api functions go

Every function and its arguments are also visible through --help:

dagger api call go --help

Pass arguments​

Arguments are flags on the function that accepts them:

dagger api call go --version=1.25 module --path=. test

Secrets are passed the same way, via provider URIs:

dagger api call deploy --token=env:DEPLOY_TOKEN

Chain functions​

Functions interconnect into a pipeline. Each function returns an object, and the next function is called on that result:

dagger -m core api call container \
from --address=alpine \
with-exec --args=echo,hello \
stdout

Collections​

A function that discovers the units of a project, such as Go packages or test files, returns a collection. Every collection has the same functions:

FunctionReturns
keysThe keys, in the order the module discovered them
listEvery item
getThe item with the given key
subsetA collection of the items with the given keys
batchFunctions that run once over every item in the collection

Select an item with get and keep chaining from it. In Dagger Shell, list the tests in one Go package:

dagger -c 'go | packages | get store | tests | keys'
TestFixture
TestDatabase

dagger check and dagger generate select collection items with flags instead. See Select collection items.

Output​

By default the result is printed to your terminal. Format it as JSON:

dagger api call go module --path=. generate-directories --json

Or save a returned file or directory to the host:

dagger api call build --output=./dist