From 41515c931e81813744965947914f95290dcec5c5 Mon Sep 17 00:00:00 2001 From: Andrea Luzzardi Date: Wed, 20 Jan 2021 16:13:33 -0800 Subject: [PATCH] dagger.Value: make compiler instance private Signed-off-by: Andrea Luzzardi --- dagger/client.go | 5 ++--- dagger/value.go | 10 +++------- 2 files changed, 5 insertions(+), 10 deletions(-) diff --git a/dagger/client.go b/dagger/client.go index 9d346ec7..b2b00fbd 100644 --- a/dagger/client.go +++ b/dagger/client.go @@ -158,7 +158,7 @@ func (c *Client) Compute(ctx context.Context) (*Value, error) { // Retrieve output eg.Go(func() error { defer outr.Close() - return c.outputfn(ctx, outr, out) + return c.outputfn(ctx, outr, out, cc) }) return out, eg.Wait() } @@ -218,7 +218,7 @@ func (c *Client) buildfn(ctx context.Context, ch chan *bk.SolveStatus, w io.Writ } // Read tar export stream from buildkit Build(), and extract cue output -func (c *Client) outputfn(ctx context.Context, r io.Reader, out *Value) error { +func (c *Client) outputfn(ctx context.Context, r io.Reader, out *Value, cc *Compiler) error { lg := log.Ctx(ctx) tr := tar.NewReader(r) @@ -242,7 +242,6 @@ func (c *Client) outputfn(ctx context.Context, r io.Reader, out *Value) error { } lg.Debug().Msg("outputfn: compiling & merging") - cc := out.Compiler() v, err := cc.Compile(h.Name, tr) if err != nil { return err diff --git a/dagger/value.go b/dagger/value.go index 623ce007..8b9d15c6 100644 --- a/dagger/value.go +++ b/dagger/value.go @@ -21,10 +21,6 @@ func (v *Value) CueInst() *cue.Instance { return v.inst } -func (v *Value) Compiler() *Compiler { - return v.cc -} - func (v *Value) Wrap(v2 cue.Value) *Value { return wrapValue(v2, v.inst, v.cc) } @@ -142,7 +138,7 @@ func (v *Value) RangeStruct(fn func(string, *Value) error) error { // FIXME: receive string path? func (v *Value) Merge(x interface{}, path ...string) (*Value, error) { if xval, ok := x.(*Value); ok { - if xval.Compiler() != v.Compiler() { + if xval.cc != v.cc { return nil, fmt.Errorf("can't merge values from different compilers") } x = xval.val @@ -242,7 +238,7 @@ func (v *Value) Validate(defs ...string) error { if len(defs) == 0 { return nil } - spec := v.Compiler().Spec() + spec := v.cc.Spec() for _, def := range defs { if err := spec.Validate(v, def); err != nil { return err @@ -321,7 +317,7 @@ func (v *Value) ScriptOrComponent() (interface{}, error) { func (v *Value) Op() (*Op, error) { // Merge #Op definition from spec to get default values - spec := v.Compiler().Spec() + spec := v.cc.Spec() v, err := spec.Get("#Op").Merge(v) if err != nil { return nil, err