Hi 👋
You are right. Here is a repro:
package main
import (
"context"
"fmt"
"log"
"os"
"dagger.io/dagger"
)
func main() {
client, err := dagger.Connect(context.Background(), dagger.WithLogOutput(os.Stderr))
if err != nil {
log.Fatal(err)
}
defer client.Close()
// create a container, lazily executed (later)
ctr := client.Container().From("alpine")
// add package, lazily executed too (later)
ctrWithCurl := ctr.WithExec([]string{"apk", "add", "curl"})
// curl google
// Here, the ctr + ctrWithCurl gets computed + cached.
// Any subsequent command relying on ctrWithCurl will rely on that cached layer.
output, err := ctrWithCurl.WithExec([]string{"curl", "google.com"}).Stdout(context.TODO())
if err != nil {
log.Fatal("did not manage to curl google", err)
}
fmt.Println("google", output)
// curl yahoo
// relies on ctrWithCurl, which has been cached
output, err = ctrWithCurl.WithExec([]string{"curl", "yahoo.com"}).Stdout(context.TODO())
if err != nil {
log.Fatal("did not manage to curl google", err)
}
fmt.Println("yahoo", output)
}