cleanup log messages
Signed-off-by: Andrea Luzzardi <aluzzardi@gmail.com>
This commit is contained in:
parent
bc3305610b
commit
1fcb36113f
@ -43,21 +43,18 @@ var computeCmd = &cobra.Command{
|
||||
if err := env.SetUpdater(updater.Value()); err != nil {
|
||||
lg.Fatal().Err(err).Msg("invalid updater script")
|
||||
}
|
||||
lg.Debug().Str("input", input.Value().SourceUnsafe()).Msg("Setting input")
|
||||
lg.Debug().Str("input", input.Value().SourceUnsafe()).Msg("setting input")
|
||||
if err := env.SetInput(input.Value()); err != nil {
|
||||
lg.Fatal().Err(err).Msg("invalid input")
|
||||
}
|
||||
lg.Debug().Str("env state", env.State().SourceUnsafe()).Msg("creating client")
|
||||
c, err := dagger.NewClient(ctx, "")
|
||||
if err != nil {
|
||||
lg.Fatal().Err(err).Msg("unable to create client")
|
||||
}
|
||||
lg.Info().Msg("running")
|
||||
output, err := c.Compute(ctx, env)
|
||||
if err != nil {
|
||||
lg.Fatal().Err(err).Msg("failed to compute")
|
||||
}
|
||||
lg.Info().Msg("processing output")
|
||||
fmt.Println(output.JSON())
|
||||
},
|
||||
}
|
||||
|
@ -37,7 +37,7 @@ func CueBuild(ctx context.Context, fs FS, args ...string) (*compiler.Value, erro
|
||||
|
||||
// Add the config files on top of the overlay
|
||||
err = fs.Walk(ctx, func(p string, f Stat) error {
|
||||
lg.Debug().Str("path", p).Msg("Compiler.Build: processing")
|
||||
lg.Debug().Str("path", p).Msg("load")
|
||||
if f.IsDir() {
|
||||
return nil
|
||||
}
|
||||
|
@ -123,20 +123,24 @@ func (c *Client) buildfn(ctx context.Context, env *Env, ch chan *bk.SolveStatus,
|
||||
resp, err := c.c.Build(ctx, opts, "", func(ctx context.Context, c bkgw.Client) (*bkgw.Result, error) {
|
||||
s := NewSolver(c)
|
||||
|
||||
lg.Debug().Msg("loading configuration")
|
||||
if err := env.Update(ctx, s); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
lg.Debug().Msg("computing env")
|
||||
|
||||
// Compute output overlay
|
||||
lg.Debug().Msg("computing env")
|
||||
if err := env.Compute(ctx, s); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
lg.Debug().Msg("exporting env")
|
||||
|
||||
// Export env to a cue directory
|
||||
lg.Debug().Msg("exporting env")
|
||||
outdir, err := env.Export(s.Scratch())
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
// Wrap cue directory in buildkit result
|
||||
return outdir.Result(ctx)
|
||||
}, ch)
|
||||
|
@ -3,6 +3,7 @@ package dagger
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"time"
|
||||
|
||||
"cuelang.org/go/cue"
|
||||
cueflow "cuelang.org/go/tools/flow"
|
||||
@ -212,10 +213,6 @@ func (env *Env) Compute(ctx context.Context, s Solver) error {
|
||||
|
||||
// Cueflow cue instance
|
||||
flowInst := env.state.CueInst()
|
||||
lg.
|
||||
Debug().
|
||||
Str("value", compiler.Wrap(flowInst.Value(), flowInst).JSON().String()).
|
||||
Msg("walking")
|
||||
|
||||
// Reset the output
|
||||
env.output = compiler.EmptyStruct()
|
||||
@ -233,11 +230,9 @@ func (env *Env) Compute(ctx context.Context, s Solver) error {
|
||||
Str("state", t.State().String()).
|
||||
Logger()
|
||||
|
||||
lg.Debug().Msg("cueflow task")
|
||||
if t.State() != cueflow.Terminated {
|
||||
return nil
|
||||
}
|
||||
lg.Debug().Msg("cueflow task: filling result")
|
||||
// Merge task value into output
|
||||
var err error
|
||||
env.output, err = env.output.MergePath(t.Value(), t.Path())
|
||||
@ -245,7 +240,7 @@ func (env *Env) Compute(ctx context.Context, s Solver) error {
|
||||
lg.
|
||||
Error().
|
||||
Err(err).
|
||||
Msg("failed to fill script result")
|
||||
Msg("failed to fill task result")
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
@ -288,6 +283,10 @@ func newPipelineTaskFunc(ctx context.Context, inst *cue.Instance, s Solver) cuef
|
||||
Logger()
|
||||
ctx := lg.WithContext(ctx)
|
||||
|
||||
start := time.Now()
|
||||
lg.
|
||||
Info().
|
||||
Msg("computing")
|
||||
for _, dep := range t.Dependencies() {
|
||||
lg.
|
||||
Debug().
|
||||
@ -296,7 +295,20 @@ func newPipelineTaskFunc(ctx context.Context, inst *cue.Instance, s Solver) cuef
|
||||
}
|
||||
v := compiler.Wrap(t.Value(), inst)
|
||||
p := NewPipeline(t.Path().String(), s, NewFillable(t))
|
||||
return p.Do(ctx, v)
|
||||
err := p.Do(ctx, v)
|
||||
if err != nil {
|
||||
lg.
|
||||
Error().
|
||||
Dur("duration", time.Since(start)).
|
||||
Err(err).
|
||||
Msg("failed")
|
||||
} else {
|
||||
lg.
|
||||
Info().
|
||||
Dur("duration", time.Since(start)).
|
||||
Msg("completed")
|
||||
}
|
||||
return err
|
||||
}), nil
|
||||
}
|
||||
}
|
||||
|
@ -254,16 +254,13 @@ func (p *Pipeline) Local(ctx context.Context, op *compiler.Value) error {
|
||||
}
|
||||
}
|
||||
|
||||
p.fs = p.fs.Change(func(st llb.State) llb.State {
|
||||
return st.File(
|
||||
llb.Copy(
|
||||
llb.Local(dir, llb.FollowPaths(include)),
|
||||
"/",
|
||||
"/",
|
||||
),
|
||||
p.fs = p.fs.Set(
|
||||
llb.Local(
|
||||
dir,
|
||||
llb.FollowPaths(include),
|
||||
llb.WithCustomName(p.vertexNamef("Local %s", dir)),
|
||||
)
|
||||
})
|
||||
),
|
||||
)
|
||||
return nil
|
||||
}
|
||||
|
||||
@ -307,7 +304,11 @@ func (p *Pipeline) Exec(ctx context.Context, op *compiler.Value) error {
|
||||
|
||||
// marker for status events
|
||||
// FIXME
|
||||
opts = append(opts, llb.WithCustomName(p.vertexNamef("Exec %q", strings.Join(cmd.Args, " "))))
|
||||
args := make([]string, 0, len(cmd.Args))
|
||||
for _, a := range cmd.Args {
|
||||
args = append(args, fmt.Sprintf("%q", a))
|
||||
}
|
||||
opts = append(opts, llb.WithCustomName(p.vertexNamef("Exec [%s]", strings.Join(args, ", "))))
|
||||
|
||||
// --> Execute
|
||||
p.fs = p.fs.Change(func(st llb.State) llb.State {
|
||||
|
Reference in New Issue
Block a user