Artifact Inspection
Just-in-time artifacts such as containers, directories and files are represented by core Dagger objects such as Container
, Directory and File
respectively. Each of these core objects defines various functions, which you can "chain" to inspect or interact with the resulting artifact.
For example, the Directory
object exposes an Entries()
function, which lists the contents of the directory. Here is an example of using it, by chaining an Entries()
function call to the returned Directory
object of a Go builder Dagger Function:
dagger -m github.com/kpenfound/dagger-modules/golang@v0.2.0 call build --source=https://github.com/dagger/dagger --args=./cmd/dagger entries
Similarly, the File
object exposes a Contents()
function, which prints the contents of the corresponding file. Here is an example of using it to print the JSON report of a ruff
linter Dagger Function, by chaining a Contents()
function call to the returned File
object:
dagger call -m github.com/dagger/dagger/dev/ruff@a29dadbb5d9968784847a15fccc5629daf2985ae lint --source https://github.com/dagger/dagger report contents
Similar, the File
object exposes a Size()
function, which returns the size of the corresponding file. Here is an example of obtaining the size of the ZIP file returned by a file archiving Dagger Function, by chaining a Size()
function call to the returned File
object:
dagger -m github.com/sagikazarmark/daggerverse/arc@40057665476af62e617cc8def9ef5a87735264a9 call archive-directory --name=dagger-cli '--directory=https://github.com/dagger/dagger#main:cmd/dagger' create --format=zip size
Container
objects expose a WithExec()
function, which lets you execute a command in the corresponding container. Here is an example of chaining this function call to a container returned by a Wolfi container builder Dagger Function, to execute the cowsay
command:
dagger -m github.com/shykes/daggerverse/wolfi@v0.1.4 call container --packages=cowsay with-exec --args=cowsay,dagger stdout