here is my dagger function in typescript
@func()
buildZshContainer(commandToRun: string): Promise<string> {
return dag
.container()
.from("alpine:latest")
.withExec(["apk", "update"])
.withExec(["apk", "add", "--no-cache", "zsh", "curl", "git", "bash"])
.withNewFile(
"/scripts/custom-functions.zsh",
`
# Custom Zsh Functions
function hello() {
echo "Hello, $1!"
}
function detectModifiedMavenModules() {
echo "maven/parent/subModule1"
}
`
)
.withExec(["/bin/zsh", "-c", "source /scripts/custom-functions.zsh; " + commandToRun]).stdout(); // execute the command and return the output
}
I can call from this module I can call:
dagger call build-zsh-container --commandToRun='hello you' --> that will work
dagger call build-zsh-container --commandToRun=detectModifiedMavenModules--> that will aslo work.
My issue / question is that the functions are "hardCoded" here in the typescript file.
If my "zsh functions" are very complex and are in multiple files,
- option1 : I could put the scripts on github and have dagger fetch them but I do not like so much this idea as it creates an "external depency" to the
buildZshContainer.
- option2: I could aggregate all my scripts and I hard code them in the typescript.
The option2 is definitely ugly, but in the end I get exactly what I want: a zsh container on which I can call some functions. (the issue is that it will be very ugly in the typescript file and whenever I want to make a change in my script file it will be horrible).
Any idea/suggestion ? (basically I think that I would like to include some zsh script file into a dagger module... is that possible ?)