Component.Compute: force "real" solve. Fixes #14.

Signed-off-by: Solomon Hykes <sh.github.6811@hykes.org>
This commit is contained in:
Solomon Hykes 2021-01-12 10:31:50 -08:00
parent 0e484be9bd
commit 8b105003bb
2 changed files with 25 additions and 4 deletions

View File

@ -41,11 +41,19 @@ func (c *Component) ComputeScript() (*Script, error) {
} }
// Compute the configuration for this component. // Compute the configuration for this component.
// Note that we simply execute the underlying compute script from an //
// empty filesystem state. // Difference with Execute:
// (It is never correct to pass an input filesystem state to compute a component) //
// 1. Always start with an empty fs state (Execute may receive any state as input)
// 2. Always solve at the end (Execute is lazy)
//
func (c *Component) Compute(ctx context.Context, s Solver, out Fillable) (FS, error) { func (c *Component) Compute(ctx context.Context, s Solver, out Fillable) (FS, error) {
return c.Execute(ctx, s.Scratch(), out) fs, err := c.Execute(ctx, s.Scratch(), out)
if err != nil {
return fs, err
}
_, err = fs.ReadDir(ctx, "/")
return fs, err
} }
// A component implements the Executable interface by returning its // A component implements the Executable interface by returning its

View File

@ -0,0 +1,13 @@
package main
www: {
source: {
#dagger: compute: [
{
do: "fetch-container"
ref: "lalalalala",
},
]
}
}