An alternative is to specify that in the constructor of the module (example below). This let functions access the files/directories they operate on, regardless of whether they are called by the user, or by another function.
func New(
// +defaultPath="."
// +ignore=["*", "!/X/"]
CheckXSource *dagger.Directory,
// +defaultPath="."
// +ignore=["*", "!/Y/"]
CheckYSource *dagger.Directory,
// +defaultPath="."
// +ignore=["*", "!/Z/"]
CheckZSource *dagger.Directory,
) *Module {
return &Module{
checkXSource: CheckXSource,
checkXSource: CheckXSource,
checkXSource: CheckXSource,
}
}
The downside of the method is that the constructor quickly becomes complex, that the relationship between a function and the files it operates on is less clear and harder to keep consistent (as things are declared far appart), and that all *Sources are populated, no matter if they are used. I feel like this last point affect performance with larger DAG but I haven't measured it.
Do I understand correctly ? Are there alternative ways to write that kind of code ? Is this pattern (fine-grained inputs + composing functions) common or should I structure things differently ? Thanks again for your help.