#Passing container as an arg in the interactive Shell

1 messages · Page 1 of 1 (latest)

floral rain
#

I want to build a container and then list the files in the container.

(see screenshot in red)
I tried doing this as 2 methods and then chaining them in the interactive shell,
1 - build container and return a Container instance
2- have a Container input arg, call container.with_exec([ ** llist files **])
workspace . | build-env https://github.com/westonplatter/terraform-mysql-admin.git | list-files-in-container However, the shell errored out with,
! no function "list-files-in-container" in type "Container"

(see screenshot in yellow)
I also tried passing the container within the same function and was able to print out the files, workspace . | build-env-and-list-files https://github.com/westonplatter/terraform-mysql-admin.git.

Is it possible to pass a container from a module's function1 to function2 and read from the container file system in function 2 ? Essentially,
function1 | function2

Full code here, https://gist.github.com/westonplatter/2df32c9522045bb958f5b4ea45cd155a

Gist

Dagger - list files in container passed as arg. GitHub Gist: instantly share code, notes, and snippets.

mortal cedar
#

The simplest method is having your intermediate functions return an instance of Workspace, and have an attribute on Workspace for the container.

#

As long as functions return Workspace you can keep chaining them

fleet current
mortal cedar
fleet current
rancid dew
mortal cedar
#

That's a simple enough substitution, I'll try it at some point. I've built modules such that containers are chained the old way