diff --git a/dagger/component.go b/dagger/component.go index 874d1512..78c1f4bf 100644 --- a/dagger/component.go +++ b/dagger/component.go @@ -57,7 +57,10 @@ func (c *Component) Compute(ctx context.Context, s Solver, out Fillable) (FS, er if err != nil { return fs, err } - _, err = fs.ReadDir(ctx, "/") + + // Force a `Solve()` in case it hasn't been called earlier. + // If the FS is already solved, this is a noop. + _, err = fs.Solve(ctx) return fs, err } diff --git a/dagger/fs.go b/dagger/fs.go index 8dc50ca0..99e70337 100644 --- a/dagger/fs.go +++ b/dagger/fs.go @@ -105,10 +105,6 @@ func (fs FS) walk(ctx context.Context, p string, fn WalkFunc) error { type WalkFunc func(string, Stat) error func (fs FS) Walk(ctx context.Context, fn WalkFunc) error { - // Lazy solve - if err := (&fs).solve(ctx); err != nil { - return err - } return fs.walk(ctx, "/", fn) } diff --git a/dagger/solver.go b/dagger/solver.go index 994d2c8a..08d4d45f 100644 --- a/dagger/solver.go +++ b/dagger/solver.go @@ -30,6 +30,7 @@ func (s Solver) Scratch() FS { return s.FS(llb.Scratch()) } +// Solve will block until the state is solved and returns a Reference. func (s Solver) Solve(ctx context.Context, st llb.State) (bkgw.Reference, error) { // marshal llb def, err := st.Marshal(ctx, llb.LinuxAmd64) @@ -37,7 +38,14 @@ func (s Solver) Solve(ctx context.Context, st llb.State) (bkgw.Reference, error) return nil, err } // call solve - res, err := s.c.Solve(ctx, bkgw.SolveRequest{Definition: def.ToPB()}) + res, err := s.c.Solve(ctx, bkgw.SolveRequest{ + Definition: def.ToPB(), + + // makes Solve() to block until LLB graph is solved. otherwise it will + // return result (that you can for example use for next build) that + // will be evaluated on export or if you access files on it. + Evaluate: true, + }) if err != nil { return nil, err }