From ed173867f5348e9dcca9eb514e13bf62e2cc0340 Mon Sep 17 00:00:00 2001 From: Maxim Slipenko Date: Wed, 12 Feb 2025 14:50:45 +0300 Subject: [PATCH] wip --- internal/shutils/decoder/decoder.go | 10 +++++----- pkg/build/build.go | 2 +- pkg/repos/pull.go | 2 +- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/internal/shutils/decoder/decoder.go b/internal/shutils/decoder/decoder.go index d59e8ea..c89bfb4 100644 --- a/internal/shutils/decoder/decoder.go +++ b/internal/shutils/decoder/decoder.go @@ -164,7 +164,10 @@ func (d *Decoder) DecodeVars(val any) error { return nil } -type ScriptFunc func(ctx context.Context, opts ...interp.RunnerOption) error +type ( + ScriptFunc func(ctx context.Context, opts ...interp.RunnerOption) error + ScriptFuncWithSubshell func(ctx context.Context, opts ...interp.RunnerOption) (*interp.Runner, error) +) // GetFunc returns a function corresponding to a bash function // with the given name @@ -197,10 +200,7 @@ func (d *Decoder) GetFuncP(name string, prepare PrepareFunc) (ScriptFunc, bool) }, true } -// TODO: replace -func (d *Decoder) GetFuncSub(name string) ( - func(ctx context.Context, opts ...interp.RunnerOption) (*interp.Runner, error), bool, -) { +func (d *Decoder) GetFuncWithSubshell(name string) (ScriptFuncWithSubshell, bool) { fn := d.getFunc(name) if fn == nil { return nil, false diff --git a/pkg/build/build.go b/pkg/build/build.go index ccda8d7..0ecd9b3 100644 --- a/pkg/build/build.go +++ b/pkg/build/build.go @@ -351,7 +351,7 @@ func (b *Builder) executeFirstPass( for _, pkgName := range b.opts.Packages { var preVars types.BuildVarsPre funcName := fmt.Sprintf("meta_%s", pkgName) - meta, ok := dec.GetFuncSub(funcName) + meta, ok := dec.GetFuncWithSubshell(funcName) if !ok { return "", nil, errors.New("func is missing") } diff --git a/pkg/repos/pull.go b/pkg/repos/pull.go index bc66824..98a86fd 100644 --- a/pkg/repos/pull.go +++ b/pkg/repos/pull.go @@ -223,7 +223,7 @@ func (rs *Repos) updatePkg(ctx context.Context, repo types.Repo, runner *interp. if err != nil { return err } - meta, ok := d.GetFuncSub(funcName) + meta, ok := d.GetFuncWithSubshell(funcName) if !ok { return errors.New("func is missing") }